From dc00870461f30dc017efefbe405c98dfb7c966e0 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Mon, 4 Jul 2016 11:21:58 +0100 Subject: [PATCH] Fix select box handling in Safari Fixes #928 --- nodes/core/core/20-inject.html | 28 ++++++++++++---------------- nodes/core/core/25-catch.html | 4 ++-- nodes/core/core/25-status.html | 4 ++-- nodes/core/hardware/36-rpi-gpio.html | 4 ++-- nodes/core/io/31-tcpin.html | 8 ++++---- nodes/core/io/32-udp.html | 12 +++++------- nodes/core/logic/10-switch.html | 14 ++++++++------ nodes/core/logic/15-change.html | 9 ++++++--- nodes/core/parsers/70-CSV.html | 2 +- 9 files changed, 42 insertions(+), 43 deletions(-) diff --git a/nodes/core/core/20-inject.html b/nodes/core/core/20-inject.html index d1fcd104e..1adddd9d5 100644 --- a/nodes/core/core/20-inject.html +++ b/nodes/core/core/20-inject.html @@ -251,7 +251,7 @@ $("#inject-time-type-select").change(function() { $("#node-input-crontab").val(''); - var id = $("#inject-time-type-select option:selected").val(); + var id = $("#inject-time-type-select").val(); $(".inject-time-row").hide(); $("#inject-time-row-"+id).show(); if ((id == "none") || (id == "interval")) { @@ -271,8 +271,8 @@ }); $("").val(24).text("00:00").appendTo("#inject-time-interval-time-end"); $("#inject-time-interval-time-start").change(function() { - var start = Number($("#inject-time-interval-time-start option:selected").val()); - var end = Number($("#inject-time-interval-time-end option:selected").val()); + var start = Number($("#inject-time-interval-time-start").val()); + var end = Number($("#inject-time-interval-time-end").val()); $("#inject-time-interval-time-end option").remove(); for (var i=start+1;i<25;i++) { var l = (i<10?"0":"")+i+":00"; @@ -291,10 +291,6 @@ min:1 }); - $("#inject-time-interval-units").change(function() { - var units = $("#inject-time-interval-units option:selected").val(); - }); - $.widget( "ui.injecttimespinner", $.ui.spinner, { options: { // seconds @@ -342,7 +338,7 @@ // Fixed time var time = cronparts[1]+":"+cronparts[0]; $("#inject-time-time").val(time); - $("#inject-time-type-select option").filter(function() {return $(this).val() == "s";}).attr('selected',true); + $("#inject-time-type-select").val("s"); if (days == "*") { $("#inject-time-time-days input[type=checkbox]").prop("checked",true); } else { @@ -397,16 +393,16 @@ end = Number(endparts[1])+1; } } - $("#inject-time-interval-time-end option").filter(function() {return $(this).val() == end;}).attr('selected',true); - $("#inject-time-interval-time-start option").filter(function() {return $(this).val() == start;}).attr('selected',true); + $("#inject-time-interval-time-end").val(end); + $("#inject-time-interval-time-start").val(start); } } else { - $("#inject-time-type-select option").filter(function() {return $(this).val() == "none";}).attr('selected',true); + $("#inject-time-type-select").val("none"); } $(".inject-time-row").hide(); - $("#inject-time-type-select option").filter(function() {return $(this).val() == repeattype;}).attr('selected',true); + $("#inject-time-type-select").val(repeattype); $("#inject-time-row-"+repeattype).show(); $("#node-input-payload").typedInput('type',this.payloadType); @@ -418,12 +414,12 @@ oneditsave: function() { var repeat = ""; var crontab = ""; - var type = $("#inject-time-type-select option:selected").val(); + var type = $("#inject-time-type-select").val(); if (type == "none") { // nothing } else if (type == "interval") { var count = $("#inject-time-interval-count").val(); - var units = $("#inject-time-interval-units option:selected").val(); + var units = $("#inject-time-interval-units").val(); if (units == "s") { repeat = count; } else { @@ -438,8 +434,8 @@ } else if (type == "interval-time") { repeat = ""; var count = $("#inject-time-interval-time-units").val(); - var startTime = Number($("#inject-time-interval-time-start option:selected").val()); - var endTime = Number($("#inject-time-interval-time-end option:selected").val()); + var startTime = Number($("#inject-time-interval-time-start").val()); + var endTime = Number($("#inject-time-interval-time-end").val()); var days = $('#inject-time-interval-time-days input[type=checkbox]:checked').map(function(_, el) { return $(el).val() }).get(); diff --git a/nodes/core/core/25-catch.html b/nodes/core/core/25-catch.html index f21b30dc1..87c87c9cc 100644 --- a/nodes/core/core/25-catch.html +++ b/nodes/core/core/25-catch.html @@ -242,7 +242,7 @@ $("#node-input-scope-select").change(function(e) { - var scope = $(this).children("option:selected").val(); + var scope = $(this).val(); if (scope === "target") { createNodeList(); $(".node-input-target-row").show(); @@ -259,7 +259,7 @@ $("#node-input-scope-select").change(); }, oneditsave: function() { - var scope = $("#node-input-scope-select").children("option:selected").val(); + var scope = $("#node-input-scope-select").val(); if (scope === 'all') { this.scope = null; } else { diff --git a/nodes/core/core/25-status.html b/nodes/core/core/25-status.html index fab27d5b3..819696af8 100644 --- a/nodes/core/core/25-status.html +++ b/nodes/core/core/25-status.html @@ -231,7 +231,7 @@ }) $("#node-input-scope-select").change(function(e) { - var scope = $(this).children("option:selected").val(); + var scope = $(this).val(); if (scope === "target") { createNodeList(); $(".node-input-target-row").show(); @@ -248,7 +248,7 @@ $("#node-input-scope-select").change(); }, oneditsave: function() { - var scope = $("#node-input-scope-select").children("option:selected").val(); + var scope = $("#node-input-scope-select").val(); if (scope === 'all') { this.scope = null; } else { diff --git a/nodes/core/hardware/36-rpi-gpio.html b/nodes/core/hardware/36-rpi-gpio.html index d4f04571c..a4f164e03 100644 --- a/nodes/core/hardware/36-rpi-gpio.html +++ b/nodes/core/hardware/36-rpi-gpio.html @@ -140,7 +140,7 @@ }); $("#node-input-intype").change(function() { - var newtype = $("#node-input-intype option:selected").val(); + var newtype = $("#node-input-intype").val(); if ((pinsInUse.hasOwnProperty(pinnow)) && (pinsInUse[pinnow] !== newtype)) { RED.notify(pinname+" "+pinnow+" "+alreadyset+" "+pinsInUse[pinnow],"error"); } @@ -286,7 +286,7 @@ }); $("#node-input-out").change(function() { - var newtype = $("#node-input-out option:selected").val(); + var newtype = $("#node-input-out").val(); if ((pinsInUse.hasOwnProperty(pinnow)) && (pinsInUse[pinnow] !== newtype)) { RED.notify(pinname+" "+pinnow+" "+alreadyset+" "+pinsInUse[pinnow],"error"); } diff --git a/nodes/core/io/31-tcpin.html b/nodes/core/io/31-tcpin.html index dcbf05a35..b0e782f76 100644 --- a/nodes/core/io/31-tcpin.html +++ b/nodes/core/io/31-tcpin.html @@ -86,14 +86,14 @@ }, oneditprepare: function() { var updateOptions = function() { - var sockettype = $("#node-input-server option:selected").val(); + var sockettype = $("#node-input-server").val(); if (sockettype == "client") { $("#node-input-host-row").show(); } else { $("#node-input-host-row").hide(); } - var datamode = $("#node-input-datamode option:selected").val(); - var datatype = $("#node-input-datatype option:selected").val(); + var datamode = $("#node-input-datamode").val(); + var datatype = $("#node-input-datatype").val(); if (datamode == "stream") { if (datatype == "utf8") { $("#node-row-newline").show(); @@ -181,7 +181,7 @@ }, oneditprepare: function() { var updateOptions = function() { - var sockettype = $("#node-input-beserver option:selected").val(); + var sockettype = $("#node-input-beserver").val(); if (sockettype == "reply") { $("#node-input-port-row").hide(); $("#node-input-host-row").hide(); diff --git a/nodes/core/io/32-udp.html b/nodes/core/io/32-udp.html index 9dbaff934..3bfa790cf 100644 --- a/nodes/core/io/32-udp.html +++ b/nodes/core/io/32-udp.html @@ -90,7 +90,7 @@ }, oneditprepare: function() { $("#node-input-multicast").change(function() { - var id = $("#node-input-multicast option:selected").val(); + var id = $("#node-input-multicast").val(); if (id == "false") { $(".node-input-group").hide(); $(".node-input-iface").hide(); @@ -202,12 +202,10 @@ var bindtarget = this._("udp.bind.target"); var type = this.outport==""?"random":"fixed"; - $("#node-input-outport-type option").filter(function() { - return $(this).val() == type; - }).attr('selected',true); + $("#node-input-outport-type").val(type); $("#node-input-outport-type").change(function() { - var type = $(this).children("option:selected").val(); + var type = $(this).val(); if (type == "random") { $("#node-input-outport").val("").hide(); } else { @@ -217,7 +215,7 @@ $("#node-input-outport-type").change(); $("#node-input-multicast").change(function() { - var id = $("#node-input-multicast option:selected").val(); + var id = $("#node-input-multicast").val(); if (id === "multi") { $(".node-input-iface").show(); $("#node-input-addr-label").html(' ' + grouplabel); @@ -233,7 +231,7 @@ $("#node-input-addr-label").html(' ' + addresslabel); $("#node-input-addr")[0].placeholder = addressph; } - var type = $(this).children("option:selected").val(); + var type = $(this).val(); if (type == "false") { $("#node-input-outport-type-random").html(bindrandom); } else { diff --git a/nodes/core/logic/10-switch.html b/nodes/core/logic/10-switch.html index 81e5c4f95..50f48ec45 100644 --- a/nodes/core/logic/10-switch.html +++ b/nodes/core/logic/10-switch.html @@ -88,7 +88,7 @@ function resizeRule(rule) { var newWidth = rule.width(); var selectField = rule.find("select"); - var type = selectField.children("option:selected").val()||""; + var type = selectField.val()||""; var valueField = rule.find(".node-input-rule-value"); var btwnField1 = rule.find(".node-input-rule-btwn-value"); var btwnField2 = rule.find(".node-input-rule-btwn-value2"); @@ -115,7 +115,10 @@ $("#node-input-rule-container").css('min-height','250px').css('min-width','450px').editableList({ addItem: function(container,i,opt) { - var rule = opt||{t:"",v:"",v2:""}; + var rule = opt; + if (!rule.hasOwnProperty('t')) { + rule.t = 'eq'; + } var row = $('
').appendTo(container); var row2 = $('
',{style:"padding-top: 5px; padding-left: 175px;"}).appendTo(container); var row3 = $('
',{style:"padding-top: 5px; padding-left: 102px;"}).appendTo(container); @@ -133,8 +136,7 @@ $('