From bce4af2dcaeeab3bd931afbbcc6f17da675ce2b6 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Mon, 24 Apr 2017 13:55:19 -0700 Subject: Add placeholder etherscan token icons --- ui/lib/icon-factory.js | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'ui/lib') diff --git a/ui/lib/icon-factory.js b/ui/lib/icon-factory.js index 82cc839d6..ac703ae40 100644 --- a/ui/lib/icon-factory.js +++ b/ui/lib/icon-factory.js @@ -10,9 +10,33 @@ module.exports = function (jazzicon) { function IconFactory (jazzicon) { this.jazzicon = jazzicon this.cache = {} + + this.presets = { + '1':{ // Main network: + '0x48c80f1f4d53d5951e5d5438b54cba84f29f32a5': 'https://etherscan.io/token/images/augur.png', + '0xc66ea802717bfb9833400264dd12c2bceaa34a6d': 'https://etherscan.io/token/images/mkr-etherscan-35.png', + '0xa74476443119a942de498590fe1f2454d7d4ac0d': 'https://etherscan.io/token/images/golem.png', + '0xaec2e87e0a235266d9c5adc9deb4b2e29b54d009': 'https://etherscan.io/token/images/sngls.png', + + } + } } -IconFactory.prototype.iconForAddress = function (address, diameter, imageify) { +IconFactory.prototype.iconForAddress = function (address, diameter, imageify, network) { + + try { + const presetUri = this.presets[network][address.toLowerCase()] + if (presetUri) { + var img = document.createElement('img') + img.src = presetUri + img.style.width = `${diameter}px` + img.style.height = `${diameter}px` + img.style.borderRadius = `${diameter/2}px` + return img + } + } catch (e) {} + + if (imageify) { return this.generateIdenticonImg(address, diameter) } else { -- cgit From 242dc1e99f1dd53e2bec9deefb5da0c8329b5f00 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Tue, 25 Apr 2017 14:39:01 -0700 Subject: Add missing changes. Create unique style for rinkeby icon. --- ui/lib/account-link.js | 3 +++ ui/lib/explorer-link.js | 3 +++ 2 files changed, 6 insertions(+) (limited to 'ui/lib') diff --git a/ui/lib/account-link.js b/ui/lib/account-link.js index 4f27b35c0..d061d0ad1 100644 --- a/ui/lib/account-link.js +++ b/ui/lib/account-link.js @@ -11,6 +11,9 @@ module.exports = function (address, network) { case 3: // ropsten test net link = `http://ropsten.etherscan.io/address/${address}` break + case 4: // rinkeby test net + link = `http://rinkeby.etherscan.io/address/${address}` + break case 42: // kovan test net link = `http://kovan.etherscan.io/address/${address}` break diff --git a/ui/lib/explorer-link.js b/ui/lib/explorer-link.js index ca89f8b25..e11249551 100644 --- a/ui/lib/explorer-link.js +++ b/ui/lib/explorer-link.js @@ -8,6 +8,9 @@ module.exports = function (hash, network) { case 3: // ropsten test net prefix = 'ropsten.' break + case 4: // rinkeby test net + prefix = 'rinkeby.' + break case 42: // kovan test net prefix = 'kovan.' break -- cgit From d8c94fca75ca2aed11387c0b1d4c6064bead447e Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Fri, 26 May 2017 00:19:24 -0700 Subject: Add address image map to icon factory Deriving from the new address image map repository I've added here: https://github.com/MetaMask/ethereum-contract-icons With this PR, images for addresses added to that repository will be shown instead of jazzicons in MetaMask. --- ui/lib/icon-factory.js | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) (limited to 'ui/lib') diff --git a/ui/lib/icon-factory.js b/ui/lib/icon-factory.js index 82cc839d6..4aed9109b 100644 --- a/ui/lib/icon-factory.js +++ b/ui/lib/icon-factory.js @@ -1,4 +1,7 @@ var iconFactory +const isValidAddress = require('ethereumjs-util').isValidAddress +const toChecksumAddress = require('ethereumjs-util').toChecksumAddress +const iconMap = require('ethereum-contract-icons') module.exports = function (jazzicon) { if (!iconFactory) { @@ -12,22 +15,12 @@ function IconFactory (jazzicon) { this.cache = {} } -IconFactory.prototype.iconForAddress = function (address, diameter, imageify) { - if (imageify) { - return this.generateIdenticonImg(address, diameter) - } else { - return this.generateIdenticonSvg(address, diameter) +IconFactory.prototype.iconForAddress = function (address, diameter) { + const addr = toChecksumAddress(address) + if (iconExistsFor(addr)) { + return imageElFor(addr) } -} - -// returns img dom element -IconFactory.prototype.generateIdenticonImg = function (address, diameter) { - var identicon = this.generateIdenticonSvg(address, diameter) - var identiconSrc = identicon.innerHTML - var dataUri = toDataUri(identiconSrc) - var img = document.createElement('img') - img.src = dataUri - return img + return this.generateIdenticonSvg(address, diameter) } // returns svg dom element @@ -49,12 +42,22 @@ IconFactory.prototype.generateNewIdenticon = function (address, diameter) { // util +function iconExistsFor (address) { + return (address in iconMap) && isValidAddress(address) +} + +function imageElFor (address) { + const fileName = iconMap[address] + const path = `images/contract/${fileName}` + const img = document.createElement('img') + img.src = path + img.style.width = '100%' + return img +} + function jsNumberForAddress (address) { var addr = address.slice(2, 10) var seed = parseInt(addr, 16) return seed } -function toDataUri (identiconSrc) { - return 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(identiconSrc) -} -- cgit From f06ad954b900aa94a36fbb3e4765d0a9222e0920 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Fri, 26 May 2017 09:58:33 -0700 Subject: Move to eth-contract-metadata --- ui/lib/icon-factory.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'ui/lib') diff --git a/ui/lib/icon-factory.js b/ui/lib/icon-factory.js index 4aed9109b..c16507527 100644 --- a/ui/lib/icon-factory.js +++ b/ui/lib/icon-factory.js @@ -1,7 +1,7 @@ var iconFactory const isValidAddress = require('ethereumjs-util').isValidAddress const toChecksumAddress = require('ethereumjs-util').toChecksumAddress -const iconMap = require('ethereum-contract-icons') +const contractMap = require('eth-contract-metadata') module.exports = function (jazzicon) { if (!iconFactory) { @@ -43,11 +43,12 @@ IconFactory.prototype.generateNewIdenticon = function (address, diameter) { // util function iconExistsFor (address) { - return (address in iconMap) && isValidAddress(address) + return (address in contractMap) && isValidAddress(address) && ('logo' in contractMap[address]) } function imageElFor (address) { - const fileName = iconMap[address] + const contract = contractMap[address] + const fileName = contract.logo const path = `images/contract/${fileName}` const img = document.createElement('img') img.src = path -- cgit From 1203bd15c2861332b62e4a39a3d961f61daed6dc Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Fri, 26 May 2017 10:25:00 -0700 Subject: Add names to contract map & conf view --- ui/lib/contract-namer.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'ui/lib') diff --git a/ui/lib/contract-namer.js b/ui/lib/contract-namer.js index a94c62b62..0800ee7df 100644 --- a/ui/lib/contract-namer.js +++ b/ui/lib/contract-namer.js @@ -6,13 +6,18 @@ */ // Nickname keys must be stored in lower case. -const nicknames = {} +const contractMap = require('eth-contract-metadata') +const ethUtil = require('ethereumjs-util') module.exports = function (addr, identities = {}) { + const checksummed = ethUtil.toChecksumAddress(addr) + if (checksummed in contractMap && 'name' in contractMap[checksummed]) { + return contractMap[checksummed].name + } + const address = addr.toLowerCase() const ids = hashFromIdentities(identities) - - return addrFromHash(address, ids) || addrFromHash(address, nicknames) + return addrFromHash(address, ids) } function hashFromIdentities (identities) { -- cgit From 5e6b23082147f530adbf52cacf61202d7edf1111 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Fri, 26 May 2017 10:54:16 -0700 Subject: Move off in operator --- ui/lib/contract-namer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ui/lib') diff --git a/ui/lib/contract-namer.js b/ui/lib/contract-namer.js index 0800ee7df..2400fa576 100644 --- a/ui/lib/contract-namer.js +++ b/ui/lib/contract-namer.js @@ -11,7 +11,7 @@ const ethUtil = require('ethereumjs-util') module.exports = function (addr, identities = {}) { const checksummed = ethUtil.toChecksumAddress(addr) - if (checksummed in contractMap && 'name' in contractMap[checksummed]) { + if (contractMap.checksummed && contractMap[checksummed].name) { return contractMap[checksummed].name } -- cgit From fd42d7bfd5cede30f14e232b6d93ba4205dbcf1d Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Fri, 26 May 2017 11:05:51 -0700 Subject: Fix contract map reference --- ui/lib/contract-namer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ui/lib') diff --git a/ui/lib/contract-namer.js b/ui/lib/contract-namer.js index 2400fa576..86bba1edc 100644 --- a/ui/lib/contract-namer.js +++ b/ui/lib/contract-namer.js @@ -11,7 +11,7 @@ const ethUtil = require('ethereumjs-util') module.exports = function (addr, identities = {}) { const checksummed = ethUtil.toChecksumAddress(addr) - if (contractMap.checksummed && contractMap[checksummed].name) { + if (contractMap[checksummed] && contractMap[checksummed].name) { return contractMap[checksummed].name } -- cgit From fb2565c9d1f6c3cc6601c0f317fe10651ad21097 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Fri, 26 May 2017 11:13:39 -0700 Subject: Remove comment --- ui/lib/contract-namer.js | 1 - 1 file changed, 1 deletion(-) (limited to 'ui/lib') diff --git a/ui/lib/contract-namer.js b/ui/lib/contract-namer.js index 86bba1edc..f05e770cc 100644 --- a/ui/lib/contract-namer.js +++ b/ui/lib/contract-namer.js @@ -5,7 +5,6 @@ * otherwise returns null. */ -// Nickname keys must be stored in lower case. const contractMap = require('eth-contract-metadata') const ethUtil = require('ethereumjs-util') -- cgit From 9d2844c7128c79314529e163b473353d42200e9c Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Fri, 26 May 2017 11:16:58 -0700 Subject: remove more in operators --- ui/lib/icon-factory.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ui/lib') diff --git a/ui/lib/icon-factory.js b/ui/lib/icon-factory.js index c16507527..45be47b7a 100644 --- a/ui/lib/icon-factory.js +++ b/ui/lib/icon-factory.js @@ -43,7 +43,7 @@ IconFactory.prototype.generateNewIdenticon = function (address, diameter) { // util function iconExistsFor (address) { - return (address in contractMap) && isValidAddress(address) && ('logo' in contractMap[address]) + return (contractMap.address) && isValidAddress(address) && (contractMap[address].logo) } function imageElFor (address) { -- cgit From 108c4ab2c58074aa8148828fbbef8cbf3a4e23f5 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Tue, 13 Jun 2017 17:47:56 -0700 Subject: Auto populate token list with popular token balances Half implements #175 Things to do: - Add ability to add tokens to the list. - Persist the token tab selection (so it is an implicit preference) - Check what's up with the token-tracker polling, it seems like it is not waiting the interval. --- ui/lib/icon-factory.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ui/lib') diff --git a/ui/lib/icon-factory.js b/ui/lib/icon-factory.js index 4ee6b600b..27a74de66 100644 --- a/ui/lib/icon-factory.js +++ b/ui/lib/icon-factory.js @@ -44,7 +44,7 @@ IconFactory.prototype.generateNewIdenticon = function (address, diameter) { // util function iconExistsFor (address) { - return (contractMap.address) && isValidAddress(address) && (contractMap[address].logo) + return contractMap[address] && isValidAddress(address) && contractMap[address].logo } function imageElFor (address) { @@ -53,7 +53,7 @@ function imageElFor (address) { const path = `images/contract/${fileName}` const img = document.createElement('img') img.src = path - img.style.width = '100%' + img.style.width = '75%' return img } -- cgit From 5440ed23d621c9ebcd24f89d54701f978e1c086e Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Tue, 27 Jun 2017 14:49:41 -0700 Subject: Support other network links --- ui/lib/etherscan-prefix-for-network.js | 21 +++++++++++++++++++++ ui/lib/explorer-link.js | 21 +++------------------ 2 files changed, 24 insertions(+), 18 deletions(-) create mode 100644 ui/lib/etherscan-prefix-for-network.js (limited to 'ui/lib') diff --git a/ui/lib/etherscan-prefix-for-network.js b/ui/lib/etherscan-prefix-for-network.js new file mode 100644 index 000000000..2c1904f1c --- /dev/null +++ b/ui/lib/etherscan-prefix-for-network.js @@ -0,0 +1,21 @@ +module.exports = function (network) { + const net = parseInt(network) + let prefix + switch (net) { + case 1: // main net + prefix = '' + break + case 3: // ropsten test net + prefix = 'ropsten.' + break + case 4: // rinkeby test net + prefix = 'rinkeby.' + break + case 42: // kovan test net + prefix = 'kovan.' + break + default: + prefix = '' + } + return prefix +} diff --git a/ui/lib/explorer-link.js b/ui/lib/explorer-link.js index e11249551..3b82ecd5f 100644 --- a/ui/lib/explorer-link.js +++ b/ui/lib/explorer-link.js @@ -1,21 +1,6 @@ +const prefixForNetwork = require('./etherscan-prefix-for-network') + module.exports = function (hash, network) { - const net = parseInt(network) - let prefix - switch (net) { - case 1: // main net - prefix = '' - break - case 3: // ropsten test net - prefix = 'ropsten.' - break - case 4: // rinkeby test net - prefix = 'rinkeby.' - break - case 42: // kovan test net - prefix = 'kovan.' - break - default: - prefix = '' - } + const prefix = prefixForNetwork(network) return `http://${prefix}etherscan.io/tx/${hash}` } -- cgit From 614501e743a0c1584062c78a25e6b9a3ddf10aab Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Mon, 17 Jul 2017 14:16:39 -0700 Subject: Fix transaction confirmation ordering Newest tx or message will now always appear last, and a new tx proposed after the user has a confirmation box open will never change the confirmation to a different tx proposed. Fixes #1637 --- ui/lib/tx-helper.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'ui/lib') diff --git a/ui/lib/tx-helper.js b/ui/lib/tx-helper.js index ec19daf64..afc62e7b6 100644 --- a/ui/lib/tx-helper.js +++ b/ui/lib/tx-helper.js @@ -12,6 +12,10 @@ module.exports = function (unapprovedTxs, unapprovedMsgs, personalMsgs, network) const personalValues = valuesFor(personalMsgs) log.debug(`tx helper found ${personalValues.length} unsigned personal messages`) allValues = allValues.concat(personalValues) + allValues = allValues.sort((a, b) => { + return a.time > b.time + }) - return allValues.sort(txMeta => txMeta.time) + return allValues } + -- cgit From a22adec66fd0c541eb350ea424a6b00d179eedaf Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Mon, 24 Jul 2017 17:04:13 -0700 Subject: Replace ui with responsive-ui --- ui/lib/tx-helper.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'ui/lib') diff --git a/ui/lib/tx-helper.js b/ui/lib/tx-helper.js index afc62e7b6..ec19daf64 100644 --- a/ui/lib/tx-helper.js +++ b/ui/lib/tx-helper.js @@ -12,10 +12,6 @@ module.exports = function (unapprovedTxs, unapprovedMsgs, personalMsgs, network) const personalValues = valuesFor(personalMsgs) log.debug(`tx helper found ${personalValues.length} unsigned personal messages`) allValues = allValues.concat(personalValues) - allValues = allValues.sort((a, b) => { - return a.time > b.time - }) - return allValues + return allValues.sort(txMeta => txMeta.time) } - -- cgit From 7a04643d8ea8a47cc159fc69c941e588e8b873cc Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Mon, 24 Jul 2017 17:27:27 -0700 Subject: Restore sort order fix --- ui/lib/tx-helper.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'ui/lib') diff --git a/ui/lib/tx-helper.js b/ui/lib/tx-helper.js index ec19daf64..5def23e51 100644 --- a/ui/lib/tx-helper.js +++ b/ui/lib/tx-helper.js @@ -12,6 +12,9 @@ module.exports = function (unapprovedTxs, unapprovedMsgs, personalMsgs, network) const personalValues = valuesFor(personalMsgs) log.debug(`tx helper found ${personalValues.length} unsigned personal messages`) allValues = allValues.concat(personalValues) + allValues = allValues.sort((a, b) => { + return a.time > b.time + }) - return allValues.sort(txMeta => txMeta.time) + return allValues } -- cgit From e260ab46cb370c3a74797f86957b5fecefda9188 Mon Sep 17 00:00:00 2001 From: sdtsui Date: Tue, 8 Aug 2017 17:50:29 -0700 Subject: Implement utility helper for checking viewport size in js --- ui/lib/is-mobile-view.js | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 ui/lib/is-mobile-view.js (limited to 'ui/lib') diff --git a/ui/lib/is-mobile-view.js b/ui/lib/is-mobile-view.js new file mode 100644 index 000000000..8a8591c1a --- /dev/null +++ b/ui/lib/is-mobile-view.js @@ -0,0 +1,5 @@ +// Checks if viewport at invoke time fits mobile dimensions +// isMobileView :: () => Bool +const isMobileView = () => window.matchMedia("screen and (max-width: 575px)").matches + +module.exports = isMobileView \ No newline at end of file -- cgit From e7b3ef0708290a81dad5c469adaa6fab3f1c45b5 Mon Sep 17 00:00:00 2001 From: Dan Date: Tue, 29 Aug 2017 12:20:48 -0230 Subject: Lint fixes --- ui/lib/is-mobile-view.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ui/lib') diff --git a/ui/lib/is-mobile-view.js b/ui/lib/is-mobile-view.js index 8a8591c1a..78fd6cb54 100644 --- a/ui/lib/is-mobile-view.js +++ b/ui/lib/is-mobile-view.js @@ -1,5 +1,5 @@ // Checks if viewport at invoke time fits mobile dimensions // isMobileView :: () => Bool -const isMobileView = () => window.matchMedia("screen and (max-width: 575px)").matches +const isMobileView = () => window.matchMedia('screen and (max-width: 575px)').matches -module.exports = isMobileView \ No newline at end of file +module.exports = isMobileView -- cgit From 8498daee88f1002b6a2d980a66101a0d62a7918c Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Fri, 1 Sep 2017 11:03:49 -0700 Subject: Update etherscan links to https Fixes #2005 --- ui/lib/account-link.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'ui/lib') diff --git a/ui/lib/account-link.js b/ui/lib/account-link.js index d061d0ad1..037d990fa 100644 --- a/ui/lib/account-link.js +++ b/ui/lib/account-link.js @@ -3,19 +3,19 @@ module.exports = function (address, network) { let link switch (net) { case 1: // main net - link = `http://etherscan.io/address/${address}` + link = `https://etherscan.io/address/${address}` break case 2: // morden test net - link = `http://morden.etherscan.io/address/${address}` + link = `https://morden.etherscan.io/address/${address}` break case 3: // ropsten test net - link = `http://ropsten.etherscan.io/address/${address}` + link = `https://ropsten.etherscan.io/address/${address}` break case 4: // rinkeby test net - link = `http://rinkeby.etherscan.io/address/${address}` + link = `https://rinkeby.etherscan.io/address/${address}` break case 42: // kovan test net - link = `http://kovan.etherscan.io/address/${address}` + link = `https://kovan.etherscan.io/address/${address}` break default: link = '' -- cgit From 06b2a04a4259a0bc7dff4004328441d353c296de Mon Sep 17 00:00:00 2001 From: Chi Kei Chan Date: Tue, 5 Sep 2017 01:48:52 -0700 Subject: Implement tokens list UI --- ui/lib/icon-factory.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ui/lib') diff --git a/ui/lib/icon-factory.js b/ui/lib/icon-factory.js index 27a74de66..31498a3a9 100644 --- a/ui/lib/icon-factory.js +++ b/ui/lib/icon-factory.js @@ -53,7 +53,7 @@ function imageElFor (address) { const path = `images/contract/${fileName}` const img = document.createElement('img') img.src = path - img.style.width = '75%' + img.style.width = '100%' return img } -- cgit From c2b8dada91c90788dcd81a0318c52a66b4b769d1 Mon Sep 17 00:00:00 2001 From: Sergey Ukustov Date: Fri, 29 Sep 2017 19:24:08 +0300 Subject: Add eth_signTypedData handler --- ui/lib/tx-helper.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'ui/lib') diff --git a/ui/lib/tx-helper.js b/ui/lib/tx-helper.js index 5def23e51..341567e2f 100644 --- a/ui/lib/tx-helper.js +++ b/ui/lib/tx-helper.js @@ -1,20 +1,27 @@ const valuesFor = require('../app/util').valuesFor -module.exports = function (unapprovedTxs, unapprovedMsgs, personalMsgs, network) { +module.exports = function (unapprovedTxs, unapprovedMsgs, personalMsgs, typedMessages, network) { log.debug('tx-helper called with params:') - log.debug({ unapprovedTxs, unapprovedMsgs, personalMsgs, network }) + log.debug({ unapprovedTxs, unapprovedMsgs, personalMsgs, typedMessages, network }) const txValues = network ? valuesFor(unapprovedTxs).filter(txMeta => txMeta.metamaskNetworkId === network) : valuesFor(unapprovedTxs) log.debug(`tx helper found ${txValues.length} unapproved txs`) + const msgValues = valuesFor(unapprovedMsgs) log.debug(`tx helper found ${msgValues.length} unsigned messages`) let allValues = txValues.concat(msgValues) + const personalValues = valuesFor(personalMsgs) log.debug(`tx helper found ${personalValues.length} unsigned personal messages`) allValues = allValues.concat(personalValues) + + const typedValues = valuesFor(typedMessages) + log.debug(`tx helper found ${typedValues.length} unsigned typed messages`) + allValues = allValues.concat(typedValues) + allValues = allValues.sort((a, b) => { return a.time > b.time }) return allValues -} +} \ No newline at end of file -- cgit From 49f76d27a9967cbeff0ba5b3d41277c558999472 Mon Sep 17 00:00:00 2001 From: Dan Date: Fri, 6 Oct 2017 00:04:01 -0230 Subject: Adds checkFeatureToggle util. --- ui/lib/feature-toggle-utils.js | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 ui/lib/feature-toggle-utils.js (limited to 'ui/lib') diff --git a/ui/lib/feature-toggle-utils.js b/ui/lib/feature-toggle-utils.js new file mode 100644 index 000000000..f4ff446d3 --- /dev/null +++ b/ui/lib/feature-toggle-utils.js @@ -0,0 +1,11 @@ +function checkFeatureToggle(name) { + const queryPairMap = window.location.search.substr(1).split('&') + .map(pair => pair.split('=')) + .reduce((pairs, [key, value]) => ({...pairs, [key]: value }), {}) + const featureToggles = queryPairMap['ft'] ? queryPairMap['ft'].split(',') : [] + return Boolean(featureToggles.find(ft => ft === name)) +} + +module.exports = { + checkFeatureToggle, +} \ No newline at end of file -- cgit From 119c2b24238b84d5a9e3beabe572da42f8e2ffcb Mon Sep 17 00:00:00 2001 From: Chi Kei Chan Date: Tue, 10 Oct 2017 14:16:57 -0700 Subject: Confirm eth v2 --- ui/lib/feature-toggle-utils.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ui/lib') diff --git a/ui/lib/feature-toggle-utils.js b/ui/lib/feature-toggle-utils.js index f4ff446d3..6d4e461ca 100644 --- a/ui/lib/feature-toggle-utils.js +++ b/ui/lib/feature-toggle-utils.js @@ -1,4 +1,4 @@ -function checkFeatureToggle(name) { +function checkFeatureToggle (name) { const queryPairMap = window.location.search.substr(1).split('&') .map(pair => pair.split('=')) .reduce((pairs, [key, value]) => ({...pairs, [key]: value }), {}) @@ -8,4 +8,4 @@ function checkFeatureToggle(name) { module.exports = { checkFeatureToggle, -} \ No newline at end of file +} -- cgit From 06094c914b324e3debf33af374bbaa280d6dc6ef Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Sat, 14 Oct 2017 11:23:44 -0400 Subject: Move etherscan link logic into module --- ui/lib/account-link.js | 26 -------------------------- ui/lib/explorer-link.js | 6 ------ 2 files changed, 32 deletions(-) delete mode 100644 ui/lib/account-link.js delete mode 100644 ui/lib/explorer-link.js (limited to 'ui/lib') diff --git a/ui/lib/account-link.js b/ui/lib/account-link.js deleted file mode 100644 index 037d990fa..000000000 --- a/ui/lib/account-link.js +++ /dev/null @@ -1,26 +0,0 @@ -module.exports = function (address, network) { - const net = parseInt(network) - let link - switch (net) { - case 1: // main net - link = `https://etherscan.io/address/${address}` - break - case 2: // morden test net - link = `https://morden.etherscan.io/address/${address}` - break - case 3: // ropsten test net - link = `https://ropsten.etherscan.io/address/${address}` - break - case 4: // rinkeby test net - link = `https://rinkeby.etherscan.io/address/${address}` - break - case 42: // kovan test net - link = `https://kovan.etherscan.io/address/${address}` - break - default: - link = '' - break - } - - return link -} diff --git a/ui/lib/explorer-link.js b/ui/lib/explorer-link.js deleted file mode 100644 index 3b82ecd5f..000000000 --- a/ui/lib/explorer-link.js +++ /dev/null @@ -1,6 +0,0 @@ -const prefixForNetwork = require('./etherscan-prefix-for-network') - -module.exports = function (hash, network) { - const prefix = prefixForNetwork(network) - return `http://${prefix}etherscan.io/tx/${hash}` -} -- cgit From a8bba2f4b7ca714d46b2e1ca405aec3135aa23b2 Mon Sep 17 00:00:00 2001 From: Chi Kei Chan Date: Wed, 18 Oct 2017 23:01:40 -0700 Subject: Merge master to NewUI-flat --- ui/lib/account-link.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 ui/lib/account-link.js (limited to 'ui/lib') diff --git a/ui/lib/account-link.js b/ui/lib/account-link.js new file mode 100644 index 000000000..037d990fa --- /dev/null +++ b/ui/lib/account-link.js @@ -0,0 +1,26 @@ +module.exports = function (address, network) { + const net = parseInt(network) + let link + switch (net) { + case 1: // main net + link = `https://etherscan.io/address/${address}` + break + case 2: // morden test net + link = `https://morden.etherscan.io/address/${address}` + break + case 3: // ropsten test net + link = `https://ropsten.etherscan.io/address/${address}` + break + case 4: // rinkeby test net + link = `https://rinkeby.etherscan.io/address/${address}` + break + case 42: // kovan test net + link = `https://kovan.etherscan.io/address/${address}` + break + default: + link = '' + break + } + + return link +} -- cgit From 43b1cb9100e74ab32efe1a59b3320d0aeadedcdf Mon Sep 17 00:00:00 2001 From: Daijiro Wachi Date: Sat, 21 Oct 2017 21:06:39 +0200 Subject: Fix lint warnings Fixed warnings: ```md app/scripts/controllers/computed-balances.js + 35:27 warning Missing space before function parentheses space-before-function-paren + 41:14 warning 'address' is never reassigned. Use 'const' instead prefer-const + 61:9 warning 'updater' is never reassigned. Use 'const' instead prefer-const + 68:11 warning 'newState' is never reassigned. Use 'const' instead prefer-const app/scripts/controllers/network.js + 104:29 warning Missing space before function parentheses space-before-function-paren app/scripts/lib/createLoggerMiddleware.js + 4:32 warning Missing space before function parentheses space-before-function-paren + 15:2 warning Newline required at end of file but not found eol-last app/scripts/lib/createOriginMiddleware.js + 4:32 warning Missing space before function parentheses space-before-function-paren + 9:2 warning Newline required at end of file but not found eol-last app/scripts/lib/createProviderMiddleware.js + 5:34 warning Missing space before function parentheses space-before-function-paren + 13:2 warning Newline required at end of file but not found eol-last app/scripts/lib/events-proxy.js + 1:50 warning Missing space before function parentheses space-before-function-paren + 31:2 warning Newline required at end of file but not found eol-last app/scripts/lib/nodeify.js + 2:22 warning Missing space before function parentheses space-before-function-paren + 2:24 warning Missing space before opening brace space-before-blocks + 5:18 warning Missing space before function parentheses space-before-function-paren + 5:20 warning Missing space before opening brace space-before-blocks app/scripts/lib/pending-balance-calculator.js + 16:19 warning Missing space before function parentheses space-before-function-paren app/scripts/lib/pending-tx-tracker.js + 85:11 warning '||' should be placed at the end of the line operator-linebreak + 87:11 warning '||' should be placed at the end of the line operator-linebreak + 88:11 warning '||' should be placed at the end of the line operator-linebreak + 90:11 warning '||' should be placed at the end of the line operator-linebreak + 91:11 warning '||' should be placed at the end of the line operator-linebreak app/scripts/lib/port-stream.js + 3:22 warning Missing space before function parentheses space-before-function-paren + 3:24 warning Missing space before opening brace space-before-blocks app/scripts/lib/tx-gas-utils.js + 84:2 warning Newline required at end of file but not found eol-last app/scripts/lib/tx-state-history-helper.js + 12:37 warning Missing space before function parentheses space-before-function-paren + 23:30 warning Missing space before function parentheses space-before-function-paren + 30:23 warning Missing space before function parentheses space-before-function-paren + 35:28 warning Missing space before function parentheses space-before-function-paren + 41:2 warning Newline required at end of file but not found eol-last app/scripts/lib/tx-state-manager.js + 94:13 warning 'value' is never reassigned. Use 'const' instead prefer-const ui/app/reducers.js + 45:7 warning 'state' is never reassigned. Use 'const' instead prefer-const + 53:7 warning 'stateString' is never reassigned. Use 'const' instead prefer-const ui/lib/tx-helper.js + 27:2 warning Newline required at end of file but not found eol-last ui/app/components/account-dropdowns.js + 163:1 warning More than 2 blank lines not allowed no-multiple-empty-lines ui/app/components/menu-droppo.js + 22:7 warning 'style' is never reassigned. Use 'const' instead prefer-const ui/app/components/shapeshift-form.js + 135:11 warning '&&' should be placed at the end of the line operator-linebreak ui/app/components/typed-message-renderer.js + 35:25 warning Missing space before function parentheses space-before-function-paren + 42:2 warning Newline required at end of file but not found eol-last mascara/server/index.js + 11:42 warning Use path.join() or path.resolve() instead of + to create paths no-path-concat + 12:36 warning Use path.join() or path.resolve() instead of + to create paths no-path-concat + 13:33 warning Use path.join() or path.resolve() instead of + to create paths no-path-concat + 14:40 warning Use path.join() or path.resolve() instead of + to create paths no-path-concat + 20:29 warning Use path.join() or path.resolve() instead of + to create paths no-path-concat + 21:29 warning Use path.join() or path.resolve() instead of + to create paths no-path-concat + 26:40 warning Use path.join() or path.resolve() instead of + to create paths no-path-concat ``` --- ui/lib/tx-helper.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ui/lib') diff --git a/ui/lib/tx-helper.js b/ui/lib/tx-helper.js index 341567e2f..de3f00d2d 100644 --- a/ui/lib/tx-helper.js +++ b/ui/lib/tx-helper.js @@ -24,4 +24,4 @@ module.exports = function (unapprovedTxs, unapprovedMsgs, personalMsgs, typedMes }) return allValues -} \ No newline at end of file +} -- cgit From 1b89ceb63aa7d96912eb32c8766ef566479dde41 Mon Sep 17 00:00:00 2001 From: Jason Clark Date: Sat, 25 Nov 2017 14:33:42 -0700 Subject: swapped out ethereum-blockies lib for MEW blockies library, tightened up identicon.js code --- ui/lib/blockies.js | 364 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 364 insertions(+) create mode 100644 ui/lib/blockies.js (limited to 'ui/lib') diff --git a/ui/lib/blockies.js b/ui/lib/blockies.js new file mode 100644 index 000000000..ee5a2a5ca --- /dev/null +++ b/ui/lib/blockies.js @@ -0,0 +1,364 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : + typeof define === 'function' && define.amd ? define(['exports'], factory) : + (factory((global.blockies = {}))); +}(this, (function (exports) { 'use strict'; + + /** + * A handy class to calculate color values. + * + * @version 1.0 + * @author Robert Eisele + * @copyright Copyright (c) 2010, Robert Eisele + * @link http://www.xarg.org/2010/03/generate-client-side-png-files-using-javascript/ + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * + */ + + +// helper functions for that ctx + function write(buffer, offs) { + for (var i = 2; i < arguments.length; i++) { + for (var j = 0; j < arguments[i].length; j++) { + buffer[offs++] = arguments[i].charAt(j); + } + } + } + + function byte2(w) { + return String.fromCharCode((w >> 8) & 255, w & 255); + } + + function byte4(w) { + return String.fromCharCode((w >> 24) & 255, (w >> 16) & 255, (w >> 8) & 255, w & 255); + } + + function byte2lsb(w) { + return String.fromCharCode(w & 255, (w >> 8) & 255); + } + + var PNG = function(width,height,depth) { + + this.width = width; + this.height = height; + this.depth = depth; + + // pixel data and row filter identifier size + this.pix_size = height * (width + 1); + + // deflate header, pix_size, block headers, adler32 checksum + this.data_size = 2 + this.pix_size + 5 * Math.floor((0xfffe + this.pix_size) / 0xffff) + 4; + + // offsets and sizes of Png chunks + this.ihdr_offs = 0; // IHDR offset and size + this.ihdr_size = 4 + 4 + 13 + 4; + this.plte_offs = this.ihdr_offs + this.ihdr_size; // PLTE offset and size + this.plte_size = 4 + 4 + 3 * depth + 4; + this.trns_offs = this.plte_offs + this.plte_size; // tRNS offset and size + this.trns_size = 4 + 4 + depth + 4; + this.idat_offs = this.trns_offs + this.trns_size; // IDAT offset and size + this.idat_size = 4 + 4 + this.data_size + 4; + this.iend_offs = this.idat_offs + this.idat_size; // IEND offset and size + this.iend_size = 4 + 4 + 4; + this.buffer_size = this.iend_offs + this.iend_size; // total PNG size + + this.buffer = new Array(); + this.palette = new Object(); + this.pindex = 0; + + var _crc32 = new Array(); + + // initialize buffer with zero bytes + for (var i = 0; i < this.buffer_size; i++) { + this.buffer[i] = "\x00"; + } + + // initialize non-zero elements + write(this.buffer, this.ihdr_offs, byte4(this.ihdr_size - 12), 'IHDR', byte4(width), byte4(height), "\x08\x03"); + write(this.buffer, this.plte_offs, byte4(this.plte_size - 12), 'PLTE'); + write(this.buffer, this.trns_offs, byte4(this.trns_size - 12), 'tRNS'); + write(this.buffer, this.idat_offs, byte4(this.idat_size - 12), 'IDAT'); + write(this.buffer, this.iend_offs, byte4(this.iend_size - 12), 'IEND'); + + // initialize deflate header + var header = ((8 + (7 << 4)) << 8) | (3 << 6); + header+= 31 - (header % 31); + + write(this.buffer, this.idat_offs + 8, byte2(header)); + + // initialize deflate block headers + for (var i = 0; (i << 16) - 1 < this.pix_size; i++) { + var size, bits; + if (i + 0xffff < this.pix_size) { + size = 0xffff; + bits = "\x00"; + } else { + size = this.pix_size - (i << 16) - i; + bits = "\x01"; + } + write(this.buffer, this.idat_offs + 8 + 2 + (i << 16) + (i << 2), bits, byte2lsb(size), byte2lsb(~size)); + } + + /* Create crc32 lookup table */ + for (var i = 0; i < 256; i++) { + var c = i; + for (var j = 0; j < 8; j++) { + if (c & 1) { + c = -306674912 ^ ((c >> 1) & 0x7fffffff); + } else { + c = (c >> 1) & 0x7fffffff; + } + } + _crc32[i] = c; + } + + // compute the index into a png for a given pixel + this.index = function(x,y) { + var i = y * (this.width + 1) + x + 1; + var j = this.idat_offs + 8 + 2 + 5 * Math.floor((i / 0xffff) + 1) + i; + return j; + }; + + // convert a color and build up the palette + this.color = function(red, green, blue, alpha) { + + alpha = alpha >= 0 ? alpha : 255; + var color = (((((alpha << 8) | red) << 8) | green) << 8) | blue; + + if (typeof this.palette[color] == "undefined") { + if (this.pindex == this.depth) return "\x00"; + + var ndx = this.plte_offs + 8 + 3 * this.pindex; + + this.buffer[ndx + 0] = String.fromCharCode(red); + this.buffer[ndx + 1] = String.fromCharCode(green); + this.buffer[ndx + 2] = String.fromCharCode(blue); + this.buffer[this.trns_offs+8+this.pindex] = String.fromCharCode(alpha); + + this.palette[color] = String.fromCharCode(this.pindex++); + } + return this.palette[color]; + }; + + // output a PNG string, Base64 encoded + this.getBase64 = function() { + + var s = this.getDump(); + + var ch = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; + var c1, c2, c3, e1, e2, e3, e4; + var l = s.length; + var i = 0; + var r = ""; + + do { + c1 = s.charCodeAt(i); + e1 = c1 >> 2; + c2 = s.charCodeAt(i+1); + e2 = ((c1 & 3) << 4) | (c2 >> 4); + c3 = s.charCodeAt(i+2); + if (l < i+2) { e3 = 64; } else { e3 = ((c2 & 0xf) << 2) | (c3 >> 6); } + if (l < i+3) { e4 = 64; } else { e4 = c3 & 0x3f; } + r+= ch.charAt(e1) + ch.charAt(e2) + ch.charAt(e3) + ch.charAt(e4); + } while ((i+= 3) < l); + return r; + }; + + // output a PNG string + this.getDump = function() { + + // compute adler32 of output pixels + row filter bytes + var BASE = 65521; /* largest prime smaller than 65536 */ + var NMAX = 5552; /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ + var s1 = 1; + var s2 = 0; + var n = NMAX; + + for (var y = 0; y < this.height; y++) { + for (var x = -1; x < this.width; x++) { + s1+= this.buffer[this.index(x, y)].charCodeAt(0); + s2+= s1; + if ((n-= 1) == 0) { + s1%= BASE; + s2%= BASE; + n = NMAX; + } + } + } + s1%= BASE; + s2%= BASE; + write(this.buffer, this.idat_offs + this.idat_size - 8, byte4((s2 << 16) | s1)); + + // compute crc32 of the PNG chunks + function crc32(png, offs, size) { + var crc = -1; + for (var i = 4; i < size-4; i += 1) { + crc = _crc32[(crc ^ png[offs+i].charCodeAt(0)) & 0xff] ^ ((crc >> 8) & 0x00ffffff); + } + write(png, offs+size-4, byte4(crc ^ -1)); + } + + crc32(this.buffer, this.ihdr_offs, this.ihdr_size); + crc32(this.buffer, this.plte_offs, this.plte_size); + crc32(this.buffer, this.trns_offs, this.trns_size); + crc32(this.buffer, this.idat_offs, this.idat_size); + crc32(this.buffer, this.iend_offs, this.iend_size); + + // convert PNG to string + return "\x89PNG\r\n\x1A\n"+this.buffer.join(''); + }; + + this.fillRect = function (x, y, w, h, color) { + for(var i = 0; i < w; i++) { + for (var j = 0; j < h; j++) { + this.buffer[this.index(x+i, y+j)] = color; + } + } + }; + }; + +// https://stackoverflow.com/questions/2353211/hsl-to-rgb-color-conversion + /** + * Converts an HSL color value to RGB. Conversion formula + * adapted from http://en.wikipedia.org/wiki/HSL_color_space. + * Assumes h, s, and l are contained in the set [0, 1] and + * returns r, g, and b in the set [0, 255]. + * + * @param {number} h The hue + * @param {number} s The saturation + * @param {number} l The lightness + * @return {Array} The RGB representation + */ + + function hue2rgb(p, q, t) { + if(t < 0) t += 1; + if(t > 1) t -= 1; + if(t < 1/6) return p + (q - p) * 6 * t; + if(t < 1/2) return q; + if(t < 2/3) return p + (q - p) * (2/3 - t) * 6; + return p; + } + + function hsl2rgb(h, s, l){ + var r, g, b; + + if(s == 0){ + r = g = b = l; // achromatic + }else{ + var q = l < 0.5 ? l * (1 + s) : l + s - l * s; + var p = 2 * l - q; + r = hue2rgb(p, q, h + 1/3); + g = hue2rgb(p, q, h); + b = hue2rgb(p, q, h - 1/3); + } + + return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255), 255]; + } + +// The random number is a js implementation of the Xorshift PRNG + var randseed = new Array(4); // Xorshift: [x, y, z, w] 32 bit values + + function seedrand(seed) { + for (var i = 0; i < randseed.length; i++) { + randseed[i] = 0; + } + for (var i = 0; i < seed.length; i++) { + randseed[i % 4] = (randseed[i % 4] << 5) - randseed[i % 4] + seed.charCodeAt(i); + } + } + + function rand() { + // based on Java's String.hashCode(), expanded to 4 32bit values + var t = randseed[0] ^ (randseed[0] << 11); + + randseed[0] = randseed[1]; + randseed[1] = randseed[2]; + randseed[2] = randseed[3]; + randseed[3] = randseed[3] ^ (randseed[3] >> 19) ^ t ^ (t >> 8); + + return (randseed[3] >>> 0) / (1 << 31 >>> 0); + } + + function createColor() { + //saturation is the whole color spectrum + var h = Math.floor(rand() * 360); + //saturation goes from 40 to 100, it avoids greyish colors + var s = rand() * 60 + 40; + //lightness can be anything from 0 to 100, but probabilities are a bell curve around 50% + var l = (rand() + rand() + rand() + rand()) * 25; + + return [h / 360,s / 100,l / 100]; + } + + function createImageData(size) { + var width = size; // Only support square icons for now + var height = size; + + var dataWidth = Math.ceil(width / 2); + var mirrorWidth = width - dataWidth; + + var data = []; + for (var y = 0; y < height; y++) { + var row = []; + for (var x = 0; x < dataWidth; x++) { + // this makes foreground and background color to have a 43% (1/2.3) probability + // spot color has 13% chance + row[x] = Math.floor(rand() * 2.3); + } + var r = row.slice(0, mirrorWidth); + r.reverse(); + row = row.concat(r); + + for (var i = 0; i < row.length; i++) { + data.push(row[i]); + } + } + + return data; + } + + function buildOpts(opts) { + if (!opts.seed) { + throw 'No seed provided' + } + + seedrand(opts.seed); + + return Object.assign({ + size: 8, + scale: 16, + color: createColor(), + bgcolor: createColor(), + spotcolor: createColor(), + }, opts) + } + + function toDataUrl(address) { + const opts = buildOpts({seed: address.toLowerCase()}); + + const imageData = createImageData(opts.size); + const width = Math.sqrt(imageData.length); + + const p = new PNG(opts.size*opts.scale, opts.size*opts.scale, 3); + const bgcolor = p.color(...hsl2rgb(...opts.bgcolor)); + const color = p.color(...hsl2rgb(...opts.color)); + const spotcolor = p.color(...hsl2rgb(...opts.spotcolor)); + + for (var i = 0; i < imageData.length; i++) { + var row = Math.floor(i / width); + var col = i % width; + // if data is 0, leave the background + if (imageData[i]) { + // if data is 2, choose spot color, if 1 choose foreground + const pngColor = imageData[i] == 1 ? color : spotcolor; + p.fillRect(col * opts.scale, row * opts.scale, opts.scale, opts.scale, pngColor); + } + } + return `data:image/png;base64,${p.getBase64()}`; + } + + exports.toDataUrl = toDataUrl; + + Object.defineProperty(exports, '__esModule', { value: true }); + +}))); -- cgit From 4b654669e692665aba88a14cb5804370dbfd4a80 Mon Sep 17 00:00:00 2001 From: Dan Date: Fri, 8 Dec 2017 21:52:31 -0330 Subject: Hide open in browser button on mobile (but still show on extension); adds a function to detect if viewing with mobile browser. --- ui/lib/is-mobile-browser.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 ui/lib/is-mobile-browser.js (limited to 'ui/lib') diff --git a/ui/lib/is-mobile-browser.js b/ui/lib/is-mobile-browser.js new file mode 100644 index 000000000..8609ed3b1 --- /dev/null +++ b/ui/lib/is-mobile-browser.js @@ -0,0 +1,12 @@ +/* eslint-disable */ + +// See https://stackoverflow.com/questions/11381673/detecting-a-mobile-browser +// Checks whether the user is viewing the app through mobile +// isMobileBrowser :: () => Bool +const isMobileBrowser = () => { + let check = false; + (function(a){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4))) check = true;})(navigator.userAgent||navigator.vendor||window.opera); + return check; +}; + +module.exports = isMobileBrowser \ No newline at end of file -- cgit From 57c91435a7357165441252acfffcdaff6e54e422 Mon Sep 17 00:00:00 2001 From: Dan Date: Tue, 12 Dec 2017 16:21:05 -0330 Subject: Substitute isMascara check for explicit check if user is on mobile browser. --- ui/lib/is-mobile-browser.js | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 ui/lib/is-mobile-browser.js (limited to 'ui/lib') diff --git a/ui/lib/is-mobile-browser.js b/ui/lib/is-mobile-browser.js deleted file mode 100644 index 8609ed3b1..000000000 --- a/ui/lib/is-mobile-browser.js +++ /dev/null @@ -1,12 +0,0 @@ -/* eslint-disable */ - -// See https://stackoverflow.com/questions/11381673/detecting-a-mobile-browser -// Checks whether the user is viewing the app through mobile -// isMobileBrowser :: () => Bool -const isMobileBrowser = () => { - let check = false; - (function(a){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4))) check = true;})(navigator.userAgent||navigator.vendor||window.opera); - return check; -}; - -module.exports = isMobileBrowser \ No newline at end of file -- cgit