From 7f9287527a11233bf18cd321cd333c6107dff204 Mon Sep 17 00:00:00 2001 From: JackDandy Date: Mon, 17 Oct 2016 19:08:14 +0100 Subject: [PATCH] Change refactor js to use sgroot. --- gui/slick/interfaces/default/inc_top.tmpl | 1 + gui/slick/js/massUpdate.js | 192 ++++++++++------------ 2 files changed, 92 insertions(+), 101 deletions(-) diff --git a/gui/slick/interfaces/default/inc_top.tmpl b/gui/slick/interfaces/default/inc_top.tmpl index d4b3956d..5a8a5f16 100644 --- a/gui/slick/interfaces/default/inc_top.tmpl +++ b/gui/slick/interfaces/default/inc_top.tmpl @@ -71,6 +71,7 @@ diff --git a/gui/slick/js/massUpdate.js b/gui/slick/js/massUpdate.js index ce14fdb3..57abf9a0 100644 --- a/gui/slick/js/massUpdate.js +++ b/gui/slick/js/massUpdate.js @@ -1,123 +1,113 @@ -$(document).ready(function(){ +/** @namespace $.SickGear.Root */ - $('#submitMassEdit').click(function(){ - var editArr = new Array() - - $('.editCheck').each(function() { - if (this.checked == true) { - editArr.push($(this).attr('id').split('-')[1]) - } - }); +$(document).ready(function() { - if (editArr.length == 0) - return + $('#submitMassEdit').click(function() { + var editArr = []; - url = 'massEdit?toEdit='+editArr.join('|') - window.location.href = url - }); + $('.editCheck').each(function() { + if (true == this.checked) { + editArr.push($(this).attr('id').split('-')[1]) + } + }); + if (0 == editArr.length) + return !1; - $('#submitMassUpdate').click(function(){ - - var updateArr = new Array() - var refreshArr = new Array() - var renameArr = new Array() - var subtitleArr = new Array() - var deleteArr = new Array() - var removeArr = new Array() - var metadataArr = new Array() - - $('.updateCheck').each(function() { - if (this.checked == true) { - updateArr.push($(this).attr('id').split('-')[1]) - } - }); - - $('.refreshCheck').each(function() { - if (this.checked == true) { - refreshArr.push($(this).attr('id').split('-')[1]) - } - }); - - $('.renameCheck').each(function() { - if (this.checked == true) { - renameArr.push($(this).attr('id').split('-')[1]) - } - }); - - $('.subtitleCheck').each(function() { - if (this.checked == true) { - subtitleArr.push($(this).attr('id').split('-')[1]) - } - }); - - $('.deleteCheck').each(function() { - if (this.checked == true) { - deleteArr.push($(this).attr('id').split('-')[1]) - } - }); - - $('.removeCheck').each(function() { - if (this.checked == true) { - removeArr.push($(this).attr('id').split('-')[1]) - } + window.location.href = $.SickGear.Root + 'massEdit?toEdit=' + editArr.join('|'); }); + + $('#submitMassUpdate').click(function() { + + var updateArr = [], refreshArr = [], renameArr = [], subtitleArr = [], + deleteArr = [], removeArr = [], metadataArr = []; + + $('.updateCheck').each(function() { + if (true == this.checked) { + updateArr.push($(this).attr('id').split('-')[1]) + } + }); + + $('.refreshCheck').each(function() { + if (true == this.checked) { + refreshArr.push($(this).attr('id').split('-')[1]) + } + }); + + $('.renameCheck').each(function() { + if (true == this.checked) { + renameArr.push($(this).attr('id').split('-')[1]) + } + }); + + $('.subtitleCheck').each(function() { + if (true == this.checked) { + subtitleArr.push($(this).attr('id').split('-')[1]) + } + }); + + $('.deleteCheck').each(function() { + if (true == this.checked) { + deleteArr.push($(this).attr('id').split('-')[1]) + } + }); + + $('.removeCheck').each(function() { + if (true == this.checked) { + removeArr.push($(this).attr('id').split('-')[1]) + } + }); + /* - $('.metadataCheck').each(function() { - if (this.checked == true) { - metadataArr.push($(this).attr('id').split('-')[1]) - } - }); + $('.metadataCheck').each(function() { + if (true == this.checked) { + metadataArr.push($(this).attr('id').split('-')[1]) + } + }); */ - if (updateArr.length+refreshArr.length+renameArr.length+subtitleArr.length+deleteArr.length+removeArr.length+metadataArr.length == 0) - return false + if (0 == updateArr.length + refreshArr.length + renameArr.length + subtitleArr.length + deleteArr.length + removeArr.length + metadataArr.length) + return !1; - url = 'massUpdate?toUpdate='+updateArr.join('|')+'&toRefresh='+refreshArr.join('|')+'&toRename='+renameArr.join('|')+'&toSubtitle='+subtitleArr.join('|')+'&toDelete='+deleteArr.join('|')+'&toRemove='+removeArr.join('|')+'&toMetadata='+metadataArr.join('|') + window.location.href = $.SickGear.Root + 'massUpdate?toUpdate=' + updateArr.join('|') + '&toRefresh=' + refreshArr.join('|') + '&toRename=' + renameArr.join('|') + '&toSubtitle=' + subtitleArr.join('|') + '&toDelete=' + deleteArr.join('|') + '&toRemove=' + removeArr.join('|') + '&toMetadata=' + metadataArr.join('|'); - window.location.href = url + }); - }); + $('.bulkCheck').click(function() { - $('.bulkCheck').click(function(){ - - var bulkCheck = this; - var whichBulkCheck = $(bulkCheck).attr('id'); + var bulkCheck = this, whichBulkCheck = $(bulkCheck).attr('id'); - $('.'+whichBulkCheck).each(function(){ - if (!this.disabled) - this.checked = !this.checked - }); - }); + $('.' + whichBulkCheck).each(function() { + if (!this.disabled) + this.checked = !this.checked + }); + }); - ['.editCheck', '.updateCheck', '.refreshCheck', '.renameCheck', '.deleteCheck', '.removeCheck'].forEach(function(name) { - var lastCheck = null; + ['.editCheck', '.updateCheck', '.refreshCheck', '.renameCheck', '.deleteCheck', '.removeCheck'].forEach(function(name) { + var lastCheck = null; - $(name).click(function(event) { + $(name).click(function(event) { - if(!lastCheck || !event.shiftKey) { - lastCheck = this; - return; - } + if(!lastCheck || !event.shiftKey) { + lastCheck = this; + return; + } - var check = this; - var found = 0; + var check = this, found = 0; - $(name).each(function() { - switch (found) { - case 2: return false; - case 1: - if (!this.disabled) - this.checked = lastCheck.checked; - } + $(name).each(function() { + switch (found) { + case 2: + return !1; + case 1: + if (!this.disabled) + this.checked = lastCheck.checked; + } - if (this == check || this == lastCheck) - found++; - }); + if (this == check || this == lastCheck) + found++; + }); + }); + }); - lastClick = this; - }); - - }); - });