diff --git a/data/index.htm.gz b/data/index.htm.gz index 6e55b26..e8fefe4 100644 Binary files a/data/index.htm.gz and b/data/index.htm.gz differ diff --git a/data/js/remora.js.gz b/data/js/remora.js.gz index 3ed56a1..e1e0c06 100644 Binary files a/data/js/remora.js.gz and b/data/js/remora.js.gz differ diff --git a/remora.h b/remora.h index 312ee19..804007f 100644 --- a/remora.h +++ b/remora.h @@ -92,7 +92,7 @@ #include #include #include - + extern "C" { #include "user_interface.h" } @@ -113,10 +113,10 @@ extern "C" { //#define DEBUG_INIT // Décommenter cette ligne si DEBUG_SERIAL est Serial1 #endif -#define DEBUG +//#define DEBUG // Décommenter cette ligne pour activer le DEBUG serial // I prefix debug macro to be sure to use specific for THIS library -// debugging, this should not interfere with main sketch or other +// debugging, this should not interfere with main sketch or other // libraries #ifdef DEBUG #define Debug(x) DEBUG_SERIAL.print(x) @@ -126,12 +126,12 @@ extern "C" { #define Debugf(...) DEBUG_SERIAL.printf(__VA_ARGS__) #define Debugflush DEBUG_SERIAL.flush #else -#define Debug(x) {} -#define Debugln(x) {} -#define DebugF(x) {} -#define DebuglnF(x) {} -#define Debugf(...) {} -#define Debugflush(){} +#define Debug(x) +#define Debugln(x) +#define DebugF(x) +#define DebuglnF(x) +#define Debugf(...) +#define Debugflush() #endif // Includes du projets remora diff --git a/webdev/config.json b/webdev/config.json index 0775288..82a1a7f 100644 --- a/webdev/config.json +++ b/webdev/config.json @@ -1,13 +1,20 @@ { -"ssid":"myssid", -"psk":"mypsk", -"host":"WifInfo", -"ap_psk":"", -"emon_host":"emoncms.org", -"emon_port":"80", -"emon_url":"/input.json", -"emon_apikey":"sdfsdsdsds", -"emon_node":"0", -"ota_auth":"WifInfo_8266", -"ota_port":"8266" -} \ No newline at end of file + "ssid":"myssid", + "psk":"mypsk", + "host":"WifInfo", + "ap_psk":"", + "emon_host":"emoncms.org", + "emon_port":"80", + "emon_url":"/input.json", + "emon_apikey":"sdfsdsdsds", + "emon_node":"0", + + "jdom_host":"jeedom.local", + "jdom_port":"12", + "jdom_url":"/jeedom/plugins/teleinfo/core/php/jeeTeleinfo.php", + "jdom_apikey":"12345678901234567890123456789012345678901234567890", + "jdom_adco":"123456789012", + + "ota_auth":"WifInfo_8266", + "ota_port":"8266" +} diff --git a/webdev/create_spiffs.js b/webdev/create_spiffs.js index 6a57c19..2329005 100644 --- a/webdev/create_spiffs.js +++ b/webdev/create_spiffs.js @@ -4,9 +4,9 @@ // This file is not part of web server, it's just used as ESP8266 SPIFFS // WEB server files preparation tool // Please install dependencies with -// npm install zlib +// npm install // after all is installed just start by typing on command line -// node create_spiffs.js +// npm run create_spiffs // once all is fine, you can upload data tiles with Arduino IDE // // Written by Charles-Henri Hallard (http://hallard.me) @@ -102,4 +102,3 @@ for (var i = 0; i < fonts.length; i++) { fs.createReadStream('fonts/' + fonts[i]).pipe(fs.createWriteStream('../data/fonts/' + fonts[i])); } console.log('finished!'); - diff --git a/webdev/index.htm b/webdev/index.htm index 3c03e09..bd00744 100644 --- a/webdev/index.htm +++ b/webdev/index.htm @@ -220,27 +220,24 @@

 Emoncms

-
+
- +
- +
- +
- +
@@ -253,7 +250,7 @@

- @@ -296,27 +293,24 @@

 Jeedom

-
+
- +
- +
- +
- +
@@ -328,7 +322,7 @@

- @@ -932,9 +926,13 @@ .fail(function() { console.log( "error while requestiong spiffs data" ); }) } else if (target=='#tab_cfg') { $.getJSON( "/config.json", function(form_data) { + + // Autofill form $("#frm_config").autofill(form_data); - }) - .fail(function() { console.log( "error while requestiong configuration data" ); }) + + // Trigger change on all form inputs + $("#frm_config input, textarea, select").trigger('change', [form_data]); + }).fail(function() { console.log( "error while requestiong configuration data" ); }) $('#tab_scan_data').bootstrapTable('refresh',{silent:true, showLoading:true, url:'/wifiscan.json'}); } @@ -1147,7 +1145,6 @@ } $('#btn_test').click(function(){ waitReboot(); }); -
@@ -1156,4 +1153,3 @@
- diff --git a/webdev/js/remora.js b/webdev/js/remora.js index 54adba3..992969a 100644 --- a/webdev/js/remora.js +++ b/webdev/js/remora.js @@ -23,4 +23,4 @@ d.trigger("activate.bs.scrollspy")},b.prototype.clear=function(){a(this.selector * Licensed MIT License */ !function(a){"use strict";a.fn.bootstrapTable.locales["fr-FR"]={formatLoadingMessage:function(){return"Chargement en cours, patientez, s´il vous plaît ..."},formatRecordsPerPage:function(a){return a+" lignes par page"},formatShowingRows:function(a,b,c){return"Affichage des lignes "+a+" à "+b+" sur "+c+" lignes au total"},formatSearch:function(){return"Rechercher"},formatNoMatches:function(){return"Aucun résultat trouvé"},formatRefresh:function(){return"Rafraîchir"},formatToggle:function(){return"Alterner"},formatColumns:function(){return"Colonnes"},formatAllRows:function(){return"Tous"}},a.extend(a.fn.bootstrapTable.defaults,a.fn.bootstrapTable.locales["fr-FR"])}(jQuery);!function(t){"function"==typeof define&&define.amd?define(["jquery"],t):t("object"==typeof exports?require("jquery"):jQuery)}(function(t){function s(s){var e=!1;return t('[data-notify="container"]').each(function(i,n){var a=t(n),o=a.find('[data-notify="title"]').text().trim(),r=a.find('[data-notify="message"]').html().trim(),l=o===t("
"+s.settings.content.title+"
").html().trim(),d=r===t("
"+s.settings.content.message+"
").html().trim(),g=a.hasClass("alert-"+s.settings.type);return l&&d&&g&&(e=!0),!e}),e}function e(e,n,a){var o={content:{message:"object"==typeof n?n.message:n,title:n.title?n.title:"",icon:n.icon?n.icon:"",url:n.url?n.url:"#",target:n.target?n.target:"-"}};a=t.extend(!0,{},o,a),this.settings=t.extend(!0,{},i,a),this._defaults=i,"-"===this.settings.content.target&&(this.settings.content.target=this.settings.url_target),this.animations={start:"webkitAnimationStart oanimationstart MSAnimationStart animationstart",end:"webkitAnimationEnd oanimationend MSAnimationEnd animationend"},"number"==typeof this.settings.offset&&(this.settings.offset={x:this.settings.offset,y:this.settings.offset}),(this.settings.allow_duplicates||!this.settings.allow_duplicates&&!s(this))&&this.init()}var i={element:"body",position:null,type:"info",allow_dismiss:!0,allow_duplicates:!0,newest_on_top:!1,showProgressbar:!1,placement:{from:"top",align:"right"},offset:20,spacing:10,z_index:1031,delay:5e3,timer:1e3,url_target:"_blank",mouse_over:null,animate:{enter:"animated fadeInDown",exit:"animated fadeOutUp"},onShow:null,onShown:null,onClose:null,onClosed:null,icon_type:"class",template:''};String.format=function(){for(var t=arguments[0],s=1;s .progress-bar').removeClass("progress-bar-"+t.settings.type),t.settings.type=i[n],this.$ele.addClass("alert-"+i[n]).find('[data-notify="progressbar"] > .progress-bar').addClass("progress-bar-"+i[n]);break;case"icon":var a=this.$ele.find('[data-notify="icon"]');"class"===t.settings.icon_type.toLowerCase()?a.removeClass(t.settings.content.icon).addClass(i[n]):(a.is("img")||a.find("img"),a.attr("src",i[n]));break;case"progress":var o=t.settings.delay-t.settings.delay*(i[n]/100);this.$ele.data("notify-delay",o),this.$ele.find('[data-notify="progressbar"] > div').attr("aria-valuenow",i[n]).css("width",i[n]+"%");break;case"url":this.$ele.find('[data-notify="url"]').attr("href",i[n]);break;case"target":this.$ele.find('[data-notify="url"]').attr("target",i[n]);break;default:this.$ele.find('[data-notify="'+n+'"]').html(i[n])}var r=this.$ele.outerHeight()+parseInt(t.settings.spacing)+parseInt(t.settings.offset.y);t.reposition(r)},close:function(){t.close()}}},buildNotify:function(){var s=this.settings.content;this.$ele=t(String.format(this.settings.template,this.settings.type,s.title,s.message,s.url,s.target)),this.$ele.attr("data-notify-position",this.settings.placement.from+"-"+this.settings.placement.align),this.settings.allow_dismiss||this.$ele.find('[data-notify="dismiss"]').css("display","none"),(this.settings.delay>0||this.settings.showProgressbar)&&this.settings.showProgressbar||this.$ele.find('[data-notify="progressbar"]').remove()},setIcon:function(){"class"===this.settings.icon_type.toLowerCase()?this.$ele.find('[data-notify="icon"]').addClass(this.settings.content.icon):this.$ele.find('[data-notify="icon"]').is("img")?this.$ele.find('[data-notify="icon"]').attr("src",this.settings.content.icon):this.$ele.find('[data-notify="icon"]').append('Notify Icon')},styleDismiss:function(){this.$ele.find('[data-notify="dismiss"]').css({position:"absolute",right:"10px",top:"5px",zIndex:this.settings.z_index+2})},styleURL:function(){this.$ele.find('[data-notify="url"]').css({backgroundImage:"url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)",height:"100%",left:0,position:"absolute",top:0,width:"100%",zIndex:this.settings.z_index+1})},placement:function(){var s=this,e=this.settings.offset.y,i={display:"inline-block",margin:"0px auto",position:this.settings.position?this.settings.position:"body"===this.settings.element?"fixed":"absolute",transition:"all .5s ease-in-out",zIndex:this.settings.z_index},n=!1,a=this.settings;switch(t('[data-notify-position="'+this.settings.placement.from+"-"+this.settings.placement.align+'"]:not([data-closing="true"])').each(function(){e=Math.max(e,parseInt(t(this).css(a.placement.from))+parseInt(t(this).outerHeight())+parseInt(a.spacing))}),this.settings.newest_on_top===!0&&(e=this.settings.offset.y),i[this.settings.placement.from]=e+"px",this.settings.placement.align){case"left":case"right":i[this.settings.placement.align]=this.settings.offset.x+"px";break;case"center":i.left=0,i.right=0}this.$ele.css(i).addClass(this.settings.animate.enter),t.each(["webkit-","moz-","o-","ms-",""],function(t,e){s.$ele[0].style[e+"AnimationIterationCount"]=1}),t(this.settings.element).append(this.$ele),this.settings.newest_on_top===!0&&(e=parseInt(e)+parseInt(this.settings.spacing)+this.$ele.outerHeight(),this.reposition(e)),t.isFunction(s.settings.onShow)&&s.settings.onShow.call(this.$ele),this.$ele.one(this.animations.start,function(){n=!0}).one(this.animations.end,function(){t.isFunction(s.settings.onShown)&&s.settings.onShown.call(this)}),setTimeout(function(){n||t.isFunction(s.settings.onShown)&&s.settings.onShown.call(this)},600)},bind:function(){var s=this;if(this.$ele.find('[data-notify="dismiss"]').on("click",function(){s.close()}),this.$ele.mouseover(function(){t(this).data("data-hover","true")}).mouseout(function(){t(this).data("data-hover","false")}),this.$ele.data("data-hover","false"),this.settings.delay>0){s.$ele.data("notify-delay",s.settings.delay);var e=setInterval(function(){var t=parseInt(s.$ele.data("notify-delay"))-s.settings.timer;if("false"===s.$ele.data("data-hover")&&"pause"===s.settings.mouse_over||"pause"!=s.settings.mouse_over){var i=(s.settings.delay-t)/s.settings.delay*100;s.$ele.data("notify-delay",t),s.$ele.find('[data-notify="progressbar"] > div').attr("aria-valuenow",i).css("width",i+"%")}t>-s.settings.timer||(clearInterval(e),s.close())},s.settings.timer)}},close:function(){var s=this,e=parseInt(this.$ele.css(this.settings.placement.from)),i=!1;this.$ele.data("closing","true").addClass(this.settings.animate.exit),s.reposition(e),t.isFunction(s.settings.onClose)&&s.settings.onClose.call(this.$ele),this.$ele.one(this.animations.start,function(){i=!0}).one(this.animations.end,function(){t(this).remove(),t.isFunction(s.settings.onClosed)&&s.settings.onClosed.call(this)}),setTimeout(function(){i||(s.$ele.remove(),s.settings.onClosed&&s.settings.onClosed(s.$ele))},600)},reposition:function(s){var e=this,i='[data-notify-position="'+this.settings.placement.from+"-"+this.settings.placement.align+'"]:not([data-closing="true"])',n=this.$ele.nextAll(i);this.settings.newest_on_top===!0&&(n=this.$ele.prevAll(i)),n.each(function(){t(this).css(e.settings.placement.from,s),s=parseInt(s)+parseInt(e.settings.spacing)+t(this).outerHeight()})}}),t.notify=function(t,s){var i=new e(this,t,s);return i.notify},t.notifyDefaults=function(s){return i=t.extend(!0,{},i,s)},t.notifyClose=function(s){void 0===s||"all"===s?t("[data-notify]").find('[data-notify="dismiss"]').trigger("click"):t('[data-notify-position="'+s+'"]').find('[data-notify="dismiss"]').trigger("click")}}); -!function(t){"function"==typeof define&&define.amd?define(["jquery"],t):"object"==typeof module&&module.exports?module.exports=t(require("jquery")):t(jQuery)}(function(t){var e={},a={};t.ajaxq=function(r,i){function n(t){if(e[r])e[r].push(t);else{e[r]=[];var i=t();a[r]=i}}function o(){if(e[r]){var t=e[r].shift();if(t){var i=t();a[r]=i}else delete e[r],delete a[r]}}if("undefined"==typeof i)throw"AjaxQ: queue name is not provided";var s=t.Deferred(),l=s.promise();l.success=l.done,l.error=l.fail,l.complete=l.always;var d="function"==typeof i,u=d?null:t.extend(!0,{},i);return n(function(){var e=t.ajax.apply(window,[d?i():u]);return e.done(function(){s.resolve.apply(this,arguments)}),e.fail(function(){s.reject.apply(this,arguments)}),e.always(o),e}),l},t.each(["getq","postq"],function(e,a){t[a]=function(e,r,i,n,o){return t.isFunction(i)&&(o=o||n,n=i,i=void 0),t.ajaxq(e,{type:"postq"===a?"post":"get",url:r,data:i,success:n,dataType:o})}});var r=function(t){return e.hasOwnProperty(t)&&e[t].length>0||a.hasOwnProperty(t)},i=function(){for(var t in e)if(r(t))return!0;return!1};t.ajaxq.isRunning=function(t){return t?r(t):i()},t.ajaxq.getActiveRequest=function(t){if(!t)throw"AjaxQ: queue name is required";return a[t]},t.ajaxq.abort=function(r){if(!r)throw"AjaxQ: queue name is required";var i=t.ajaxq.getActiveRequest(r);delete e[r],delete a[r],i&&i.abort()},t.ajaxq.clear=function(t){if(t)e[t]&&(e[t]=[]);else for(var a in e)e.hasOwnProperty(a)&&(e[a]=[])}}),function(t){t.fn.extend({autofill:function(e,a){var r={findbyname:!0,restrict:!0},i=this;return a&&t.extend(r,a),this.each(function(){t.each(e,function(e,a){var n,o;if(r.findbyname)n='[name="'+e+'"]',o=r.restrict?i.find(n):t(n),1==o.length?o.val("checkbox"==o.attr("type")?[a]:a):o.length>1?o.val([a]):(n='[name="'+e+'[]"]',o=r.restrict?i.find(n):t(n),o.each(function(){t(this).val(a)}));else if(n="#"+e,o=r.restrict?i.find(n):t(n),1==o.length)o.val("checkbox"==o.attr("type")?[a]:a);else{var s=!1;o=r.restrict?i.find('input:radio[name="'+e+'"]'):t('input:radio[name="'+e+'"]'),o.each(function(){s=!0,this.value==a&&(this.checked=!0)}),s||(o=r.restrict?i.find('input:checkbox[name="'+e+'[]"]'):t('input:checkbox[name="'+e+'[]"]'),o.each(function(){t(this).val(a)}))}})})}})}(jQuery),+function(t){"use strict";function e(e){return this.each(function(){var r=t(this),i=t.extend({},a.DEFAULTS,r.data(),"object"==typeof e&&e),n=r.data("bs.validator");(n||"destroy"!=e)&&(n||r.data("bs.validator",n=new a(this,i)),"string"==typeof e&&n[e]())})}var a=function(e,r){this.$element=t(e),this.options=r,r.errors=t.extend({},a.DEFAULTS.errors,r.errors);for(var i in r.custom)if(!r.errors[i])throw new Error("Missing default error message for custom validator: "+i);t.extend(a.VALIDATORS,r.custom),this.$element.attr("novalidate",!0),this.toggleSubmit(),this.$element.on("input.bs.validator change.bs.validator focusout.bs.validator",t.proxy(this.validateInput,this)),this.$element.on("submit.bs.validator",t.proxy(this.onSubmit,this)),this.$element.find("[data-match]").each(function(){var e=t(this),a=e.data("match");t(a).on("input.bs.validator",function(t){e.val()&&e.trigger("input.bs.validator")})})};a.INPUT_SELECTOR=':input:not([type="submit"], button):enabled:visible',a.DEFAULTS={delay:500,html:!1,disable:!0,custom:{},errors:{match:"Does not match",minlength:"Not long enough"},feedback:{success:"glyphicon-ok",error:"glyphicon-remove"}},a.VALIDATORS={native:function(t){var e=t[0];return!e.checkValidity||e.checkValidity()},match:function(e){var a=e.data("match");return!e.val()||e.val()===t(a).val()},minlength:function(t){var e=t.data("minlength");return!t.val()||t.val().length>=e}},a.prototype.validateInput=function(e){var a=t(e.target),r=a.data("bs.validator.errors");if(a.is('[type="radio"]')&&(a=this.$element.find('input[name="'+a.attr("name")+'"]')),this.$element.trigger(e=t.Event("validate.bs.validator",{relatedTarget:a[0]})),!e.isDefaultPrevented()){var i=this;this.runValidators(a).done(function(n){a.data("bs.validator.errors",n),n.length?i.showErrors(a):i.clearErrors(a),r&&n.toString()===r.toString()||(e=n.length?t.Event("invalid.bs.validator",{relatedTarget:a[0],detail:n}):t.Event("valid.bs.validator",{relatedTarget:a[0],detail:r}),i.$element.trigger(e)),i.toggleSubmit(),i.$element.trigger(t.Event("validated.bs.validator",{relatedTarget:a[0]}))})}},a.prototype.runValidators=function(e){function r(t){return e.data(t+"-error")||e.data("error")||"native"==t&&e[0].validationMessage||o.errors[t]}var i=[],n=t.Deferred(),o=this.options;return e.data("bs.validator.deferred")&&e.data("bs.validator.deferred").reject(),e.data("bs.validator.deferred",n),t.each(a.VALIDATORS,t.proxy(function(t,a){if((e.data(t)||"native"==t)&&!a.call(this,e)){var n=r(t);!~i.indexOf(n)&&i.push(n)}},this)),!i.length&&e.val()&&e.data("remote")?this.defer(e,function(){var a={};a[e.attr("name")]=e.val(),t.get(e.data("remote"),a).fail(function(t,e,a){i.push(r("remote")||a)}).always(function(){n.resolve(i)})}):n.resolve(i),n.promise()},a.prototype.validate=function(){var t=this.options.delay;return this.options.delay=0,this.$element.find(a.INPUT_SELECTOR).trigger("input.bs.validator"),this.options.delay=t,this},a.prototype.showErrors=function(e){var a=this.options.html?"html":"text";this.defer(e,function(){var r=e.closest(".form-group"),i=r.find(".help-block.with-errors"),n=r.find(".form-control-feedback"),o=e.data("bs.validator.errors");o.length&&(o=t("
    ").addClass("list-unstyled").append(t.map(o,function(e){return t("
  • ")[a](e)})),void 0===i.data("bs.validator.originalContent")&&i.data("bs.validator.originalContent",i.html()),i.empty().append(o),r.addClass("has-error"),n.length&&n.removeClass(this.options.feedback.success)&&n.addClass(this.options.feedback.error)&&r.removeClass("has-success"))})},a.prototype.clearErrors=function(t){var e=t.closest(".form-group"),a=e.find(".help-block.with-errors"),r=e.find(".form-control-feedback");a.html(a.data("bs.validator.originalContent")),e.removeClass("has-error"),r.length&&r.removeClass(this.options.feedback.error)&&r.addClass(this.options.feedback.success)&&e.addClass("has-success")},a.prototype.hasErrors=function(){function e(){return!!(t(this).data("bs.validator.errors")||[]).length}return!!this.$element.find(a.INPUT_SELECTOR).filter(e).length},a.prototype.isIncomplete=function(){function e(){return"checkbox"===this.type?!this.checked:"radio"===this.type?!t('[name="'+this.name+'"]:checked').length:""===t.trim(this.value)}return!!this.$element.find(a.INPUT_SELECTOR).filter("[required]").filter(e).length},a.prototype.onSubmit=function(t){this.validate(),(this.isIncomplete()||this.hasErrors())&&t.preventDefault()},a.prototype.toggleSubmit=function(){if(this.options.disable){var e=t('button[type="submit"], input[type="submit"]').filter('[form="'+this.$element.attr("id")+'"]').add(this.$element.find('input[type="submit"], button[type="submit"]'));e.toggleClass("disabled",this.isIncomplete()||this.hasErrors())}},a.prototype.defer=function(e,a){return a=t.proxy(a,this),this.options.delay?(window.clearTimeout(e.data("bs.validator.timeout")),void e.data("bs.validator.timeout",window.setTimeout(a,this.options.delay))):a()},a.prototype.destroy=function(){return this.$element.removeAttr("novalidate").removeData("bs.validator").off(".bs.validator"),this.$element.find(a.INPUT_SELECTOR).off(".bs.validator").removeData(["bs.validator.errors","bs.validator.deferred"]).each(function(){var e=t(this),a=e.data("bs.validator.timeout");window.clearTimeout(a)&&e.removeData("bs.validator.timeout")}),this.$element.find(".help-block.with-errors").each(function(){var e=t(this),a=e.data("bs.validator.originalContent");e.removeData("bs.validator.originalContent").html(a)}),this.$element.find('input[type="submit"], button[type="submit"]').removeClass("disabled"),this.$element.find(".has-error").removeClass("has-error"),this};var r=t.fn.validator;t.fn.validator=e,t.fn.validator.Constructor=a,t.fn.validator.noConflict=function(){return t.fn.validator=r,this},t(window).on("load",function(){t('form[data-toggle="validator"]').each(function(){var a=t(this);e.call(a,a.data())})})}(jQuery); \ No newline at end of file +!function(t){"function"==typeof define&&define.amd?define(["jquery"],t):"object"==typeof module&&module.exports?module.exports=t(require("jquery")):t(jQuery)}(function(t){var e={},a={};t.ajaxq=function(r,i){function n(t){if(e[r])e[r].push(t);else{e[r]=[];var i=t();a[r]=i}}function o(){if(e[r]){var t=e[r].shift();if(t){var i=t();a[r]=i}else delete e[r],delete a[r]}}if("undefined"==typeof i)throw"AjaxQ: queue name is not provided";var s=t.Deferred(),l=s.promise();l.success=l.done,l.error=l.fail,l.complete=l.always;var d="function"==typeof i,u=d?null:t.extend(!0,{},i);return n(function(){var e=t.ajax.apply(window,[d?i():u]);return e.done(function(){s.resolve.apply(this,arguments)}),e.fail(function(){s.reject.apply(this,arguments)}),e.always(o),e}),l},t.each(["getq","postq"],function(e,a){t[a]=function(e,r,i,n,o){return t.isFunction(i)&&(o=o||n,n=i,i=void 0),t.ajaxq(e,{type:"postq"===a?"post":"get",url:r,data:i,success:n,dataType:o})}});var r=function(t){return e.hasOwnProperty(t)&&e[t].length>0||a.hasOwnProperty(t)},i=function(){for(var t in e)if(r(t))return!0;return!1};t.ajaxq.isRunning=function(t){return t?r(t):i()},t.ajaxq.getActiveRequest=function(t){if(!t)throw"AjaxQ: queue name is required";return a[t]},t.ajaxq.abort=function(r){if(!r)throw"AjaxQ: queue name is required";var i=t.ajaxq.getActiveRequest(r);delete e[r],delete a[r],i&&i.abort()},t.ajaxq.clear=function(t){if(t)e[t]&&(e[t]=[]);else for(var a in e)e.hasOwnProperty(a)&&(e[a]=[])}}),function(t){t.fn.extend({autofill:function(e,a){var r={findbyname:!0,restrict:!0},i=this;return a&&t.extend(r,a),this.each(function(){t.each(e,function(e,a){var n,o;if(r.findbyname)n='[name="'+e+'"]',o=r.restrict?i.find(n):t(n),1==o.length?o.val("checkbox"==o.attr("type")?[a]:a):o.length>1?o.val([a]):(n='[name="'+e+'[]"]',o=r.restrict?i.find(n):t(n),o.each(function(){t(this).val(a)}));else if(n="#"+e,o=r.restrict?i.find(n):t(n),1==o.length)o.val("checkbox"==o.attr("type")?[a]:a);else{var s=!1;o=r.restrict?i.find('input:radio[name="'+e+'"]'):t('input:radio[name="'+e+'"]'),o.each(function(){s=!0,this.value==a&&(this.checked=!0)}),s||(o=r.restrict?i.find('input:checkbox[name="'+e+'[]"]'):t('input:checkbox[name="'+e+'[]"]'),o.each(function(){t(this).val(a)}))}})})}})}(jQuery),+function(t){"use strict";function e(e){return this.each(function(){var r=t(this),i=t.extend({},a.DEFAULTS,r.data(),"object"==typeof e&&e),n=r.data("bs.validator");(n||"destroy"!=e)&&(n||r.data("bs.validator",n=new a(this,i)),"string"==typeof e&&n[e]())})}var a=function(e,r){this.$element=t(e),this.options=r,r.errors=t.extend({},a.DEFAULTS.errors,r.errors);for(var i in r.custom)if(!r.errors[i])throw new Error("Missing default error message for custom validator: "+i);t.extend(a.VALIDATORS,r.custom),this.$element.attr("novalidate",!0),this.toggleSubmit(),this.$element.on("input.bs.validator change.bs.validator focusout.bs.validator",t.proxy(this.validateInput,this)),this.$element.on("submit.bs.validator",t.proxy(this.onSubmit,this)),this.$element.find("[data-match]").each(function(){var e=t(this),a=e.data("match");t(a).on("input.bs.validator",function(t){e.val()&&e.trigger("input.bs.validator")})})};a.INPUT_SELECTOR=':input:not([type="submit"], button):enabled:visible',a.DEFAULTS={delay:500,html:!1,disable:!0,custom:{},errors:{match:"Does not match",minlength:"Not long enough"},feedback:{success:"glyphicon-ok",error:"glyphicon-remove"}},a.VALIDATORS={"native":function(t){var e=t[0];return e.checkValidity?e.checkValidity():!0},match:function(e){var a=e.data("match");return!e.val()||e.val()===t(a).val()},minlength:function(t){var e=t.data("minlength");return!t.val()||t.val().length>=e}},a.prototype.validateInput=function(e){var a=t(e.target),r=a.data("bs.validator.errors");if(a.is('[type="radio"]')&&(a=this.$element.find('input[name="'+a.attr("name")+'"]')),this.$element.trigger(e=t.Event("validate.bs.validator",{relatedTarget:a[0]})),!e.isDefaultPrevented()){var i=this;this.runValidators(a).done(function(n){a.data("bs.validator.errors",n),n.length?i.showErrors(a):i.clearErrors(a),r&&n.toString()===r.toString()||(e=n.length?t.Event("invalid.bs.validator",{relatedTarget:a[0],detail:n}):t.Event("valid.bs.validator",{relatedTarget:a[0],detail:r}),i.$element.trigger(e)),i.toggleSubmit(),i.$element.trigger(t.Event("validated.bs.validator",{relatedTarget:a[0]}))})}},a.prototype.runValidators=function(e){function r(t){return e.data(t+"-error")||e.data("error")||"native"==t&&e[0].validationMessage||o.errors[t]}var i=[],n=t.Deferred(),o=this.options;return e.data("bs.validator.deferred")&&e.data("bs.validator.deferred").reject(),e.data("bs.validator.deferred",n),t.each(a.VALIDATORS,t.proxy(function(t,a){if((e.data(t)||"native"==t)&&!a.call(this,e)){var n=r(t);!~i.indexOf(n)&&i.push(n)}},this)),!i.length&&e.val()&&e.data("remote")?this.defer(e,function(){var a={};a[e.attr("name")]=e.val(),t.get(e.data("remote"),a).fail(function(t,e,a){i.push(r("remote")||a)}).always(function(){n.resolve(i)})}):n.resolve(i),n.promise()},a.prototype.validate=function(){var t=this.options.delay;return this.options.delay=0,this.$element.find(a.INPUT_SELECTOR).trigger("input.bs.validator"),this.options.delay=t,this},a.prototype.showErrors=function(e){var a=this.options.html?"html":"text";this.defer(e,function(){var r=e.closest(".form-group"),i=r.find(".help-block.with-errors"),n=r.find(".form-control-feedback"),o=e.data("bs.validator.errors");o.length&&(o=t("
      ").addClass("list-unstyled").append(t.map(o,function(e){return t("
    • ")[a](e)})),void 0===i.data("bs.validator.originalContent")&&i.data("bs.validator.originalContent",i.html()),i.empty().append(o),r.addClass("has-error"),n.length&&n.removeClass(this.options.feedback.success)&&n.addClass(this.options.feedback.error)&&r.removeClass("has-success"))})},a.prototype.clearErrors=function(t){var e=t.closest(".form-group"),a=e.find(".help-block.with-errors"),r=e.find(".form-control-feedback");a.html(a.data("bs.validator.originalContent")),e.removeClass("has-error"),r.length&&r.removeClass(this.options.feedback.error)&&r.addClass(this.options.feedback.success)&&e.addClass("has-success")},a.prototype.hasErrors=function(){function e(){return!!(t(this).data("bs.validator.errors")||[]).length}return!!this.$element.find(a.INPUT_SELECTOR).filter(e).length},a.prototype.isIncomplete=function(){function e(){return"checkbox"===this.type?!this.checked:"radio"===this.type?!t('[name="'+this.name+'"]:checked').length:""===t.trim(this.value)}return!!this.$element.find(a.INPUT_SELECTOR).filter("[required]").filter(e).length},a.prototype.onSubmit=function(t){this.validate(),(this.isIncomplete()||this.hasErrors())&&t.preventDefault()},a.prototype.toggleSubmit=function(){if(this.options.disable){var e=t('button[type="submit"], input[type="submit"]').filter('[form="'+this.$element.attr("id")+'"]').add(this.$element.find('input[type="submit"], button[type="submit"]'));e.toggleClass("disabled",this.isIncomplete()||this.hasErrors())}},a.prototype.defer=function(e,a){return a=t.proxy(a,this),this.options.delay?(window.clearTimeout(e.data("bs.validator.timeout")),void e.data("bs.validator.timeout",window.setTimeout(a,this.options.delay))):a()},a.prototype.destroy=function(){return this.$element.removeAttr("novalidate").removeData("bs.validator").off(".bs.validator"),this.$element.find(a.INPUT_SELECTOR).off(".bs.validator").removeData(["bs.validator.errors","bs.validator.deferred"]).each(function(){var e=t(this),a=e.data("bs.validator.timeout");window.clearTimeout(a)&&e.removeData("bs.validator.timeout")}),this.$element.find(".help-block.with-errors").each(function(){var e=t(this),a=e.data("bs.validator.originalContent");e.removeData("bs.validator.originalContent").html(a)}),this.$element.find('input[type="submit"], button[type="submit"]').removeClass("disabled"),this.$element.find(".has-error").removeClass("has-error"),this};var r=t.fn.validator;t.fn.validator=e,t.fn.validator.Constructor=a,t.fn.validator.noConflict=function(){return t.fn.validator=r,this},t(window).on("load",function(){t('form[data-toggle="validator"]').each(function(){var a=t(this);e.call(a,a.data())})})}(jQuery); \ No newline at end of file diff --git a/webdev/package.json b/webdev/package.json new file mode 100644 index 0000000..f0a6622 --- /dev/null +++ b/webdev/package.json @@ -0,0 +1,34 @@ +{ + "name": "remora", + "version": "1.0.0", + "description": "remora node server (for development purpose only)", + "scripts": { + "start": "node web_server.js", + "create_spiffs": "node create_spiffs.js", + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+ssh://git@github.com/hallard/remora_soft.git" + }, + "keywords": [ + "remora" + ], + "author": "hallard", + "license": "MIT", + "bugs": { + "url": "https://github.com/hallard/remora_soft/issues" + }, + "homepage": "https://github.com/hallard/remora_soft#readme", + "dependencies": { + "formidable": "1.0.17", + "httpdispatcher": "2.0.1", + "mime": "1.3.4", + "websocket": "1.0.24" + }, + "devDependencies": { + "zlib": "^1.0.5", + "concat-files": "^0.1.1", + "uglify": "^0.1.5" + } +} diff --git a/webdev/web_server.js b/webdev/web_server.js index d9aaeae..94079ff 100644 --- a/webdev/web_server.js +++ b/webdev/web_server.js @@ -1,8 +1,8 @@ // ====================================================================== // ESP8266 WEB Server Simulator // ====================================================================== -// This file is not part of web server, it's just used as ESP8266 -// Simulator to check HTLM / JQuery and all web stuff without needing +// This file is not part of web server, it's just used as ESP8266 +// Simulator to check HTLM / JQuery and all web stuff without needing // to flash ESP8266 target, you'll need nodejs to run it // Please install dependencies with // npm install mime httpdispatcher websocket mime formidable @@ -20,7 +20,8 @@ var mime = require('mime'); var formidable = require("formidable"); var util = require('util'); var os = require('os'); -var dispatcher = require('httpdispatcher'); +var HttpDispatcher = require('httpdispatcher'); +var dispatcher = new HttpDispatcher(); var interval; var startTime = Date.now(); var ws = require('websocket').server; @@ -28,6 +29,7 @@ var temperature=20; var humidity=50; + var config = { "ssid":"CH2I-HOTSPOT", "psk":"DummyOne", @@ -95,7 +97,7 @@ var relais = { "fnct_relais": 2 } -var spiffs = { +var spiffs = { "files":[ {"na":"/css/nrjmeter.css.gz","va":"24325"} ,{"na":"/favicon.ico","va":"1150"} @@ -156,14 +158,14 @@ return[ function humanSize(bytes) { var units = ['kB','MB','GB','TB','PB','EB','ZB','YB'] var thresh = 1024; - if(Math.abs(bytes) < thresh) + if(Math.abs(bytes) < thresh) return bytes + ' B'; var u = -1; do { bytes /= thresh; ++u; - } + } while(Math.abs(bytes) >= thresh && u < units.length - 1); return bytes.toFixed(1)+' '+units[u]; } @@ -173,7 +175,7 @@ function handleRequest(req, res) { try { console.log(req.url); dispatcher.dispatch(req, res); - } + } catch(err) { console.log(err); } @@ -252,7 +254,7 @@ dispatcher.onError(function(req, res) { if (filePath == './') { filePath = './index.htm'; } - + contentType = mime.lookup(filePath); // Stream out he file @@ -268,7 +270,7 @@ dispatcher.onError(function(req, res) { else { res.writeHead(500); res.end('Sorry, check with the site admin for error: '+error.code+' ..\n'); - res.end(); + res.end(); console.log("Error "+filePath+ ' => '+contentType); } } @@ -288,17 +290,17 @@ function rnd(low, high) { return Math.floor((Math.random() * 100 ) * (high - low) + low) ; } -function rTemp() { - temperature = (rnd(-20,20) + 20) / 100.0; +function rTemp() { + temperature = (rnd(-20,20) + 20) / 100.0; return temperature; } -function rHum() { - humidity = (rnd(-20,20) + 50)/100.0; +function rHum() { + humidity = (rnd(-20,20) + 50)/100.0; return humidity; } -function sensors() { +function sensors() { var sensors = { "si7021":[ {"temperature":rTemp(), "humidity":rHum(), "seen":1} ], "sht10":[ {"temperature":rTemp(), "humidity":rHum(), "seen":1} ] } return sensors; @@ -326,7 +328,7 @@ dispatcher.onGet('/tinfo.json', function(req, res) { dispatcher.onGet("/sensors", function(req, res) { res.writeHead(200, {"Content-Type": "text/json"}); res.end(JSON.stringify(sensors())); -}); +}); dispatcher.onGet("/system.json", function(req, res) { //console.log('s[0]=' + util.inspect(system[0], false, null)); @@ -334,17 +336,17 @@ dispatcher.onGet("/system.json", function(req, res) { //system[1].va = humanSize(os.freemem()); res.writeHead(200, {"Content-Type": "text/json"}); res.end(JSON.stringify(system())); -}); +}); dispatcher.onGet("/spiffs", function(req, res) { res.writeHead(200, {"Content-Type": "text/json"}); res.end(JSON.stringify(spiffs)); -}); +}); dispatcher.onGet("/config", function(req, res) { res.writeHead(200, {"Content-Type": "text/json"}); res.end(JSON.stringify(config)); -}); +}); dispatcher.onGet("/fp", function(req, res) { res.writeHead(200, {"Content-Type": "text/json"}); @@ -375,19 +377,19 @@ dispatcher.onGet("/?", function(req, res) { }); form.parse(req); -}); +}); dispatcher.onGet("/wifiscan.json", function(req, res) { setTimeout(function() { res.writeHead(200, {"Content-Type": "text/json"}); res.end(JSON.stringify(wifiscan)); }, 1000, req, res); -}); +}); dispatcher.onGet("/hb", function(req, res) { res.writeHead(200, {"Content-Type": "text/html"}); res.end("OK"); -}); +}); var server = http.createServer(handleRequest); var wsSrv = new ws({ httpServer: server }); @@ -406,7 +408,7 @@ wsSrv.on('request', function(request) { msg = msg[0] console.log('WS msg="' + msg + '" value="'+value+'"'); // Command message - if ( msg.charAt(0)=='$' ) + if ( msg.charAt(0)=='$' ) { clearInterval(interval); @@ -440,4 +442,4 @@ wsSrv.on('request', function(request) { server.listen(8088, function() { //Callback triggered when server is successfully listening. Hurray! console.log("Server listening on: http://localhost:%s", 8088); -}); \ No newline at end of file +});