/** @namespace $.SickGear.Root */ /** @namespace config.showLang */ /** @namespace config.showIsAnime */ /** @namespace config.expandIds */ /*globals $, config, sbRoot, generateAniGroupList*/ $(document).ready(function () { $('#location').fileBrowser({title: 'Select Show Location'}); String.prototype.padLeft = function padLeft(length, leadingChar) { if (undefined === leadingChar) leadingChar = '0'; return this.length < length ? (leadingChar + this).padLeft(length, leadingChar) : this; }; function htmlFlag(lang) { return ' class="flag" style="background-image:url(' + $.SickGear.Root + '/images/flags/' + lang + '.png)"' } $.getJSON($.SickGear.Root + '/add-shows/get-infosrc-languages', {}, function (data) { var result = '', currentLangAdded = '', selected = ' selected="selected"'; if (!data.results.length) { result = ''; } else { currentLangAdded = !1; $.each(data.results, function (index, strLang) { var htmlSelected = ''; if (strLang === config.showLang) { currentLangAdded = !0; htmlSelected = selected; } result += ''; }); if (!currentLangAdded) result += ''; } $('#infosrc-lang-select-edit').html(result); }); function getExceptions() { var allExceptions = []; $('#exceptions_list').find('option').each(function () { allExceptions.push($(this).val()); }); return allExceptions } function okExit(action){ return ('the-main' === ($('input[name="set-main"]:checked').attr('id') || 'the-main') || confirm('A "set main" change is pending\n\n' + action + ' without saving changes?')) } $('a:contains("Cancel Edit")').on('click', function () { if (!okExit('Cancel')) return !1; }); $('#submit').on('click', function () { if (!okExit('Update')) return !1; $('#exceptions_list').val(getExceptions()); if (config.showIsAnime) generateAniGroupList(); }); $('#addSceneName').on('click', function () { var elSceneName = $('#SceneName'), elSceneNameSeason = $('#SceneNameSeason'), sceneEx = elSceneName.val(), sceneExSeason = elSceneNameSeason.val(); elSceneName.val(''); elSceneNameSeason.val(''); if (-1 < $.inArray(sceneExSeason + '|' + sceneEx, getExceptions()) || ('' === sceneEx)) return; $('#SceneException').fadeIn('fast', 'linear'); var option = $('