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
+
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();
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
+
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
+
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
+
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
+
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
+
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
+