From e5eea1fe6ae44b6edfb34e92f71bb3b48e647219 Mon Sep 17 00:00:00 2001 From: "H.Plato" Date: Wed, 20 Sep 2017 17:25:16 -0600 Subject: [PATCH] IA7 v1.6.200 - sortable collection --- code/common/weather_wunderground.pl | 8 ++-- web/ia7/include/javascript.js | 61 ++++++++++++++++++++++++++--- web/ia7/index.shtml | 18 +++++++++ 3 files changed, 78 insertions(+), 9 deletions(-) diff --git a/code/common/weather_wunderground.pl b/code/common/weather_wunderground.pl index 23709fac7..bc2a82a71 100644 --- a/code/common/weather_wunderground.pl +++ b/code/common/weather_wunderground.pl @@ -151,12 +151,12 @@ weather_wunderground_addelem( $channel, 'HumidOutdoor', 'relative_humidity' ); #IsRaining - my $israining = 0; - $israining = 1 if ($wunderground_data{Conditions} =~ m/rain/i); + $wunderground_data{IsRaining} = 0; + $wunderground_data{IsRaining} = 1 if ($wunderground_data{Conditions} =~ m/rain/i); #IsSnowing - my $issnowing = 0; - $issnowing = 1 if ($wunderground_data{Conditions} =~ m/snow/i); + $wunderground_data{IsSnowing} = 0; + $wunderground_data{IsSnowing} = 1 if ($wunderground_data{Conditions} =~ m/snow/i); weather_wunderground_addelem( $channel, 'Clouds', 'weather' ); diff --git a/web/ia7/include/javascript.js b/web/ia7/include/javascript.js index c3f8ee565..eab253451 100644 --- a/web/ia7/include/javascript.js +++ b/web/ia7/include/javascript.js @@ -1,5 +1,5 @@ -var ia7_ver = "v1.6.150"; +var ia7_ver = "v1.6.200"; var entity_store = {}; //global storage of entities var json_store = {}; var updateSocket; @@ -1249,6 +1249,7 @@ var loadCollection = function(collection_keys) { var button_html = "
"; + button_html = "
" + button_html + "
"; entity_arr.push(button_html); items += item+","; } @@ -1283,6 +1284,7 @@ var loadCollection = function(collection_keys) { } else { button_html = ""+name+""; } + button_html = "
" + button_html + "
"; entity_arr.push(button_html); } } @@ -1297,7 +1299,9 @@ var loadCollection = function(collection_keys) { $('#list_content').append("
"); $('#buffer'+row).append("
"); } - $('#row'+row).append("
" + entity_arr[i] + "
"); +// $('#row'+row).append("
" + entity_arr[i] + "
"); + $('#row'+row).append(entity_arr[i]); + if (column == 3){ column = 0; row++; @@ -1520,7 +1524,9 @@ var get_stats = function(tagline) { $('.mh-wi').click( function () { var summary = "Summary:  "+json.data.summary_long+"
"; summary += "Last Updated:  "+json.data.weather_lastupdated; - + if ($('.mh-wi-icon').hasClass("wi-na")) { + summary += "
Clouds:  "+json.data.clouds; + } $('#lastResponse').find('.modal-body').html(summary); $('#lastResponse').modal({ show: true @@ -1550,6 +1556,12 @@ var get_wi_icon = function (conditions,rain,snow,night) { icon = "wi-cloudy"; if (rain) icon = "wi-rain"; if (snow) icon = "wi-snow"; + + } else if (conditions == "rain") { + icon += "rain"; + + } else if (conditions == "snow") { + icon += "snow"; } else if (conditions == "sky clear" || conditions == "" || conditions == "clear") { if (night) { @@ -1581,7 +1593,7 @@ var get_wi_icon = function (conditions,rain,snow,night) { } } - } else if (conditions.includes("few clouds") || conditions == "scattered clouds" || conditions == "broken clouds") { + } else if (conditions.includes("few clouds") || conditions == "scattered clouds" || conditions == "broken clouds" || conditions == "cloudy") { if (rain) { icon += "rain"; } else if (snow) { @@ -1593,7 +1605,6 @@ var get_wi_icon = function (conditions,rain,snow,night) { } else { icon = "wi-na"; } - return icon; } @@ -3454,6 +3465,46 @@ $(document).ready(function() { display_mode = $(this).find('input').attr('id'); developer = false; } + + if (developer == true) { + //turn on collections drag-n-dropping + $("#list_content").sortable({ + tolerance: "pointer", + items: ".col-sm-4", + update: function( event, ui ) { + var URLHash = URLToHash(); + //Get Sorted Array of Entities + var outputJSON = $( "#list_content" ).sortable( "toArray", { attribute: "colid" } ); + //outputJSON = '["' + outputJSON.join('","') + '"]'; + //URLHash.path = "/objects/" + entity + "/sort_order"; + //delete URLHash.parents; + console.log("outputJSON="+JSON.stringify(outputJSON)); + //URLHash={"_collection_key":"0,6"} + console.log("URLHash="+JSON.stringify(URLHash)); + console.log("Key="+URLHash._collection_key.substr(URLHash._collection_key.lastIndexOf(',') + 1)); + + }, + //to prevent long clicks from firing while dragging + start: function(event, ui) { + // $("#list_content").mayTriggerLongClicks().off(); + }, + stop: function(event, ui) { + // $("#list_content").mayTriggerLongClicks().on( 'longClick', function() { + // var entity = $(this).attr("entity"); + // console.log("long_click="+JSON.stringify($(this))); + // }); + } + }); + //$('#list_content').disableSelection(); + $("#list_content").mayTriggerLongClicks().on( 'longClick', function() { + var entity = $(this).attr("entity"); + console.log("long_click="+JSON.stringify($(this))); + }); + } else { + $("#list_content").sortable("destroy"); + //$("#list_content").enableSelection(); + $("#list_content").mayTriggerLongClicks().off(); + } document.cookie = "display_mode="+display_mode; document.cookie = "developer="+developer; diff --git a/web/ia7/index.shtml b/web/ia7/index.shtml index e635c72d7..ff486f8e6 100644 --- a/web/ia7/index.shtml +++ b/web/ia7/index.shtml @@ -372,6 +372,24 @@
+ +
\ No newline at end of file