From faef55081008c7b13dd1598dd9e8bf8c28f2f44a Mon Sep 17 00:00:00 2001 From: Robin van Baalen Date: Mon, 17 Jan 2022 15:35:44 -0400 Subject: [PATCH 1/9] Alphabetically sort resources --- huemagic/hue-brightness.html | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/huemagic/hue-brightness.html b/huemagic/hue-brightness.html index 26bae7e..014d628 100644 --- a/huemagic/hue-brightness.html +++ b/huemagic/hue-brightness.html @@ -81,6 +81,19 @@ buttonIcon.removeClass("fa-pencil"); buttonIcon.addClass("fa-search"); } + + function sortResourcesBy(prop, resources) + { + return resources.sort((a, b) => { + if ( a[prop] < b[prop] ){ + return -1; + } + if ( a[prop] > b[prop] ){ + return 1; + } + return 0; + }); + } function searchAndSelect() { @@ -98,6 +111,7 @@ $.get('hue/resources', { bridge: bridgeConfig.bridge, key: bridgeConfig.key, type: "motion" }) .done( function(data) { var allResources = JSON.parse(data); + allResources = sortResourcesBy('name', allResources); if(allResources.length <= 0) { notification.close(); @@ -194,4 +208,4 @@ } } }); - \ No newline at end of file + From c2f664ae54c61d4e1e6796ff3cfd80bd1ba4e472 Mon Sep 17 00:00:00 2001 From: Robin van Baalen Date: Mon, 17 Jan 2022 15:40:40 -0400 Subject: [PATCH 2/9] Added sorting of resources --- huemagic/hue-brightness.html | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/huemagic/hue-brightness.html b/huemagic/hue-brightness.html index 26bae7e..a64042e 100644 --- a/huemagic/hue-brightness.html +++ b/huemagic/hue-brightness.html @@ -81,6 +81,19 @@ buttonIcon.removeClass("fa-pencil"); buttonIcon.addClass("fa-search"); } + + function sortResourcesBy(prop, resources) + { + return resources.sort((a, b) => { + if ( a[prop] < b[prop] ){ + return -1; + } + if ( a[prop] > b[prop] ){ + return 1; + } + return 0; + }); + } function searchAndSelect() { @@ -97,7 +110,7 @@ // GET THE SENSORS $.get('hue/resources', { bridge: bridgeConfig.bridge, key: bridgeConfig.key, type: "motion" }) .done( function(data) { - var allResources = JSON.parse(data); + var allResources = sortResourcesBy("name", JSON.parse(data)); if(allResources.length <= 0) { notification.close(); @@ -194,4 +207,4 @@ } } }); - \ No newline at end of file + From 4d253a221a49f55b0ccd0d4979510229785055f5 Mon Sep 17 00:00:00 2001 From: Robin van Baalen Date: Mon, 17 Jan 2022 15:42:53 -0400 Subject: [PATCH 3/9] Add sorting --- huemagic/hue-buttons.html | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/huemagic/hue-buttons.html b/huemagic/hue-buttons.html index 3035dde..3109fa5 100644 --- a/huemagic/hue-buttons.html +++ b/huemagic/hue-buttons.html @@ -81,6 +81,19 @@ buttonIcon.removeClass("fa-pencil"); buttonIcon.addClass("fa-search"); } + + function sortResourcesBy(prop, resources) + { + return resources.sort((a, b) => { + if ( a[prop] < b[prop] ){ + return -1; + } + if ( a[prop] > b[prop] ){ + return 1; + } + return 0; + }); + } function searchAndSelect() { @@ -98,6 +111,7 @@ $.get('hue/resources', { bridge: bridgeConfig.bridge, key: bridgeConfig.key, type: "button" }) .done( function(data) { var allResources = JSON.parse(data); + allResources = sortResourcesBy('name', allResources); if(allResources.length <= 0) { notification.close(); From f6a49dddfd8f613755882b4199947e57351d967d Mon Sep 17 00:00:00 2001 From: Robin van Baalen Date: Mon, 17 Jan 2022 15:43:42 -0400 Subject: [PATCH 4/9] Add sorting --- huemagic/hue-group.html | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/huemagic/hue-group.html b/huemagic/hue-group.html index 446e195..4fbb968 100644 --- a/huemagic/hue-group.html +++ b/huemagic/hue-group.html @@ -81,6 +81,19 @@ buttonIcon.removeClass("fa-pencil"); buttonIcon.addClass("fa-search"); } + + function sortResourcesBy(prop, resources) + { + return resources.sort((a, b) => { + if ( a[prop] < b[prop] ){ + return -1; + } + if ( a[prop] > b[prop] ){ + return 1; + } + return 0; + }); + } function searchAndSelect() { @@ -98,6 +111,7 @@ $.get('hue/resources', { bridge: bridgeConfig.bridge, key: bridgeConfig.key, type: "group" }) .done( function(data) { var allResources = JSON.parse(data); + allResources = sortResourcesBy('name', allResources); if(allResources.length <= 0) { notification.close(); @@ -205,4 +219,4 @@ } } }); - \ No newline at end of file + From e1e82e00170997e611a93d21a96561435dd222a4 Mon Sep 17 00:00:00 2001 From: Robin van Baalen Date: Mon, 17 Jan 2022 15:44:58 -0400 Subject: [PATCH 5/9] Add sorting --- huemagic/hue-light.html | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/huemagic/hue-light.html b/huemagic/hue-light.html index d260e11..b9b2fcd 100644 --- a/huemagic/hue-light.html +++ b/huemagic/hue-light.html @@ -88,6 +88,19 @@ buttonIcon.removeClass("fa-pencil"); buttonIcon.addClass("fa-search"); } + + function sortResourcesBy(prop, resources) + { + return resources.sort((a, b) => { + if ( a[prop] < b[prop] ){ + return -1; + } + if ( a[prop] > b[prop] ){ + return 1; + } + return 0; + }); + } function searchAndSelect() { @@ -105,6 +118,7 @@ $.get('hue/resources', { bridge: bridgeConfig.bridge, key: bridgeConfig.key, type: "light" }) .done( function(data) { var allResources = JSON.parse(data); + allResources = sortResourcesBy('name', allResources); if(allResources.length <= 0) { notification.close(); @@ -201,4 +215,4 @@ } } }); - \ No newline at end of file + From 81067b8055ea9d9110b1d27c740d71eb81950e78 Mon Sep 17 00:00:00 2001 From: Robin van Baalen Date: Mon, 17 Jan 2022 15:46:21 -0400 Subject: [PATCH 6/9] Add resource sorting --- huemagic/hue-motion.html | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/huemagic/hue-motion.html b/huemagic/hue-motion.html index e2a7c65..96c01ba 100644 --- a/huemagic/hue-motion.html +++ b/huemagic/hue-motion.html @@ -81,6 +81,19 @@ buttonIcon.removeClass("fa-pencil"); buttonIcon.addClass("fa-search"); } + + function sortResourcesBy(prop, resources) + { + return resources.sort((a, b) => { + if ( a[prop] < b[prop] ){ + return -1; + } + if ( a[prop] > b[prop] ){ + return 1; + } + return 0; + }); + } function searchAndSelect() { @@ -98,6 +111,7 @@ $.get('hue/resources', { bridge: bridgeConfig.bridge, key: bridgeConfig.key, type: "motion" }) .done( function(data) { var allResources = JSON.parse(data); + allResources = sortResourcesBy('name', allResources); if(allResources.length <= 0) { notification.close(); @@ -194,4 +208,4 @@ } } }); - \ No newline at end of file + From 1da11a27b36f4d933747f3935b8d2d47f6893c6f Mon Sep 17 00:00:00 2001 From: Robin van Baalen Date: Mon, 17 Jan 2022 15:46:57 -0400 Subject: [PATCH 7/9] Add resource sorting --- huemagic/hue-rules.html | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/huemagic/hue-rules.html b/huemagic/hue-rules.html index a7a96d9..c3f111c 100644 --- a/huemagic/hue-rules.html +++ b/huemagic/hue-rules.html @@ -81,6 +81,19 @@ buttonIcon.removeClass("fa-pencil"); buttonIcon.addClass("fa-search"); } + + function sortResourcesBy(prop, resources) + { + return resources.sort((a, b) => { + if ( a[prop] < b[prop] ){ + return -1; + } + if ( a[prop] > b[prop] ){ + return 1; + } + return 0; + }); + } function searchAndSelect() { @@ -98,6 +111,7 @@ $.get('hue/resources', { bridge: bridgeConfig.bridge, key: bridgeConfig.key, type: "rule" }) .done( function(data) { var allResources = JSON.parse(data); + allResources = sortResourcesBy('name', allResources); if(allResources.length <= 0) { notification.close(); @@ -187,4 +201,4 @@ } } }); - \ No newline at end of file + From f3e63f3c49bbe11a8a17f7094710330cfda61b74 Mon Sep 17 00:00:00 2001 From: Robin van Baalen Date: Mon, 17 Jan 2022 15:47:41 -0400 Subject: [PATCH 8/9] Add resource name --- huemagic/hue-scene.html | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/huemagic/hue-scene.html b/huemagic/hue-scene.html index c8767fa..c70e196 100644 --- a/huemagic/hue-scene.html +++ b/huemagic/hue-scene.html @@ -67,6 +67,19 @@ buttonIcon.removeClass("fa-pencil"); buttonIcon.addClass("fa-search"); } + + function sortResourcesBy(prop, resources) + { + return resources.sort((a, b) => { + if ( a[prop] < b[prop] ){ + return -1; + } + if ( a[prop] > b[prop] ){ + return 1; + } + return 0; + }); + } function searchAndSelectScenes() { @@ -84,6 +97,7 @@ $.get('hue/resources', { bridge: bridgeConfig.bridge, key: bridgeConfig.key, type: "scene" }) .done( function(data) { var allResources = JSON.parse(data); + allResources = sortResourcesBy('name', allResources); if(allResources.length <= 0) { notification.close(); @@ -167,4 +181,4 @@ } } }); - \ No newline at end of file + From 408d4b05da824807f801ca4056116bda8bb6b354 Mon Sep 17 00:00:00 2001 From: Robin van Baalen Date: Mon, 17 Jan 2022 15:48:22 -0400 Subject: [PATCH 9/9] Add resource sorting --- huemagic/hue-temperature.html | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/huemagic/hue-temperature.html b/huemagic/hue-temperature.html index decad7c..f2941aa 100644 --- a/huemagic/hue-temperature.html +++ b/huemagic/hue-temperature.html @@ -81,6 +81,19 @@ buttonIcon.removeClass("fa-pencil"); buttonIcon.addClass("fa-search"); } + + function sortResourcesBy(prop, resources) + { + return resources.sort((a, b) => { + if ( a[prop] < b[prop] ){ + return -1; + } + if ( a[prop] > b[prop] ){ + return 1; + } + return 0; + }); + } function searchAndSelect() { @@ -98,6 +111,7 @@ $.get('hue/resources', { bridge: bridgeConfig.bridge, key: bridgeConfig.key, type: "temperature" }) .done( function(data) { var allResources = JSON.parse(data); + allResources = sortResourcesBy('name', allResources); if(allResources.length <= 0) { notification.close(); @@ -194,4 +208,4 @@ } } }); - \ No newline at end of file +