/** @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)"' } function uriFlag(lang) { return $.SickGear.Root + '/images/flags/' + lang + '.png' } $.getJSON($.SickGear.Root + '/add-shows/get-infosrc-languages', {}, function (data) { var htmlText = '', currentLangAdded = '', selected = ' selected="selected"', htmlSelected = '', elInfosrcLang = $('#infosrc-lang-select'), useSelect2 = 0 < data.results_ext.length, populateItem; if (!data.results.length && !data.results_ext.length) { htmlText = ''; } else { currentLangAdded = !1; if (useSelect2){ // 3 letter abbr object $.each(data.results_ext, function (index, obj) { htmlSelected = ''; if (obj.std_abbr === config.showLang) { currentLangAdded = !0; htmlSelected = selected; } htmlText += ''; }); } else { // legacy 2 letter abbr list $.each(data.results, function (index, strLang) { htmlSelected = ''; if (strLang === config.showLang) { currentLangAdded = !0; htmlSelected = selected; } htmlText += ''; }); } if (!currentLangAdded) htmlText += ''; } elInfosrcLang.html(htmlText); if (useSelect2) { populateItem = function (data) { if (!!data.element) return $('' + data.text + ''); return data.text; } elInfosrcLang.select2({templateResult: populateItem, templateSelection: populateItem, width: 162}); } }); 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 = $('