Skip to content
This repository has been archived by the owner on Sep 5, 2020. It is now read-only.

Commit

Permalink
Merge branch 'develop' of github.com:ethereum/mist into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
frozeman committed Dec 12, 2016
2 parents 038cb0b + 8dc4a66 commit ea32f2c
Show file tree
Hide file tree
Showing 15 changed files with 4,585 additions and 2,830 deletions.
9 changes: 9 additions & 0 deletions interface/.eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,12 @@ env: # don't warn about no-def meteor keywords

rules:
no-undef: 0
no-var: 0
prefer-arrow-callback: 0
prefer-template: 0
no-underscore-dangle:
- error
- allow: ['_id', '_escape']

globals:
Blaze: true
4 changes: 2 additions & 2 deletions interface/client/appStart.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ The init function of Mist
mistInit = function(){
console.info('Initialise Mist Interface');

EthBlocks.init();

Tabs.onceSynced.then(function() {
if (0 <= location.search.indexOf('reset-tabs')) {
console.info('Resetting UI tabs');
Expand Down Expand Up @@ -55,8 +57,6 @@ Meteor.startup(function(){
console.info('Meteor starting up...');

EthAccounts.init();
EthBlocks.init();

mistInit();

console.debug('Setting language');
Expand Down
116 changes: 71 additions & 45 deletions interface/client/mistAPIBackend.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ Filters a id the id to only contain a-z A-Z 0-9 _ -.
@method filterId
*/
var filterId = function(str) {
var filterId = function (str) {
var newStr = '';
for (var i = 0; i < str.length; i++) {
if(/[a-zA-Z0-9_-]/.test(str.charAt(i)))
var i;
for (i = 0; i < str.length; i += 1) {
if (/[a-zA-Z0-9_-]/.test(str.charAt(i))) {
newStr += str.charAt(i);
}
}
return newStr;
};
Expand All @@ -28,94 +30,118 @@ The backend side of the mist API.
@method mistAPIBackend
*/
mistAPIBackend = function(event) {
mistAPIBackend = function (event) {
var template = this.template;
var webview = this.webview;
var arg = event.args[0];

// console.trace('mistAPIBackend event', event);

if(event.channel === 'setWebviewId') {
Tabs.update(template.data._id, {$set:{
webviewId: webview.getId()
}});
if (event.channel === 'setWebviewId') {
Tabs.update(template.data._id, { $set: {
webviewId: webview.getId(),
} });
}

// Send TEST DATA
if(event.channel === 'sendTestData') {
webview.send('uiAction_sendTestData', Tabs.findOne('tests'));
if (event.channel === 'sendTestData') {
var tests = Tabs.findOne('tests');

if (tests) {
web3.eth.getCoinbase(function (e, coinbase) {
webview.send('uiAction_sendTestData', tests.permissions, coinbase);
});
}
}

// SET FAVICON
if(event.channel === 'favicon') {
Tabs.update(template.data._id, {$set:{
icon: Blaze._escape(arg || '')
}});
if (event.channel === 'favicon') {
Tabs.update(template.data._id, { $set: {
icon: Blaze._escape(arg || ''),
} });
}

// SET APPBAR
if(event.channel === 'appBar') {
if (event.channel === 'appBar') {
var appBarClass = Blaze._escape(arg || '');

Tabs.update(template.data._id, {$set:{
Tabs.update(template.data._id, { $set: {
appBar: (_.contains(allowedBrowserBarStyles, appBarClass) ? appBarClass : null)
}});
}

if(event.channel === 'mistAPI_sound') {
if (event.channel === 'mistAPI_sound') {
sound.pause();
sound.src = Blaze._escape(arg);
sound.play();
}

// STOP HERE, IF BROWSER
if(template.data._id === 'browser')
if (template.data._id === 'browser') {
return;
}

// Actions: --------

if(event.channel === 'mistAPI_setBadge') {
Tabs.update(template.data._id, {$set:{
badge: arg
}});
if (event.channel === 'mistAPI_setBadge') {
Tabs.update(template.data._id, { $set: {
badge: arg,
} });
}

if(event.channel === 'mistAPI_menuChanges' && arg instanceof Array) {
arg.forEach(function(arg){
if (event.channel === 'mistAPI_menuChanges' && arg instanceof Array) {
arg.forEach(function (eventArg) {
var query;

if(arg.action === 'addMenu') {
if (eventArg.action === 'addMenu') {
// filter ID
if(arg.entry && arg.entry.id)
arg.entry.id = filterId(arg.entry.id);

var query = {'$set': {}};
if (eventArg.entry && eventArg.entry.id) {
eventArg.entry.id = filterId(eventArg.entry.id);
}

query = { $set: {} };

if(arg.entry.id)
query['$set']['menu.'+ arg.entry.id +'.id'] = arg.entry.id;
if (eventArg.entry.id) {
query.$set['menu.' + eventArg.entry.id + '.id'] = eventArg.entry.id;
}

query['$set']['menu.'+ arg.entry.id +'.selected'] = !!arg.entry.selected;
query.$set['menu.' + eventArg.entry.id + '.selected'] = !!eventArg.entry.selected;

if(!_.isUndefined(arg.entry.position))
query['$set']['menu.'+ arg.entry.id +'.position'] = arg.entry.position;
if(!_.isUndefined(arg.entry.name))
query['$set']['menu.'+ arg.entry.id +'.name'] = arg.entry.name;
if(!_.isUndefined(arg.entry.badge))
query['$set']['menu.'+ arg.entry.id +'.badge'] = arg.entry.badge;
if (!_.isUndefined(eventArg.entry.position)) {
query.$set['menu.' + eventArg.entry.id + '.position'] = eventArg.entry.position;
}
if (!_.isUndefined(eventArg.entry.name)) {
query.$set['menu.' + eventArg.entry.id + '.name'] = eventArg.entry.name;
}
if (!_.isUndefined(eventArg.entry.badge)) {
query.$set['menu.' + eventArg.entry.id + '.badge'] = eventArg.entry.badge;
}

Tabs.update(template.data._id, query);
}

if(arg.action === 'removeMenu') {
query = {'$unset': {}};
if (eventArg.action === 'selectMenu') {
var tab = Tabs.findOne(template.data._id);

query['$unset']['menu.'+ arg.id] = '';
for (var e in tab.menu) {
if ({}.hasOwnProperty.call(tab.menu, e)) {
tab.menu[e].selected = (e === eventArg.id);
}
}
Tabs.update(template.data._id, { $set: { menu: tab.menu } });
}

Tabs.update(template.data._id, query);
if (eventArg.action === 'removeMenu') {
var removeQuery = { $unset: {} };

removeQuery.$unset['menu.' + eventArg.id] = '';

Tabs.update(template.data._id, removeQuery);
}

if(arg.action === 'clearMenu') {
Tabs.update(template.data._id, {$set: {menu: {}}});
if (eventArg.action === 'clearMenu') {
Tabs.update(template.data._id, { $set: { menu: {} } });
}
});
}
};
};
6 changes: 3 additions & 3 deletions interface/client/templates/views/webview.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<template name="views_webview">
<div class="webview {{isVisible}} {{#if appBar}}app-bar-{{appBar}}{{/if}}">
{{#if $eq _id "tests"}}
<webview src="file://{{dirname}}/tests/mocha-in-browser/runner.html" useragent="{{useragent}}" data-id="{{_id}}" preload="{{preloaderFile}}" autosize="on"></webview>
<webview src="file://{{dirname}}/tests/mocha-in-browser/runner.html" useragent="{{useragent}}" data-id="{{_id}}" preload="{{preloaderFile}}" autosize="on"></webview>
{{else}}
<webview src="{{checkedUrl}}" useragent="{{useragent}}" data-id="{{_id}}" preload="{{preloaderFile}}" autosize="on"></webview>
<webview src="{{checkedUrl}}" useragent="{{useragent}}" data-id="{{_id}}" preload="{{preloaderFile}}" autosize="on"></webview>
{{/if}}
</div>
</template>
</template>
19 changes: 3 additions & 16 deletions interface/client/templates/views/webview.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,11 @@ Template['views_webview'].onRendered(function(){
webview = template.find('webview');


// Send updated TEST DATA
if(tabId === 'tests') {
this.autorun(function(c){
var tab = Tabs.findOne('tests');

if(!c.firstRun)
webview.send('uiAction_sendTestData', tab);

// ADD SWITCHUNG USING webview.loadURL();
});
}


ipc.on('uiAction_reloadSelectedTab', function(e) {
console.log('uiAction_reloadSelectedTab', LocalStore.get('selectedTab'));
if(LocalStore.get('selectedTab') === this._id){
var webview = Helpers.getWebview(LocalStore.get('selectedTab'));
webview.reload();
webview.reload();
}
});

Expand All @@ -45,7 +32,7 @@ Template['views_webview'].onRendered(function(){
webview.addEventListener('did-stop-loading', function(e){
TemplateVar.set(template, 'loading', false);
});

// change url
webview.addEventListener('did-navigate', webviewChangeUrl.bind(webview, tabId));
webview.addEventListener('did-navigate-in-page', webviewChangeUrl.bind(webview, tabId));
Expand Down Expand Up @@ -149,7 +136,7 @@ Template['views_webview'].helpers({
console.warn('Not allowed URL: '+ template.url);
return 'file://'+ dirname + '/errorPages/400.html';
}

// remove redirect
if(url) {
template.url = url;
Expand Down
2 changes: 1 addition & 1 deletion interface/i18n/mist.es.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"backupMist": "Datos de la aplicación"
},
"develop": {
"label": "Desarrollar",
"label": "Desarrollo",
"devTools": "Herramientas para desarrolladores",
"devToolsMistUI": "UI de Mist",
"devToolsWalletUI": "UI del monedero",
Expand Down
Loading

0 comments on commit ea32f2c

Please sign in to comment.