From d23dc68057b1bfbfeeb3c46e9f778c4e715e2adf Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 20 Jun 2017 14:45:19 +0800 Subject: [PATCH] fix Object.assign not working on some browser bug --- res/index.html | 2 ++ res/js/index.js | 9 +-------- res/js/promise-polyfill.min.js | 3 +++ 3 files changed, 6 insertions(+), 8 deletions(-) create mode 100644 res/js/promise-polyfill.min.js diff --git a/res/index.html b/res/index.html index 423808c..5799539 100644 --- a/res/index.html +++ b/res/index.html @@ -222,6 +222,8 @@ + + diff --git a/res/js/index.js b/res/js/index.js index d2df786..a9f274a 100644 --- a/res/js/index.js +++ b/res/js/index.js @@ -1,6 +1,5 @@ /* index.js */ var W = {}; - var testPrograms = [{ program: { name: "gggg", @@ -36,12 +35,10 @@ var vm = new Vue({ }); }, showEditProgram: function(p) { - this.edit.program = Object.assign({}, p); + this.edit.program = Object.assign({}, p); // here require polyfill.min.js $("#programEdit").modal('show'); - console.log(p.name, p); }, editProgram: function() { - console.log(this.edit.program); var p = this.edit.program; $.ajax({ url: "/api/programs/" + p.name, @@ -199,7 +196,6 @@ Vue.filter('colorStatus', function(value) { default: return makeColorText(value, "gray"); } - return value; }) Vue.directive('disable', function(value) { @@ -230,9 +226,6 @@ $(function() { e.preventDefault() }); - - console.log("HEE") - function newEventWatcher() { W.events = newWebsocket("/ws/events", { onopen: function(evt) { diff --git a/res/js/promise-polyfill.min.js b/res/js/promise-polyfill.min.js new file mode 100644 index 0000000..1ef53dc --- /dev/null +++ b/res/js/promise-polyfill.min.js @@ -0,0 +1,3 @@ +/* Disable minification (remove `.min` from URL path) for more info */ + +(function(undefined) {!function(){function e(e){var n,t=!1,r=[];if("function"==typeof e.next)for(;!t&&(n=e.next(),n.hasOwnProperty("value")&&n.hasOwnProperty("done"));){if(n.done===!0){t=!0;break}if(n.done!==!1)break;r.push(n.value)}return!!t&&r}Object.defineProperty(Array,"from",{configurable:!0,value:function(n){if(n===undefined||null===n)throw new TypeError(n+" is not an object");if(1 in arguments&&!(arguments[1]instanceof Function))throw new TypeError(arguments[1]+" is not a function");var t,r,o="string"==typeof n?n.split(""):Object(n),i=arguments[1],a=arguments[2],f=[],u=-1,c=Math.min(Math.max(Number(o.length)||0,0),9007199254740991);r=e(o),"function"==typeof o.entries&&"function"==typeof o.values&&("Set"===o.constructor.name&&"values"in Set.prototype&&(r=e(o.values())),"Map"===o.constructor.name&&"entries"in Map.prototype&&(r=e(o.entries()))),r&&(o=r,c=r.length);for(;++u=e.length)return{done:!0,value:undefined};var r=e[n++];return{done:!1,value:"key"===t?r.name:"value"===t?r.value:[r.name,r.value]}}}function l(t,n){function r(){var e=l.href.replace(/#$|\?$|\?(?=#)/g,"");l.href!==e&&(l.href=e)}function u(){m._setList(l.search?a(l.search.substring(1)):[]),m._update_steps()}if(!(this instanceof e.URL))throw new TypeError("Failed to construct 'URL': Please use the 'new' operator.");n&&(t=function(){if(c)return new s(t,n).href;var e;if(document.implementation&&document.implementation.createHTMLDocument?e=document.implementation.createHTMLDocument(""):document.implementation&&document.implementation.createDocument?(e=document.implementation.createDocument("http://www.w3.org/1999/xhtml","html",null),e.documentElement.appendChild(e.createElement("head")),e.documentElement.appendChild(e.createElement("body"))):window.ActiveXObject&&(e=new window.ActiveXObject("htmlfile"),e.write(""),e.close()),!e)throw Error("base not supported");var r=e.createElement("base");r.href=n,e.getElementsByTagName("head")[0].appendChild(r);var a=e.createElement("a");return a.href=t,a.href}());var l=i(t||""),f=function(){if(!("defineProperties"in Object))return!1;try{var e={};return Object.defineProperties(e,{prop:{get:function(){return!0}}}),e.prop}catch(t){return!1}}(),h=f?this:document.createElement("a"),m=new o(l.search?l.search.substring(1):null);return m._url_object=h,Object.defineProperties(h,{href:{get:function(){return l.href},set:function(e){l.href=e,r(),u()},enumerable:!0,configurable:!0},origin:{get:function(){return"origin"in l?l.origin:this.protocol+"//"+this.host},enumerable:!0,configurable:!0},protocol:{get:function(){return l.protocol},set:function(e){l.protocol=e},enumerable:!0,configurable:!0},username:{get:function(){return l.username},set:function(e){l.username=e},enumerable:!0,configurable:!0},password:{get:function(){return l.password},set:function(e){l.password=e},enumerable:!0,configurable:!0},host:{get:function(){var e={"http:":/:80$/,"https:":/:443$/,"ftp:":/:21$/}[l.protocol];return e?l.host.replace(e,""):l.host},set:function(e){l.host=e},enumerable:!0,configurable:!0},hostname:{get:function(){return l.hostname},set:function(e){l.hostname=e},enumerable:!0,configurable:!0},port:{get:function(){return l.port},set:function(e){l.port=e},enumerable:!0,configurable:!0},pathname:{get:function(){return"/"!==l.pathname.charAt(0)?"/"+l.pathname:l.pathname},set:function(e){l.pathname=e},enumerable:!0,configurable:!0},search:{get:function(){return l.search},set:function(e){l.search!==e&&(l.search=e,r(),u())},enumerable:!0,configurable:!0},searchParams:{get:function(){return m},enumerable:!0,configurable:!0},hash:{get:function(){return l.hash},set:function(e){l.hash=e,r()},enumerable:!0,configurable:!0},toString:{value:function(){return l.toString()},enumerable:!1,configurable:!0},valueOf:{value:function(){return l.valueOf()},enumerable:!1,configurable:!0}}),h}var c,s=e.URL;try{if(s){if("searchParams"in(c=new e.URL("http://example.com")))return;"href"in c||(c=undefined)}}catch(h){}if(Object.defineProperties(o.prototype,{append:{value:function(e,t){this._list.push({name:e,value:t}),this._update_steps()},writable:!0,enumerable:!0,configurable:!0},"delete":{value:function(e){for(var t=0;t1?arguments[1]:undefined;this._list.forEach(function(n,r){e.call(t,n.value,n.name)})},writable:!0,enumerable:!0,configurable:!0},toString:{value:function(){return r(this._list)},writable:!0,enumerable:!1,configurable:!0}}),"Symbol"in e&&"iterator"in e.Symbol&&(Object.defineProperty(o.prototype,e.Symbol.iterator,{value:o.prototype.entries,writable:!0,enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,e.Symbol.iterator,{value:function(){return this},writable:!0,enumerable:!0,configurable:!0})),s)for(var f in s)s.hasOwnProperty(f)&&"function"==typeof s[f]&&(l[f]=s[f]);e.URL=l,e.URLSearchParams=o}(),function(){if("1"!==new e.URLSearchParams([["a",1]]).get("a")||"1"!==new e.URLSearchParams({a:1}).get("a")){var r=e.URLSearchParams;e.URLSearchParams=function(e){if(e&&"object"==typeof e&&t(e)){var a=new r;return n(e).forEach(function(e){if(!t(e))throw TypeError();var r=n(e);if(2!==r.length)throw TypeError();a.append(r[0],r[1])}),a}return e&&"object"==typeof e?(a=new r,Object.keys(e).forEach(function(t){a.set(t,e[t])}),a):new r(e)}}}()}(self);}).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {}); \ No newline at end of file