Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(161)

Side by Side Diff: mojo/spy/ui/spy_shell.js

Issue 281623007: Add mojo web UI framework based on Nat's TVCM (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: missed a few Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/spy/ui/spy_shell.html ('k') | mojo/spy/ui/spy_shell_to_html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 'use strict';
6
7 tvcm.require('ui.spy');
8 tvcm.require('tvcm.ui');
9 tvcm.require('tvcm.ui.dom_helpers');
10 tvcm.requireTemplate('ui.spy_shell');
11
12 tvcm.exportTo('ui', function() {
13 /**
14 * @constructor
15 */
16 var SpyShell = tvcm.ui.define('x-spy-shell');
17
18 SpyShell.prototype = {
19 __proto__: HTMLUnknownElement.prototype,
20
21 decorate: function(socketURL) {
22 var node = tvcm.instantiateTemplate('#x-spy-shell-template');
23 this.appendChild(node);
24
25 this.socketURL_ = socketURL;
26 this.conn_ = undefined;
27
28 this.statusEl_ = this.querySelector('#status');
29 this.statusEl_.textContent = 'Not connected';
30
31 this.spy_ = this.querySelector('x-spy');
32 tvcm.ui.decorate(this.spy_, ui.Spy);
33
34 this.openConnection_();
35 },
36
37 get socketURL() {
38 return this.socketURL_;
39 },
40
41 openConnection_: function() {
42 if (!(this.conn_ == undefined ||
43 this.conn_.readyState === undefined ||
44 conn.readyState > 1)) {
45 return;
46 }
47
48 this.conn_ = new WebSocket(this.socketURL_);
49 this.conn_.onopen = function() {
50 this.statusEl_.textContent = 'connected at ' + this.socketURL_;
51 this.spy_.connection = this.conn_;
52 }.bind(this);
53
54 this.conn_.onclose = function(event) {
55 this.statusEl_.textContent = 'connection closed';
56 this.spy_.connection = undefined;
57 }.bind(this);
58 this.conn_.onerror = function(event) {
59 this.statusEl_.innerHTML = 'got error';
60 }.bind(this);
61 }
62
63 };
64
65 return {
66 SpyShell: SpyShell
67 };
68 });
OLDNEW
« no previous file with comments | « mojo/spy/ui/spy_shell.html ('k') | mojo/spy/ui/spy_shell_to_html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698