From 4319b2c2e58a19e28da2a674ca47811a036f597c Mon Sep 17 00:00:00 2001 From: Eric Schultz Date: Mon, 25 Jan 2016 09:06:38 -0600 Subject: [PATCH 1/3] tweaks to tablesorter to restore saved filters + minor optimizations --- .../plugins/NerdPack/js/jquery.NerdPack.js | 95 +++++++++---------- 1 file changed, 47 insertions(+), 48 deletions(-) diff --git a/source/NerdPack/usr/local/emhttp/plugins/NerdPack/js/jquery.NerdPack.js b/source/NerdPack/usr/local/emhttp/plugins/NerdPack/js/jquery.NerdPack.js index 189e4597..a2a72caa 100644 --- a/source/NerdPack/usr/local/emhttp/plugins/NerdPack/js/jquery.NerdPack.js +++ b/source/NerdPack/usr/local/emhttp/plugins/NerdPack/js/jquery.NerdPack.js @@ -1,4 +1,22 @@ $(function(){ + // tablesorter options + $("#tblPackages").tablesorter({ + sortList: [[0,1]], + widgets: ["saveSort", "filter", "stickyHeaders"], + widgetOptions: { + stickyHeaders_filteredToTop: true, + filter_hideEmpty: true, + filter_liveSearch: true, + filter_saveFilters: true, + filter_reset: "button.reset", + filter_functions: { + ".filter-version": true, + ".filter-downloaded": true, + ".filter-installed": true + } + } + }); + // "uninstall package" switch and cookie $("#uninstallpkg") .switchButton({ @@ -23,6 +41,20 @@ $(function(){ $.cookie("nerdpack_packages_delete", $(this).prop("checked") ? "--delete" : "", { expires: 3650 }); }); + // select all packages switch + $("#checkall") + .switchButton({ + labels_placement: "right", + on_label: "Select All", + off_label: "Select All", + checked: $.cookie("nerdpack_checkall") == "yes" + }) + .change(function () { + var myval = $(this).prop("checked"); + $.cookie("nerdpack_checkall", myval ? "yes" : "no", { expires: 3650 }); + $("#tblPackages tbody td:visible .pkgcheckbox").switchButton({checked: myval}); + }); + // set cookie on apply button press $("#btnApply").click(function() { checkDepends(); @@ -70,62 +102,29 @@ function packageQuery(force) { ""+data[i].size+""+ // package size ""+Downloaded+""+ // package installed ""+Installed+""+ // package installed - ""+ + ""+ ""+ ""); - - $("#"+data[i].pkgname) - .switchButton({ - labels_placement: "right", - on_label: "On", - off_label: "Off", - checked: data[i].config == "yes" - }) - .change(function() { - $(this).parent().parent().find(".pkgvalue").val(this.checked ? "yes": "no"); - if (this.checked) - checkDepends(); - $("#btnApply").prop("disabled", false); - }); } - $("#tblPackages").trigger("update"); - - // tablesorter options - $("#tblPackages").tablesorter({ - sortList: [[0,0]], - widgets: ["saveSort", "filter", "stickyHeaders"], - widgetOptions: { - stickyHeaders_filteredToTop: true, - filter_hideEmpty: true, - filter_liveSearch: true, - filter_saveFilters: true, - filter_reset: ".reset", - filter_functions: { - ".filter-version": true, - ".filter-downloaded": true, - ".filter-installed": true - } - } - }); - // select all packages switch - $("#checkall") + // attach switch buttons to every package checkbox all at once + $(".pkgcheckbox") .switchButton({ labels_placement: "right", - on_label: "Select All", - off_label: "Select All", - checked: $.cookie("nerdpack_checkall") == "yes" + on_label: "On", + off_label: "Off" }) - .change(function () { - var myval = $(this).prop("checked"); - $.cookie("nerdpack_checkall", myval ? "yes" : "no", { expires: 3650 }); - $(".pkgcheckbox").each(function() { // loop through each checkbox - $(this).switchButton({checked: myval}); - }); - $(".pkgvalue").each(function() { // loop through each value - $(this).val(myval ? "yes": "no"); - }); + .change(function() { + $(this).parent().parent().find(".pkgvalue").val(this.checked ? "yes": "no"); + if (this.checked) + checkDepends(); + $("#btnApply").prop("disabled", false); }); + + // restore filters + var lastSearch = $("#tblPackages")[0].config.lastSearch; + $("#tblPackages").trigger("update"); + $("#tblPackages").trigger("search", [lastSearch]); }); } From 9bc076878becdff285928fae2ff1676685f5c988 Mon Sep 17 00:00:00 2001 From: Derek Macias Date: Mon, 25 Jan 2016 08:58:25 -0700 Subject: [PATCH 2/3] update plugin --- plugins/NerdPack.plg | 6 +++++- plugins/NerdPack.xml | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/plugins/NerdPack.plg b/plugins/NerdPack.plg index 945d471c..c296efbd 100644 --- a/plugins/NerdPack.plg +++ b/plugins/NerdPack.plg @@ -3,7 +3,7 @@ - + @@ -16,6 +16,10 @@ +###2016.01.25 +- Merge eschultz pull request +- tweaks to tablesorter to restore saved filters +- minor optimizations ###2016.01.24 - Merged eschultz's package repo and following fixes - Fixed first time running warnings about missing packages.json / desc files diff --git a/plugins/NerdPack.xml b/plugins/NerdPack.xml index 1fc4b8d5..b8fa534a 100644 --- a/plugins/NerdPack.xml +++ b/plugins/NerdPack.xml @@ -11,8 +11,12 @@ This plugin allows installation of extra packages, mostly CLI, for advanced user http://lime-technology.com/forum/index.php?topic=37541.0 https://raw.githubusercontent.com/dmacias72/unRAID-plugins/master/plugins/NerdPack.png -2016-01-24 +2016-01-25 +###2016.01.25 +- Merge eschultz pull request +- tweaks to tablesorter to restore saved filters +- minor optimizations ###2016.01.24 - Merged eschultz's package repo and following fixes - Fixed first time running warnings about missing packages.json / desc files From 82b46b2f7c10b3b8ad47ddbb392651e85beef735 Mon Sep 17 00:00:00 2001 From: Derek Macias Date: Mon, 25 Jan 2016 08:59:46 -0700 Subject: [PATCH 3/3] fixed reset filter button --- .../usr/local/emhttp/plugins/NerdPack/NerdPack.page | 4 ++-- .../usr/local/emhttp/plugins/NerdPack/js/jquery.NerdPack.js | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/source/NerdPack/usr/local/emhttp/plugins/NerdPack/NerdPack.page b/source/NerdPack/usr/local/emhttp/plugins/NerdPack/NerdPack.page index 5a2d9609..66ed910a 100644 --- a/source/NerdPack/usr/local/emhttp/plugins/NerdPack/NerdPack.page +++ b/source/NerdPack/usr/local/emhttp/plugins/NerdPack/NerdPack.page @@ -27,7 +27,7 @@ Title="Nerd Pack" - + : @@ -35,4 +35,4 @@ Title="Nerd Pack" - \ No newline at end of file + diff --git a/source/NerdPack/usr/local/emhttp/plugins/NerdPack/js/jquery.NerdPack.js b/source/NerdPack/usr/local/emhttp/plugins/NerdPack/js/jquery.NerdPack.js index a2a72caa..20d0cd36 100644 --- a/source/NerdPack/usr/local/emhttp/plugins/NerdPack/js/jquery.NerdPack.js +++ b/source/NerdPack/usr/local/emhttp/plugins/NerdPack/js/jquery.NerdPack.js @@ -1,14 +1,14 @@ $(function(){ // tablesorter options $("#tblPackages").tablesorter({ - sortList: [[0,1]], + sortList: [[0,0]], widgets: ["saveSort", "filter", "stickyHeaders"], widgetOptions: { stickyHeaders_filteredToTop: true, filter_hideEmpty: true, filter_liveSearch: true, filter_saveFilters: true, - filter_reset: "button.reset", + filter_reset: ".reset", filter_functions: { ".filter-version": true, ".filter-downloaded": true, @@ -137,4 +137,4 @@ function checkDepends() { $("#python").switchButton({checked: true}); $("#python", ".pkgvalue").val("yes"); } -} \ No newline at end of file +}