Skip to content

Commit

Permalink
Move more UI code to use specific sites
Browse files Browse the repository at this point in the history
  • Loading branch information
arlolra committed Jul 25, 2019
1 parent 7284cad commit f9c515c
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 42 deletions.
44 changes: 43 additions & 1 deletion proxy/init-testing.js
@@ -1,4 +1,46 @@
/* global TESTING, Util, Params, Config, DebugUI, UI, Broker, Snowflake */
/* global TESTING, Util, Params, Config, UI, Broker, Snowflake */

/*
UI
*/

class DebugUI extends UI {

constructor() {
super();
// Setup other DOM handlers if it's debug mode.
this.$status = document.getElementById('status');
this.$msglog = document.getElementById('msglog');
this.$msglog.value = '';
}

// Status bar
setStatus(msg) {
var txt;
txt = document.createTextNode('Status: ' + msg);
while (this.$status.firstChild) {
this.$status.removeChild(this.$status.firstChild);
}
return this.$status.appendChild(txt);
}

setActive(connected) {
super.setActive(connected);
return this.$msglog.className = connected ? 'active' : '';
}

log(msg) {
// Scroll to latest
this.$msglog.value += msg + '\n';
return this.$msglog.scrollTop = this.$msglog.scrollHeight;
}

}

// DOM elements references.
DebugUI.prototype.$msglog = null;

DebugUI.prototype.$status = null;

/*
Entry point.
Expand Down
2 changes: 2 additions & 0 deletions proxy/init-webext.js
Expand Up @@ -105,6 +105,8 @@ WebExtUI.prototype.port = null;

WebExtUI.prototype.stats = null;

WebExtUI.prototype.enabled = true;

/*
Entry point.
*/
Expand Down
41 changes: 0 additions & 41 deletions proxy/ui.js
Expand Up @@ -15,44 +15,3 @@ class UI {
}

UI.prototype.active = false;

UI.prototype.enabled = true;


class DebugUI extends UI {

constructor() {
super();
// Setup other DOM handlers if it's debug mode.
this.$status = document.getElementById('status');
this.$msglog = document.getElementById('msglog');
this.$msglog.value = '';
}

// Status bar
setStatus(msg) {
var txt;
txt = document.createTextNode('Status: ' + msg);
while (this.$status.firstChild) {
this.$status.removeChild(this.$status.firstChild);
}
return this.$status.appendChild(txt);
}

setActive(connected) {
super.setActive(connected);
return this.$msglog.className = connected ? 'active' : '';
}

log(msg) {
// Scroll to latest
this.$msglog.value += msg + '\n';
return this.$msglog.scrollTop = this.$msglog.scrollHeight;
}

}

// DOM elements references.
DebugUI.prototype.$msglog = null;

DebugUI.prototype.$status = null;

0 comments on commit f9c515c

Please sign in to comment.