diff --git a/.gitignore b/.gitignore index 736ea04..817405d 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ .idea/* www/js/*.js +www/js/libs/*.js www/css/styles.css www/css/*.min.css __index.html diff --git a/js_src/SettingsWindow.js b/js_src/SettingsWindow.js index 0338258..4b38378 100644 --- a/js_src/SettingsWindow.js +++ b/js_src/SettingsWindow.js @@ -43,6 +43,7 @@ function SettingsWindow() { this.retryLoadSettingsDelay; // retry setTimout instance this.retrySaveSettingsDelay; // retry setTimout instance + this.retryResetSettingsDelay // retry setTimout instance this.retryRetrieveNetworkStatusDelay;// retry setTimout instance this.apFieldSet; @@ -119,7 +120,8 @@ function SettingsWindow() { self.clientFieldSet = self.form.find("#clientSettings"); self.gcodeSettings = self.form.find("#gcodeSettings"); self.x3gSettings = self.form.find("#x3gSettings"); - + self.btnRestoreSettings = self.form.find("#restoreSettings"); + btnAP.on('touchstart mousedown',self.showAPSettings); btnClient.on('touchstart mousedown',self.showClientSettings); btnRefresh.on('touchstart mousedown',self.refreshNetworks); @@ -127,6 +129,8 @@ function SettingsWindow() { btnCreate.on('touchstart mousedown',self.createAP); self.printerSelector.change(self.printerSelectorChanged); networkSelector.change(self.networkSelectorChanged); + self.btnRestoreSettings.on('touchstart mousedown',self.resetSettings); + // update panel var $updatePanelElement = self.form.find("#updatePanel"); @@ -263,6 +267,40 @@ function SettingsWindow() { }); } } + this.resetSettings = function() { + console.log("resetSettings"); + //$("#restoreSettings").addClass("disabled"); + self.btnRestoreSettings.attr("disabled", true); + + //console.log(" self.wifiboxURL: ",self.wifiboxURL); + + if (communicateWithWifibox) { + $.ajax({ + url: self.wifiboxURL + "/config/resetall", + type: "POST", + dataType: 'json', + timeout: this.timeoutTime, + success: function(response){ + console.log("Settings:resetSettings response: ",response); + if(response.status == "error") { + clearTimeout(self.retryResetSettingsDelay); + self.retryResetSettingsDelay = setTimeout(function() { self.resetSettings() },self.retryDelay); // retry after delay + } else { + settings = response.data; + console.log(" settings: ",settings); + self.fillForm(); + $(document).trigger(SettingsWindow.SETTINGS_LOADED); + + self.btnRestoreSettings.removeAttr("disabled"); + } + } + }).fail(function() { + console.log("Settings:resetSettings: failed"); + clearTimeout(self.retryResetSettingsDelay); + self.retryResetSettingsDelay = setTimeout(function() { self.resetSettings() },self.retryDelay); // retry after delay + }); + } + } this.displayValidationError = function(key,msg) { var formElement = self.form.find("[name|='"+key+"']"); formElement.addClass("error"); diff --git a/less/settingsPopup.less b/less/settingsPopup.less index 7c93ca8..4497375 100644 --- a/less/settingsPopup.less +++ b/less/settingsPopup.less @@ -64,23 +64,28 @@ border: 1px solid rgb(187, 187, 187); border-radius: 5px; } - > .btnContainer { + > .right { width: 15%; height: 100%; float:right; position:relative; right: 0; - > .btnOK { - position: absolute; - bottom: 3%; - right: 7%; - max-width: 85px; - min-width: 42px; - width: 88%; - height: auto; - margin: 0 2% 2% 0; - cursor: pointer; + > .btnContainer { + position: absolute; + bottom: 3%; + right: 7%; + width: 100%; + + > .btn { + max-width: 85px; + min-width: 42px; + width: 88%; + height: auto; + margin: 8% 2% 2% 0; + cursor: pointer; + float:right; + } } } } diff --git a/www/img/buttons/btnReset_settings.png b/www/img/buttons/btnReset_settings.png new file mode 100644 index 0000000..f79bfa0 Binary files /dev/null and b/www/img/buttons/btnReset_settings.png differ diff --git a/www/index.html b/www/index.html index 2965c91..fc98387 100644 --- a/www/index.html +++ b/www/index.html @@ -115,8 +115,10 @@
-
- settings +
+
+ save +
diff --git a/www/js/libs/jquery-1-9-1.min.js b/www/js/libs/jquery-1-9-1.min.js deleted file mode 100644 index bd92be8..0000000 --- a/www/js/libs/jquery-1-9-1.min.js +++ /dev/null @@ -1,3 +0,0 @@ -!function(a,b){function c(a){var b=a.length,c=ib.type(a);return ib.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||"function"!==c&&(0===b||"number"==typeof b&&b>0&&b-1 in a)}function d(a){var b=xb[a]={};return ib.each(a.match(kb)||[],function(a,c){b[c]=!0}),b}function e(a,c,d,e){if(ib.acceptData(a)){var f,g,h=ib.expando,i="string"==typeof c,j=a.nodeType,k=j?ib.cache:a,l=j?a[h]:a[h]&&h;if(l&&k[l]&&(e||k[l].data)||!i||d!==b)return l||(j?a[h]=l=_.pop()||ib.guid++:l=h),k[l]||(k[l]={},j||(k[l].toJSON=ib.noop)),("object"==typeof c||"function"==typeof c)&&(e?k[l]=ib.extend(k[l],c):k[l].data=ib.extend(k[l].data,c)),f=k[l],e||(f.data||(f.data={}),f=f.data),d!==b&&(f[ib.camelCase(c)]=d),i?(g=f[c],null==g&&(g=f[ib.camelCase(c)])):g=f,g}}function f(a,b,c){if(ib.acceptData(a)){var d,e,f,g=a.nodeType,i=g?ib.cache:a,j=g?a[ib.expando]:ib.expando;if(i[j]){if(b&&(f=c?i[j]:i[j].data)){ib.isArray(b)?b=b.concat(ib.map(b,ib.camelCase)):b in f?b=[b]:(b=ib.camelCase(b),b=b in f?[b]:b.split(" "));for(d=0,e=b.length;e>d;d++)delete f[b[d]];if(!(c?h:ib.isEmptyObject)(f))return}(c||(delete i[j].data,h(i[j])))&&(g?ib.cleanData([a],!0):ib.support.deleteExpando||i!=i.window?delete i[j]:i[j]=null)}}}function g(a,c,d){if(d===b&&1===a.nodeType){var e="data-"+c.replace(zb,"-$1").toLowerCase();if(d=a.getAttribute(e),"string"==typeof d){try{d="true"===d?!0:"false"===d?!1:"null"===d?null:+d+""===d?+d:yb.test(d)?ib.parseJSON(d):d}catch(f){}ib.data(a,c,d)}else d=b}return d}function h(a){var b;for(b in a)if(("data"!==b||!ib.isEmptyObject(a[b]))&&"toJSON"!==b)return!1;return!0}function i(){return!0}function j(){return!1}function k(a,b){do a=a[b];while(a&&1!==a.nodeType);return a}function l(a,b,c){if(b=b||0,ib.isFunction(b))return ib.grep(a,function(a,d){var e=!!b.call(a,d,a);return e===c});if(b.nodeType)return ib.grep(a,function(a){return a===b===c});if("string"==typeof b){var d=ib.grep(a,function(a){return 1===a.nodeType});if(Rb.test(b))return ib.filter(b,d,!c);b=ib.filter(b,d)}return ib.grep(a,function(a){return ib.inArray(a,b)>=0===c})}function m(a){var b=Ub.split("|"),c=a.createDocumentFragment();if(c.createElement)for(;b.length;)c.createElement(b.pop());return c}function n(a,b){return a.getElementsByTagName(b)[0]||a.appendChild(a.ownerDocument.createElement(b))}function o(a){var b=a.getAttributeNode("type");return a.type=(b&&b.specified)+"/"+a.type,a}function p(a){var b=ec.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function q(a,b){for(var c,d=0;null!=(c=a[d]);d++)ib._data(c,"globalEval",!b||ib._data(b[d],"globalEval"))}function r(a,b){if(1===b.nodeType&&ib.hasData(a)){var c,d,e,f=ib._data(a),g=ib._data(b,f),h=f.events;if(h){delete g.handle,g.events={};for(c in h)for(d=0,e=h[c].length;e>d;d++)ib.event.add(b,c,h[c][d])}g.data&&(g.data=ib.extend({},g.data))}}function s(a,b){var c,d,e;if(1===b.nodeType){if(c=b.nodeName.toLowerCase(),!ib.support.noCloneEvent&&b[ib.expando]){e=ib._data(b);for(d in e.events)ib.removeEvent(b,d,e.handle);b.removeAttribute(ib.expando)}"script"===c&&b.text!==a.text?(o(b).text=a.text,p(b)):"object"===c?(b.parentNode&&(b.outerHTML=a.outerHTML),ib.support.html5Clone&&a.innerHTML&&!ib.trim(b.innerHTML)&&(b.innerHTML=a.innerHTML)):"input"===c&&bc.test(a.type)?(b.defaultChecked=b.checked=a.checked,b.value!==a.value&&(b.value=a.value)):"option"===c?b.defaultSelected=b.selected=a.defaultSelected:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}}function t(a,c){var d,e,f=0,g=typeof a.getElementsByTagName!==V?a.getElementsByTagName(c||"*"):typeof a.querySelectorAll!==V?a.querySelectorAll(c||"*"):b;if(!g)for(g=[],d=a.childNodes||a;null!=(e=d[f]);f++)!c||ib.nodeName(e,c)?g.push(e):ib.merge(g,t(e,c));return c===b||c&&ib.nodeName(a,c)?ib.merge([a],g):g}function u(a){bc.test(a.type)&&(a.defaultChecked=a.checked)}function v(a,b){if(b in a)return b;for(var c=b.charAt(0).toUpperCase()+b.slice(1),d=b,e=yc.length;e--;)if(b=yc[e]+c,b in a)return b;return d}function w(a,b){return a=b||a,"none"===ib.css(a,"display")||!ib.contains(a.ownerDocument,a)}function x(a,b){for(var c,d,e,f=[],g=0,h=a.length;h>g;g++)d=a[g],d.style&&(f[g]=ib._data(d,"olddisplay"),c=d.style.display,b?(f[g]||"none"!==c||(d.style.display=""),""===d.style.display&&w(d)&&(f[g]=ib._data(d,"olddisplay",B(d.nodeName)))):f[g]||(e=w(d),(c&&"none"!==c||!e)&&ib._data(d,"olddisplay",e?c:ib.css(d,"display"))));for(g=0;h>g;g++)d=a[g],d.style&&(b&&"none"!==d.style.display&&""!==d.style.display||(d.style.display=b?f[g]||"":"none"));return a}function y(a,b,c){var d=rc.exec(b);return d?Math.max(0,d[1]-(c||0))+(d[2]||"px"):b}function z(a,b,c,d,e){for(var f=c===(d?"border":"content")?4:"width"===b?1:0,g=0;4>f;f+=2)"margin"===c&&(g+=ib.css(a,c+xc[f],!0,e)),d?("content"===c&&(g-=ib.css(a,"padding"+xc[f],!0,e)),"margin"!==c&&(g-=ib.css(a,"border"+xc[f]+"Width",!0,e))):(g+=ib.css(a,"padding"+xc[f],!0,e),"padding"!==c&&(g+=ib.css(a,"border"+xc[f]+"Width",!0,e)));return g}function A(a,b,c){var d=!0,e="width"===b?a.offsetWidth:a.offsetHeight,f=kc(a),g=ib.support.boxSizing&&"border-box"===ib.css(a,"boxSizing",!1,f);if(0>=e||null==e){if(e=lc(a,b,f),(0>e||null==e)&&(e=a.style[b]),sc.test(e))return e;d=g&&(ib.support.boxSizingReliable||e===a.style[b]),e=parseFloat(e)||0}return e+z(a,b,c||(g?"border":"content"),d,f)+"px"}function B(a){var b=W,c=uc[a];return c||(c=C(a,b),"none"!==c&&c||(jc=(jc||ib("