1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Tweak some node labels to make the behaviour more consistent (at least per palette section)

This commit is contained in:
Dave C-J 2013-09-27 10:38:59 +01:00
parent e4f105c7a1
commit 9c6fb698ea
4 changed files with 36 additions and 35 deletions

View File

@ -15,61 +15,62 @@
-->
<script type="text/x-red" data-template-name="inject">
<div class="form-row">
<label for="node-input-topic"><i class="icon-tasks"></i> Topic</label>
<input type="text" id="node-input-topic" placeholder="Topic">
</div>
<div class="form-row node-input-payload">
<label for="node-input-payload"><i class="icon-envelope"></i> Payload</label>
<input type="text" id="node-input-payload" placeholder="Payload">
</div>
<div class="form-row">
<label for="node-input-topic"><i class="icon-tasks"></i> Topic</label>
<input type="text" id="node-input-topic" placeholder="Topic">
</div>
<div class="form-row">
<label>&nbsp;</label>
<input type="checkbox" id="node-input-once" placeholder="once" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-input-once" style="width: 70%;">Fire once at start ?</label>
</div>
<div class="form-row">
<label for=""><i class="icon-repeat"></i> Repeat</label>
<select id="inject-time-type-select"><option value="none">None</option><option value="interval">interval</option><option value="interval-time">interval between times</option><option value="time">at a specific time</option></select>
<input type="hidden" id="node-input-repeat" placeholder="Payload">
<input type="hidden" id="node-input-crontab" placeholder="Payload">
</div>
<div class="form-row inject-time-row hidden" id="inject-time-row-interval">
every <input id="inject-time-interval-count" class="inject-time-count" value="1"></input>
<select style="width: 100px" id="inject-time-interval-units"><option value="s">seconds</option><option value="m">minutes</option><option value="h">hours</option></select><br/>
on <select disabled id="inject-time-interval-days" class="inject-time-days"></select>
</div>
<div class="form-row inject-time-row hidden" id="inject-time-row-interval-time">
every <input id="inject-time-interval-time-units" class="inject-time-count" value="1"></input> minutes<br/>
every <input id="inject-time-interval-time-units" class="inject-time-count" value="1"></input> minutes<br/>
between <select id="inject-time-interval-time-start" class="inject-time-times"></select>
and <select id="inject-time-interval-time-end" class="inject-time-times"></select><br/>
on <select id="inject-time-interval-time-days" class="inject-time-days"></select>
</div>
<div class="form-row inject-time-row hidden" id="inject-time-row-time">
at <input id="inject-time-time" value="12:00"></input><br/>
on <select id="inject-time-time-days" class="inject-time-days"></select>
</div>
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-tips">Tip: Injects Date.now() if no payload set</div>
<script>
{
$("#inject-time-type-select").change(function() {
var id = $("#inject-time-type-select option:selected").val();
$(".inject-time-row").hide();
$("#inject-time-row-"+id).show();
});
var days = [
{v:"*",t:"every day"},
{v:"1-5",t:"Mondays to Fridays"},
@ -87,7 +88,7 @@
$(this).append($("<option></option>").val(days[d].v).text(days[d].t));
}
});
$(".inject-time-times").each(function() {
for (var i=0;i<24;i++) {
var l = (i<10?"0":"")+i+":00";
@ -98,14 +99,14 @@
min:1,
max:60
});
$("#inject-time-interval-units").change(function() {
var units = $("#inject-time-interval-units option:selected").val();
$("#inject-time-interval-days").prop("disabled",(units == "s")?"disabled":false);
$(".inject-time-count").spinner("option","max",(units == "h")?24:60);
});
$.widget( "ui.injecttimespinner", $.ui.spinner, {
options: {
@ -131,16 +132,16 @@
var d = new Date(value);
var h = d.getHours();
var m = d.getMinutes();
return ((h<10)?"0":"")+h+":"+((m<10)?"0":"")+m;
}
});
$("#inject-time-time").injecttimespinner();
};
</script>
</script>
<style>
@ -169,7 +170,7 @@
width: 30px !important;
}
.
</style>
<script type="text/x-red" data-help-name="inject">
<p>Pressing the button on the left side of the node allows a message on a topic to be injected into the flow. This is mainly for test purposes.</p>
@ -194,7 +195,7 @@
outputs:1,
icon: "inject.png",
label: function() {
return this.name||this.topic||this.payload;
return this.name||this.topic||this.payload||"inject";
},
labelStyle: function() {
return this.name?"node_label_italic":"";
@ -216,7 +217,7 @@
$("#inject-time-time").val(time);
$("#inject-time-type-select option").filter(function() {return $(this).val() == "s";}).attr('selected',true);
$("#inject-time-time-days option").filter(function() {return $(this).val() == days;}).attr('selected',true);
} else if (cronparts[0] == "0") {
// interval - hours
var hours = cronparts[1].slice(2);
@ -257,7 +258,7 @@
// 23,0 or 17-23,0-10 or 23,0-2 or 17-23,0
var startparts = timeparts[0].split("-");
start = startparts[0];
var endparts = timeparts[1].split("-");
if (endparts.length == 1) {
end = Number(endparts[0])+1;
@ -272,12 +273,12 @@
} else {
$("#inject-time-type-select option").filter(function() {return $(this).val() == "none";}).attr('selected',true);
}
$(".inject-time-row").hide();
$("#inject-time-type-select option").filter(function() {return $(this).val() == repeattype;}).attr('selected',true);
$("#inject-time-row-"+repeattype).show();
},
oneditsave: function() {
var repeat = "";
@ -297,7 +298,7 @@
} else if (units == "h") {
crontab = "0 */"+count+" * * "+days;
}
}
}
} else if (type == "interval-time") {
var count = $("#inject-time-interval-time-units").val();
var startTime = Number($("#inject-time-interval-time-start option:selected").val());
@ -338,10 +339,10 @@
repeat = 0;
crontab = parts[1]+" "+parts[0]+" * * "+days;
}
$("#node-input-repeat").val(repeat);
$("#node-input-crontab").val(crontab);
},
button: {
onclick: function() {

View File

@ -43,7 +43,7 @@
outputs:0,
icon: "file.png",
label: function() {
return this.name||"comment";
return this.name||"";
},
labelStyle: function() {
return this.name?"node_label_italic":"";

View File

@ -47,7 +47,7 @@
outputs:1,
icon: "bridge.png",
label: function() {
return this.name||this.topic;
return this.name||this.topic||"mqtt";
},
labelStyle: function() {
return this.name?"node_label_italic":"";
@ -90,7 +90,7 @@
icon: "bridge.png",
align: "right",
label: function() {
return this.name||this.topic;
return this.name||this.topic||"mqtt";
},
labelStyle: function() {
return this.name?"node_label_italic":"";

View File

@ -50,10 +50,10 @@
outputs:1,
icon: "white-globe.png",
label: function() {
return this.name||this.baseurl||"http(s) get";
return this.name||this.baseurl;
},
labelStyle: function() {
return (this.name||!this.baseurl)?"node_label_italic":"";
return this.name?"node_label_italic":"";
}
});
</script>