Initial commit
This commit is contained in:
3
widgets/template/css/style.css
Normal file
3
widgets/template/css/style.css
Normal file
@@ -0,0 +1,3 @@
|
||||
.template-class {
|
||||
font-style: italic;
|
||||
}
|
||||
BIN
widgets/template/img/test.png
Normal file
BIN
widgets/template/img/test.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.5 KiB |
68
widgets/template/js/template.js
Normal file
68
widgets/template/js/template.js
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
ioBroker.template Widget-Set
|
||||
|
||||
version: "0.5.0"
|
||||
|
||||
Copyright 10.2015-2016 @@Author@@<@@email@@>
|
||||
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
// add translations for edit mode
|
||||
if (vis.editMode) {
|
||||
$.extend(true, systemDictionary, {
|
||||
"myColor": {"en": "myColor", "de": "mainColor", "ru": "Мой цвет"},
|
||||
"myColor_tooltip": {
|
||||
"en": "Description of\x0AmyColor",
|
||||
"de": "Beschreibung von\x0AmyColor",
|
||||
"ru": "Описание\x0AmyColor"
|
||||
},
|
||||
"htmlText": {"en": "htmlText", "de": "htmlText", "ru": "htmlText"},
|
||||
"group_extraMyset": {"en": "extraMyset", "de": "extraMyset", "ru": "extraMyset"},
|
||||
"extraAttr": {"en": "extraAttr", "de": "extraAttr", "ru": "extraAttr"}
|
||||
});
|
||||
}
|
||||
|
||||
// add translations for non-edit mode
|
||||
$.extend(true, systemDictionary, {
|
||||
"Instance": {"en": "Instance", "de": "Instanz", "ru": "Инстанция"}
|
||||
});
|
||||
|
||||
// this code can be placed directly in template.html
|
||||
vis.binds.template = {
|
||||
version: "0.5.0",
|
||||
showVersion: function () {
|
||||
if (vis.binds.template.version) {
|
||||
console.log('Version template: ' + vis.binds.template.version);
|
||||
vis.binds.template.version = null;
|
||||
}
|
||||
},
|
||||
createWidget: function (widgetID, view, data, style) {
|
||||
var $div = $('#' + widgetID);
|
||||
// if nothing found => wait
|
||||
if (!$div.length) {
|
||||
return setTimeout(function () {
|
||||
vis.binds.template.createWidget(widgetID, view, data, style);
|
||||
}, 100);
|
||||
}
|
||||
|
||||
var text = '';
|
||||
text += 'OID: ' + data.oid + '</div><br>';
|
||||
text += 'OID value: <span class="myset-value">' + vis.states[data.oid + '.val'] + '</span><br>';
|
||||
text += 'Color: <span style="color: ' + data.myColor + '">' + data.myColor + '</span><br>';
|
||||
text += 'extraAttr: ' + data.extraAttr + '<br>';
|
||||
text += 'Browser instance: ' + vis.instance + '<br>';
|
||||
text += 'htmlText: <textarea readonly style="width:100%">' + (data.htmlText || '') + '</textarea><br>';
|
||||
|
||||
$('#' + widgetID).html(text);
|
||||
|
||||
// subscribe on updates of value
|
||||
if (data.oid) {
|
||||
vis.states.bind(data.oid + '.val', function (e, newVal, oldVal) {
|
||||
$div.find('.template-value').html(newVal);
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
vis.binds.template.showVersion();
|
||||
Reference in New Issue
Block a user