You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by da...@apache.org on 2017/06/26 09:13:51 UTC
[1/9] incubator-weex git commit: + [html5] add webSocket api for web
platform @notdanger
Repository: incubator-weex
Updated Branches:
refs/heads/0.14-dev 43adf4012 -> cbc2e2d89
+ [html5] add webSocket api for web platform @notdanger
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/9df3655d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/9df3655d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/9df3655d
Branch: refs/heads/0.14-dev
Commit: 9df3655d5e42bb335c09aa21d29fe03979175894
Parents: 9994583
Author: erha19 <75...@qq.com>
Authored: Thu Jun 22 11:57:45 2017 +0800
Committer: erha19 <75...@qq.com>
Committed: Thu Jun 22 14:41:50 2017 +0800
----------------------------------------------------------------------
html5/render/vue/env/weex.js | 3 +
html5/render/vue/modules/index.js | 2 +
html5/render/vue/modules/websocket/index.js | 26 ++++++++
html5/render/vue/modules/websocket/websocket.js | 66 ++++++++++++++++++++
4 files changed, 97 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/9df3655d/html5/render/vue/env/weex.js
----------------------------------------------------------------------
diff --git a/html5/render/vue/env/weex.js b/html5/render/vue/env/weex.js
index e5ae94b..9b804cb 100644
--- a/html5/render/vue/env/weex.js
+++ b/html5/render/vue/env/weex.js
@@ -78,6 +78,9 @@ const weex = {
if (!weexModules[name]) {
weexModules[name] = {}
}
+ if (!!meta && meta.mountType === 'full') {
+ weexModules[name] = module
+ }
for (const key in module) {
if (module.hasOwnProperty(key)) {
weexModules[name][key] = utils.bind(module[key], this)
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/9df3655d/html5/render/vue/modules/index.js
----------------------------------------------------------------------
diff --git a/html5/render/vue/modules/index.js b/html5/render/vue/modules/index.js
index 4237f9d..27f0592 100644
--- a/html5/render/vue/modules/index.js
+++ b/html5/render/vue/modules/index.js
@@ -33,6 +33,7 @@ import globalEvent from './globalEvent'
import modal from './modal'
import navigator from './navigator'
import webview from './webview'
+import websocket from './websocket'
const legacyModules = {
event,
@@ -57,6 +58,7 @@ export default {
weex.install(legacyModules[k])
}
weex.install(modal)
+ weex.install(websocket)
for (const k in modules) {
weex.registerModule(k, modules[k])
}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/9df3655d/html5/render/vue/modules/websocket/index.js
----------------------------------------------------------------------
diff --git a/html5/render/vue/modules/websocket/index.js b/html5/render/vue/modules/websocket/index.js
new file mode 100644
index 0000000..273ed58
--- /dev/null
+++ b/html5/render/vue/modules/websocket/index.js
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import websocket from './websocket'
+
+// TODO: rewrite the module meta
+export default {
+ init: function (Weex) {
+ Weex.registerModule('webSocket', websocket, { mountType: 'full' })
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/9df3655d/html5/render/vue/modules/websocket/websocket.js
----------------------------------------------------------------------
diff --git a/html5/render/vue/modules/websocket/websocket.js b/html5/render/vue/modules/websocket/websocket.js
new file mode 100644
index 0000000..c5cfa26
--- /dev/null
+++ b/html5/render/vue/modules/websocket/websocket.js
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * websocket module
+ */
+// let instance = null
+
+export default (function () {
+ let instance = null
+ const registerListeners = ['onopen', 'onmessage', 'onerror', 'onclose']
+ const ws = {
+ hasOwnProperty: function (e) {
+ return true
+ },
+ WebSocket: function (url, protocol) {
+ if (!url) {
+ return
+ }
+ if (!protocol) {
+ instance = new WebSocket(url)
+ }
+ else {
+ instance = new WebSocket(url, protocol)
+ }
+ return instance
+ },
+ send: function (messages) {
+ instance && instance.send(messages)
+ },
+ close: function () {
+ instance && instance.close()
+ }
+ }
+ for (const i in registerListeners) {
+ if (registerListeners.hasOwnProperty(i)) {
+ Object.defineProperty(ws, registerListeners[i], {
+ get: function () {
+ return instance && instance[registerListeners[i]]
+ },
+ set: function (fn) {
+ if (instance) {
+ instance[registerListeners[i]] = fn
+ }
+ }
+ })
+ }
+ }
+ return ws
+})()
[4/9] incubator-weex git commit: - [html5] remove hasOwnproperty key
on ws
Posted by da...@apache.org.
- [html5] remove hasOwnproperty key on ws
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/5d312028
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/5d312028
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/5d312028
Branch: refs/heads/0.14-dev
Commit: 5d3120288ed5bbca344401fae6d32d4a1eefa3bd
Parents: 5c86cf3
Author: erha19 <fa...@gmail.com>
Authored: Thu Jun 22 17:15:48 2017 +0800
Committer: erha19 <fa...@gmail.com>
Committed: Thu Jun 22 17:15:48 2017 +0800
----------------------------------------------------------------------
html5/render/vue/modules/websocket/websocket.js | 3 ---
1 file changed, 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/5d312028/html5/render/vue/modules/websocket/websocket.js
----------------------------------------------------------------------
diff --git a/html5/render/vue/modules/websocket/websocket.js b/html5/render/vue/modules/websocket/websocket.js
index c5cfa26..f52aa12 100644
--- a/html5/render/vue/modules/websocket/websocket.js
+++ b/html5/render/vue/modules/websocket/websocket.js
@@ -26,9 +26,6 @@ export default (function () {
let instance = null
const registerListeners = ['onopen', 'onmessage', 'onerror', 'onclose']
const ws = {
- hasOwnProperty: function (e) {
- return true
- },
WebSocket: function (url, protocol) {
if (!url) {
return
[2/9] incubator-weex git commit: + [html5] add example for webSocket
Posted by da...@apache.org.
+ [html5] add example for webSocket
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/d0a5e4d1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/d0a5e4d1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/d0a5e4d1
Branch: refs/heads/0.14-dev
Commit: d0a5e4d1f8195623e021b25dd8f19163b6320c2f
Parents: 9df3655
Author: erha19 <75...@qq.com>
Authored: Thu Jun 22 14:52:21 2017 +0800
Committer: erha19 <75...@qq.com>
Committed: Thu Jun 22 14:52:21 2017 +0800
----------------------------------------------------------------------
examples/vue/index.vue | 1 +
examples/vue/modules/websocket.vue | 116 ++++++++++++++++++++++++++++++++
2 files changed, 117 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/d0a5e4d1/examples/vue/index.vue
----------------------------------------------------------------------
diff --git a/examples/vue/index.vue b/examples/vue/index.vue
index 69d867d..ebea3ad 100644
--- a/examples/vue/index.vue
+++ b/examples/vue/index.vue
@@ -34,6 +34,7 @@
// module
{name: root + '/modules/instance-api', title: 'Instance API'},
{name: root + '/modules/modal', title: 'Modal'},
+ {name: root + '/modules/webSocket', title: 'WebSocket'},
{name: root + '/modules/stream', title: 'Stream'},
{name: root + '/modules/storage',title:'Storage'},
// {name: 'module/clipboard', title: 'Clipboard'}, // 0.8 , developing
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/d0a5e4d1/examples/vue/modules/websocket.vue
----------------------------------------------------------------------
diff --git a/examples/vue/modules/websocket.vue b/examples/vue/modules/websocket.vue
new file mode 100644
index 0000000..72d7ea1
--- /dev/null
+++ b/examples/vue/modules/websocket.vue
@@ -0,0 +1,116 @@
+<template>
+ <scroller>
+ <div>
+ <div style="background-color: #286090">
+ <text class="title" style="height: 80px ;padding: 20px;color: white">websocket</text>
+ </div>
+ <input type="text" placeholder="please input message to send" class="input" autofocus="false" value="" @input="oninput" ref="input" />
+ <div style="flex-direction: row; justify-content: center;">
+ <text class="button" @click="connect">connect</text>
+ <text class="button" @click="send">send</text>
+ <text class="button" @click="close">close</text>
+ </div>
+ <div style="background-color: lightgray">
+ <text class="title" style="height: 80px ;padding: 20px;color: black">method = close</text>
+ </div>
+ <text style="color: black;height: 80px">{{closeinfo}}</text>
+ <div style="background-color: lightgray">
+ <text class="title" style="height: 80px ;padding: 20px;color: black">method = send</text>
+ </div>
+ <text style="color: black;height: 80px">{{sendinfo}}</text>
+ <div style="background-color: lightgray">
+ <text class="title" style="height: 80px ;padding: 20px;color: black">method = onopen</text>
+ </div>
+ <text style="color: black;height: 80px">{{onopeninfo}}</text>
+ <div style="background-color: lightgray">
+ <text class="title" style="height: 80px ;padding: 20px;color: black">method = onmessage</text>
+ </div>
+ <text style="color: black;height: 400px">{{onmessage}}</text>
+ <div style="background-color: lightgray">
+ <text class="title" style="height: 80px ;padding: 20px;color: black">method = onclose</text>
+ </div>
+ <text style="color: black;height: 80px">{{oncloseinfo}}</text>
+ <div style="background-color: lightgray">
+ <text class="title" style="height: 80px ;padding: 20px;color: black">method = onerror</text>
+ </div>
+ <text style="color: black;height: 80px">{{onerrorinfo}}</text>
+ </div>
+ </scroller>
+</template>
+
+<style scoped>
+ .input {
+ font-size: 40px;
+ height: 80px;
+ width: 600px;
+ }
+
+ .button {
+ font-size: 36px;
+ width: 150px;
+ color: #41B883;
+ text-align: center;
+ padding-top: 25px;
+ padding-bottom: 25px;
+ border-width: 2px;
+ border-style: solid;
+ margin-right: 20px;
+ border-color: rgb(162, 217, 192);
+ background-color: rgba(162, 217, 192, 0.2);
+ }
+</style>
+
+<script>
+ var websocket = weex.requireModule('webSocket')
+ export default {
+ data() {
+ return {
+ connectinfo: '',
+ sendinfo: '',
+ onopeninfo: '',
+ onmessage: '',
+ oncloseinfo: '',
+ onerrorinfo: '',
+ closeinfo: '',
+ txtInput: '',
+ navBarHeight: 88,
+ title: 'Navigator',
+ dir: 'examples',
+ baseURL: ''
+ }
+ },
+ methods: {
+ connect: function() {
+ websocket.WebSocket('ws://echo.websocket.org', '');
+ var self = this;
+ self.onopeninfo = 'connecting...'
+ websocket.onopen = function(e) {
+ self.onopeninfo = 'websocket open';
+ }
+ websocket.onmessage = function(e) {
+ self.onmessage = e.data;
+ }
+ websocket.onerror = function(e) {
+ self.onerrorinfo = e.data;
+ }
+ websocket.onclose = function(e) {
+ self.onopeninfo = '';
+ self.oncloseinfo = e.code;
+ }
+ },
+ send: function(e) {
+ var input = this.$refs.input;
+ input.blur();
+ websocket.send(this.txtInput);
+ this.sendinfo = this.txtInput;
+ },
+ oninput: function(event) {
+ this.txtInput = event.value;
+ },
+ close: function(e) {
+ this.closeinfo = 'close connect';
+ websocket.close();
+ },
+ },
+ }
+</script>
\ No newline at end of file
[8/9] incubator-weex git commit: * [html5] fix lint error in
webSocket test code
Posted by da...@apache.org.
* [html5] fix lint error in webSocket test code
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/96cf5de6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/96cf5de6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/96cf5de6
Branch: refs/heads/0.14-dev
Commit: 96cf5de6399ed8ad741e5d8eeac06feee0c3430e
Parents: e6b55f7
Author: erha19 <fa...@gmail.com>
Authored: Sat Jun 24 21:20:19 2017 +0800
Committer: erha19 <fa...@gmail.com>
Committed: Sat Jun 24 21:20:19 2017 +0800
----------------------------------------------------------------------
html5/test/render/vue/modules/websocket.js | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/96cf5de6/html5/test/render/vue/modules/websocket.js
----------------------------------------------------------------------
diff --git a/html5/test/render/vue/modules/websocket.js b/html5/test/render/vue/modules/websocket.js
index 28b5958..f3534ef 100644
--- a/html5/test/render/vue/modules/websocket.js
+++ b/html5/test/render/vue/modules/websocket.js
@@ -1,11 +1,11 @@
-import websocket from '../../../../render/vue/modules/websocket/websocket';
-describe('webSocket module', function() {
- afterEach(function(done) {
+import websocket from '../../../../render/vue/modules/websocket/websocket'
+describe('webSocket module', function () {
+ afterEach(function (done) {
// Cleanup
- websocket.close();
- done();
- });
+ websocket.close()
+ done()
+ })
it('should have connection lifecycle constants defined on the instance', () => {
- expect(websocket.WebSocket('wss://echo.websocket.org').CONNECTING).to.be.equal(0);
- });
-});
+ expect(websocket.WebSocket('wss://echo.websocket.org').CONNECTING).to.be.equal(0)
+ })
+})
[6/9] incubator-weex git commit: + [html5] add unit test for
webSocket module
Posted by da...@apache.org.
+ [html5] add unit test for webSocket module
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/323b8367
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/323b8367
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/323b8367
Branch: refs/heads/0.14-dev
Commit: 323b836731f4d66a0b5836aa4ab82bc3cfa43b0a
Parents: dfc5d31
Author: erha19 <fa...@gmail.com>
Authored: Fri Jun 23 16:23:24 2017 +0800
Committer: erha19 <fa...@gmail.com>
Committed: Fri Jun 23 16:23:24 2017 +0800
----------------------------------------------------------------------
html5/test/render/vue/modules/websocket.js | 11 +++++++++++
1 file changed, 11 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/323b8367/html5/test/render/vue/modules/websocket.js
----------------------------------------------------------------------
diff --git a/html5/test/render/vue/modules/websocket.js b/html5/test/render/vue/modules/websocket.js
new file mode 100644
index 0000000..28b5958
--- /dev/null
+++ b/html5/test/render/vue/modules/websocket.js
@@ -0,0 +1,11 @@
+import websocket from '../../../../render/vue/modules/websocket/websocket';
+describe('webSocket module', function() {
+ afterEach(function(done) {
+ // Cleanup
+ websocket.close();
+ done();
+ });
+ it('should have connection lifecycle constants defined on the instance', () => {
+ expect(websocket.WebSocket('wss://echo.websocket.org').CONNECTING).to.be.equal(0);
+ });
+});
[7/9] incubator-weex git commit: * [html5] fix websocket module dange
code
Posted by da...@apache.org.
* [html5] fix websocket module dange code
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/e6b55f7c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/e6b55f7c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/e6b55f7c
Branch: refs/heads/0.14-dev
Commit: e6b55f7c3bde474a75dfc9757b2e5f0b0b180d93
Parents: 323b836
Author: erha19 <fa...@gmail.com>
Authored: Fri Jun 23 17:34:44 2017 +0800
Committer: erha19 <fa...@gmail.com>
Committed: Fri Jun 23 17:34:44 2017 +0800
----------------------------------------------------------------------
html5/render/vue/modules/websocket/websocket.js | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/e6b55f7c/html5/render/vue/modules/websocket/websocket.js
----------------------------------------------------------------------
diff --git a/html5/render/vue/modules/websocket/websocket.js b/html5/render/vue/modules/websocket/websocket.js
index b430789..743dc1d 100644
--- a/html5/render/vue/modules/websocket/websocket.js
+++ b/html5/render/vue/modules/websocket/websocket.js
@@ -19,35 +19,36 @@
/**
* websocket module
*/
-export default (function() {
+export default (function () {
const registerListeners = ['onopen', 'onmessage', 'onerror', 'onclose']
const ws = {
INSTANCE: null,
- WebSocket: function(url, protocol) {
+ WebSocket: function (url, protocol) {
if (!url) {
return
}
if (!protocol) {
ws.INSTANCE = new WebSocket(url)
- } else {
+ }
+ else {
ws.INSTANCE = new WebSocket(url, protocol)
}
return ws.INSTANCE
},
- send: function(messages) {
+ send: function (messages) {
ws.INSTANCE && ws.INSTANCE.send(messages)
},
- close: function() {
+ close: function () {
ws.INSTANCE && ws.INSTANCE.close()
}
}
for (const i in registerListeners) {
if (registerListeners.hasOwnProperty(i)) {
Object.defineProperty(ws, registerListeners[i], {
- get: function() {
+ get: function () {
return ws.INSTANCE && ws.INSTANCE[registerListeners[i]]
},
- set: function(fn) {
+ set: function (fn) {
if (ws.INSTANCE) {
ws.INSTANCE[registerListeners[i]] = fn
}
@@ -56,4 +57,4 @@ export default (function() {
}
}
return ws
-})()
\ No newline at end of file
+})()
[9/9] incubator-weex git commit: Merge branch '0.14-dev' of
https://github.com/erha19/incubator-weex into 0.14-dev
Posted by da...@apache.org.
Merge branch '0.14-dev' of https://github.com/erha19/incubator-weex into 0.14-dev
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/cbc2e2d8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/cbc2e2d8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/cbc2e2d8
Branch: refs/heads/0.14-dev
Commit: cbc2e2d89b5ecd4882968c9f4e1af252f122cdac
Parents: 43adf40 96cf5de
Author: MrRaindrop <te...@gmail.com>
Authored: Mon Jun 26 17:13:24 2017 +0800
Committer: MrRaindrop <te...@gmail.com>
Committed: Mon Jun 26 17:13:24 2017 +0800
----------------------------------------------------------------------
examples/vue/index.vue | 1 +
examples/vue/modules/websocket.vue | 116 +++++++++++++++++++
html5/render/vue/env/weex.js | 3 +
html5/render/vue/modules/index.js | 2 +
html5/render/vue/modules/websocket/index.js | 26 +++++
html5/render/vue/modules/websocket/websocket.js | 60 ++++++++++
html5/test/render/vue/modules/websocket.js | 11 ++
7 files changed, 219 insertions(+)
----------------------------------------------------------------------
[5/9] incubator-weex git commit: - [html5] remove some useless code
in websocket module
Posted by da...@apache.org.
- [html5] remove some useless code in websocket module
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/dfc5d31b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/dfc5d31b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/dfc5d31b
Branch: refs/heads/0.14-dev
Commit: dfc5d31b2efd44729dfe1ba3a6b22598c800f5ad
Parents: 5d31202
Author: erha19 <fa...@gmail.com>
Authored: Fri Jun 23 16:22:50 2017 +0800
Committer: erha19 <fa...@gmail.com>
Committed: Fri Jun 23 16:22:50 2017 +0800
----------------------------------------------------------------------
html5/render/vue/modules/websocket/websocket.js | 38 +++++++++-----------
1 file changed, 17 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/dfc5d31b/html5/render/vue/modules/websocket/websocket.js
----------------------------------------------------------------------
diff --git a/html5/render/vue/modules/websocket/websocket.js b/html5/render/vue/modules/websocket/websocket.js
index f52aa12..b430789 100644
--- a/html5/render/vue/modules/websocket/websocket.js
+++ b/html5/render/vue/modules/websocket/websocket.js
@@ -16,48 +16,44 @@
* specific language governing permissions and limitations
* under the License.
*/
-
/**
* websocket module
*/
-// let instance = null
-
-export default (function () {
- let instance = null
+export default (function() {
const registerListeners = ['onopen', 'onmessage', 'onerror', 'onclose']
const ws = {
- WebSocket: function (url, protocol) {
+ INSTANCE: null,
+ WebSocket: function(url, protocol) {
if (!url) {
return
}
if (!protocol) {
- instance = new WebSocket(url)
+ ws.INSTANCE = new WebSocket(url)
+ } else {
+ ws.INSTANCE = new WebSocket(url, protocol)
}
- else {
- instance = new WebSocket(url, protocol)
- }
- return instance
+ return ws.INSTANCE
},
- send: function (messages) {
- instance && instance.send(messages)
+ send: function(messages) {
+ ws.INSTANCE && ws.INSTANCE.send(messages)
},
- close: function () {
- instance && instance.close()
+ close: function() {
+ ws.INSTANCE && ws.INSTANCE.close()
}
}
for (const i in registerListeners) {
if (registerListeners.hasOwnProperty(i)) {
Object.defineProperty(ws, registerListeners[i], {
- get: function () {
- return instance && instance[registerListeners[i]]
+ get: function() {
+ return ws.INSTANCE && ws.INSTANCE[registerListeners[i]]
},
- set: function (fn) {
- if (instance) {
- instance[registerListeners[i]] = fn
+ set: function(fn) {
+ if (ws.INSTANCE) {
+ ws.INSTANCE[registerListeners[i]] = fn
}
}
})
}
}
return ws
-})()
+})()
\ No newline at end of file
[3/9] incubator-weex git commit: Merge branch '0.14-dev' of
https://github.com/apache/incubator-weex into 0.14-dev
Posted by da...@apache.org.
Merge branch '0.14-dev' of https://github.com/apache/incubator-weex into 0.14-dev
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/5c86cf3c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/5c86cf3c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/5c86cf3c
Branch: refs/heads/0.14-dev
Commit: 5c86cf3cbedc5988a7b50ae3d967bac03764d104
Parents: d0a5e4d 49ba77f
Author: erha19 <fa...@gmail.com>
Authored: Thu Jun 22 15:23:20 2017 +0800
Committer: erha19 <fa...@gmail.com>
Committed: Thu Jun 22 15:23:20 2017 +0800
----------------------------------------------------------------------
.../ui/component/AbstractEditComponent.java | 14 +-
.../com/taobao/weex/ui/component/Textarea.java | 6 +
.../taobao/weex/ui/component/WXComponent.java | 2 +-
.../com/taobao/weex/ui/view/WXEditText.java | 9 +-
html5/render/vue/components/index.js | 4 +-
html5/render/vue/components/input.js | 52 +++++--
.../components/scrollable/loading-indicator.js | 145 +++++++++++++++++--
.../render/vue/components/scrollable/loading.js | 4 +-
.../render/vue/components/scrollable/refresh.js | 4 +-
html5/render/vue/mixins/style.js | 11 +-
html5/render/vue/styles/base.css | 56 -------
html5/render/vue/utils/func.js | 30 ++++
html5/render/vue/utils/style.js | 49 +++++++
13 files changed, 292 insertions(+), 94 deletions(-)
----------------------------------------------------------------------