Archived
0

fix javascript

This commit is contained in:
2017-05-02 13:58:37 +03:00
parent 20e42c950f
commit 3378c49444
3 changed files with 112 additions and 112 deletions

View File

@@ -5,8 +5,8 @@ const nbsp = '\u00a0';
var MainMenuItem = React.createClass({ var MainMenuItem = React.createClass({
render: function(){ render: function(){
var liActive = {} var liActive = {};
var aText = this.props.title var aText = this.props.title;
if (this.props.active) { if (this.props.active) {
liActive = {className: 'active'}; liActive = {className: 'active'};
@@ -47,12 +47,12 @@ var Navbar = React.createClass({
var Panel = React.createClass({ var Panel = React.createClass({
render: function(){ render: function(){
colored = 'default'; var colored = 'default';
if (this.props.colored) { if (this.props.colored) {
colored = this.props.colored; colored = this.props.colored;
} }
elements = [ce('div', {className: 'panel-body'}, this.props.children)]; var elements = [ce('div', {className: 'panel-body'}, this.props.children)];
if (this.props.title) { if (this.props.title) {
elements.unshift(ce('div', {className: 'panel-heading'}, this.props.title)); elements.unshift(ce('div', {className: 'panel-heading'}, this.props.title));
} }

View File

@@ -10,7 +10,7 @@
iterable: 'Symbol' in self && 'iterator' in Symbol, iterable: 'Symbol' in self && 'iterator' in Symbol,
blob: 'FileReader' in self && 'Blob' in self && (function() { blob: 'FileReader' in self && 'Blob' in self && (function() {
try { try {
new Blob() new Blob();
return true return true
} catch(e) { } catch(e) {
return false return false
@@ -18,7 +18,7 @@
})(), })(),
formData: 'FormData' in self, formData: 'FormData' in self,
arrayBuffer: 'ArrayBuffer' in self arrayBuffer: 'ArrayBuffer' in self
} };
if (support.arrayBuffer) { if (support.arrayBuffer) {
var viewClasses = [ var viewClasses = [
@@ -31,11 +31,11 @@
'[object Uint32Array]', '[object Uint32Array]',
'[object Float32Array]', '[object Float32Array]',
'[object Float64Array]' '[object Float64Array]'
] ];
var isDataView = function(obj) { var isDataView = function(obj) {
return obj && DataView.prototype.isPrototypeOf(obj) return obj && DataView.prototype.isPrototypeOf(obj)
} };
var isArrayBufferView = ArrayBuffer.isView || function(obj) { var isArrayBufferView = ArrayBuffer.isView || function(obj) {
return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1 return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1
@@ -46,7 +46,7 @@
if (typeof name !== 'string') { if (typeof name !== 'string') {
name = String(name) name = String(name)
} }
if (/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(name)) { if (/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(name)) {
throw new TypeError('Invalid character in header field name') throw new TypeError('Invalid character in header field name')
} }
return name.toLowerCase() return name.toLowerCase()
@@ -63,10 +63,10 @@
function iteratorFor(items) { function iteratorFor(items) {
var iterator = { var iterator = {
next: function() { next: function() {
var value = items.shift() var value = items.shift();
return {done: value === undefined, value: value} return {done: value === undefined, value: value}
} }
} };
if (support.iterable) { if (support.iterable) {
iterator[Symbol.iterator] = function() { iterator[Symbol.iterator] = function() {
@@ -78,7 +78,7 @@
} }
function Headers(headers) { function Headers(headers) {
this.map = {} this.map = {};
if (headers instanceof Headers) { if (headers instanceof Headers) {
headers.forEach(function(value, name) { headers.forEach(function(value, name) {
@@ -96,28 +96,28 @@
} }
Headers.prototype.append = function(name, value) { Headers.prototype.append = function(name, value) {
name = normalizeName(name) name = normalizeName(name);
value = normalizeValue(value) value = normalizeValue(value);
var oldValue = this.map[name] var oldValue = this.map[name];
this.map[name] = oldValue ? oldValue+','+value : value this.map[name] = oldValue ? oldValue+','+value : value
} };
Headers.prototype['delete'] = function(name) { Headers.prototype['delete'] = function(name) {
delete this.map[normalizeName(name)] delete this.map[normalizeName(name)]
} };
Headers.prototype.get = function(name) { Headers.prototype.get = function(name) {
name = normalizeName(name) name = normalizeName(name);
return this.has(name) ? this.map[name] : null return this.has(name) ? this.map[name] : null
} };
Headers.prototype.has = function(name) { Headers.prototype.has = function(name) {
return this.map.hasOwnProperty(normalizeName(name)) return this.map.hasOwnProperty(normalizeName(name))
} };
Headers.prototype.set = function(name, value) { Headers.prototype.set = function(name, value) {
this.map[normalizeName(name)] = normalizeValue(value) this.map[normalizeName(name)] = normalizeValue(value)
} };
Headers.prototype.forEach = function(callback, thisArg) { Headers.prototype.forEach = function(callback, thisArg) {
for (var name in this.map) { for (var name in this.map) {
@@ -125,25 +125,25 @@
callback.call(thisArg, this.map[name], name, this) callback.call(thisArg, this.map[name], name, this)
} }
} }
} };
Headers.prototype.keys = function() { Headers.prototype.keys = function() {
var items = [] var items = [];
this.forEach(function(value, name) { items.push(name) }) this.forEach(function(value, name) { items.push(name) });
return iteratorFor(items) return iteratorFor(items)
} };
Headers.prototype.values = function() { Headers.prototype.values = function() {
var items = [] var items = [];
this.forEach(function(value) { items.push(value) }) this.forEach(function(value) { items.push(value) });
return iteratorFor(items) return iteratorFor(items)
} };
Headers.prototype.entries = function() { Headers.prototype.entries = function() {
var items = [] var items = [];
this.forEach(function(value, name) { items.push([name, value]) }) this.forEach(function(value, name) { items.push([name, value]) });
return iteratorFor(items) return iteratorFor(items)
} };
if (support.iterable) { if (support.iterable) {
Headers.prototype[Symbol.iterator] = Headers.prototype.entries Headers.prototype[Symbol.iterator] = Headers.prototype.entries
@@ -160,7 +160,7 @@
return new Promise(function(resolve, reject) { return new Promise(function(resolve, reject) {
reader.onload = function() { reader.onload = function() {
resolve(reader.result) resolve(reader.result)
} };
reader.onerror = function() { reader.onerror = function() {
reject(reader.error) reject(reader.error)
} }
@@ -168,22 +168,22 @@
} }
function readBlobAsArrayBuffer(blob) { function readBlobAsArrayBuffer(blob) {
var reader = new FileReader() var reader = new FileReader();
var promise = fileReaderReady(reader) var promise = fileReaderReady(reader);
reader.readAsArrayBuffer(blob) reader.readAsArrayBuffer(blob);
return promise return promise
} }
function readBlobAsText(blob) { function readBlobAsText(blob) {
var reader = new FileReader() var reader = new FileReader();
var promise = fileReaderReady(reader) var promise = fileReaderReady(reader);
reader.readAsText(blob) reader.readAsText(blob);
return promise return promise
} }
function readArrayBufferAsText(buf) { function readArrayBufferAsText(buf) {
var view = new Uint8Array(buf) var view = new Uint8Array(buf);
var chars = new Array(view.length) var chars = new Array(view.length);
for (var i = 0; i < view.length; i++) { for (var i = 0; i < view.length; i++) {
chars[i] = String.fromCharCode(view[i]) chars[i] = String.fromCharCode(view[i])
@@ -195,17 +195,17 @@
if (buf.slice) { if (buf.slice) {
return buf.slice(0) return buf.slice(0)
} else { } else {
var view = new Uint8Array(buf.byteLength) var view = new Uint8Array(buf.byteLength);
view.set(new Uint8Array(buf)) view.set(new Uint8Array(buf));
return view.buffer return view.buffer
} }
} }
function Body() { function Body() {
this.bodyUsed = false this.bodyUsed = false;
this._initBody = function(body) { this._initBody = function(body) {
this._bodyInit = body this._bodyInit = body;
if (!body) { if (!body) {
this._bodyText = '' this._bodyText = ''
} else if (typeof body === 'string') { } else if (typeof body === 'string') {
@@ -217,7 +217,7 @@
} else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) { } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
this._bodyText = body.toString() this._bodyText = body.toString()
} else if (support.arrayBuffer && support.blob && isDataView(body)) { } else if (support.arrayBuffer && support.blob && isDataView(body)) {
this._bodyArrayBuffer = bufferClone(body.buffer) this._bodyArrayBuffer = bufferClone(body.buffer);
// IE 10-11 can't handle a DataView body. // IE 10-11 can't handle a DataView body.
this._bodyInit = new Blob([this._bodyArrayBuffer]) this._bodyInit = new Blob([this._bodyArrayBuffer])
} else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) { } else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) {
@@ -235,11 +235,11 @@
this.headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8') this.headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8')
} }
} }
} };
if (support.blob) { if (support.blob) {
this.blob = function() { this.blob = function() {
var rejected = consumed(this) var rejected = consumed(this);
if (rejected) { if (rejected) {
return rejected return rejected
} }
@@ -253,7 +253,7 @@
} else { } else {
return Promise.resolve(new Blob([this._bodyText])) return Promise.resolve(new Blob([this._bodyText]))
} }
} };
this.arrayBuffer = function() { this.arrayBuffer = function() {
if (this._bodyArrayBuffer) { if (this._bodyArrayBuffer) {
@@ -265,7 +265,7 @@
} }
this.text = function() { this.text = function() {
var rejected = consumed(this) var rejected = consumed(this);
if (rejected) { if (rejected) {
return rejected return rejected
} }
@@ -279,7 +279,7 @@
} else { } else {
return Promise.resolve(this._bodyText) return Promise.resolve(this._bodyText)
} }
} };
if (support.formData) { if (support.formData) {
this.formData = function() { this.formData = function() {
@@ -289,49 +289,49 @@
this.json = function() { this.json = function() {
return this.text().then(JSON.parse) return this.text().then(JSON.parse)
} };
return this return this
} }
// HTTP methods whose capitalization should be normalized // HTTP methods whose capitalization should be normalized
var methods = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT'] var methods = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT'];
function normalizeMethod(method) { function normalizeMethod(method) {
var upcased = method.toUpperCase() var upcased = method.toUpperCase();
return (methods.indexOf(upcased) > -1) ? upcased : method return (methods.indexOf(upcased) > -1) ? upcased : method
} }
function Request(input, options) { function Request(input, options) {
options = options || {} options = options || {};
var body = options.body var body = options.body;
if (input instanceof Request) { if (input instanceof Request) {
if (input.bodyUsed) { if (input.bodyUsed) {
throw new TypeError('Already read') throw new TypeError('Already read')
} }
this.url = input.url this.url = input.url;
this.credentials = input.credentials this.credentials = input.credentials;
if (!options.headers) { if (!options.headers) {
this.headers = new Headers(input.headers) this.headers = new Headers(input.headers)
} }
this.method = input.method this.method = input.method;
this.mode = input.mode this.mode = input.mode;
if (!body && input._bodyInit != null) { if (!body && input._bodyInit !== null) {
body = input._bodyInit body = input._bodyInit;
input.bodyUsed = true input.bodyUsed = true
} }
} else { } else {
this.url = String(input) this.url = String(input)
} }
this.credentials = options.credentials || this.credentials || 'omit' this.credentials = options.credentials || this.credentials || 'omit';
if (options.headers || !this.headers) { if (options.headers || !this.headers) {
this.headers = new Headers(options.headers) this.headers = new Headers(options.headers)
} }
this.method = normalizeMethod(options.method || this.method || 'GET') this.method = normalizeMethod(options.method || this.method || 'GET');
this.mode = options.mode || this.mode || null this.mode = options.mode || this.mode || null;
this.referrer = null this.referrer = null;
if ((this.method === 'GET' || this.method === 'HEAD') && body) { if ((this.method === 'GET' || this.method === 'HEAD') && body) {
throw new TypeError('Body not allowed for GET or HEAD requests') throw new TypeError('Body not allowed for GET or HEAD requests')
@@ -341,51 +341,51 @@
Request.prototype.clone = function() { Request.prototype.clone = function() {
return new Request(this, { body: this._bodyInit }) return new Request(this, { body: this._bodyInit })
} };
function decode(body) { function decode(body) {
var form = new FormData() var form = new FormData();
body.trim().split('&').forEach(function(bytes) { body.trim().split('&').forEach(function(bytes) {
if (bytes) { if (bytes) {
var split = bytes.split('=') var split = bytes.split('=');
var name = split.shift().replace(/\+/g, ' ') var name = split.shift().replace(/\+/g, ' ');
var value = split.join('=').replace(/\+/g, ' ') var value = split.join('=').replace(/\+/g, ' ');
form.append(decodeURIComponent(name), decodeURIComponent(value)) form.append(decodeURIComponent(name), decodeURIComponent(value))
} }
}) });
return form return form
} }
function parseHeaders(rawHeaders) { function parseHeaders(rawHeaders) {
var headers = new Headers() var headers = new Headers();
rawHeaders.split(/\r?\n/).forEach(function(line) { rawHeaders.split(/\r?\n/).forEach(function(line) {
var parts = line.split(':') var parts = line.split(':');
var key = parts.shift().trim() var key = parts.shift().trim();
if (key) { if (key) {
var value = parts.join(':').trim() var value = parts.join(':').trim();
headers.append(key, value) headers.append(key, value)
} }
}) });
return headers return headers
} }
Body.call(Request.prototype) Body.call(Request.prototype);
function Response(bodyInit, options) { function Response(bodyInit, options) {
if (!options) { if (!options) {
options = {} options = {}
} }
this.type = 'default' this.type = 'default';
this.status = 'status' in options ? options.status : 200 this.status = 'status' in options ? options.status : 200;
this.ok = this.status >= 200 && this.status < 300 this.ok = this.status >= 200 && this.status < 300;
this.statusText = 'statusText' in options ? options.statusText : 'OK' this.statusText = 'statusText' in options ? options.statusText : 'OK';
this.headers = new Headers(options.headers) this.headers = new Headers(options.headers);
this.url = options.url || '' this.url = options.url || '';
this._initBody(bodyInit) this._initBody(bodyInit)
} }
Body.call(Response.prototype) Body.call(Response.prototype);
Response.prototype.clone = function() { Response.prototype.clone = function() {
return new Response(this._bodyInit, { return new Response(this._bodyInit, {
@@ -394,15 +394,15 @@
headers: new Headers(this.headers), headers: new Headers(this.headers),
url: this.url url: this.url
}) })
} };
Response.error = function() { Response.error = function() {
var response = new Response(null, {status: 0, statusText: ''}) var response = new Response(null, {status: 0, statusText: ''});
response.type = 'error' response.type = 'error';
return response return response
} };
var redirectStatuses = [301, 302, 303, 307, 308] var redirectStatuses = [301, 302, 303, 307, 308];
Response.redirect = function(url, status) { Response.redirect = function(url, status) {
if (redirectStatuses.indexOf(status) === -1) { if (redirectStatuses.indexOf(status) === -1) {
@@ -410,37 +410,37 @@
} }
return new Response(null, {status: status, headers: {location: url}}) return new Response(null, {status: status, headers: {location: url}})
} };
self.Headers = Headers self.Headers = Headers;
self.Request = Request self.Request = Request;
self.Response = Response self.Response = Response;
self.fetch = function(input, init) { self.fetch = function(input, init) {
return new Promise(function(resolve, reject) { return new Promise(function(resolve, reject) {
var request = new Request(input, init) var request = new Request(input, init);
var xhr = new XMLHttpRequest() var xhr = new XMLHttpRequest();
xhr.onload = function() { xhr.onload = function() {
var options = { var options = {
status: xhr.status, status: xhr.status,
statusText: xhr.statusText, statusText: xhr.statusText,
headers: parseHeaders(xhr.getAllResponseHeaders() || '') headers: parseHeaders(xhr.getAllResponseHeaders() || '')
} };
options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL') options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL');
var body = 'response' in xhr ? xhr.response : xhr.responseText var body = 'response' in xhr ? xhr.response : xhr.responseText;
resolve(new Response(body, options)) resolve(new Response(body, options))
} };
xhr.onerror = function() { xhr.onerror = function() {
reject(new TypeError('Network request failed')) reject(new TypeError('Network request failed'))
} };
xhr.ontimeout = function() { xhr.ontimeout = function() {
reject(new TypeError('Network request failed')) reject(new TypeError('Network request failed'))
} };
xhr.open(request.method, request.url, true) xhr.open(request.method, request.url, true);
if (request.credentials === 'include') { if (request.credentials === 'include') {
xhr.withCredentials = true xhr.withCredentials = true
@@ -452,10 +452,10 @@
request.headers.forEach(function(value, name) { request.headers.forEach(function(value, name) {
xhr.setRequestHeader(name, value) xhr.setRequestHeader(name, value)
}) });
xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit) xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit)
}) })
} };
self.fetch.polyfill = true self.fetch.polyfill = true
})(typeof self !== 'undefined' ? self : this); })(typeof self !== 'undefined' ? self : this);

View File

@@ -24,13 +24,13 @@ var BundleTableRow = React.createClass({
lastModified: this.props.lastModified lastModified: this.props.lastModified
}}, }},
stateToStr: function(state) { stateToStr: function(state) {
if (state == 1) {return 'UNINSTALLED'} if (state === 1) {return 'UNINSTALLED'}
else if (state == 2) {return 'INSTALLED'} else if (state === 2) {return 'INSTALLED'}
else if (state == 4) {return 'RESOLVED'} else if (state === 4) {return 'RESOLVED'}
else if (state == 8) {return 'STARTING'} else if (state === 8) {return 'STARTING'}
else if (state == 16) {return 'STOPPING'} else if (state === 16) {return 'STOPPING'}
else if (state == 32) {return 'ACTIVE'} else if (state === 32) {return 'ACTIVE'}
else {return 'UNKNOW('+state+')'} else {return 'UNKNOW('+state+')'}
}, },
bndUpd: function() { bndUpd: function() {
var _this = this; var _this = this;
@@ -52,7 +52,7 @@ var BundleTableRow = React.createClass({
}); });
}, },
render: function(){ render: function(){
vertAlign = {'vertical-align': 'middle'}; var vertAlign = {'vertical-align': 'middle'};
return( return(
ce('tr', null, ce('tr', null,
ce('td', {style: vertAlign}, this.state.id), ce('td', {style: vertAlign}, this.state.id),