Standard: use !== and ===

pull/1/head
Alex Beregszaszi 9 years ago
parent 7cd61b1601
commit 0bbbb237ea
  1. 10
      src/app.js
  2. 2
      src/app/compiler.js
  3. 2
      src/app/gist-handler.js
  4. 20
      src/app/renderer.js
  5. 2
      src/app/storage-handler.js
  6. 20
      src/universal-dapp.js

@ -13,7 +13,7 @@ var Compiler = require('./app/compiler');
var filesToLoad = null;
var loadFilesCallback = function(files) { filesToLoad = files; }; // will be replaced later
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]);
}
}, false);
@ -24,7 +24,7 @@ var run = function() {
for (var f in files) {
var key = utils.fileKey(f);
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 otherKey = key + count;
while ((key + count) in window.localStorage) count = count - 1;
@ -47,7 +47,7 @@ var run = function() {
// ------------------ query params (hash) ----------------
function syncQueryParams() {
$('#optimize').attr( 'checked', (queryParams.get().optimize == "true") );
$('#optimize').attr( 'checked', (queryParams.get().optimize === "true") );
}
window.onhashchange = syncQueryParams;
@ -211,7 +211,7 @@ var run = function() {
function activeFileTab() {
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() {
setVersionText("(loading)");
queryParams.update({version: version});
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
// "Uncaught RangeError: Maximum call stack size exceeded" error on Chromium,
// resort to non-worker version in that case.

@ -114,7 +114,7 @@ function Compiler(editor, handleGithubCall, outputField, hidingRHP, updateFiles)
renderer.error(data['error']);
if (utils.errortype(data['error']) !== 'warning') noFatalErrors = false;
}
if (data['errors'] != undefined) {
if (data['errors'] !== undefined) {
data['errors'].forEach(function(err) {
renderer.error(err);
if (utils.errortype(err) !== 'warning') noFatalErrors = false;

@ -3,7 +3,7 @@ var queryParams = require('./query-params');
function handleLoad(cb) {
var params = queryParams.get();
var loadingFromGist = false;
if (typeof params['gist'] != undefined) {
if (typeof params['gist'] !== undefined) {
var gistId;
if (params['gist'] === '') {
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) {
// Forcing all of this setup into its own scope.
(function(){
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;
executionContext = 'vm';
} else {
@ -25,7 +25,7 @@ function Renderer(editor, compiler, updateFiles) {
function setProviderFromEndpoint() {
var endpoint = $web3endpoint.val();
if (endpoint == 'ipc')
if (endpoint === 'ipc')
web3.setProvider(new web3.providers.IpcProvider());
else
web3.setProvider(new web3.providers.HttpProvider(endpoint));
@ -44,7 +44,7 @@ function Renderer(editor, compiler, updateFiles) {
$web3Toggle.on('change', executionContextChange );
$web3endpoint.on('change', function() {
setProviderFromEndpoint();
if (executionContext == 'web3') compiler.compile();
if (executionContext === 'web3') compiler.compile();
});
})();
@ -58,7 +58,7 @@ function Renderer(editor, compiler, updateFiles) {
var errFile = err[1];
var errLine = parseInt(err[2], 10) - 1;
var errCol = err[4] ? parseInt(err[4], 10) : 0;
if (errFile == '' || errFile == editor.getCacheFile()) {
if (errFile === '' || errFile === editor.getCacheFile()) {
compiler.addAnnotation({
row: errLine,
column: errCol,
@ -67,7 +67,7 @@ function Renderer(editor, compiler, updateFiles) {
});
}
$error.click(function(ev){
if (errFile != '' && errFile != editor.getCacheFile() && editor.hasFile(errFile)) {
if (errFile !== '' && errFile !== editor.getCacheFile() && editor.hasFile(errFile)) {
// Switch to file
editor.setCacheFile(errFile);
updateFiles();
@ -203,17 +203,17 @@ function Renderer(editor, compiler, updateFiles) {
};
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';
var text = prefix + '.code\n';
$.each(asm['.code'], function(i, item) {
var v = item.value === undefined ? '' : item.value;
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');
if (src.length > 30)
src = src.slice(0, 30) + '...';
if (item.name != 'tag')
if (item.name !== 'tag')
text += ' ';
text += prefix + item.name + ' ' + v + '\t\t\t' + src + '\n';
});
@ -248,7 +248,7 @@ function Renderer(editor, compiler, updateFiles) {
"\n gas: 3000000"+
"\n }, function(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 }" +
"\n })";
@ -260,7 +260,7 @@ function Renderer(editor, compiler, updateFiles) {
function getConstructorInterface(abi) {
var funABI = {'name':'','inputs':[],'type':'constructor','outputs':[]};
for (var i = 0; i < abi.length; i++)
if (abi[i].type == 'constructor') {
if (abi[i].type === 'constructor') {
funABI.inputs = abi[i].inputs || [];
break;
}

@ -14,7 +14,7 @@ function StorageHandler(updateFiles) {
function check(key){
chrome.storage.sync.get( key, function(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 );
localStorage.setItem( key, resp[key] );
updateFiles();

@ -81,7 +81,7 @@ UniversalDApp.prototype.getBalance = function (address, cb) {
};
UniversalDApp.prototype.render = function () {
if (this.contracts.length == 0) {
if (this.contracts.length === 0) {
this.$el.append( this.getABIInputForm() );
} else {
@ -114,7 +114,7 @@ UniversalDApp.prototype.render = function () {
UniversalDApp.prototype.getContractByName = function(contractName) {
for (var c in this.contracts)
if (this.contracts[c].name == contractName)
if (this.contracts[c].name === contractName)
return this.contracts[c];
return null;
};
@ -165,7 +165,7 @@ UniversalDApp.prototype.getInstanceInterface = function (contract, address, $tar
if (a.name > b.name) return -1;
else return 1;
}).sort(function(a,b){
if (a.constant == true) return -1;
if (a.constant === true) return -1;
else return 1;
});
var web3contract = this.web3.eth.contract(abi);
@ -252,7 +252,7 @@ UniversalDApp.prototype.getInstanceInterface = function (contract, address, $tar
}));
$.each(abi, function(i, funABI) {
if (funABI.type != 'function') return;
if (funABI.type !== 'function') return;
// @todo getData cannot be used with overloaded functions
$instance.append(self.getCallButton({
abi: funABI,
@ -287,7 +287,7 @@ UniversalDApp.prototype.getInstanceInterface = function (contract, address, $tar
UniversalDApp.prototype.getConstructorInterface = function(abi) {
var funABI = {'name':'','inputs':[],'type':'constructor','outputs':[]};
for (var i = 0; i < abi.length; i++)
if (abi[i].type == 'constructor') {
if (abi[i].type === 'constructor') {
funABI.inputs = abi[i].inputs || [];
break;
}
@ -303,7 +303,7 @@ UniversalDApp.prototype.getCallButton = function(args) {
var inputs = '';
$.each(args.abi.inputs, function(i, inp) {
if (inputs != '') inputs += ', ';
if (inputs !== '') inputs += ', ';
inputs += inp.type + ' ' + inp.name;
});
var inputField = $('<input/>').attr('placeholder', inputs).attr('title', inputs);
@ -385,9 +385,9 @@ UniversalDApp.prototype.getCallButton = function(args) {
return;
}
}
if (data.slice(0, 9) == 'undefined')
if (data.slice(0, 9) === 'undefined')
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>'));
@ -516,7 +516,7 @@ UniversalDApp.prototype.linkBytecode = function(contractName, cb) {
if (err) return cb(err);
var libLabel = '__' + libraryName + Array(39 - libraryName.length).join('_');
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;
while (bytecode.indexOf(libLabel) >= 0)
bytecode = bytecode.replace(libLabel, hexAddress);
@ -554,7 +554,7 @@ UniversalDApp.prototype.runTx = function( data, args, cb) {
var to = args.address;
var constant = args.abi.constant;
var isConstructor = args.bytecode !== undefined;
if (data.slice(0, 2) != '0x')
if (data.slice(0, 2) !== '0x')
data = '0x' + data;
var gas = self.options.getGas ? self.options.getGas : 1000000;

Loading…
Cancel
Save