Commit 0bbbb237 authored by Alex Beregszaszi's avatar Alex Beregszaszi

Standard: use !== and ===

parent 7cd61b16
...@@ -13,7 +13,7 @@ var Compiler = require('./app/compiler'); ...@@ -13,7 +13,7 @@ var Compiler = require('./app/compiler');
var filesToLoad = null; var filesToLoad = null;
var loadFilesCallback = function(files) { filesToLoad = files; }; // will be replaced later var loadFilesCallback = function(files) { filesToLoad = files; }; // will be replaced later
window.addEventListener("message", function(ev) { window.addEventListener("message", function(ev) {
if (typeof ev.data == typeof [] && ev.data[0] === "loadFiles") { if (typeof ev.data === typeof [] && ev.data[0] === "loadFiles") {
loadFilesCallback(ev.data[1]); loadFilesCallback(ev.data[1]);
} }
}, false); }, false);
...@@ -24,7 +24,7 @@ var run = function() { ...@@ -24,7 +24,7 @@ var run = function() {
for (var f in files) { for (var f in files) {
var key = utils.fileKey(f); var key = utils.fileKey(f);
var content = files[f].content; var content = files[f].content;
if (key in window.localStorage && window.localStorage[key] != content) { if (key in window.localStorage && window.localStorage[key] !== content) {
var count = ''; var count = '';
var otherKey = key + count; var otherKey = key + count;
while ((key + count) in window.localStorage) count = count - 1; while ((key + count) in window.localStorage) count = count - 1;
...@@ -47,7 +47,7 @@ var run = function() { ...@@ -47,7 +47,7 @@ var run = function() {
// ------------------ query params (hash) ---------------- // ------------------ query params (hash) ----------------
function syncQueryParams() { function syncQueryParams() {
$('#optimize').attr( 'checked', (queryParams.get().optimize == "true") ); $('#optimize').attr( 'checked', (queryParams.get().optimize === "true") );
} }
window.onhashchange = syncQueryParams; window.onhashchange = syncQueryParams;
...@@ -211,7 +211,7 @@ var run = function() { ...@@ -211,7 +211,7 @@ var run = function() {
function activeFileTab() { function activeFileTab() {
var name = editor.getCacheFile(); var name = editor.getCacheFile();
return $('#files .file').filter(function(){ return $(this).find('.name').text() == name; }); return $('#files .file').filter(function(){ return $(this).find('.name').text() === name; });
} }
...@@ -416,7 +416,7 @@ var run = function() { ...@@ -416,7 +416,7 @@ var run = function() {
setVersionText("(loading)"); setVersionText("(loading)");
queryParams.update({version: version}); queryParams.update({version: version});
var isFirefox = typeof InstallTrigger !== 'undefined'; var isFirefox = typeof InstallTrigger !== 'undefined';
if (document.location.protocol != 'file:' && Worker !== undefined && isFirefox) { if (document.location.protocol !== 'file:' && Worker !== undefined && isFirefox) {
// Workers cannot load js on "file:"-URLs and we get a // Workers cannot load js on "file:"-URLs and we get a
// "Uncaught RangeError: Maximum call stack size exceeded" error on Chromium, // "Uncaught RangeError: Maximum call stack size exceeded" error on Chromium,
// resort to non-worker version in that case. // resort to non-worker version in that case.
......
...@@ -114,7 +114,7 @@ function Compiler(editor, handleGithubCall, outputField, hidingRHP, updateFiles) ...@@ -114,7 +114,7 @@ function Compiler(editor, handleGithubCall, outputField, hidingRHP, updateFiles)
renderer.error(data['error']); renderer.error(data['error']);
if (utils.errortype(data['error']) !== 'warning') noFatalErrors = false; if (utils.errortype(data['error']) !== 'warning') noFatalErrors = false;
} }
if (data['errors'] != undefined) { if (data['errors'] !== undefined) {
data['errors'].forEach(function(err) { data['errors'].forEach(function(err) {
renderer.error(err); renderer.error(err);
if (utils.errortype(err) !== 'warning') noFatalErrors = false; if (utils.errortype(err) !== 'warning') noFatalErrors = false;
......
...@@ -3,7 +3,7 @@ var queryParams = require('./query-params'); ...@@ -3,7 +3,7 @@ var queryParams = require('./query-params');
function handleLoad(cb) { function handleLoad(cb) {
var params = queryParams.get(); var params = queryParams.get();
var loadingFromGist = false; var loadingFromGist = false;
if (typeof params['gist'] != undefined) { if (typeof params['gist'] !== undefined) {
var gistId; var gistId;
if (params['gist'] === '') { if (params['gist'] === '') {
var str = prompt("Enter the URL or ID of the Gist you would like to load."); var str = prompt("Enter the URL or ID of the Gist you would like to load.");
......
...@@ -13,7 +13,7 @@ function Renderer(editor, compiler, updateFiles) { ...@@ -13,7 +13,7 @@ function Renderer(editor, compiler, updateFiles) {
// Forcing all of this setup into its own scope. // Forcing all of this setup into its own scope.
(function(){ (function(){
function executionContextChange (ev) { function executionContextChange (ev) {
if (ev.target.value == 'web3' && !confirm("Are you sure you want to connect to a local ethereum node?") ) { if (ev.target.value === 'web3' && !confirm("Are you sure you want to connect to a local ethereum node?") ) {
$vmToggle.get(0).checked = true; $vmToggle.get(0).checked = true;
executionContext = 'vm'; executionContext = 'vm';
} else { } else {
...@@ -25,7 +25,7 @@ function Renderer(editor, compiler, updateFiles) { ...@@ -25,7 +25,7 @@ function Renderer(editor, compiler, updateFiles) {
function setProviderFromEndpoint() { function setProviderFromEndpoint() {
var endpoint = $web3endpoint.val(); var endpoint = $web3endpoint.val();
if (endpoint == 'ipc') if (endpoint === 'ipc')
web3.setProvider(new web3.providers.IpcProvider()); web3.setProvider(new web3.providers.IpcProvider());
else else
web3.setProvider(new web3.providers.HttpProvider(endpoint)); web3.setProvider(new web3.providers.HttpProvider(endpoint));
...@@ -44,7 +44,7 @@ function Renderer(editor, compiler, updateFiles) { ...@@ -44,7 +44,7 @@ function Renderer(editor, compiler, updateFiles) {
$web3Toggle.on('change', executionContextChange ); $web3Toggle.on('change', executionContextChange );
$web3endpoint.on('change', function() { $web3endpoint.on('change', function() {
setProviderFromEndpoint(); setProviderFromEndpoint();
if (executionContext == 'web3') compiler.compile(); if (executionContext === 'web3') compiler.compile();
}); });
})(); })();
...@@ -58,7 +58,7 @@ function Renderer(editor, compiler, updateFiles) { ...@@ -58,7 +58,7 @@ function Renderer(editor, compiler, updateFiles) {
var errFile = err[1]; var errFile = err[1];
var errLine = parseInt(err[2], 10) - 1; var errLine = parseInt(err[2], 10) - 1;
var errCol = err[4] ? parseInt(err[4], 10) : 0; var errCol = err[4] ? parseInt(err[4], 10) : 0;
if (errFile == '' || errFile == editor.getCacheFile()) { if (errFile === '' || errFile === editor.getCacheFile()) {
compiler.addAnnotation({ compiler.addAnnotation({
row: errLine, row: errLine,
column: errCol, column: errCol,
...@@ -67,7 +67,7 @@ function Renderer(editor, compiler, updateFiles) { ...@@ -67,7 +67,7 @@ function Renderer(editor, compiler, updateFiles) {
}); });
} }
$error.click(function(ev){ $error.click(function(ev){
if (errFile != '' && errFile != editor.getCacheFile() && editor.hasFile(errFile)) { if (errFile !== '' && errFile !== editor.getCacheFile() && editor.hasFile(errFile)) {
// Switch to file // Switch to file
editor.setCacheFile(errFile); editor.setCacheFile(errFile);
updateFiles(); updateFiles();
...@@ -203,17 +203,17 @@ function Renderer(editor, compiler, updateFiles) { ...@@ -203,17 +203,17 @@ function Renderer(editor, compiler, updateFiles) {
}; };
var formatAssemblyText = function(asm, prefix, source) { var formatAssemblyText = function(asm, prefix, source) {
if (typeof(asm) == typeof('') || asm === null || asm === undefined) if (typeof(asm) === typeof('') || asm === null || asm === undefined)
return prefix + asm + '\n'; return prefix + asm + '\n';
var text = prefix + '.code\n'; var text = prefix + '.code\n';
$.each(asm['.code'], function(i, item) { $.each(asm['.code'], function(i, item) {
var v = item.value === undefined ? '' : item.value; var v = item.value === undefined ? '' : item.value;
var src = ''; var src = '';
if (item.begin !== undefined && item.end != undefined) if (item.begin !== undefined && item.end !== undefined)
src = source.slice(item.begin, item.end).replace('\n', '\\n', 'g'); src = source.slice(item.begin, item.end).replace('\n', '\\n', 'g');
if (src.length > 30) if (src.length > 30)
src = src.slice(0, 30) + '...'; src = src.slice(0, 30) + '...';
if (item.name != 'tag') if (item.name !== 'tag')
text += ' '; text += ' ';
text += prefix + item.name + ' ' + v + '\t\t\t' + src + '\n'; text += prefix + item.name + ' ' + v + '\t\t\t' + src + '\n';
}); });
...@@ -248,7 +248,7 @@ function Renderer(editor, compiler, updateFiles) { ...@@ -248,7 +248,7 @@ function Renderer(editor, compiler, updateFiles) {
"\n gas: 3000000"+ "\n gas: 3000000"+
"\n }, function(e, contract){"+ "\n }, function(e, contract){"+
"\n console.log(e, contract);"+ "\n console.log(e, contract);"+
"\n if (typeof contract.address != 'undefined') {"+ "\n if (typeof contract.address !== 'undefined') {"+
"\n console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);" + "\n console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);" +
"\n }" + "\n }" +
"\n })"; "\n })";
...@@ -260,7 +260,7 @@ function Renderer(editor, compiler, updateFiles) { ...@@ -260,7 +260,7 @@ function Renderer(editor, compiler, updateFiles) {
function getConstructorInterface(abi) { function getConstructorInterface(abi) {
var funABI = {'name':'','inputs':[],'type':'constructor','outputs':[]}; var funABI = {'name':'','inputs':[],'type':'constructor','outputs':[]};
for (var i = 0; i < abi.length; i++) for (var i = 0; i < abi.length; i++)
if (abi[i].type == 'constructor') { if (abi[i].type === 'constructor') {
funABI.inputs = abi[i].inputs || []; funABI.inputs = abi[i].inputs || [];
break; break;
} }
......
...@@ -14,7 +14,7 @@ function StorageHandler(updateFiles) { ...@@ -14,7 +14,7 @@ function StorageHandler(updateFiles) {
function check(key){ function check(key){
chrome.storage.sync.get( key, function(resp){ chrome.storage.sync.get( key, function(resp){
console.log("comparing to cloud", key, resp); console.log("comparing to cloud", key, resp);
if (typeof resp[key] != 'undefined' && obj[key] !== resp[key] && confirm("Overwrite '" + fileNameFromKey(key) + "'? Click Ok to overwrite local file with file from cloud. Cancel will push your local file to the cloud.")) { if (typeof resp[key] !== 'undefined' && obj[key] !== resp[key] && confirm("Overwrite '" + fileNameFromKey(key) + "'? Click Ok to overwrite local file with file from cloud. Cancel will push your local file to the cloud.")) {
console.log("Overwriting", key ); console.log("Overwriting", key );
localStorage.setItem( key, resp[key] ); localStorage.setItem( key, resp[key] );
updateFiles(); updateFiles();
......
...@@ -81,7 +81,7 @@ UniversalDApp.prototype.getBalance = function (address, cb) { ...@@ -81,7 +81,7 @@ UniversalDApp.prototype.getBalance = function (address, cb) {
}; };
UniversalDApp.prototype.render = function () { UniversalDApp.prototype.render = function () {
if (this.contracts.length == 0) { if (this.contracts.length === 0) {
this.$el.append( this.getABIInputForm() ); this.$el.append( this.getABIInputForm() );
} else { } else {
...@@ -114,7 +114,7 @@ UniversalDApp.prototype.render = function () { ...@@ -114,7 +114,7 @@ UniversalDApp.prototype.render = function () {
UniversalDApp.prototype.getContractByName = function(contractName) { UniversalDApp.prototype.getContractByName = function(contractName) {
for (var c in this.contracts) for (var c in this.contracts)
if (this.contracts[c].name == contractName) if (this.contracts[c].name === contractName)
return this.contracts[c]; return this.contracts[c];
return null; return null;
}; };
...@@ -165,7 +165,7 @@ UniversalDApp.prototype.getInstanceInterface = function (contract, address, $tar ...@@ -165,7 +165,7 @@ UniversalDApp.prototype.getInstanceInterface = function (contract, address, $tar
if (a.name > b.name) return -1; if (a.name > b.name) return -1;
else return 1; else return 1;
}).sort(function(a,b){ }).sort(function(a,b){
if (a.constant == true) return -1; if (a.constant === true) return -1;
else return 1; else return 1;
}); });
var web3contract = this.web3.eth.contract(abi); var web3contract = this.web3.eth.contract(abi);
...@@ -252,7 +252,7 @@ UniversalDApp.prototype.getInstanceInterface = function (contract, address, $tar ...@@ -252,7 +252,7 @@ UniversalDApp.prototype.getInstanceInterface = function (contract, address, $tar
})); }));
$.each(abi, function(i, funABI) { $.each(abi, function(i, funABI) {
if (funABI.type != 'function') return; if (funABI.type !== 'function') return;
// @todo getData cannot be used with overloaded functions // @todo getData cannot be used with overloaded functions
$instance.append(self.getCallButton({ $instance.append(self.getCallButton({
abi: funABI, abi: funABI,
...@@ -287,7 +287,7 @@ UniversalDApp.prototype.getInstanceInterface = function (contract, address, $tar ...@@ -287,7 +287,7 @@ UniversalDApp.prototype.getInstanceInterface = function (contract, address, $tar
UniversalDApp.prototype.getConstructorInterface = function(abi) { UniversalDApp.prototype.getConstructorInterface = function(abi) {
var funABI = {'name':'','inputs':[],'type':'constructor','outputs':[]}; var funABI = {'name':'','inputs':[],'type':'constructor','outputs':[]};
for (var i = 0; i < abi.length; i++) for (var i = 0; i < abi.length; i++)
if (abi[i].type == 'constructor') { if (abi[i].type === 'constructor') {
funABI.inputs = abi[i].inputs || []; funABI.inputs = abi[i].inputs || [];
break; break;
} }
...@@ -303,7 +303,7 @@ UniversalDApp.prototype.getCallButton = function(args) { ...@@ -303,7 +303,7 @@ UniversalDApp.prototype.getCallButton = function(args) {
var inputs = ''; var inputs = '';
$.each(args.abi.inputs, function(i, inp) { $.each(args.abi.inputs, function(i, inp) {
if (inputs != '') inputs += ', '; if (inputs !== '') inputs += ', ';
inputs += inp.type + ' ' + inp.name; inputs += inp.type + ' ' + inp.name;
}); });
var inputField = $('<input/>').attr('placeholder', inputs).attr('title', inputs); var inputField = $('<input/>').attr('placeholder', inputs).attr('title', inputs);
...@@ -385,9 +385,9 @@ UniversalDApp.prototype.getCallButton = function(args) { ...@@ -385,9 +385,9 @@ UniversalDApp.prototype.getCallButton = function(args) {
return; return;
} }
} }
if (data.slice(0, 9) == 'undefined') if (data.slice(0, 9) === 'undefined')
data = data.slice(9); data = data.slice(9);
if (data.slice(0, 2) == '0x') data = data.slice(2); if (data.slice(0, 2) === '0x') data = data.slice(2);
replaceOutput($result, $('<span>Waiting for transaction to be mined...</span>')); replaceOutput($result, $('<span>Waiting for transaction to be mined...</span>'));
...@@ -516,7 +516,7 @@ UniversalDApp.prototype.linkBytecode = function(contractName, cb) { ...@@ -516,7 +516,7 @@ UniversalDApp.prototype.linkBytecode = function(contractName, cb) {
if (err) return cb(err); if (err) return cb(err);
var libLabel = '__' + libraryName + Array(39 - libraryName.length).join('_'); var libLabel = '__' + libraryName + Array(39 - libraryName.length).join('_');
var hexAddress = address.toString('hex'); var hexAddress = address.toString('hex');
if (hexAddress.slice(0, 2) == '0x') hexAddress = hexAddress.slice(2); if (hexAddress.slice(0, 2) === '0x') hexAddress = hexAddress.slice(2);
hexAddress = Array(40 - hexAddress.length + 1).join('0') + hexAddress; hexAddress = Array(40 - hexAddress.length + 1).join('0') + hexAddress;
while (bytecode.indexOf(libLabel) >= 0) while (bytecode.indexOf(libLabel) >= 0)
bytecode = bytecode.replace(libLabel, hexAddress); bytecode = bytecode.replace(libLabel, hexAddress);
...@@ -554,7 +554,7 @@ UniversalDApp.prototype.runTx = function( data, args, cb) { ...@@ -554,7 +554,7 @@ UniversalDApp.prototype.runTx = function( data, args, cb) {
var to = args.address; var to = args.address;
var constant = args.abi.constant; var constant = args.abi.constant;
var isConstructor = args.bytecode !== undefined; var isConstructor = args.bytecode !== undefined;
if (data.slice(0, 2) != '0x') if (data.slice(0, 2) !== '0x')
data = '0x' + data; data = '0x' + data;
var gas = self.options.getGas ? self.options.getGas : 1000000; var gas = self.options.getGas ? self.options.getGas : 1000000;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment