diff --git a/i18n/parse.js b/i18n/parse.js
index 7393f1bc0..3cd200c22 100644
--- a/i18n/parse.js
+++ b/i18n/parse.js
@@ -74,7 +74,7 @@ const app = fs.readFileSync(appPath, {encoding: 'utf8'})
const outPath = path.resolve(__dirname, '../i18n/ui/lbm-ui_en-US.po')
const coins = [
- 'Bitcoin', 'Ethereum', 'Zcash', 'Litecoin', 'Dash', 'Bitcoin Cash'
+ 'Bitcoin', 'Ethereum', 'Zcash', 'Litecoin', 'Dash', 'Bitcoin Cash', 'Monero', 'USDT'
]
function run (){
diff --git a/i18n/ui/lbm-ui_en-US.po b/i18n/ui/lbm-ui_en-US.po
index 3f8f5cf0e..09abe6c15 100644
--- a/i18n/ui/lbm-ui_en-US.po
+++ b/i18n/ui/lbm-ui_en-US.po
@@ -102,6 +102,10 @@ msgstr "Please contact the operator if you wish to learn more."
msgid "Languages"
msgstr "Languages"
+#: On screen: choose_coin
+msgid "Rates"
+msgstr "Rates"
+
#: On screen: choose_coin
msgid "Redeem"
msgstr "Redeem"
@@ -594,6 +598,22 @@ msgstr "If you are sure of the code, please contact the operator for clarificati
msgid "Enter a different code"
msgstr "Enter a different code"
+#: On screen: rates
+msgid "Exchange Rates"
+msgstr "Exchange Rates"
+
+#: On screen: rates
+msgid "Buy"
+msgstr "Buy"
+
+#: On screen: rates
+msgid "Crypto"
+msgstr "Crypto"
+
+#: On screen: rates
+msgid "Sell"
+msgstr "Sell"
+
#: On screen: recycler-continue
msgid "Depositing bills..."
msgstr "Depositing bills..."
@@ -1078,3 +1098,11 @@ msgstr "Dash"
msgid "Bitcoin Cash"
msgstr "Bitcoin Cash"
+#: On screen: coins
+msgid "Monero"
+msgstr "Monero"
+
+#: On screen: coins
+msgid "USDT"
+msgstr "USDT"
+
diff --git a/lib/brain.js b/lib/brain.js
index 4c933103f..6a822e1f1 100644
--- a/lib/brain.js
+++ b/lib/brain.js
@@ -1098,6 +1098,7 @@ Brain.prototype._connectedBrowser = function _connectedBrowser () {
cryptomatModel,
version,
operatorInfo: this.trader?.operatorInfo ?? { active: false },
+ screenOpts: this.trader?.machineScreenOpts
}
return this.browser().send(rec)
@@ -1130,7 +1131,8 @@ Brain.prototype._connectedBrowser = function _connectedBrowser () {
operatorInfo: this.trader.operatorInfo,
cryptomatModel,
areThereAvailablePromoCodes: this.trader.areThereAvailablePromoCodes,
- supportedCoins: this.mapCryptoUnitsDisplay(this.trader.coins)
+ supportedCoins: this.mapCryptoUnitsDisplay(this.trader.coins),
+ screenOpts: this.trader.machineScreenOpts
}
this.browser().send(fullRec)
@@ -1375,6 +1377,9 @@ Brain.prototype._processReal = function _processReal (req) {
case 'leftoverBillsRemoved':
this._leftoverBillsRemoved()
break
+ case 'ratesScreen':
+ this.ratesScreen()
+ break
default:
break
}
@@ -2334,6 +2339,7 @@ Brain.prototype._chooseCoinScreen = function _chooseCoinsScreen (localeInfo, cas
localeInfo: localeInfo,
cassettes: cassettes,
coins: this.trader.coins,
+ screenOpts: this.trader.machineScreenOpts,
twoWayMode: this.twoWayMode(),
supportedCoins: this.mapCryptoUnitsDisplay(this.trader.coins)
})
@@ -2670,7 +2676,8 @@ Brain.prototype.sendRates = function sendRates () {
terms: _.assign(this.trader.terms, this._getTermsDelayConfig()),
operatorInfo: this.trader.operatorInfo,
areThereAvailablePromoCodes: this.trader.areThereAvailablePromoCodes,
- supportedCoins: this.mapCryptoUnitsDisplay(this.trader.coins)
+ supportedCoins: this.mapCryptoUnitsDisplay(this.trader.coins),
+ screenOpts: this.trader.machineScreenOpts
}
this.browser().send(rec)
@@ -4163,6 +4170,13 @@ Brain.prototype.cancelTransaction = function cancelTransaction (previousState) {
}
}
+Brain.prototype.ratesScreen = function () {
+ const coins = _.map(it => it.cryptoCode, this.trader.coins)
+ const rates = _.reduce((acc, value) => Object.assign({ [value]: _.mapValues(it => it.toString(), this.trader.rates(value)) }, acc), {}, coins)
+
+ this._transitionState('rates', { allRates: rates, ratesFiat: this.trader.locale.fiatCode })
+}
+
Brain.prototype.browser = function browser () {
return this.browserObj
}
diff --git a/lib/trader.js b/lib/trader.js
index 591899523..758397cfa 100644
--- a/lib/trader.js
+++ b/lib/trader.js
@@ -90,6 +90,12 @@ query($configVersion: Int, $currentHash: String) {
addressQRCode
}
+ screenOptions {
+ rates {
+ active
+ }
+ }
+
triggersAutomation {
sanctions
idCardPhoto
@@ -716,6 +722,7 @@ Trader.prototype.pollHandler = function pollHandler (data) {
)
)
this.triggers = addCustomInfoRequestIdToTriggers(data.triggers)
+ this.machineScreenOpts = data.screenOptions
this.receiptPrintingActive = data.receiptInfo && data.receiptInfo.paper
this.smsReceiptActive = data.receiptInfo && data.receiptInfo.sms
@@ -907,7 +914,7 @@ Trader.prototype.networkHeartbeat = function networkHeartbeat (obj) {
body: obj,
method: 'POST'
})
- .catch(err => console.error('Failed to send network heartbeat', err))
+ .catch(err => console.error('Failed to send network heartbeat', err))
}
Trader.prototype.networkPerformance = function networkPerformance (obj) {
@@ -916,7 +923,7 @@ Trader.prototype.networkPerformance = function networkPerformance (obj) {
body: obj,
method: 'POST'
})
- .catch(err => console.error('Failed to send network performance', err))
+ .catch(err => console.error('Failed to send network performance', err))
}
Trader.prototype.emptyUnit = function emptyUnit (body) {
@@ -1030,7 +1037,8 @@ function isNewState (res) {
const pare = r => ({
twoWayMode: r.twoWayMode,
locale: r.locale,
- coins: _.map('cryptoCode', r.coins)
+ coins: _.map('cryptoCode', r.coins),
+ screenOps: r.machineScreenOpts
})
if (_.isEqual(pare(res), oldState)) return false
diff --git a/ui/css/main.scss b/ui/css/main.scss
index 2c0d31dc6..0c3daa346 100644
--- a/ui/css/main.scss
+++ b/ui/css/main.scss
@@ -733,6 +733,10 @@ footer {
width: 30vh;
}
+.rates-section {
+ margin-left: 2em;
+}
+
#change-language-section #language-dropdown-toggle {
align-items: center;
}
@@ -1444,6 +1448,10 @@ footer {
display: flex;
justify-content: flex-end;
}
+ .rates-section {
+ margin-left: 0;
+ margin-right: 2em;
+ }
}
.send-only-total {
diff --git a/ui/html/choose-coin.html b/ui/html/choose-coin.html
index 5f1f3ddf8..13c0de851 100644
--- a/ui/html/choose-coin.html
+++ b/ui/html/choose-coin.html
@@ -15,6 +15,11 @@
+
diff --git a/ui/html/insert_promo_code.html b/ui/html/insert_promo_code.html
index 3685dfcbc..b4dc222d8 100644
--- a/ui/html/insert_promo_code.html
+++ b/ui/html/insert_promo_code.html
@@ -72,7 +72,7 @@
diff --git a/ui/html/rates.html b/ui/html/rates.html
new file mode 100644
index 000000000..4e584ed44
--- /dev/null
+++ b/ui/html/rates.html
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
Buy
+ Crypto
+ Sell
+
+
+
+
diff --git a/ui/html/withdraw-failure.html b/ui/html/withdraw-failure.html
index dd1534053..fcf6de1fb 100644
--- a/ui/html/withdraw-failure.html
+++ b/ui/html/withdraw-failure.html
@@ -8,7 +8,7 @@
We got this
-
+
Our Internet was down for a bit but you'll receive your funds as soon as our connection is back.
You Purchased
diff --git a/ui/js/app.js b/ui/js/app.js
index a6f19a170..c69bf2c6d 100644
--- a/ui/js/app.js
+++ b/ui/js/app.js
@@ -93,6 +93,7 @@ var LN = 'LN';
var BTC = 'BTC';
function processData(data) {
+ if (data.screenOpts) setScreenOptions(data.screenOpts);
if (data.localeInfo) setLocaleInfo(data.localeInfo);
if (data.locale) setLocale(data.locale);
if (data.supportedCoins) setCoins(data.supportedCoins);
@@ -112,7 +113,9 @@ function processData(data) {
if (data.cassettes) buildCassetteButtons(data.cassettes, NUMBER_OF_BUTTONS);
if (data.readingBills) readingBills(data.readingBills);
if (data.cryptoCode) translateCoin(data.cryptoCode);
- if (data.tx && data.tx.cashInFee) setFixedFee(data.tx.cashInFee);
+ if (data.tx) {
+ if (data.tx.cashInFee) setFixedFee(data.tx.cashInFee);else if (data.tx.cashOutFee) setFixedFee(data.tx.cashOutFee);
+ }
if (data.terms) setTermsScreen(data.terms);
if (data.dispenseBatch) dispenseBatch(data.dispenseBatch);
if (data.direction) setDirection(data.direction);
@@ -120,6 +123,7 @@ function processData(data) {
if (data.hardLimit) setHardLimit(data.hardLimit);
if (data.cryptomatModel) setCryptomatModel(data.cryptomatModel);
if (data.areThereAvailablePromoCodes !== undefined) setAvailablePromoCodes(data.areThereAvailablePromoCodes);
+ if (data.allRates && data.ratesFiat) setRates(data.allRates, data.ratesFiat);
if (data.tx && data.tx.discount) setCurrentDiscount(data.tx.discount);
if (data.receiptStatus) setReceiptPrint(data.receiptStatus, null);
@@ -298,6 +302,9 @@ function processData(data) {
clearTimeout(complianceTimeout);
externalCompliance(data.externalComplianceUrl);
break;
+ case 'rates':
+ setState('rates');
+ break;
default:
if (data.action) setState(window.snakecase(data.action));
}
@@ -843,6 +850,9 @@ $(document).ready(function () {
setupButton('terms-ok', 'termsAccepted');
setupButton('terms-ko', 'idle');
+ setupImmediateButton('rates-close', 'idle');
+ setupButton('rates-section-button', 'ratesScreen');
+
setupButton('maintenance_restart', 'maintenanceRestart');
calculateAspectRatio();
@@ -2036,4 +2046,30 @@ function externalCompliance(url) {
qrize(url, $('#qr-code-external-validation'), cashDirection === 'cashIn' ? CASH_IN_QR_COLOR : CASH_OUT_QR_COLOR);
return setScreen('external_compliance');
}
+
+function setScreenOptions(opts) {
+ opts.rates && opts.rates.active ? $('#rates-section').show() : $('#rates-section').hide();
+}
+
+function thousandSeparator(number, country, minimumFractionDigits) {
+ var numberFormatter = Intl.NumberFormat(country, { minimumFractionDigits: minimumFractionDigits });
+ return numberFormatter.format(number);
+}
+
+function setRates(allRates, fiat) {
+ var ratesTable = $('.rates-content');
+ var tableHeader = $('\n
' + translate('Buy') + '
\n ' + translate('Crypto') + '
\n ' + translate('Sell') + '
\n');
+ var coinEntries = [];
+
+ Object.keys(allRates).forEach(function (it) {
+ var cashIn = BN(allRates[it].cashIn);
+ var cashOut = BN(allRates[it].cashOut);
+ var biggestDecimalPlaces = Math.max(cashIn.dp(), cashOut.dp());
+
+ coinEntries.push($('\n
' + thousandSeparator(BN(allRates[it].cashIn).toFixed(2), localeCode) + '
\n
' + it + '
\n
' + thousandSeparator(BN(allRates[it].cashOut).toFixed(2), localeCode) + '
\n
'));
+ });
+
+ $('#rates-fiat-currency').text(fiat);
+ ratesTable.empty().append(tableHeader).append(coinEntries);
+}
//# sourceMappingURL=app.js.map
\ No newline at end of file
diff --git a/ui/js/app.js.map b/ui/js/app.js.map
index 735ebd7b7..fb1668559 100644
--- a/ui/js/app.js.map
+++ b/ui/js/app.js.map
@@ -1 +1 @@
-{"version":3,"sources":["../src/app.js"],"names":["queryString","window","location","search","params","URLSearchParams","substring","DEBUG_MODE","get","CASH_OUT_QR_COLOR","CASH_IN_QR_COLOR","NUMBER_OF_BUTTONS","scrollSize","textHeightQuantity","currentPage","totalPages","aspectRatio","isTwoWay","isRTL","cryptomatModel","termsConditionsTimeout","termsConditionsAcceptanceInterval","T_C_TIMEOUT","complianceTimeout","cashDirection","fiatCode","locale","defaultLocale","loadI18n","localeCode","jsLocaleCode","_primaryLocales","lastRates","coins","currentState","websocket","promoKeyboard","usSsnKeypad","phoneKeypad","securityKeypad","previousState","buttonActive","currentCryptoCode","currentCoin","currentCoins","emailKeyboard","customRequirementNumericalKeypad","customRequirementTextKeyboard","customRequirementChoiceList","MUSEO","connect","console","log","HOST","PORT","WebSocket","onmessage","event","data","$","parseJSON","processData","onerror","err","verifyConnection","readyState","CLOSED","buttonPressed","button","deactivate","setTimeout","activate","res","send","JSON","stringify","displayLN","displayBTC","LN","BTC","localeInfo","setLocaleInfo","setLocale","supportedCoins","setCoins","setFiatCode","rates","setExchangeRate","buyerAddress","setBuyerAddress","credit","lastBill","action","setCredit","tx","setTx","sendOnly","reason","fiatCredit","depositInfo","setDepositAddress","version","setVersion","cassettes","buildCassetteButtons","readingBills","cryptoCode","translateCoin","cashInFee","setFixedFee","terms","setTermsScreen","dispenseBatch","direction","setDirection","operatorInfo","setOperatorInfo","hardLimit","setHardLimit","setCryptomatModel","areThereAvailablePromoCodes","undefined","setAvailablePromoCodes","discount","setCurrentDiscount","receiptStatus","setReceiptPrint","smsReceiptStatus","context","hide","show","isRecycler","billValidator","setState","text","setComplianceTimeout","setConstraint","disableRecyclerBillButtons","enableRecyclerBillButtons","highBill","highestBill","minimumTx","lowestBill","isCashInOnlyCoin","chooseFiat","deposit","fiatReceipt","fiatComplete","chooseCoin","twoWayMode","smsVerification","emailVerification","idVerification","facephotoPermission","usSsnPermission","externalPermission","blockedCustomer","customInfoRequestPermission","customInfoRequest","invalidAddress","lnInvoiceTypeError","clearTimeout","externalCompliance","externalComplianceUrl","snakecase","translate","fetchArgs","fetch","error","e","setScreen","screen1","title","interval","complianceButton","input","type","screen2","setOpts","constraint","constraintType","maxLength","numDigits","label1","label2","removeClass","addClass","replaceChoices","choiceList","setChooseCoinColors","defaultCoin","slice","setCryptoBuy","setCryptoSell","setupCoinsButtons","openLanguageDropdown","closeLanguageDropdown","openCoinDropdown","closeCoinDropdown","empty","dropdownCoins","length","showMoreButton","forEach","coin","activeClass","el","toLowerCase","display","append","each","html","trim","cashIn","translatedCoin","buyStr","cashOut","sellStr","getCryptoCurrency","cryptoCurrency","find","c","Error","switchCoin","selectedIndex","indexOf","it","splice","document","ready","attachFastClick","Origami","fastclick","body","addEventListener","calculateAspectRatio","onclick","oncontextmenu","onmousedown","onmousemove","onmouseup","BigNumber","config","ROUNDING_MODE","ROUND_HALF_EVEN","Keyboard","id","inputBox","init","Keypad","result","country","submitButtonWrapper","ChoiceList","setInterval","initTranslatePage","sendCoinsButton","getElementById","sendCoinsButton2","touchEvent","setupButton","blockedCustomerOk","insertBillCancelButton","touchImmediateEvent","insertBillCancelRecyclerButton","setupImmediateButton","promoCodeCancelButton","bind","submitCodeButton","code","submitEmailButton","submitTextRequirementButton","nextFieldTextRequirementButton","previousFieldTextRequirementButton","val","setInputBox","cryptoButtons","target","is","closest","wantedCoin","areYouSureCancel","areYouSureContinue","coinRedeem","otherLocale","cashInBox","cashOutBox","languageOverlay","cryptoOverlay","languageButtons","languageButtonJ","newLocale","attr","buildCassetteButtonEvents","initDebug","targetButton","element","classList","special","contains","parentNode","callback","handler","add","remove","stopPropagation","preventDefault","shouldEnableTouch","buttonClass","buttonAction","actionData","newScreen","oldScreen","css","top","left","newView","state","delay","clearTermsConditionsTimeout","clearTermsConditionsAcceptanceDelay","reset","revertScreen","setUpDirectionElement","operator","active","name","email","phone","limits","component","hardLimitWeeks","hardLimitDays","hardLimitHours","model","versions","startsWith","continueButton","finishButton","disabled","states","$screen","startPage","acceptDisabled","cancel","accept","setTermsConditionsTimeout","setAcceptButtonDisabled","setTermsConditionsAcceptanceDelay","screen","acceptButton","prop","Boolean","delayTimer","isNaN","seconds","tmpbtn","clone","appendTo","width","outerWidth","clearInterval","resetTermsConditionsTimeout","scrollUp","div","updateButtonStyles","updatePageCounter","scrollTo","acceptedTerms","offsetHeight","style","Math","ceil","textContent","scrollDown","buttonDown","buttonUp","setCountry","setPrimaryLocales","primaryLocales","primaryLocale","otherLanguageName","lang","lookupLocaleNames","nativeName","split","isArabic","isHebrew","translatePage","ex","elem","img","areArraysEqual","arr1","arr2","i","langMap","languageMappingList","language","localeNames","languages","sortedPrimaryLocales","filter","sort","a","b","langA","langB","englishName","localeCompare","l","toggleClass","_fee","fee","parseFloat","fixedFee","formatFiat","fiat","cryptoAtoms","scale","pow","displayScale","cryptoAmount","toNumber","cryptoDisplayCode","displayCode","updateCrypto","inserted","formatDenomination","denom","toLocaleString","useGrouping","maximumFractionDigits","minimumFractionDigits","_cassettes","numberOfButtons","activeCassettes","count","inactiveCassettes","allCassettes","concat","selectedCassettes","sortedCassettes","denomination","updateCassetteButtons","activeDenoms","children","fiatButtons","lastTouch","now","Date","cashButtonJ","hasClass","selector","formatCrypto","lookupDecimalChar","num","localized","splitNumber","localize","decimalChar","join","formatNumber","amount","fractionDigits","_rates","cryptoToFiat","rateStr","round","cashOutCryptoToFiat","qrize","color","lightning","size","image","_size","clientHeight","opts","crisp","fill","render","rounded","quiet","mPosX","mPosY","mSize","mode","kjua","txId","isPaperWallet","hasBills","bills","promoCodeApplied","formatAddressNoBreakLines","address","firstPart","replace","secondPart","formatAddress","toBr","reasonText","t","bill","errorMessages","transactionLimit","validatorError","lowBalance","str","_cryptoCode","cryptoCodeDisplay","base","messages","locales","Jed","reachFiatLimit","rec","msg","isEmpty","txLimitReached","displayCrypto","decimalPlaces","unitScale","BN","s","activeDenominations","fiatDisplay","cryptoDisplay","eq","activeMap","toAddress","depositUrl","of","current","createElement","innerHTML","getElementsByTagName","appendChild","height","gcd","w","h","r","aspectRatioPt1","aspectRatioPt2","background","ua","navigator","userAgent","match","chromiumVersion","chromeVersion","chromiumPlus73","chromePlus73","currentDiscount","successMessage","status","className","printing","success","message","failMessage","url"],"mappings":"AAAA;AACA;;;;AAEA,IAAMA,cAAcC,OAAOC,QAAP,CAAgBC,MAApC;AACA,IAAMC,SAAS,IAAIC,eAAJ,CAAoBL,YAAYM,SAAZ,CAAsB,CAAtB,CAApB,CAAf;AACA,IAAMC,aAAaH,OAAOI,GAAP,CAAW,OAAX,CAAnB;AACA,IAAMC,oBAAoB,SAA1B;AACA,IAAMC,mBAAmB,SAAzB;AACA,IAAMC,oBAAoB,CAA1B;;AAEA,IAAIC,aAAa,CAAjB;AACA,IAAIC,qBAAqB,CAAzB;AACA,IAAIC,cAAc,CAAlB;AACA,IAAIC,aAAa,CAAjB;AACA,IAAIC,cAAc,OAAlB;AACA,IAAIC,WAAW,IAAf;AACA,IAAIC,QAAQ,KAAZ;AACA,IAAIC,iBAAiB,IAArB;AACA,IAAIC,yBAAyB,IAA7B;AACA,IAAIC,oCAAoC,IAAxC;AACA,IAAIC,cAAc,KAAlB;AACA,IAAIC,oBAAoB,IAAxB;AACA,IAAIC,gBAAgB,IAApB;;AAEA,IAAIC,WAAW,IAAf;AACA,IAAIC,SAAS,IAAb;AACA,IAAIC,gBAAgBC,SAAS,OAAT,KAAqB,IAAzC;AACA,IAAIC,aAAa,IAAjB;AACA,IAAIC,eAAe,IAAnB,C,CAAwB;AACxB,IAAIC,kBAAk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AA9F;AACA,SAAOiK,UAAU,qBAAV,CAAP;AACD","file":"app.js","sourcesContent":["/* globals $, URLSearchParams, WebSocket, locales, Keyboard, Keypad, Jed, BigNumber, HOST, PORT, Origami, kjua, TimelineMax, Two */\n'use strict'\n\nconst queryString = window.location.search\nconst params = new URLSearchParams(queryString.substring(1))\nconst DEBUG_MODE = params.get('debug')\nconst CASH_OUT_QR_COLOR = '#403c51'\nconst CASH_IN_QR_COLOR = '#0e4160'\nconst NUMBER_OF_BUTTONS = 3\n\nvar scrollSize = 0\nvar textHeightQuantity = 0\nvar currentPage = 0\nvar totalPages = 0\nvar aspectRatio = '16:10'\nvar isTwoWay = null\nvar isRTL = false\nvar cryptomatModel = null\nvar termsConditionsTimeout = null\nvar termsConditionsAcceptanceInterval = null\nvar T_C_TIMEOUT = 30000\nvar complianceTimeout = null;\nvar cashDirection = null;\n\nvar fiatCode = null\nvar locale = null\nvar defaultLocale = loadI18n('en-US') || null\nvar localeCode = null\nvar jsLocaleCode = null // Sometimes slightly different than localeCode\nvar _primaryLocales = []\nvar lastRates = null\nvar coins\n\nvar currentState\n\nvar websocket = null\nvar promoKeyboard = null\nvar usSsnKeypad = null\nvar phoneKeypad = null\nvar securityKeypad = null\nvar previousState = null\nvar buttonActive = true\nlet currentCryptoCode = null\nlet currentCoin = null\nlet currentCoins = []\nlet emailKeyboard = null\nlet customRequirementNumericalKeypad = null\nlet customRequirementTextKeyboard = null\nlet customRequirementChoiceList = null\n\nvar MUSEO = ['ca', 'cs', 'da', 'de', 'en', 'es', 'et', 'fi', 'fr', 'hr',\n 'hu', 'it', 'lt', 'nb', 'nl', 'pl', 'pt', 'ro', 'sl', 'sv', 'tr']\n\nfunction connect () {\n console.log(`ws://${HOST}:${PORT}/`)\n websocket = new WebSocket(`ws://${HOST}:${PORT}/`)\n websocket.onmessage = function (event) {\n var data = $.parseJSON(event.data)\n processData(data)\n }\n websocket.onerror = err => console.log(err)\n}\n\nfunction verifyConnection () {\n if (websocket.readyState === websocket.CLOSED) {\n connect()\n }\n}\n\nfunction buttonPressed (button, data) {\n if (!buttonActive) return\n promoKeyboard.deactivate()\n emailKeyboard.deactivate()\n customRequirementTextKeyboard.deactivate()\n buttonActive = false\n setTimeout(function () {\n buttonActive = true\n promoKeyboard.activate()\n emailKeyboard.activate()\n customRequirementTextKeyboard.activate()\n }, 300)\n var res = { button: button }\n if (data || data === null) res.data = data\n if (websocket) websocket.send(JSON.stringify(res))\n}\n\nconst displayLN = 'Lightning Network'\nconst displayBTC = 'Bitcoin
(LN)'\nconst LN = 'LN'\nconst BTC = 'BTC'\n\nfunction processData (data) {\n if (data.localeInfo) setLocaleInfo(data.localeInfo)\n if (data.locale) setLocale(data.locale)\n if (data.supportedCoins) setCoins(data.supportedCoins)\n if (!locale) return\n if (data.fiatCode) setFiatCode(data.fiatCode)\n if (data.rates) setExchangeRate(data.rates)\n if (data.buyerAddress) setBuyerAddress(data.buyerAddress)\n if (data.credit) {\n var lastBill = data.action === 'rejectedBill' ? null : data.credit.lastBill\n setCredit(data.credit, lastBill)\n }\n if (data.tx) setTx(data.tx)\n if (data.sendOnly) sendOnly(data.reason)\n if (data.fiatCredit) fiatCredit(data.fiatCredit)\n if (data.depositInfo) setDepositAddress(data.depositInfo)\n if (data.version) setVersion(data.version)\n if (data.cassettes) buildCassetteButtons(data.cassettes, NUMBER_OF_BUTTONS)\n if (data.readingBills) readingBills(data.readingBills)\n if (data.cryptoCode) translateCoin(data.cryptoCode)\n if (data.tx && data.tx.cashInFee) setFixedFee(data.tx.cashInFee)\n if (data.terms) setTermsScreen(data.terms)\n if (data.dispenseBatch) dispenseBatch(data.dispenseBatch)\n if (data.direction) setDirection(data.direction)\n if (data.operatorInfo) setOperatorInfo(data.operatorInfo)\n if (data.hardLimit) setHardLimit(data.hardLimit)\n if (data.cryptomatModel) setCryptomatModel(data.cryptomatModel)\n if (data.areThereAvailablePromoCodes !== undefined) setAvailablePromoCodes(data.areThereAvailablePromoCodes)\n\n if (data.tx && data.tx.discount) setCurrentDiscount(data.tx.discount)\n if (data.receiptStatus) setReceiptPrint(data.receiptStatus, null)\n if (data.smsReceiptStatus) setReceiptPrint(null, data.smsReceiptStatus)\n\n if (data.context) {\n $('.js-context').hide()\n $('.js-context-' + data.context).show()\n }\n\n const isRecycler = billValidator => {\n return billValidator === 'HCM2'\n }\n\n switch (data.action) {\n case 'pairing':\n setState('pairing')\n break\n case 'pairingError':\n $('.js-pairing-error').text(data.err)\n // Give it some time to update text in background\n setTimeout(function () { setState('pairing_error') }, 500)\n break\n case 'booting':\n if (currentState !== 'maintenance') setState('booting')\n break\n case 'idle':\n case 'fakeIdle':\n setState('idle')\n break\n case 'dualIdle':\n case 'fakeDualIdle':\n setState('dual_idle')\n break\n case 'registerUsSsn':\n usSsnKeypad.activate()\n setState('register_us_ssn')\n setComplianceTimeout(null, 'finishBeforeSms')\n break\n case 'registerPhone':\n phoneKeypad.activate()\n setState('register_phone')\n break\n case 'registerEmail':\n emailKeyboard.setConstraint('email', ['#submit-email'])\n setState('register_email')\n break\n case 'securityCode':\n securityKeypad.activate()\n setState('security_code')\n break\n case 'scanned':\n isRecycler(data.billValidator)\n ? setState('insert_first_bills_recycler')\n : setState('insert_bills')\n break\n case 'acceptingFirstBill':\n $('.js-send-crypto-enable').show()\n setState('insert_bills')\n break\n case 'acceptingBills':\n $('.blocked-customer-top').hide()\n setState('insert_more_bills')\n break\n case 'acceptingFirstRecyclerBills':\n $('.js-continue-crypto-enable').show()\n $('.js-send-crypto-enable').show()\n setState('insert_first_bills_recycler')\n break\n case 'recyclerContinue':\n disableRecyclerBillButtons()\n break;\n case 'acceptingRecyclerBills':\n enableRecyclerBillButtons()\n $('.blocked-customer-top').hide()\n setState('insert_bills_recycler')\n break\n case 'acceptingBill':\n case 'rejectedBill':\n // still need to prevent screen change\n break\n case 'cryptoTransferPending':\n setState('sending_coins')\n break\n case 'cryptoTransferComplete':\n setState('completed')\n break\n case 'networkDown':\n setState('trouble')\n break\n case 'balanceLow':\n setState('limit_reached')\n break\n case 'insufficientFunds':\n setState('out_of_coins')\n break\n case 'highBill':\n highBill(data.highestBill, data.reason)\n break\n case 'minimumTx':\n minimumTx(data.lowestBill)\n break\n case 'chooseFiat':\n if (data.isCashInOnlyCoin) {\n setState('cash_in_only_coin')\n break\n }\n chooseFiat(data.chooseFiat)\n break\n case 'deposit':\n setState('deposit')\n deposit(data.tx)\n break\n case 'rejectedDeposit':\n setState('deposit_timeout')\n break\n case 'fiatReceipt':\n fiatReceipt(data.tx)\n break\n case 'fiatComplete':\n fiatComplete(data.tx)\n break\n case 'restart':\n setState('restart')\n break\n case 'chooseCoin':\n chooseCoin(data.coins, data.twoWayMode)\n break\n case 'smsVerification':\n smsVerification()\n break\n case 'emailVerification':\n emailVerification();\n break;\n case 'permission_id':\n idVerification()\n break\n case 'permission_face_photo':\n facephotoPermission()\n break\n case 'usSsnPermission':\n usSsnPermission()\n break\n case 'externalPermission':\n externalPermission()\n break\n case 'blockedCustomer':\n blockedCustomer()\n break\n case 'insertPromoCode':\n promoKeyboard.activate()\n setState('insert_promo_code')\n break\n case 'invalidPromoCode':\n setState('promo_code_not_found')\n break\n case 'customInfoRequestPermission':\n customInfoRequestPermission(data.customInfoRequest)\n break\n case 'inputCustomInfoRequest':\n customInfoRequest(data.customInfoRequest)\n break\n case 'actionRequiredMaintenance':\n setState('action_required_maintenance')\n break\n case 'cashSlotRemoveBills':\n setState('cash_slot_remove_bills')\n break\n case 'leftoverBillsInCashSlot':\n setState('leftover_bills_in_cash_slot')\n break\n case 'invalidAddress':\n invalidAddress(data.lnInvoiceTypeError)\n break\n case 'externalCompliance':\n clearTimeout(complianceTimeout)\n externalCompliance(data.externalComplianceUrl)\n break\n default:\n if (data.action) setState(window.snakecase(data.action))\n }\n}\n\nfunction translate (data, fetchArgs) {\n if (data === \"\")\n return data\n\n try {\n return fetchArgs\n ? locale.translate(data).fetch(...fetchArgs)\n : locale.translate(data).fetch()\n } catch (error) {\n if (!defaultLocale) console.error('Error while translating: ', error)\n else {\n try {\n return fetchArgs\n ? defaultLocale.translate(data).fetch(...fetchArgs)\n : defaultLocale.translate(data).fetch()\n } catch (e) {\n console.error('Error while translating: ', e)\n return data\n }\n }\n }\n}\n\nfunction facephotoPermission () {\n setComplianceTimeout(null, 'finishBeforeSms')\n setScreen('permission_face_photo')\n}\n\nfunction usSsnPermission () {\n setComplianceTimeout(null, 'finishBeforeSms')\n setScreen('us_ssn_permission')\n}\n\nfunction externalPermission () {\n setComplianceTimeout(null, 'finishBeforeSms')\n setScreen('external_permission')\n}\n\nfunction customInfoRequestPermission (customInfoRequest) {\n $('#custom-screen1-title').text(customInfoRequest.screen1.title)\n $('#custom-screen1-text').text(customInfoRequest.screen1.text)\n setComplianceTimeout(null, 'finishBeforeSms')\n setScreen('custom_permission')\n}\n\nfunction setComplianceTimeout (interval, complianceButton) {\n clearTimeout(complianceTimeout)\n\n if (interval === 0) {\n return\n }\n\n complianceTimeout = setTimeout(function () {\n buttonPressed(complianceButton)\n }, interval == null ? 60000 : interval)\n}\n\nfunction invalidAddress (lnInvoiceTypeError) {\n if (lnInvoiceTypeError) {\n $('#invalid-address').hide()\n $('#invalid-invoice').show()\n } else {\n $('#invalid-invoice').hide()\n $('#invalid-address').show()\n }\n setState('invalid_address')\n}\n\nfunction customInfoRequest (customInfoRequest) {\n switch (customInfoRequest.input.type) {\n case 'numerical':\n $('#custom-screen2-numerical-title').text(customInfoRequest.screen2.title)\n $('#custom-screen2-numerical-text').text(customInfoRequest.screen2.text)\n customRequirementNumericalKeypad.setOpts({\n type: 'custom',\n constraint: customInfoRequest.input.constraintType,\n maxLength: customInfoRequest.input.numDigits\n })\n customRequirementNumericalKeypad.activate()\n setState('custom_permission_screen2_numerical')\n setScreen('custom_permission_screen2_numerical')\n setComplianceTimeout(null, 'cancelCustomInfoRequest')\n break\n case 'text':\n $('#custom-requirement-text-label1').text(customInfoRequest.input.label1)\n $('#custom-requirement-text-label2').text(customInfoRequest.input.label2)\n $('#previous-text-requirement').hide()\n $('#submit-text-requirement').hide()\n $('#next-text-requirement').hide()\n $('#optional-text-field-2').hide()\n $('.key.backspace.standard-backspace-key').removeClass('backspace-margin-left-override')\n $('.custom-info-request-space-key').show()\n // set type of constraint and buttons where that constraint should apply to disable/ enable\n customRequirementTextKeyboard.setConstraint(customInfoRequest.input.constraintType, ['#submit-text-requirement'])\n if (customInfoRequest.input.constraintType === 'spaceSeparation') {\n $('#optional-text-field-2').show()\n $('.key.backspace.standard-backspace-key').addClass('backspace-margin-left-override')\n $('.custom-info-request-space-key').hide()\n customRequirementTextKeyboard.setConstraint(customInfoRequest.input.constraintType, ['#next-text-requirement'])\n }\n setState('custom_permission_screen2_text')\n setScreen('custom_permission_screen2_text')\n setComplianceTimeout(null, 'cancelCustomInfoRequest')\n break\n case 'choiceList':\n $('#custom-screen2-choiceList-title').text(customInfoRequest.screen2.title)\n $('#custom-screen2-choiceList-text').text(customInfoRequest.screen2.text)\n customRequirementChoiceList.replaceChoices(customInfoRequest.input.choiceList, customInfoRequest.input.constraintType)\n setState('custom_permission_screen2_choiceList')\n setScreen('custom_permission_screen2_choiceList')\n setComplianceTimeout(null, 'cancelCustomInfoRequest')\n break\n default:\n return blockedCustomer()\n }\n}\n\nfunction idVerification () {\n setComplianceTimeout(null, 'finishBeforeSms')\n setScreen('permission_id')\n}\n\nfunction smsVerification () {\n setComplianceTimeout(null, 'finishBeforeSms')\n setScreen('sms_verification')\n}\n\nfunction emailVerification() {\n setComplianceTimeout(null, 'finishBeforeSms');\n setScreen('email_verification');\n}\n\nfunction blockedCustomer () {\n return setScreen('blocked_customer')\n}\n\nfunction chooseCoin (coins, twoWayMode) {\n if (twoWayMode) {\n $('.choose_coin_state').removeClass('choose-coin-cash-in').addClass('choose-coin-two-way')\n } else {\n $('.choose_coin_state').removeClass('choose-coin-two-way').addClass('choose-coin-cash-in')\n }\n\n isTwoWay = twoWayMode\n setChooseCoinColors()\n\n const defaultCoin = coins[0]\n\n currentCryptoCode = defaultCoin.cryptoCode\n currentCoin = defaultCoin\n currentCoins = coins.slice(0)\n\n setCryptoBuy(defaultCoin)\n setCryptoSell(defaultCoin)\n\n setupCoinsButtons(coins, currentCryptoCode)\n\n setState('choose_coin')\n}\n\nfunction openLanguageDropdown () {\n $('#language-dropdown-toggle').addClass('hide')\n $('#languages').removeClass('hide')\n $('#language-overlay').removeClass('hide')\n}\n\nfunction closeLanguageDropdown () {\n $('#language-dropdown-toggle').removeClass('hide')\n $('#languages').addClass('hide')\n $('#language-overlay').addClass('hide')\n}\n\nfunction openCoinDropdown () {\n $('#crypto-dropdown-toggle').addClass('hide')\n $('#crypto-overlay').removeClass('hide')\n $('#cryptos').removeClass('hide')\n}\n\nfunction closeCoinDropdown () {\n $('#crypto-dropdown-toggle').removeClass('hide')\n $('#crypto-overlay').addClass('hide')\n $('#cryptos').addClass('hide')\n}\n\nfunction setupCoinsButtons () {\n $('.crypto-buttons').empty()\n closeCoinDropdown()\n\n let coins = currentCoins.slice()\n let dropdownCoins = []\n\n if (coins.length === 1) return\n\n const showMoreButton = coins.length > 4\n if (showMoreButton) {\n $('crypto-dropdown-toggle').removeClass('hide')\n dropdownCoins = coins.slice(3)\n coins = coins.slice(0, 3)\n } else {\n $('crypto-dropdown-toggle').addClass('hide')\n }\n\n coins.forEach(function (coin) {\n const activeClass = coin.cryptoCode === currentCryptoCode ? 'choose-coin-button-active' : ''\n const el = ``\n $('.crypto-buttons').append(el)\n })\n if (showMoreButton) {\n $('.crypto-buttons').append(`\n \n `)\n dropdownCoins.forEach(coin => {\n const el = ``\n $('#cryptos').append(el)\n })\n const el = ``\n $('#cryptos').append(el)\n // As we add buttons 'more' and 'less' after initTranslate\n // they don't have baseTranslation translation data attached to them.\n $('.crypto-buttons .js-i18n').each(function () {\n var el = $(this)\n el.data('baseTranslation', el.html().trim())\n })\n }\n}\n\nfunction setCryptoBuy (coin) {\n const cashIn = $('.cash-in')\n const translatedCoin = translate(coin.display === displayLN ? displayBTC : coin.display)\n const buyStr = translate('Buy
%s', [translatedCoin])\n\n cashIn.html(buyStr)\n}\n\nfunction setCryptoSell (coin) {\n const cashOut = $('.cash-out')\n const translatedCoin = translate(coin.display === displayLN ? displayBTC : coin.display)\n const sellStr = translate('Sell
%s', [translatedCoin])\n\n cashOut.html(sellStr)\n}\n\nfunction setCoins (supportedCoins) {\n coins = supportedCoins\n}\n\nfunction getCryptoCurrency (cryptoCode) {\n const cryptoCurrency = coins.find(c => c.cryptoCode === cryptoCode)\n if (!cryptoCurrency) throw new Error(`Unsupported crypto: ${cryptoCode}`)\n return cryptoCurrency\n}\n\nfunction switchCoin (coin) {\n const cashIn = $('.cash-in')\n const cashOut = $('.cash-out')\n const cryptoCode = coin.cryptoCode\n\n if (currentCryptoCode === cryptoCode) return\n\n $(`.coin-${currentCryptoCode.toLowerCase()}`).removeClass('choose-coin-button-active')\n $(`.coin-${cryptoCode.toLowerCase()}`).addClass('choose-coin-button-active')\n currentCryptoCode = cryptoCode\n currentCoin = coin\n\n cashIn.addClass('crypto-switch')\n setTimeout(() => setCryptoBuy(coin), 100)\n setTimeout(() => cashIn.removeClass('crypto-switch'), 1000)\n\n setTimeout(() => {\n cashOut.addClass('crypto-switch')\n setTimeout(() => setCryptoSell(coin), 100)\n setTimeout(() => cashOut.removeClass('crypto-switch'), 1000)\n }, 80)\n\n const selectedIndex = currentCoins.indexOf(currentCoins.find(it => it.cryptoCode === cryptoCode))\n if (currentCoins.length > 4 && selectedIndex > 2) {\n currentCoins.splice(2, 0, currentCoins.splice(selectedIndex, 1)[0])\n }\n\n setupCoinsButtons()\n}\n\n$(document).ready(function () {\n const attachFastClick = Origami.fastclick\n attachFastClick(document.body)\n\n window.addEventListener('resize', () => {\n calculateAspectRatio()\n setChooseCoinColors()\n })\n\n // Matt's anti-drag hack\n window.onclick =\n window.oncontextmenu =\n window.onmousedown =\n window.onmousemove =\n window.onmouseup =\n function () { return false }\n\n BigNumber.config({ ROUNDING_MODE: BigNumber.ROUND_HALF_EVEN })\n\n promoKeyboard = new Keyboard({\n id: 'promo-keyboard',\n inputBox: '.promo-code-input'\n }).init(function () {\n if (currentState !== 'insert_promo_code') return\n buttonPressed('cancelPromoCode')\n })\n\n usSsnKeypad = new Keypad('us-ssn-keypad', { type: 'usSsn' }, function (result) {\n if (currentState !== 'register_us_ssn') return\n buttonPressed('usSsn', result)\n })\n\n phoneKeypad = new Keypad('phone-keypad', { type: 'phoneNumber', country: 'US' }, function (result) {\n if (currentState !== 'register_phone') return\n buttonPressed('phoneNumber', result)\n })\n\n securityKeypad = new Keypad('security-keypad', { type: 'code' }, function (result) {\n if (currentState !== 'security_code') return\n buttonPressed('securityCode', result)\n })\n\n customRequirementNumericalKeypad = new Keypad('custom-requirement-numeric-keypad', {\n type: 'custom'\n }, function (result) {\n if (currentState !== 'custom_permission_screen2_numerical') return\n buttonPressed('customInfoRequestSubmit', result)\n })\n\n emailKeyboard = new Keyboard({\n id: 'email-keyboard',\n inputBox: '#email-input',\n submitButtonWrapper: '#submit-email-wrapper',\n setComplianceTimeout: setComplianceTimeout\n }).init(function (result) {\n if (currentState !== 'register_email') return\n buttonPressed('email', result)\n })\n\n customRequirementTextKeyboard = new Keyboard({\n id: 'custom-requirement-text-keyboard',\n inputBox: '.text-input-field-1',\n submitButtonWrapper: '.submit-text-requirement-button-wrapper',\n setComplianceTimeout: setComplianceTimeout\n }).init(function () {\n if (currentState !== 'custom_permission_screen2_text') return\n buttonPressed('customInfoRequestSubmit')\n })\n\n customRequirementChoiceList = new ChoiceList({\n id: 'custom-requirement-choicelist-wrapper',\n setComplianceTimeout: setComplianceTimeout\n }).init(function (result) {\n if (currentState !== 'custom_permission_screen2_choiceList') return\n buttonPressed('customInfoRequestSubmit', result)\n })\n\n if (DEBUG_MODE !== 'demo') {\n connect()\n setInterval(verifyConnection, 1000)\n }\n\n initTranslatePage()\n\n var sendCoinsButton = document.getElementById('send-coins')\n var sendCoinsButton2 = document.getElementById('send-only-send-coins')\n touchEvent(sendCoinsButton, function () {\n setState('sending_coins')\n buttonPressed('sendCoins')\n })\n\n touchEvent(sendCoinsButton2, function () {\n setState('sending_coins')\n buttonPressed('sendCoins')\n })\n\n setupButton('recycler-continue-start', 'recyclerContinue')\n setupButton('recycler-continue', 'recyclerContinue')\n setupButton('recycler-finish', 'sendCoins')\n setupButton('cash-slot-bills-removed', 'cashSlotBillsRemoved')\n setupButton('leftover-bills-removed', 'leftoverBillsRemoved')\n\n const blockedCustomerOk = document.getElementById('blocked-customer-ok')\n touchEvent(blockedCustomerOk, function () {\n buttonPressed('blockedCustomerOk')\n })\n var insertBillCancelButton = document.getElementById('insertBillCancel')\n touchImmediateEvent(insertBillCancelButton, function () {\n setBuyerAddress(null)\n buttonPressed('cancelInsertBill')\n })\n\n var insertBillCancelRecyclerButton = document.getElementById('insertBillCancelRecycler')\n touchImmediateEvent(insertBillCancelRecyclerButton, function () {\n setBuyerAddress(null)\n buttonPressed('cancelInsertBill')\n })\n\n setupImmediateButton('scanCancel', 'cancelScan')\n setupImmediateButton('completed_viewport', 'completed')\n setupImmediateButton('withdraw_failure_viewport', 'completed')\n setupImmediateButton('out_of_coins_viewport', 'completed')\n setupImmediateButton('fiat_receipt_viewport', 'completed')\n setupImmediateButton('fiat_complete_viewport', 'completed')\n setupImmediateButton('chooseFiatCancel', 'chooseFiatCancel')\n setupImmediateButton('depositCancel', 'depositCancel')\n setupImmediateButton('printer-scan-cancel', 'cancelScan')\n\n setupButton('printer-back-to-home', 'idle')\n setupButton('printer-print-again', 'printAgain')\n setupButton('printer-print-again2', 'printAgain')\n setupButton('printer-scan-again', 'printerScanAgain')\n\n setupButton('insert-first-bill-promo-button', 'insertPromoCode')\n setupButton('insert-first-recycler-bills-promo-button', 'insertPromoCode')\n setupButton('choose-fiat-promo-button', 'insertPromoCode')\n\n var promoCodeCancelButton = document.getElementById('promo-code-cancel')\n touchImmediateEvent(promoCodeCancelButton, function () {\n promoKeyboard.deactivate.bind(promoKeyboard)\n buttonPressed('cancelPromoCode')\n })\n\n var submitCodeButton = document.getElementById('submit-promo-code')\n touchEvent(submitCodeButton, function () {\n promoKeyboard.deactivate.bind(promoKeyboard)\n var code = $('.promo-code-input').data('content')\n buttonPressed('submitPromoCode', { input: code })\n })\n\n const submitEmailButton = document.getElementById('submit-email')\n const submitTextRequirementButton = document.getElementById('submit-text-requirement')\n const nextFieldTextRequirementButton = document.getElementById('next-text-requirement')\n const previousFieldTextRequirementButton = document.getElementById('previous-text-requirement')\n touchEvent(submitEmailButton, function () {\n emailKeyboard.deactivate.bind(emailKeyboard)\n var text = $('#email-input').data('content')\n buttonPressed('email', text)\n $('#email-input').data('content', '').val('')\n emailKeyboard.setInputBox('#email-input')\n })\n touchEvent(submitTextRequirementButton, function () {\n customRequirementTextKeyboard.deactivate.bind(customRequirementTextKeyboard)\n var text = `${$('.text-input-field-1').data('content')} ${$('.text-input-field-2').data('content') || ''}`\n buttonPressed('customInfoRequestSubmit', text)\n $('.text-input-field-1').removeClass('faded').data('content', '').val('')\n $('.text-input-field-2').addClass('faded').data('content', '').val('')\n customRequirementTextKeyboard.setInputBox('.text-input-field-1')\n })\n touchEvent(nextFieldTextRequirementButton, function() {\n $('.text-input-field-1').addClass('faded')\n $('.text-input-field-2').removeClass('faded')\n $('#next-text-requirement').hide()\n $('#previous-text-requirement').show()\n $('#submit-text-requirement').show()\n // changing input box changes buttons where validation works on\n customRequirementTextKeyboard.setInputBox('.text-input-field-2', ['#submit-text-requirement'])\n })\n touchEvent(previousFieldTextRequirementButton, function() {\n $('.text-input-field-1').removeClass('faded')\n $('.text-input-field-2').addClass('faded')\n $('#next-text-requirement').show()\n $('#previous-text-requirement').hide()\n $('#submit-text-requirement').hide()\n customRequirementTextKeyboard.setInputBox('.text-input-field-1', ['#next-text-requirement'])\n })\n\n setupButton('submit-promo-code', 'submitPromoCode', {\n input: $('.promo-code-input').data('content')\n })\n setupButton('promo-code-try-again', 'insertPromoCode')\n setupButton('promo-code-continue', 'cancelPromoCode')\n\n setupButton('initialize', 'initialize')\n setupButton('pairing-scan', 'pairingScan')\n setupImmediateButton('pairing-scan-cancel', 'pairingScanCancel')\n setupButton('pairing-error-ok', 'pairingErrorOk')\n setupButton('cash-out-button', 'cashOut')\n\n setupImmediateButton('scan-id-cancel', 'idDataActionCancel')\n setupImmediateButton('scan-photo-cancel', 'idPhotoActionCancel')\n setupImmediateButton('scan-photo-manual-cancel', 'idPhotoActionCancel')\n setupImmediateButton('us-ssn-cancel', 'cancelUsSsn',\n usSsnKeypad.deactivate.bind(usSsnKeypad))\n setupImmediateButton('phone-number-cancel', 'cancelPhoneNumber',\n phoneKeypad.deactivate.bind(phoneKeypad))\n setupImmediateButton('security-code-cancel', 'cancelSecurityCode',\n securityKeypad.deactivate.bind(securityKeypad))\n setupButton('id-verification-failed-ok', 'idVerificationFailedOk')\n setupButton('id-scan-failed-try-again', 'idCodeFailedRetry')\n setupButton('id-scan-failed-cancel', 'idVerificationFailedOk')\n setupButton('id-code-failed-retry', 'idCodeFailedRetry')\n setupButton('id-code-failed-cancel', 'bye')\n setupButton('id-verification-error-ok', 'idVerificationErrorOk')\n setupButton('photo-scan-failed-retry', 'retryPhotoScan')\n setupButton('photo-scan-failed-cancel', 'photoScanVerificationCancel')\n setupButton('photo-verification-failed-ok', 'cancelIdScan')\n setupButton('invalid-address-try-again', 'invalidAddressTryAgain')\n setupButton('address-reuse-start-over', 'idle')\n setupButton('suspicious-address-start-over', 'idle')\n\n setupButton('sanctions-failure-ok', 'idle')\n setupButton('limit-reached-ok', 'idle')\n setupButton('hard-limit-reached-ok', 'idle')\n setupButton('deposit-timeout-sent-yes', 'depositTimeout')\n setupButton('deposit-timeout-sent-no', 'depositTimeoutNotSent')\n setupButton('out-of-cash-ok', 'idle')\n setupButton('cash-in-disabled-ok', 'idle')\n setupButton('cash-in-only-ok', 'idle')\n\n setupButton('bad-phone-number-ok', 'badPhoneNumberOk')\n setupButton('bad-security-code-ok', 'badSecurityCodeOk')\n setupButton('max-phone-retries-ok', 'maxPhoneRetriesOk')\n //setupButton('max-email-retries-ok', 'maxEmailRetriesOk')\n setupButton('redeem-later-ok', 'idle')\n setupButton('fiat-error-ok', 'idle')\n setupButton('network-down-ok', 'idle')\n setupButton('fiat-transaction-error-ok', 'fiatReceipt')\n\n setupButton('unknown-phone-number-ok', 'idle')\n setupButton('unknown-email-ok', 'idle')\n setupButton('unconfirmed-deposit-ok', 'idle')\n setupButton('tx-not-seen-ok', 'idle')\n setupButton('wrong-dispenser-currency-ok', 'idle')\n\n setupButton('print-receipt-cash-in-button', 'printReceipt')\n setupButton('print-receipt-cash-out-button', 'printReceipt')\n setupButton('print-receipt-cash-in-fail-button', 'printReceipt')\n\n setupButton('send-sms-receipt-cash-in-button', 'sendSmsReceipt')\n setupButton('send-sms-receipt-cash-out-button', 'sendSmsReceipt')\n setupButton('send-sms-receipt-cash-in-fail-button', 'sendSmsReceipt')\n\n setupButton('terms-ok', 'termsAccepted')\n setupButton('terms-ko', 'idle')\n\n setupButton('maintenance_restart', 'maintenanceRestart')\n\n calculateAspectRatio()\n\n const cryptoButtons = document.getElementById('crypto-buttons')\n touchEvent(cryptoButtons, event => {\n let el = $(event.target)\n if (el.is('path') || el.is('svg') || el.is('span')) {\n el = el.closest('div')\n }\n\n if (el.data('more')) {\n openCoinDropdown()\n return\n }\n\n if (el.data('less')) {\n closeCoinDropdown()\n return\n }\n\n const cryptoCode = el.data('cryptoCode')\n if (!cryptoCode) return\n\n const wantedCoin = currentCoins.find(it => it.cryptoCode === cryptoCode)\n if (!wantedCoin) return\n\n const coin = { cryptoCode, display: wantedCoin.display === displayLN ? displayBTC : wantedCoin.display }\n switchCoin(coin)\n })\n\n var areYouSureCancel = document.getElementById('are-you-sure-cancel-transaction')\n touchEvent(areYouSureCancel, () => buttonPressed('cancelTransaction', previousState))\n\n var areYouSureContinue = document.getElementById('are-you-sure-continue-transaction')\n touchEvent(areYouSureContinue, () => buttonPressed('continueTransaction', previousState))\n\n var coinRedeem = document.getElementById('coin-redeem-button')\n touchEvent(coinRedeem, () => {\n setDirection('cashOut')\n buttonPressed('redeem')\n })\n\n setupButton('facephoto-scan-failed-retry', 'retryFacephoto')\n setupButton('id-start-verification', 'permissionIdCompliance')\n setupButton('sms-start-verification', 'permissionSmsCompliance')\n setupButton('email-start-verification', 'permissionEmailCompliance');\n setupButton('ready-to-scan-id-card-photo', 'scanIdCardPhoto')\n setupButton('facephoto-permission-yes', 'permissionPhotoCompliance')\n setupButton('us-ssn-permission-yes', 'permissionUsSsnCompliance')\n setupButton('external-permission-yes', 'permissionExternalCompliance')\n\n setupButton('send-coins-id', 'finishBeforeSms')\n setupButton('send-coins-id-2', 'finishBeforeSms')\n setupButton('send-coins-sms', 'finishBeforeSms')\n setupButton('send-coins-sms-2', 'finishBeforeSms')\n setupButton('send-coins-email', 'finishBeforeSms');\n setupButton('send-coins-email-2', 'finishBeforeSms');\n\n setupButton('facephoto-permission-no', 'finishBeforeSms')\n setupButton('us-ssn-permission-send-coins', 'finishBeforeSms')\n setupButton('us-ssn-permission-cancel', 'finishBeforeSms')\n setupButton('us-ssn-cancel', 'finishBeforeSms')\n setupButton('external-permission-send-coins', 'finishBeforeSms')\n setupButton('facephoto-scan-failed-cancel', 'finishBeforeSms')\n setupButton('facephoto-scan-failed-cancel2', 'finishBeforeSms')\n\n setupButton('custom-permission-yes', 'permissionCustomInfoRequest')\n setupButton('custom-permission-no', 'finishBeforeSms')\n setupImmediateButton('custom-permission-cancel-numerical', 'cancelCustomInfoRequest', () => {\n customRequirementNumericalKeypad.deactivate.bind(customRequirementNumericalKeypad)\n })\n setupImmediateButton('email-cancel', 'cancelEmail', () => {\n emailKeyboard.deactivate.bind(emailKeyboard)\n $('#email-input').data('content', '').val('')\n emailKeyboard.setInputBox('#email-input')\n })\n setupImmediateButton('custom-permission-cancel-text', 'cancelCustomInfoRequest', () => {\n customRequirementTextKeyboard.deactivate.bind(customRequirementTextKeyboard)\n $('.text-input-field-1').removeClass('faded').data('content', '').val('')\n $('.text-input-field-2').addClass('faded').data('content', '').val('')\n customRequirementTextKeyboard.setInputBox('.text-input-field-1')\n })\n setupImmediateButton('custom-permission-cancel-choiceList', 'cancelCustomInfoRequest', () => {\n })\n\n setupButton('custom-permission-yes', 'permissionCustomInfoRequest')\n setupButton('custom-permission-no', 'finishBeforeSms')\n setupImmediateButton('custom-permission-cancel-numerical', 'cancelCustomInfoRequest', () => {\n customRequirementNumericalKeypad.deactivate.bind(customRequirementNumericalKeypad)\n })\n\n setupButton('external-validation-ok', 'finishBeforeSms')\n\n touchEvent(document.getElementById('change-language-section'), () => {\n if (_primaryLocales.length === 2) {\n setLocale(otherLocale())\n setCryptoBuy(currentCoin)\n setCryptoSell(currentCoin)\n return\n }\n openLanguageDropdown()\n })\n\n const cashInBox = document.getElementById('cash-in-box')\n touchEvent(cashInBox, () => {\n buttonPressed('start', { cryptoCode: currentCryptoCode, direction: 'cashIn' })\n })\n\n const cashOutBox = document.getElementById('cash-out-box')\n touchEvent(cashOutBox, () => {\n buttonPressed('start', { cryptoCode: currentCryptoCode, direction: 'cashOut' })\n })\n\n var languageOverlay = document.getElementById('language-overlay')\n touchEvent(languageOverlay, function (e) {\n closeLanguageDropdown()\n })\n\n var cryptoOverlay = document.getElementById('crypto-overlay')\n touchEvent(cryptoOverlay, function (e) {\n closeCoinDropdown()\n })\n\n var languageButtons = document.getElementById('languages')\n touchEvent(languageButtons, function (e) {\n var languageButtonJ = $(e.target).closest('button')\n if (languageButtonJ.length === 0) return\n var newLocale = languageButtonJ.attr('data-locale')\n\n if (!newLocale) {\n closeLanguageDropdown()\n return\n }\n\n setLocale(newLocale)\n setCryptoBuy(currentCoin)\n setCryptoSell(currentCoin)\n closeLanguageDropdown()\n })\n\n buildCassetteButtonEvents()\n if (DEBUG_MODE === 'dev') initDebug()\n})\n\nfunction targetButton (element) {\n var classList = element.classList || []\n var special = classList.contains('button') ||\n classList.contains('circle-button') ||\n classList.contains('square-button')\n if (special) { return element }\n return targetButton(element.parentNode)\n}\n\nfunction touchEvent (element, callback) {\n function handler (e) {\n var target = targetButton(e.target)\n\n target.classList.add('active')\n\n // Wait for transition to finish\n setTimeout(function () {\n target.classList.remove('active')\n }, 300)\n\n setTimeout(function () {\n callback(e)\n }, 200)\n\n e.stopPropagation()\n e.preventDefault()\n }\n\n if (shouldEnableTouch()) {\n element.addEventListener('touchstart', handler)\n }\n element.addEventListener('mousedown', handler)\n}\n\nfunction touchImmediateEvent (element, callback) {\n function handler (e) {\n callback(e)\n e.stopPropagation()\n e.preventDefault()\n }\n if (shouldEnableTouch()) {\n element.addEventListener('touchstart', handler)\n }\n element.addEventListener('mousedown', handler)\n}\n\nfunction setupImmediateButton (buttonClass, buttonAction, callback) {\n var button = document.getElementById(buttonClass)\n touchImmediateEvent(button, function () {\n if (callback) callback()\n buttonPressed(buttonAction)\n })\n}\n\nfunction setupButton (buttonClass, buttonAction, actionData) {\n var button = document.getElementById(buttonClass)\n touchEvent(button, function () {\n buttonPressed(buttonAction, actionData)\n })\n}\n\nfunction setScreen (newScreen, oldScreen) {\n if (newScreen === oldScreen) return\n\n if (newScreen === 'insert_bills') {\n $('.js-processing-bill').html(translate('Lamassu Cryptomat'))\n $('.bill img').css({'-webkit-transform': 'none', top: 0, left: 0})\n }\n\n var newView = $('.' + newScreen + '_state')\n if (newView.length !== 1) console.log('FATAL: ' + newView.length + ' screens found of class ' + newScreen + '_state')\n\n $('.viewport').removeClass('viewport-active')\n newView.addClass('viewport-active')\n}\n\nfunction setState (state, delay) {\n if (state === currentState) return\n\n if (currentState === 'terms_screen') {\n clearTermsConditionsTimeout()\n clearTermsConditionsAcceptanceDelay()\n }\n\n setComplianceTimeout(0)\n\n previousState = currentState\n currentState = state\n\n promoKeyboard.reset()\n emailKeyboard.reset()\n customRequirementTextKeyboard.reset()\n\n if (state === 'idle') {\n $('.qr-code').empty()\n $('.qr-code-deposit').empty()\n }\n\n if (delay) {\n window.setTimeout(function () {\n setScreen(currentState, previousState)\n }, delay)\n } else setScreen(currentState, previousState)\n}\n\nfunction revertScreen () { setScreen(currentState) }\n\nfunction setUpDirectionElement (element, direction) {\n if (direction === 'cashOut') {\n element.removeClass('cash-in-color')\n element.addClass('cash-out-color')\n } else {\n element.addClass('cash-in-color')\n element.removeClass('cash-out-color')\n }\n}\n\nfunction setOperatorInfo (operator) {\n if (!operator || !operator.active) {\n $('.contacts, .contacts-compact').addClass('hide')\n } else {\n $('.contacts, .contacts-compact').removeClass('hide')\n $('.operator-name').text(operator.name)\n $('.operator-email').text(operator.email)\n $('.operator-phone').text(operator.phone)\n }\n}\n\nfunction setHardLimit (limits) {\n const component = $('#hard-limit-hours')\n if (limits.hardLimitWeeks >= 1) {\n return component.text(translate('Please come back in %s weeks', [limits.hardLimitWeeks]))\n }\n\n if (limits.hardLimitDays >= 1) {\n return component.text(translate('Please come back in %s days and %s hours', [limits.hardLimitDays, limits.hardLimitHours]))\n }\n\n component.text(translate('Please come back in %s hours', [limits.hardLimitHours]))\n}\n\nfunction setCryptomatModel (model) {\n cryptomatModel = model\n const versions = ['sintra', 'douro', 'gaia', 'tejo', 'grandola', 'aveiro', 'coincloud', 'gmuk1', 'batm7in']\n const body = $('body')\n\n versions.forEach(it => body.removeClass(it))\n $('body').addClass(model.startsWith('douro') ? 'douro' : model)\n}\n\nfunction enableRecyclerBillButtons() {\n var continueButton = document.getElementById('recycler-continue');\n var finishButton = document.getElementById('recycler-finish');\n continueButton.disabled = false;\n finishButton.disabled = false;\n}\n\nfunction disableRecyclerBillButtons() {\n var continueButton = document.getElementById('recycler-continue');\n var finishButton = document.getElementById('recycler-finish');\n continueButton.disabled = true;\n finishButton.disabled = true;\n}\n\nfunction setDirection (direction) {\n let states = [\n $('.scan_id_photo_state'),\n $('.scan_manual_id_photo_state'),\n $('.scan_id_data_state'),\n $('.security_code_state'),\n $('.register_us_ssn_state'),\n $('.us_ssn_permission_state'),\n $('.register_phone_state'),\n $('.register_email_state'),\n $('.terms_screen_state'),\n $('.verifying_id_photo_state'),\n $('.verifying_face_photo_state'),\n $('.verifying_id_data_state'),\n $('.permission_id_state'),\n $('.sms_verification_state'),\n $('.email_verification_state'),\n $('.bad_phone_number_state'),\n $('.bad_security_code_state'),\n $('.max_phone_retries_state'),\n $('.max_email_retries_state'),\n $('.failed_permission_id_state'),\n $('.failed_verifying_id_photo_state'),\n $('.blocked_customer_state'),\n $('.fiat_error_state'),\n $('.fiat_transaction_error_state'),\n $('.failed_scan_id_data_state'),\n $('.sanctions_failure_state'),\n $('.error_permission_id_state'),\n $('.scan_face_photo_state'),\n $('.retry_scan_face_photo_state'),\n $('.permission_face_photo_state'),\n $('.failed_scan_face_photo_state'),\n $('.hard_limit_reached_state'),\n $('.failed_scan_id_photo_state'),\n $('.retry_permission_id_state'),\n $('.waiting_state'),\n $('.insert_promo_code_state'),\n $('.promo_code_not_found_state'),\n $('.custom_permission_state'),\n $('.external_permission_state'),\n $('.custom_permission_screen2_numerical_state'),\n $('.custom_permission_screen2_text_state'),\n $('.custom_permission_screen2_choiceList_state'),\n $('.external_compliance_state')\n ]\n cashDirection = direction\n states.forEach(it => {\n setUpDirectionElement(it, direction)\n })\n}\n\n/**\n *\n * @param {Object} data\n * @param {boolean} data.active\n * @param {String} data.title\n * @param {String} data.text\n * @param {String} data.accept\n * @param {String} data.cancel\n */\nfunction setTermsScreen (data) {\n const $screen = $('.terms_screen_state')\n $screen.find('.js-terms-title').html(data.title)\n startPage(data.text, data.acceptDisabled)\n $screen.find('.js-terms-cancel-button').html(data.cancel)\n $screen.find('.js-terms-accept-button').html(data.accept)\n setTermsConditionsTimeout()\n setAcceptButtonDisabled($screen, data)\n setTermsConditionsAcceptanceDelay($screen, data)\n}\n\nfunction setAcceptButtonDisabled (screen, data) {\n var acceptButton = screen.find('.js-terms-accept-button');\n acceptButton.prop('disabled', Boolean(data.acceptDisabled));\n}\n\nfunction clearTermsConditionsTimeout () {\n clearTimeout(termsConditionsTimeout)\n}\n\nfunction setTermsConditionsTimeout () {\n termsConditionsTimeout = setTimeout(function () {\n if (currentState === 'terms_screen') {\n buttonPressed('idle')\n }\n }, T_C_TIMEOUT)\n}\n\nfunction setTermsConditionsAcceptanceDelay (screen, data) {\n let acceptButton = screen.find('.js-terms-accept-button')\n acceptButton.css({ 'min-width': 0 })\n\n if (!data.delay) return\n\n const delayTimer = isNaN(data.delayTimer) ? 0 : data.delayTimer\n let seconds = delayTimer / 1000\n acceptButton.prop('disabled', true)\n acceptButton.html(seconds > 0 ? `${data.accept} (${seconds})` : `${data.accept}`)\n\n var tmpbtn = acceptButton.clone().appendTo('body').css({ 'display': 'block', 'visibility': 'hidden' })\n var width = tmpbtn.outerWidth()\n tmpbtn.remove()\n acceptButton.css({ 'min-width': `${width}px` })\n termsConditionsAcceptanceInterval = setInterval(function () {\n seconds--\n if (currentState === 'terms_screen' && seconds > 0) {\n acceptButton.html(`${data.accept} (${seconds})`)\n }\n if (currentState === 'terms_screen' && seconds <= 0) {\n acceptButton.prop('disabled', false)\n acceptButton.html(`${data.accept}`)\n }\n if (seconds <= 0) {\n clearInterval(termsConditionsAcceptanceInterval)\n }\n }, 1000)\n}\n\nfunction clearTermsConditionsAcceptanceDelay () {\n clearInterval(termsConditionsAcceptanceInterval)\n}\n\nfunction resetTermsConditionsTimeout () {\n clearTermsConditionsTimeout()\n setTermsConditionsTimeout()\n}\n\n// click page up button\nfunction scrollUp () {\n resetTermsConditionsTimeout()\n const div = document.getElementById('js-terms-text-div')\n if (currentPage !== 0) {\n currentPage -= 1\n updateButtonStyles()\n updatePageCounter()\n div.scrollTo(0, currentPage * scrollSize)\n }\n}\n\n// start page\nfunction startPage (text, acceptedTerms) {\n const $screen = $('.terms_screen_state')\n $screen.find('.js-terms-text').html(text)\n if (!acceptedTerms) currentPage = 0\n totalPages = 0\n setTimeout(function () {\n const div = document.getElementById('js-terms-text-div')\n textHeightQuantity = document.getElementById('js-terms-text').offsetHeight\n scrollSize = div.offsetHeight - 40\n updateButtonStyles()\n if (text.length <= 1000 && textHeightQuantity <= div.offsetHeight) {\n document.getElementById('actions-scroll').style.display = 'none'\n } else {\n document.getElementById('actions-scroll').style.display = ''\n if (!acceptedTerms) div.scrollTo(0, 0)\n totalPages = Math.ceil(textHeightQuantity / scrollSize)\n updatePageCounter()\n }\n }, 100)\n}\n\nfunction updatePageCounter () {\n document.getElementById('terms-page-counter').textContent = `${currentPage + 1}/${totalPages}`\n}\n\n// click page up button\nfunction scrollDown () {\n resetTermsConditionsTimeout()\n const div = document.getElementById('js-terms-text-div')\n if (!(currentPage * scrollSize + scrollSize > textHeightQuantity && currentPage !== 0)) {\n currentPage += 1\n updateButtonStyles()\n updatePageCounter()\n div.scrollTo(0, currentPage * scrollSize)\n }\n}\n\nfunction updateButtonStyles () {\n textHeightQuantity = document.getElementById('js-terms-text').offsetHeight\n const buttonDown = document.getElementById('scroll-down')\n const buttonUp = document.getElementById('scroll-up')\n buttonUp.disabled = currentPage === 0;\n buttonDown.disabled = currentPage * scrollSize + scrollSize > textHeightQuantity && currentPage !== 0;\n}\n\nfunction setLocaleInfo (data) {\n phoneKeypad.setCountry(data.country)\n setPrimaryLocales(data.primaryLocales)\n setLocale(data.primaryLocale)\n}\n\nfunction otherLanguageName () {\n const lang = lookupLocaleNames(otherLocale())\n return lang && lang.nativeName\n}\n\nfunction otherLocale () {\n return _primaryLocales.find(c => c !== localeCode)\n}\n\nfunction setLocale (data) {\n if (!data || data === localeCode) return\n localeCode = data\n jsLocaleCode = data\n var lang = localeCode.split('-')[0]\n\n if (jsLocaleCode === 'fr-QC') jsLocaleCode = 'fr-CA'\n\n var isArabic = jsLocaleCode.indexOf('ar-') === 0\n var isHebrew = jsLocaleCode.indexOf('he-') === 0\n isRTL = isArabic || isHebrew\n\n setChooseCoinColors()\n\n if (isRTL) {\n $('body').addClass('i18n-rtl')\n } else {\n $('body').removeClass('i18n-rtl')\n }\n\n if (isArabic) {\n $('body').addClass('i18n-ar')\n } else {\n $('body').removeClass('i18n-ar')\n }\n\n if (isHebrew) {\n $('body').addClass('i18n-he')\n } else {\n $('body').removeClass('i18n-he')\n }\n\n if (MUSEO.indexOf(lang) !== -1) $('body').addClass('museo')\n else $('body').removeClass('museo')\n\n locale = loadI18n(localeCode)\n try { translatePage() } catch (ex) {}\n\n $('.js-two-language').html(otherLanguageName())\n\n if (lastRates) setExchangeRate(lastRates)\n}\n\nfunction setChooseCoinColors () {\n var elem = $('#bg-to-show > img')\n let img = `images/background/${isTwoWay ? '2way' : '1way'}-${aspectRatio}${isRTL ? '-rtl' : ''}.svg`\n if (img !== elem.attr('src')) {\n elem.attr('src', img)\n }\n\n if (isTwoWay) {\n $('.choose_coin_state .change-language').removeClass('cash-in-color').addClass('cash-out-color')\n } else {\n $('.choose_coin_state .change-language').removeClass('cash-out-color').addClass('cash-in-color')\n }\n}\n\nfunction areArraysEqual (arr1, arr2) {\n if (arr1.length !== arr2.length) return false\n for (var i = 0; i < arr1.length; i++) {\n if (arr1[i] !== arr2[i]) return false\n }\n return true\n}\n\nfunction lookupLocaleNames (locale) {\n if (!locale) return\n var langMap = window.languageMappingList\n var language = locale.split('-')[0]\n var localeNames = langMap[language]\n return localeNames || langMap[locale]\n}\n\nfunction setPrimaryLocales (primaryLocales) {\n if (areArraysEqual(primaryLocales, _primaryLocales)) return\n _primaryLocales = primaryLocales\n\n var languages = $('#languages')\n closeLanguageDropdown()\n languages.empty()\n var sortedPrimaryLocales = primaryLocales.filter(lookupLocaleNames).sort(function (a, b) {\n var langA = lookupLocaleNames(a)\n var langB = lookupLocaleNames(b)\n return langA.englishName.localeCompare(langB.englishName)\n })\n\n languages.append(``)\n for (var i = 0; i < sortedPrimaryLocales.length; i++) {\n var l = sortedPrimaryLocales[i]\n var lang = lookupLocaleNames(l)\n var name = lang.nativeName || lang.englishName\n var div = ``\n languages.append(div)\n }\n\n $('.js-two-language').html(otherLanguageName())\n\n $('.js-menu-language').toggleClass('hide', sortedPrimaryLocales.length <= 1)\n $('.js-multi-language').toggleClass('hide', sortedPrimaryLocales.length === 2)\n $('.js-two-language').toggleClass('hide', sortedPrimaryLocales.length > 2)\n}\n\nfunction setFiatCode (data) {\n fiatCode = data\n $('.js-currency').text(fiatCode)\n}\n\nfunction setFixedFee (_fee) {\n const fee = parseFloat(_fee)\n if (fee > 0) {\n const fixedFee = translate('Transaction Fee: %s', [formatFiat(fee, 2)])\n $('.js-i18n-fixed-fee').html(fixedFee)\n } else {\n $('.js-i18n-fixed-fee').html('')\n }\n}\n\nfunction setCredit (credit, lastBill) {\n const { fiat, cryptoAtoms, cryptoCode } = credit\n var coin = getCryptoCurrency(cryptoCode)\n\n var scale = new BigNumber(10).pow(coin.displayScale)\n var cryptoAmount = new BigNumber(cryptoAtoms).div(scale).toNumber()\n var cryptoDisplayCode = coin.displayCode\n updateCrypto('.total-crypto-rec', cryptoAmount, cryptoDisplayCode)\n $('.amount-deposited').html(translate('You deposited %s', [`${fiat} ${fiatCode}`]))\n $('.fiat .js-amount').html(fiat)\n\n var inserted = lastBill\n ? translate('You inserted a %s bill', [formatFiat(lastBill)])\n : translate('Lamassu Cryptomat')\n\n $('.js-processing-bill').html(inserted)\n\n $('.js-continue-crypto-enable').show()\n $('.js-send-crypto-enable').show()\n}\n\nfunction formatDenomination (denom) {\n return denom.toLocaleString(jsLocaleCode, {\n useGrouping: true,\n maximumFractionDigits: 0,\n minimumFractionDigits: 0\n })\n}\n\nfunction buildCassetteButtons (_cassettes, numberOfButtons) {\n var activeCassettes = _cassettes.filter(it => it.count === null || it.count > 0)\n var inactiveCassettes = _cassettes.filter(it => it.count === 0)\n\n var allCassettes = activeCassettes.concat(inactiveCassettes)\n var selectedCassettes = allCassettes.slice(0, numberOfButtons)\n var sortedCassettes = selectedCassettes.sort((a, b) => a.denomination - b.denomination)\n\n for (var i = 0; i < sortedCassettes.length; i++) {\n var denomination = formatDenomination(sortedCassettes[i].denomination || 0)\n $('.cash-button[data-denomination-index=' + i + '] .js-denomination').text(denomination)\n }\n}\n\nfunction updateCassetteButtons (activeDenoms, numberOfButtons) {\n for(var i = 0; i < numberOfButtons; i++) {\n var button = $('.choose_fiat_state .cash-button[data-denomination-index=' + i + ']')\n var denomination = button.children('.js-denomination').text()\n button.prop('disabled', !Boolean(activeDenoms[denomination]))\n }\n}\n\nfunction buildCassetteButtonEvents () {\n var fiatButtons = document.getElementById('js-fiat-buttons')\n var lastTouch = null\n\n touchImmediateEvent(fiatButtons, function (e) {\n var now = Date.now()\n if (lastTouch && now - lastTouch < 100) return\n lastTouch = now\n var cashButtonJ = $(e.target).closest('.cash-button')\n if (cashButtonJ.length === 0) return\n if (cashButtonJ.hasClass('disabled')) return\n if (cashButtonJ.hasClass('clear')) return buttonPressed('clearFiat')\n buttonPressed('fiatButton', { denomination: cashButtonJ.children('.js-denomination').text() })\n })\n}\n\nfunction updateCrypto (selector, cryptoAmount, cryptoDisplayCode) {\n $(selector).find('.crypto-amount').html(formatCrypto(cryptoAmount))\n $(selector).find('.crypto-units').html(cryptoDisplayCode)\n}\n\nfunction lookupDecimalChar (localeCode) {\n var num = 1.1\n var localized = num.toLocaleString(localeCode, {\n useGrouping: true,\n maximumFractionDigits: 1,\n minimumFractionDigits: 1\n })\n\n return localized[1]\n}\n\nfunction splitNumber (localize, localeCode) {\n var decimalChar = lookupDecimalChar(localeCode)\n var split = localize.split(decimalChar)\n\n if (split.length === 1) {\n return ['', split[0], ''].join('')\n }\n\n return [\n '', split[0], '',\n decimalChar, '', split[1], ''\n ].join('')\n}\n\nfunction formatNumber (num) {\n var localized = num.toLocaleString(jsLocaleCode, {\n useGrouping: true,\n maximumFractionDigits: 6,\n minimumFractionDigits: 3\n })\n\n return splitNumber(localized, jsLocaleCode)\n}\n\nfunction formatCrypto (amount) {\n return formatNumber(amount)\n}\n\nfunction formatFiat (amount, fractionDigits) {\n if (!fractionDigits) fractionDigits = 0\n\n const localized = amount.toLocaleString(jsLocaleCode, {\n useGrouping: true,\n maximumFractionDigits: fractionDigits,\n minimumFractionDigits: fractionDigits\n })\n return splitNumber(localized, jsLocaleCode) + ' ' + fiatCode\n}\n\nfunction setExchangeRate (_rates) {\n lastRates = _rates\n var cryptoCode = _rates.cryptoCode\n var rates = _rates.rates\n\n var coin = getCryptoCurrency(cryptoCode)\n var displayCode = coin.displayCode\n\n if (rates.cashIn) {\n var cryptoToFiat = new BigNumber(rates.cashIn)\n var rateStr = formatFiat(cryptoToFiat.round(2).toNumber(), 2)\n\n $('.crypto-rate-cash-in').html(`1 ${cryptoCode === LN ? BTC : cryptoCode} = ${rateStr}`)\n }\n\n if (rates.cashOut) {\n var cashOut = new BigNumber(rates.cashOut)\n var cashOutCryptoToFiat = cashOut && formatFiat(cashOut.round(2).toNumber(), 2)\n\n $('.crypto-rate-cash-out').html(`1 ${cryptoCode === LN ? BTC : cryptoCode} = ${cashOutCryptoToFiat}`)\n }\n\n $('.js-crypto-display-units').text(displayCode)\n}\n\nfunction qrize (text, target, color, lightning, size = 'normal') {\n const image = document.getElementById('bolt-img')\n // Hack for surf browser\n const _size = size === 'normal'\n ? document.body.clientHeight * 0.36\n : document.body.clientHeight * 0.25\n\n const opts = {\n crisp: true,\n fill: color || 'black',\n text,\n size: _size,\n render: 'canvas',\n rounded: 50,\n quiet: 2,\n mPosX: 50,\n mPosY: 50,\n mSize: 30,\n image\n }\n\n if (lightning) {\n opts.mode = 'image'\n }\n\n const el = kjua(opts)\n\n target.empty().append(el)\n}\n\nfunction setTx (tx) {\n const txId = tx.id\n const isPaperWallet = tx.isPaperWallet\n const hasBills = tx.bills && tx.bills.length > 0\n\n if (hasBills) {\n $('.js-inserted-notes').show()\n $('.js-no-inserted-notes').hide()\n } else {\n $('.js-inserted-notes').hide()\n $('.js-no-inserted-notes').show()\n }\n\n $('.js-paper-wallet').toggleClass('hide', !isPaperWallet)\n\n setCurrentDiscount(tx.discount, tx.promoCodeApplied)\n\n setTimeout(() => {\n qrize(txId, $('#cash-in-qr-code'), CASH_IN_QR_COLOR)\n qrize(txId, $('#cash-in-fail-qr-code'), CASH_IN_QR_COLOR)\n qrize(txId, $('#cash-in-no-funds-qr-code'), CASH_IN_QR_COLOR, null, 'small')\n qrize(txId, $('#qr-code-fiat-receipt'), CASH_OUT_QR_COLOR)\n qrize(txId, $('#qr-code-fiat-complete'), CASH_OUT_QR_COLOR)\n }, 1000)\n}\n\nfunction formatAddressNoBreakLines (address) {\n if (!address) return\n if (address.length > 60) {\n const firstPart = address.substring(0, 40).replace(/(.{4})/g, '$1 ')\n const secondPart = address.substring(address.length-16, address.length).replace(/(.{4})/g, '$1 ')\n return firstPart.concat('... ').concat(secondPart)\n }\n return address.replace(/(.{4})/g, '$1 ')\n}\n\nfunction formatAddress (address) {\n let toBr = formatAddressNoBreakLines(address)\n if (!toBr) return\n\n return toBr.replace(/((.{4} ){5})/g, '$1
')\n}\n\nfunction setBuyerAddress (address) {\n $('.crypto-address-no-br').html(formatAddressNoBreakLines(address))\n $('.crypto-address').html(formatAddress(address))\n}\n\nfunction highBill (highestBill, reason) {\n var reasonText = reason === 'transactionLimit'\n ? translate('Transaction limit reached.')\n : translate(\"We're a little low on crypto.\")\n\n t('high-bill-header', reasonText)\n t('highest-bill', translate('Please insert %s or less.', [formatFiat(highestBill)]))\n\n setScreen('high_bill')\n window.setTimeout(revertScreen, 3000)\n}\n\nfunction minimumTx (lowestBill) {\n t('lowest-bill', translate('Minimum first bill is %s.', [formatFiat(lowestBill)]))\n\n setScreen('minimum_tx')\n window.setTimeout(revertScreen, 3000)\n}\n\nfunction readingBills (bill) {\n $('.js-processing-bill').html(translate('Processing %s ...', [formatFiat(bill)]))\n $('.js-continue-crypto-enable').hide()\n $('.js-send-crypto-enable').hide()\n}\n\nfunction sendOnly (reason) {\n // TODO: sendOnly should be made into its own state on brain.js\n if (currentState === 'send_only') return\n\n const errorMessages = {\n transactionLimit: translate('Transaction limit reached'),\n validatorError: translate('Error in validation'),\n lowBalance: translate(\"We're out of coins!\"),\n blockedCustomer: translate('Transaction limit reached')\n }\n\n // If no reason provided defaults to lowBalance\n const reasonText = errorMessages[reason] || errorMessages.lowBalance\n $('#send-only-title').text(reasonText)\n\n if (reason === 'blockedCustomer') {\n $('.js-send-only-text').text(translate(\"Due to local regulations, you've reached your transaction limit. Please contact us if you'd like to raise your limit.\"))\n } else {\n $('.js-send-only-text').text('')\n }\n\n setState('send_only')\n}\n\nfunction t (id, str) {\n $('#js-i18n-' + id).html(str)\n}\n\nfunction translateCoin (_cryptoCode) {\n const coin = getCryptoCurrency(_cryptoCode)\n const cryptoCode = coin.cryptoCodeDisplay || _cryptoCode\n $('.js-i18n-scan-your-address').html(translate('Scan your
%s address', [cryptoCode]))\n $('.js-i18n-please-scan').html(translate('Please scan the QR code
to send us your %s.', [cryptoCode]))\n $('.js-i18n-did-send-coins').html(translate('Have you sent the %s yet?', [cryptoCode]))\n $('.js-i18n-scan-address').html(translate('Scan your %s address', [cryptoCode]))\n $('.js-i18n-invalid-address').html(translate('Invalid %s address', [cryptoCode]))\n}\n\nfunction initTranslatePage () {\n $('.js-i18n').each(function () {\n var el = $(this)\n el.data('baseTranslation', el.html().trim())\n })\n $('input[placeholder]').each(function () {\n var el = $(this)\n el.data('baseTranslation', el.attr('placeholder'))\n })\n}\n\nfunction translatePage () {\n $('.js-i18n').each(function () {\n var el = $(this)\n var base = el.data('baseTranslation')\n el.html(translate(base))\n })\n $('input[placeholder]').each(function () {\n var el = $(this)\n var base = el.data('baseTranslation')\n el.attr('placeholder', translate(base))\n })\n\n // Adjust send coins button\n var length = $('#send-coins span').text().length\n if (length > 17) $('body').addClass('i18n-long-send-coins')\n else $('body').removeClass('i18n-long-send-coins')\n}\n\nfunction loadI18n (localeCode) {\n var messages = locales[localeCode] || locales['en-US']\n\n return new Jed({\n 'missing_key_callback': function () {},\n 'locale_data': {\n 'messages': messages\n }\n })\n}\n\nfunction reachFiatLimit (rec) {\n var msg = null\n if (rec.isEmpty) msg = translate(`We're a little low, please cash out`)\n else if (rec.txLimitReached) msg = translate('Transaction limit reached, please cash out')\n\n var el = $('.choose_fiat_state .limit')\n if (msg) el.html(msg).show()\n else el.hide()\n}\n\nfunction chooseFiat (data) {\n fiatCredit(data)\n setState('choose_fiat')\n}\n\nfunction displayCrypto (cryptoAtoms, cryptoCode) {\n var coin = getCryptoCurrency(cryptoCode)\n var scale = new BigNumber(10).pow(coin.displayScale)\n // number of decimal places vary based on displayScale value\n var decimalPlaces = (coin.displayScale - coin.unitScale) + 6\n var cryptoAmount = new BigNumber(cryptoAtoms).div(scale).round(decimalPlaces).toNumber()\n return formatCrypto(cryptoAmount)\n}\n\nfunction BN (s) { return new BigNumber(s) }\n\nfunction fiatCredit (data) {\n var tx = data.tx\n var cryptoCode = tx.cryptoCode\n var activeDenominations = data.activeDenominations\n var coin = getCryptoCurrency(cryptoCode)\n const fiat = BN(tx.fiat)\n\n var fiatDisplay = BN(tx.fiat).toNumber().toLocaleString(jsLocaleCode, {\n useGrouping: true,\n maximumFractionDigits: 0,\n minimumFractionDigits: 0\n })\n\n var cryptoAtoms = BN(tx.cryptoAtoms)\n var cryptoDisplay = displayCrypto(cryptoAtoms, cryptoCode)\n\n var cryptoDisplayCode = coin.displayCode\n\n setCurrentDiscount(tx.discount, tx.promoCodeApplied)\n\n if (cryptoAtoms.eq(0) || cryptoAtoms.isNaN()) $('#js-i18n-choose-digital-amount').hide()\n else $('#js-i18n-choose-digital-amount').show()\n\n if (fiat.eq(0)) $('#cash-out-button').prop('disabled', true)\n else $('#cash-out-button').prop('disabled', false)\n\n updateCassetteButtons(activeDenominations.activeMap, NUMBER_OF_BUTTONS)\n $('.choose_fiat_state .fiat-amount').text(fiatDisplay)\n t('choose-digital-amount',\n translate(\"You'll be sending %s %s\", [cryptoDisplay, cryptoDisplayCode]))\n\n reachFiatLimit(activeDenominations)\n}\n\nfunction setDepositAddress (depositInfo) {\n $('.deposit_state .loading').hide()\n $('.deposit_state .send-notice .crypto-address').html(formatAddress(depositInfo.toAddress))\n $('.deposit_state .send-notice').show()\n\n qrize(depositInfo.depositUrl, $('#qr-code-deposit'), CASH_OUT_QR_COLOR)\n}\n\nfunction setVersion (version) {\n $('.version-number').html(`Version: ${version}`)\n}\n\nfunction deposit (tx) {\n var cryptoCode = tx.cryptoCode\n var display = displayCrypto(tx.cryptoAtoms, cryptoCode)\n\n $('.js-wallet-address').show()\n\n $('.deposit_state .digital .js-amount').html(display)\n $('.deposit_state .fiat .js-amount').text(tx.fiat)\n $('.deposit_state .send-notice').hide()\n $('#qr-code-deposit').empty()\n $('.deposit_state .loading').show()\n $('#qr-code-deposit').show()\n $('#lightning-enabled').hide()\n if (tx.cryptoCode === 'LN') $('#lightning-enabled').show()\n\n setState('deposit')\n}\n\nfunction fiatReceipt (tx) {\n var cryptoCode = tx.cryptoCode\n var display = displayCrypto(tx.cryptoAtoms, cryptoCode)\n\n $('.fiat_receipt_state .digital .js-amount').html(display)\n $('.fiat_receipt_state .fiat .js-amount').text(tx.fiat)\n $('.fiat_receipt_state .sent-coins .crypto-address').html(formatAddress(tx.toAddress))\n\n setState('fiat_receipt')\n}\n\nfunction fiatComplete (tx) {\n var cryptoCode = tx.cryptoCode\n var display = displayCrypto(tx.cryptoAtoms, cryptoCode)\n\n $('.fiat_complete_state .digital .js-amount').html(display)\n $('.fiat_complete_state .fiat .js-amount').text(tx.fiat)\n $('.fiat_complete_state .sent-coins .crypto-address').html(formatAddress(tx.toAddress))\n\n setState('fiat_complete')\n}\n\nfunction dispenseBatch (data) {\n $('.batch').css('visibility', data.of === 1 ? 'hidden' : 'visible')\n $('.batch').text(`${data.current}/${data.of}`)\n}\n\nfunction initDebug () {\n $('body').css('cursor', 'default')\n var style = document.createElement('style')\n style.type = 'text/css'\n style.innerHTML = 'button { cursor: default !important; }'\n document.getElementsByTagName('head')[0].appendChild(style)\n}\n\nfunction calculateAspectRatio () {\n const width = $('body').width()\n const height = $('body').height()\n\n function gcd (a, b) {\n return (b === 0) ? a : gcd(b, a % b)\n }\n\n const w = width\n const h = height\n const r = gcd(w, h)\n const aspectRatioPt1 = w / r\n const aspectRatioPt2 = h / r\n\n if (aspectRatioPt1 < aspectRatioPt2) {\n aspectRatio = '9:16'\n } else if (aspectRatioPt1 === 8 && aspectRatioPt2 === 5) {\n aspectRatio = '16:10'\n } else if (aspectRatioPt1 === 16 && aspectRatioPt2 === 9) {\n aspectRatio = '16:9'\n } else {\n aspectRatio = w < 1420 ? '16:10' : '16:9'\n }\n}\n\nlet background = null\n\nfunction shouldEnableTouch () {\n const ua = navigator.userAgent\n if (ua.match(/surf/ig)) return false\n\n // ACP has chromium 34 and upboard 73\n const chromiumVersion = ua.match(/chromium\\/(\\d+)/i)\n const chromeVersion = ua.match(/chrome\\/(\\d+)/i)\n const chromiumPlus73 = chromiumVersion && chromiumVersion[1] >= 73\n const chromePlus73 = chromeVersion && chromeVersion[1] >= 73\n\n return chromiumPlus73 || chromePlus73\n}\n\nfunction setAvailablePromoCodes (areThereAvailablePromoCodes) {\n if (areThereAvailablePromoCodes) {\n $('#insert-first-bill-promo-button').show()\n $('#insert-first-recycler-bills-promo-button').show()\n $('#choose-fiat-promo-button').show()\n } else {\n $('#insert-first-bill-promo-button').hide()\n $('#insert-first-recycler-bills-promo-button').hide()\n $('#choose-fiat-promo-button').hide()\n }\n}\n\nfunction setCurrentDiscount (currentDiscount, promoCodeApplied) {\n if (promoCodeApplied) {\n $('#insert-first-bill-promo-button').hide()\n $('#insert-first-recycler-bills-promo-button').hide()\n $('#choose-fiat-promo-button').hide()\n }\n\n if (!currentDiscount) {\n $('#insert-first-bill-code-added').hide()\n $('#insert-first-recycler-bills-code-added').hide()\n $('#choose-fiat-code-added').hide()\n } else if (currentDiscount > 0) {\n const successMessage = '✔ ' + translate('Discount added (%s off commissions)', [`${currentDiscount}%`])\n $('#insert-first-bill-code-added').html(successMessage)\n $('#insert-first-recycler-bills-code-added').html(successMessage)\n $('#choose-fiat-code-added').html(successMessage)\n $('#insert-first-bill-code-added').show()\n $('#insert-first-recycler-bills-code-added').show()\n $('#choose-fiat-code-added').show()\n\n } else {\n $('#insert-first-bill-promo-button').show()\n $('#insert-first-recycler-bills-promo-button').show()\n $('#choose-fiat-promo-button').show()\n $('#insert-first-bill-code-added').hide()\n $('#insert-first-recycler-bills-code-added').hide()\n $('#choose-fiat-code-added').hide()\n }\n}\n\nfunction setReceiptPrint (receiptStatus, smsReceiptStatus) {\n const status = receiptStatus ? receiptStatus : smsReceiptStatus\n\n const className = receiptStatus ? 'print-receipt' : 'send-sms-receipt'\n const printing = receiptStatus ? 'Printing receipt...' : 'Sending receipt...'\n const success = receiptStatus ? 'Receipt printed successfully!' : 'Receipt sent successfully!'\n\n switch (status) {\n case 'disabled':\n $(`#${className}-cash-in-message`).addClass('hide')\n $(`#${className}-cash-in-button`).addClass('hide')\n $(`#${className}-cash-out-message`).addClass('hide')\n $(`#${className}-cash-out-button`).addClass('hide')\n $(`#${className}-cash-in-fail-message`).addClass('hide')\n $(`#${className}-cash-in-fail-button`).addClass('hide')\n break\n case 'available':\n $(`#${className}-cash-in-message`).addClass('hide')\n $(`#${className}-cash-in-button`).removeClass('hide')\n $(`#${className}-cash-out-message`).addClass('hide')\n $(`#${className}-cash-out-button`).removeClass('hide')\n $(`#${className}-cash-in-fail-message`).addClass('hide')\n $(`#${className}-cash-in-fail-button`).removeClass('hide')\n break\n case 'printing':\n const message = locale.translate(printing).fetch()\n $(`#${className}-cash-in-button`).addClass('hide')\n $(`#${className}-cash-in-message`).html(message)\n $(`#${className}-cash-in-message`).removeClass('hide')\n $(`#${className}-cash-out-button`).addClass('hide')\n $(`#${className}-cash-out-message`).html(message)\n $(`#${className}-cash-out-message`).removeClass('hide')\n $(`#${className}-cash-in-fail-button`).addClass('hide')\n $(`#${className}-cash-in-fail-message`).html(message)\n $(`#${className}-cash-in-fail-message`).removeClass('hide')\n break\n case 'success':\n const successMessage = '✔ ' + locale.translate(success).fetch()\n $(`#${className}-cash-in-button`).addClass('hide')\n $(`#${className}-cash-in-message`).html(successMessage)\n $(`#${className}-cash-in-message`).removeClass('hide')\n $(`#${className}-cash-out-button`).addClass('hide')\n $(`#${className}-cash-out-message`).html(successMessage)\n $(`#${className}-cash-out-message`).removeClass('hide')\n $(`#${className}-cash-in-fail-button`).addClass('hide')\n $(`#${className}-cash-in-fail-message`).html(successMessage)\n $(`#${className}-cash-in-fail-message`).removeClass('hide')\n break\n case 'failed':\n const failMessage = '✖ ' + locale.translate('An error occurred, try again.').fetch()\n $(`#${className}-cash-in-button`).addClass('hide')\n $(`#${className}-cash-in-message`).html(failMessage)\n $(`#${className}-cash-in-message`).removeClass('hide')\n $(`#${className}-cash-out-button`).addClass('hide')\n $(`#${className}-cash-out-message`).html(failMessage)\n $(`#${className}-cash-out-message`).removeClass('hide')\n $(`#${className}-cash-in-fail-button`).addClass('hide')\n $(`#${className}-cash-in-fail-message`).html(failMessage)\n $(`#${className}-cash-in-fail-message`).removeClass('hide')\n break\n }\n}\n\nfunction externalCompliance (url) {\n qrize(url, $('#qr-code-external-validation'), cashDirection === 'cashIn' ? CASH_IN_QR_COLOR : CASH_OUT_QR_COLOR)\n return setScreen('external_compliance')\n}\n"]}
\ No newline at end of file
+{"version":3,"sources":["../src/app.js"],"names":["queryString","window","location","search","params","URLSearchParams","substring","DEBUG_MODE","get","CASH_OUT_QR_COLOR","CASH_IN_QR_COLOR","NUMBER_OF_BUTTONS","scrollSize","textHeightQuantity","currentPage","totalPages","aspectRatio","isTwoWay","isRTL","cryptomatModel","termsConditionsTimeout","termsConditionsAcceptanceInterval","T_C_TIMEOUT","complianceTimeout","cashDirection","fiatCode","locale","defaultLocale","loadI18n","localeCode","jsLocaleCode","_primaryLocales","lastRates","coins","currentState","websocket","promoKeyboard","usSsnKeypad","phoneKeypad","securityKeypad","previousState","buttonActive","currentCryptoCode","currentCoin","currentCoins","emailKeyboard","customRequirementNumericalKeypad","customRequirementTextKeyboard","customRequirementChoiceList","MUSEO","connect","console","log","HOST","PORT","WebSocket","onmessage","event","data","$","parseJSON","processData","onerror","err","verifyConnection","readyState","CLOSED","buttonPressed","button","deactivate","setTimeout","activate","res","send","JSON","stringify","displayLN","displayBTC","LN","BTC","screenOpts","setScreenOptions","localeInfo","setLocaleInfo","setLocale","supportedCoins","setCoins","setFiatCode","rates","setExchangeRate","buyerAddress","setBuyerAddress","credit","lastBill","action","setCredit","tx","setTx","sendOnly","reason","fiatCredit","depositInfo","setDepositAddress","version","setVersion","cassettes","buildCassetteButtons","readingBills","cryptoCode","translateCoin","cashInFee","setFixedFee","cashOutFee","terms","setTermsScreen","dispenseBatch","direction","setDirection","operatorInfo","setOperatorInfo","hardLimit","setHardLimit","setCryptomatModel","areThereAvailablePromoCodes","undefined","setAvailablePromoCodes","allRates","ratesFiat","setRates","discount","setCurrentDiscount","receiptStatus","setReceiptPrint","smsReceiptStatus","context","hide","show","isRecycler","billValidator","setState","text","setComplianceTimeout","setConstraint","disableRecyclerBillButtons","enableRecyclerBillButtons","highBill","highestBill","minimumTx","lowestBill","isCashInOnlyCoin","chooseFiat","deposit","fiatReceipt","fiatComplete","chooseCoin","twoWayMode","smsVerification","emailVerification","idVerification","facephotoPermission","usSsnPermission","externalPermission","blockedCustomer","customInfoRequestPermission","customInfoRequest","invalidAddress","lnInvoiceTypeError","clearTimeout","externalCompliance","externalComplianceUrl","snakecase","translate","fetchArgs","fetch","error","e","setScreen","screen1","title","interval","complianceButton","input","type","screen2","setOpts","constraint","constraintType","maxLength","numDigits","label1","label2","removeClass","addClass","replaceChoices","choiceList","setChooseCoinColors","defaultCoin","slice","setCryptoBuy","setCryptoSell","setupCoinsButtons","openLanguageDropdown","closeLanguageDropdown","openCoinDropdown","closeCoinDropdown","empty","dropdownCoins","length","showMoreButton","forEach","coin","activeClass","el","toLowerCase","display","append","each","html","trim","cashIn","translatedCoin","buyStr","cashOut","sellStr","getCryptoCurrency","cryptoCurrency","find","c","Error","switchCoin","selectedIndex","indexOf","it","splice","document","ready","attachFastClick","Origami","fastclick","body","addEventListener","calculateAspectRatio","onclick","oncontextmenu","onmousedown","onmousemove","onmouseup","BigNumber","config","ROUNDING_MODE","ROUND_HALF_EVEN","Keyboard","id","inputBox","init","Keypad","result","country","submitButtonWrapper","ChoiceList","setInterval","initTranslatePage","sendCoinsButton","getElementById","sendCoinsButton2","touchEvent","setupButton","blockedCustomerOk","insertBillCancelButton","touchImmediateEvent","insertBillCancelRecyclerButton","setupImmediateButton","promoCodeCancelButton","bind","submitCodeButton","code","submitEmailButton","submitTextRequirementButton","nextFieldTextRequirementButton","previousFieldTextRequirementButton","val","setInputBox","cryptoButtons","target","is","closest","wantedCoin","areYouSureCancel","areYouSureContinue","coinRedeem","otherLocale","cashInBox","cashOutBox","languageOverlay","cryptoOverlay","languageButtons","languageButtonJ","newLocale","attr","buildCassetteButtonEvents","initDebug","targetButton","element","classList","special","contains","parentNode","callback","handler","add","remove","stopPropagation","preventDefault","shouldEnableTouch","buttonClass","buttonAction","actionData","newScreen","oldScreen","css","top","left","newView","state","delay","clearTermsConditionsTimeout","clearTermsConditionsAcceptanceDelay","reset","revertScreen","setUpDirectionElement","operator","active","name","email","phone","limits","component","hardLimitWeeks","hardLimitDays","hardLimitHours","model","versions","startsWith","continueButton","finishButton","disabled","states","$screen","startPage","acceptDisabled","cancel","accept","setTermsConditionsTimeout","setAcceptButtonDisabled","setTermsConditionsAcceptanceDelay","screen","acceptButton","prop","Boolean","delayTimer","isNaN","seconds","tmpbtn","clone","appendTo","width","outerWidth","clearInterval","resetTermsConditionsTimeout","scrollUp","div","updateButtonStyles","updatePageCounter","scrollTo","acceptedTerms","offsetHeight","style","Math","ceil","textContent","scrollDown","buttonDown","buttonUp","setCountry","setPrimaryLocales","primaryLocales","primaryLocale","otherLanguageName","lang","lookupLocaleNames","nativeName","split","isArabic","isHebrew","translatePage","ex","elem","img","areArraysEqual","arr1","arr2","i","langMap","languageMappingList","language","localeNames","languages","sortedPrimaryLocales","filter","sort","a","b","langA","langB","englishName","localeCompare","l","toggleClass","_fee","fee","parseFloat","fixedFee","formatFiat","fiat","cryptoAtoms","scale","pow","displayScale","cryptoAmount","toNumber","cryptoDisplayCode","displayCode","updateCrypto","inserted","formatDenomination","denom","toLocaleString","useGrouping","maximumFractionDigits","minimumFractionDigits","_cassettes","numberOfButtons","activeCassettes","count","inactiveCassettes","allCassettes","concat","selectedCassettes","sortedCassettes","denomination","updateCassetteButtons","activeDenoms","children","fiatButtons","lastTouch","now","Date","cashButtonJ","hasClass","selector","formatCrypto","lookupDecimalChar","num","localized","splitNumber","localize","decimalChar","join","formatNumber","amount","fractionDigits","_rates","cryptoToFiat","rateStr","round","cashOutCryptoToFiat","qrize","color","lightning","size","image","_size","clientHeight","opts","crisp","fill","render","rounded","quiet","mPosX","mPosY","mSize","mode","kjua","txId","isPaperWallet","hasBills","bills","promoCodeApplied","formatAddressNoBreakLines","address","firstPart","replace","secondPart","formatAddress","toBr","reasonText","t","bill","errorMessages","transactionLimit","validatorError","lowBalance","str","_cryptoCode","cryptoCodeDisplay","base","messages","locales","Jed","reachFiatLimit","rec","msg","isEmpty","txLimitReached","displayCrypto","decimalPlaces","unitScale","BN","s","activeDenominations","fiatDisplay","cryptoDisplay","eq","activeMap","toAddress","depositUrl","of","current","createElement","innerHTML","getElementsByTagName","appendChild","height","gcd","w","h","r","aspectRatioPt1","aspectRatioPt2","background","ua","navigator","userAgent","match","chromiumVersion","chromeVersion","chromiumPlus73","chromePlus73","currentDiscount","successMessage","status","className","printing","success","message","failMessage","url","thousandSeparator","number","numberFormatter","Intl","NumberFormat","format","ratesTable","tableHeader","coinEntries","Object","keys","biggestDecimalPlaces","max","dp","push","toFixed"],"mappings":"AAAA;AACA;;;;AAEA,IAAMA,cAAcC,OAAOC,QAAP,CAAgBC,MAApC;AACA,IAAMC,SAAS,IAAIC,eAAJ,CAAoBL,YAAYM,SAAZ,CAAsB,CAAtB,CAApB,CAAf;AACA,IAAMC,aAAaH,OAAOI,GAAP,CAAW,OAAX,CAAnB;AACA,IAAMC,oBAAoB,SAA1B;AACA,IAAMC,mBAAmB,SAAzB;AACA,IAAMC,oBAAoB,CAA1B;;AAEA,IAAIC,aAAa,CAAjB;AACA,IAAIC,qBAAqB,CAAzB;AACA,IA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F,EAA3B,CAAxB;AACA,SAAOmI,gBAAgBG,MAAhB,CAAuBJ,MAAvB,CAAP;AACD;;AAED,SAASzb,QAAT,CAAmBF,QAAnB,EAA6ByS,IAA7B,EAAmC;AACjC,MAAMuJ,aAAangB,EAAE,gBAAF,CAAnB;AACA,MAAMogB,cAAcpgB,6DACEgH,UAAU,KAAV,CADF,qCAEEA,UAAU,QAAV,CAFF,qCAGEA,UAAU,MAAV,CAHF,mBAApB;AAKA,MAAMqZ,cAAc,EAApB;;AAEAC,SAAOC,IAAP,CAAYpc,QAAZ,EAAsBmF,OAAtB,CAA8B,cAAM;AAClC,QAAMU,SAASqT,GAAGlZ,SAAS0G,EAAT,EAAab,MAAhB,CAAf;AACA,QAAMG,UAAUkT,GAAGlZ,SAAS0G,EAAT,EAAaV,OAAhB,CAAhB;AACA,QAAMqW,uBAAuB1M,KAAK2M,GAAL,CAASzW,OAAO0W,EAAP,EAAT,EAAsBvW,QAAQuW,EAAR,EAAtB,CAA7B;;AAEAL,gBAAYM,IAAZ,CAAiB3gB,iEACO6f,kBAAkBxC,GAAGlZ,SAAS0G,EAAT,EAAab,MAAhB,EAAwB4W,OAAxB,CAAgC,CAAhC,CAAlB,EAAsD1iB,UAAtD,CADP,sCAEK2M,EAFL,yCAGOgV,kBAAkBxC,GAAGlZ,SAAS0G,EAAT,EAAaV,OAAhB,EAAyByW,OAAzB,CAAiC,CAAjC,CAAlB,EAAuD1iB,UAAvD,CAHP,oBAAjB;AAKD,GAVD;;AAYA8B,IAAE,sBAAF,EAA0BiF,IAA1B,CAA+B2R,IAA/B;AACAuJ,aAAWjX,KAAX,GAAmBU,MAAnB,CAA0BwW,WAA1B,EAAuCxW,MAAvC,CAA8CyW,WAA9C;AACD","file":"app.js","sourcesContent":["/* globals $, URLSearchParams, WebSocket, locales, Keyboard, Keypad, Jed, BigNumber, HOST, PORT, Origami, kjua, TimelineMax, Two */\n'use strict'\n\nconst queryString = window.location.search\nconst params = new URLSearchParams(queryString.substring(1))\nconst DEBUG_MODE = params.get('debug')\nconst CASH_OUT_QR_COLOR = '#403c51'\nconst CASH_IN_QR_COLOR = '#0e4160'\nconst NUMBER_OF_BUTTONS = 3\n\nvar scrollSize = 0\nvar textHeightQuantity = 0\nvar currentPage = 0\nvar totalPages = 0\nvar aspectRatio = '16:10'\nvar isTwoWay = null\nvar isRTL = false\nvar cryptomatModel = null\nvar termsConditionsTimeout = null\nvar termsConditionsAcceptanceInterval = null\nvar T_C_TIMEOUT = 30000\nvar complianceTimeout = null;\nvar cashDirection = null;\n\nvar fiatCode = null\nvar locale = null\nvar defaultLocale = loadI18n('en-US') || null\nvar localeCode = null\nvar jsLocaleCode = null // Sometimes slightly different than localeCode\nvar _primaryLocales = []\nvar lastRates = null\nvar coins\n\nvar currentState\n\nvar websocket = null\nvar promoKeyboard = null\nvar usSsnKeypad = null\nvar phoneKeypad = null\nvar securityKeypad = null\nvar previousState = null\nvar buttonActive = true\nlet currentCryptoCode = null\nlet currentCoin = null\nlet currentCoins = []\nlet emailKeyboard = null\nlet customRequirementNumericalKeypad = null\nlet customRequirementTextKeyboard = null\nlet customRequirementChoiceList = null\n\nvar MUSEO = ['ca', 'cs', 'da', 'de', 'en', 'es', 'et', 'fi', 'fr', 'hr',\n 'hu', 'it', 'lt', 'nb', 'nl', 'pl', 'pt', 'ro', 'sl', 'sv', 'tr']\n\nfunction connect () {\n console.log(`ws://${HOST}:${PORT}/`)\n websocket = new WebSocket(`ws://${HOST}:${PORT}/`)\n websocket.onmessage = function (event) {\n var data = $.parseJSON(event.data)\n processData(data)\n }\n websocket.onerror = err => console.log(err)\n}\n\nfunction verifyConnection () {\n if (websocket.readyState === websocket.CLOSED) {\n connect()\n }\n}\n\nfunction buttonPressed (button, data) {\n if (!buttonActive) return\n promoKeyboard.deactivate()\n emailKeyboard.deactivate()\n customRequirementTextKeyboard.deactivate()\n buttonActive = false\n setTimeout(function () {\n buttonActive = true\n promoKeyboard.activate()\n emailKeyboard.activate()\n customRequirementTextKeyboard.activate()\n }, 300)\n var res = { button: button }\n if (data || data === null) res.data = data\n if (websocket) websocket.send(JSON.stringify(res))\n}\n\nconst displayLN = 'Lightning Network'\nconst displayBTC = 'Bitcoin
(LN)'\nconst LN = 'LN'\nconst BTC = 'BTC'\n\nfunction processData (data) {\n if (data.screenOpts) setScreenOptions(data.screenOpts)\n if (data.localeInfo) setLocaleInfo(data.localeInfo)\n if (data.locale) setLocale(data.locale)\n if (data.supportedCoins) setCoins(data.supportedCoins)\n if (!locale) return\n if (data.fiatCode) setFiatCode(data.fiatCode)\n if (data.rates) setExchangeRate(data.rates)\n if (data.buyerAddress) setBuyerAddress(data.buyerAddress)\n if (data.credit) {\n var lastBill = data.action === 'rejectedBill' ? null : data.credit.lastBill\n setCredit(data.credit, lastBill)\n }\n if (data.tx) setTx(data.tx)\n if (data.sendOnly) sendOnly(data.reason)\n if (data.fiatCredit) fiatCredit(data.fiatCredit)\n if (data.depositInfo) setDepositAddress(data.depositInfo)\n if (data.version) setVersion(data.version)\n if (data.cassettes) buildCassetteButtons(data.cassettes, NUMBER_OF_BUTTONS)\n if (data.readingBills) readingBills(data.readingBills)\n if (data.cryptoCode) translateCoin(data.cryptoCode)\n if (data.tx) {\n if (data.tx.cashInFee) setFixedFee(data.tx.cashInFee)\n else if (data.tx.cashOutFee) setFixedFee(data.tx.cashOutFee)\n }\n if (data.terms) setTermsScreen(data.terms)\n if (data.dispenseBatch) dispenseBatch(data.dispenseBatch)\n if (data.direction) setDirection(data.direction)\n if (data.operatorInfo) setOperatorInfo(data.operatorInfo)\n if (data.hardLimit) setHardLimit(data.hardLimit)\n if (data.cryptomatModel) setCryptomatModel(data.cryptomatModel)\n if (data.areThereAvailablePromoCodes !== undefined) setAvailablePromoCodes(data.areThereAvailablePromoCodes)\n if (data.allRates && data.ratesFiat) setRates(data.allRates, data.ratesFiat)\n\n if (data.tx && data.tx.discount) setCurrentDiscount(data.tx.discount)\n if (data.receiptStatus) setReceiptPrint(data.receiptStatus, null)\n if (data.smsReceiptStatus) setReceiptPrint(null, data.smsReceiptStatus)\n\n if (data.context) {\n $('.js-context').hide()\n $('.js-context-' + data.context).show()\n }\n\n const isRecycler = billValidator => {\n return billValidator === 'HCM2'\n }\n\n switch (data.action) {\n case 'pairing':\n setState('pairing')\n break\n case 'pairingError':\n $('.js-pairing-error').text(data.err)\n // Give it some time to update text in background\n setTimeout(function () { setState('pairing_error') }, 500)\n break\n case 'booting':\n if (currentState !== 'maintenance') setState('booting')\n break\n case 'idle':\n case 'fakeIdle':\n setState('idle')\n break\n case 'dualIdle':\n case 'fakeDualIdle':\n setState('dual_idle')\n break\n case 'registerUsSsn':\n usSsnKeypad.activate()\n setState('register_us_ssn')\n setComplianceTimeout(null, 'finishBeforeSms')\n break\n case 'registerPhone':\n phoneKeypad.activate()\n setState('register_phone')\n break\n case 'registerEmail':\n emailKeyboard.setConstraint('email', ['#submit-email'])\n setState('register_email')\n break\n case 'securityCode':\n securityKeypad.activate()\n setState('security_code')\n break\n case 'scanned':\n isRecycler(data.billValidator)\n ? setState('insert_first_bills_recycler')\n : setState('insert_bills')\n break\n case 'acceptingFirstBill':\n $('.js-send-crypto-enable').show()\n setState('insert_bills')\n break\n case 'acceptingBills':\n $('.blocked-customer-top').hide()\n setState('insert_more_bills')\n break\n case 'acceptingFirstRecyclerBills':\n $('.js-continue-crypto-enable').show()\n $('.js-send-crypto-enable').show()\n setState('insert_first_bills_recycler')\n break\n case 'recyclerContinue':\n disableRecyclerBillButtons()\n break;\n case 'acceptingRecyclerBills':\n enableRecyclerBillButtons()\n $('.blocked-customer-top').hide()\n setState('insert_bills_recycler')\n break\n case 'acceptingBill':\n case 'rejectedBill':\n // still need to prevent screen change\n break\n case 'cryptoTransferPending':\n setState('sending_coins')\n break\n case 'cryptoTransferComplete':\n setState('completed')\n break\n case 'networkDown':\n setState('trouble')\n break\n case 'balanceLow':\n setState('limit_reached')\n break\n case 'insufficientFunds':\n setState('out_of_coins')\n break\n case 'highBill':\n highBill(data.highestBill, data.reason)\n break\n case 'minimumTx':\n minimumTx(data.lowestBill)\n break\n case 'chooseFiat':\n if (data.isCashInOnlyCoin) {\n setState('cash_in_only_coin')\n break\n }\n chooseFiat(data.chooseFiat)\n break\n case 'deposit':\n setState('deposit')\n deposit(data.tx)\n break\n case 'rejectedDeposit':\n setState('deposit_timeout')\n break\n case 'fiatReceipt':\n fiatReceipt(data.tx)\n break\n case 'fiatComplete':\n fiatComplete(data.tx)\n break\n case 'restart':\n setState('restart')\n break\n case 'chooseCoin':\n chooseCoin(data.coins, data.twoWayMode)\n break\n case 'smsVerification':\n smsVerification()\n break\n case 'emailVerification':\n emailVerification();\n break;\n case 'permission_id':\n idVerification()\n break\n case 'permission_face_photo':\n facephotoPermission()\n break\n case 'usSsnPermission':\n usSsnPermission()\n break\n case 'externalPermission':\n externalPermission()\n break\n case 'blockedCustomer':\n blockedCustomer()\n break\n case 'insertPromoCode':\n promoKeyboard.activate()\n setState('insert_promo_code')\n break\n case 'invalidPromoCode':\n setState('promo_code_not_found')\n break\n case 'customInfoRequestPermission':\n customInfoRequestPermission(data.customInfoRequest)\n break\n case 'inputCustomInfoRequest':\n customInfoRequest(data.customInfoRequest)\n break\n case 'actionRequiredMaintenance':\n setState('action_required_maintenance')\n break\n case 'cashSlotRemoveBills':\n setState('cash_slot_remove_bills')\n break\n case 'leftoverBillsInCashSlot':\n setState('leftover_bills_in_cash_slot')\n break\n case 'invalidAddress':\n invalidAddress(data.lnInvoiceTypeError)\n break\n case 'externalCompliance':\n clearTimeout(complianceTimeout)\n externalCompliance(data.externalComplianceUrl)\n break\n case 'rates':\n setState('rates')\n break\n default:\n if (data.action) setState(window.snakecase(data.action))\n }\n}\n\nfunction translate (data, fetchArgs) {\n if (data === \"\")\n return data\n\n try {\n return fetchArgs\n ? locale.translate(data).fetch(...fetchArgs)\n : locale.translate(data).fetch()\n } catch (error) {\n if (!defaultLocale) console.error('Error while translating: ', error)\n else {\n try {\n return fetchArgs\n ? defaultLocale.translate(data).fetch(...fetchArgs)\n : defaultLocale.translate(data).fetch()\n } catch (e) {\n console.error('Error while translating: ', e)\n return data\n }\n }\n }\n}\n\nfunction facephotoPermission () {\n setComplianceTimeout(null, 'finishBeforeSms')\n setScreen('permission_face_photo')\n}\n\nfunction usSsnPermission () {\n setComplianceTimeout(null, 'finishBeforeSms')\n setScreen('us_ssn_permission')\n}\n\nfunction externalPermission () {\n setComplianceTimeout(null, 'finishBeforeSms')\n setScreen('external_permission')\n}\n\nfunction customInfoRequestPermission (customInfoRequest) {\n $('#custom-screen1-title').text(customInfoRequest.screen1.title)\n $('#custom-screen1-text').text(customInfoRequest.screen1.text)\n setComplianceTimeout(null, 'finishBeforeSms')\n setScreen('custom_permission')\n}\n\nfunction setComplianceTimeout (interval, complianceButton) {\n clearTimeout(complianceTimeout)\n\n if (interval === 0) {\n return\n }\n\n complianceTimeout = setTimeout(function () {\n buttonPressed(complianceButton)\n }, interval == null ? 60000 : interval)\n}\n\nfunction invalidAddress (lnInvoiceTypeError) {\n if (lnInvoiceTypeError) {\n $('#invalid-address').hide()\n $('#invalid-invoice').show()\n } else {\n $('#invalid-invoice').hide()\n $('#invalid-address').show()\n }\n setState('invalid_address')\n}\n\nfunction customInfoRequest (customInfoRequest) {\n switch (customInfoRequest.input.type) {\n case 'numerical':\n $('#custom-screen2-numerical-title').text(customInfoRequest.screen2.title)\n $('#custom-screen2-numerical-text').text(customInfoRequest.screen2.text)\n customRequirementNumericalKeypad.setOpts({\n type: 'custom',\n constraint: customInfoRequest.input.constraintType,\n maxLength: customInfoRequest.input.numDigits\n })\n customRequirementNumericalKeypad.activate()\n setState('custom_permission_screen2_numerical')\n setScreen('custom_permission_screen2_numerical')\n setComplianceTimeout(null, 'cancelCustomInfoRequest')\n break\n case 'text':\n $('#custom-requirement-text-label1').text(customInfoRequest.input.label1)\n $('#custom-requirement-text-label2').text(customInfoRequest.input.label2)\n $('#previous-text-requirement').hide()\n $('#submit-text-requirement').hide()\n $('#next-text-requirement').hide()\n $('#optional-text-field-2').hide()\n $('.key.backspace.standard-backspace-key').removeClass('backspace-margin-left-override')\n $('.custom-info-request-space-key').show()\n // set type of constraint and buttons where that constraint should apply to disable/ enable\n customRequirementTextKeyboard.setConstraint(customInfoRequest.input.constraintType, ['#submit-text-requirement'])\n if (customInfoRequest.input.constraintType === 'spaceSeparation') {\n $('#optional-text-field-2').show()\n $('.key.backspace.standard-backspace-key').addClass('backspace-margin-left-override')\n $('.custom-info-request-space-key').hide()\n customRequirementTextKeyboard.setConstraint(customInfoRequest.input.constraintType, ['#next-text-requirement'])\n }\n setState('custom_permission_screen2_text')\n setScreen('custom_permission_screen2_text')\n setComplianceTimeout(null, 'cancelCustomInfoRequest')\n break\n case 'choiceList':\n $('#custom-screen2-choiceList-title').text(customInfoRequest.screen2.title)\n $('#custom-screen2-choiceList-text').text(customInfoRequest.screen2.text)\n customRequirementChoiceList.replaceChoices(customInfoRequest.input.choiceList, customInfoRequest.input.constraintType)\n setState('custom_permission_screen2_choiceList')\n setScreen('custom_permission_screen2_choiceList')\n setComplianceTimeout(null, 'cancelCustomInfoRequest')\n break\n default:\n return blockedCustomer()\n }\n}\n\nfunction idVerification () {\n setComplianceTimeout(null, 'finishBeforeSms')\n setScreen('permission_id')\n}\n\nfunction smsVerification () {\n setComplianceTimeout(null, 'finishBeforeSms')\n setScreen('sms_verification')\n}\n\nfunction emailVerification() {\n setComplianceTimeout(null, 'finishBeforeSms');\n setScreen('email_verification');\n}\n\nfunction blockedCustomer () {\n return setScreen('blocked_customer')\n}\n\nfunction chooseCoin (coins, twoWayMode) {\n if (twoWayMode) {\n $('.choose_coin_state').removeClass('choose-coin-cash-in').addClass('choose-coin-two-way')\n } else {\n $('.choose_coin_state').removeClass('choose-coin-two-way').addClass('choose-coin-cash-in')\n }\n\n isTwoWay = twoWayMode\n setChooseCoinColors()\n\n const defaultCoin = coins[0]\n\n currentCryptoCode = defaultCoin.cryptoCode\n currentCoin = defaultCoin\n currentCoins = coins.slice(0)\n\n setCryptoBuy(defaultCoin)\n setCryptoSell(defaultCoin)\n\n setupCoinsButtons(coins, currentCryptoCode)\n\n setState('choose_coin')\n}\n\nfunction openLanguageDropdown () {\n $('#language-dropdown-toggle').addClass('hide')\n $('#languages').removeClass('hide')\n $('#language-overlay').removeClass('hide')\n}\n\nfunction closeLanguageDropdown () {\n $('#language-dropdown-toggle').removeClass('hide')\n $('#languages').addClass('hide')\n $('#language-overlay').addClass('hide')\n}\n\nfunction openCoinDropdown () {\n $('#crypto-dropdown-toggle').addClass('hide')\n $('#crypto-overlay').removeClass('hide')\n $('#cryptos').removeClass('hide')\n}\n\nfunction closeCoinDropdown () {\n $('#crypto-dropdown-toggle').removeClass('hide')\n $('#crypto-overlay').addClass('hide')\n $('#cryptos').addClass('hide')\n}\n\nfunction setupCoinsButtons () {\n $('.crypto-buttons').empty()\n closeCoinDropdown()\n\n let coins = currentCoins.slice()\n let dropdownCoins = []\n\n if (coins.length === 1) return\n\n const showMoreButton = coins.length > 4\n if (showMoreButton) {\n $('crypto-dropdown-toggle').removeClass('hide')\n dropdownCoins = coins.slice(3)\n coins = coins.slice(0, 3)\n } else {\n $('crypto-dropdown-toggle').addClass('hide')\n }\n\n coins.forEach(function (coin) {\n const activeClass = coin.cryptoCode === currentCryptoCode ? 'choose-coin-button-active' : ''\n const el = ``\n $('.crypto-buttons').append(el)\n })\n if (showMoreButton) {\n $('.crypto-buttons').append(`\n \n `)\n dropdownCoins.forEach(coin => {\n const el = ``\n $('#cryptos').append(el)\n })\n const el = ``\n $('#cryptos').append(el)\n // As we add buttons 'more' and 'less' after initTranslate\n // they don't have baseTranslation translation data attached to them.\n $('.crypto-buttons .js-i18n').each(function () {\n var el = $(this)\n el.data('baseTranslation', el.html().trim())\n })\n }\n}\n\nfunction setCryptoBuy (coin) {\n const cashIn = $('.cash-in')\n const translatedCoin = translate(coin.display === displayLN ? displayBTC : coin.display)\n const buyStr = translate('Buy
%s', [translatedCoin])\n\n cashIn.html(buyStr)\n}\n\nfunction setCryptoSell (coin) {\n const cashOut = $('.cash-out')\n const translatedCoin = translate(coin.display === displayLN ? displayBTC : coin.display)\n const sellStr = translate('Sell
%s', [translatedCoin])\n\n cashOut.html(sellStr)\n}\n\nfunction setCoins (supportedCoins) {\n coins = supportedCoins\n}\n\nfunction getCryptoCurrency (cryptoCode) {\n const cryptoCurrency = coins.find(c => c.cryptoCode === cryptoCode)\n if (!cryptoCurrency) throw new Error(`Unsupported crypto: ${cryptoCode}`)\n return cryptoCurrency\n}\n\nfunction switchCoin (coin) {\n const cashIn = $('.cash-in')\n const cashOut = $('.cash-out')\n const cryptoCode = coin.cryptoCode\n\n if (currentCryptoCode === cryptoCode) return\n\n $(`.coin-${currentCryptoCode.toLowerCase()}`).removeClass('choose-coin-button-active')\n $(`.coin-${cryptoCode.toLowerCase()}`).addClass('choose-coin-button-active')\n currentCryptoCode = cryptoCode\n currentCoin = coin\n\n cashIn.addClass('crypto-switch')\n setTimeout(() => setCryptoBuy(coin), 100)\n setTimeout(() => cashIn.removeClass('crypto-switch'), 1000)\n\n setTimeout(() => {\n cashOut.addClass('crypto-switch')\n setTimeout(() => setCryptoSell(coin), 100)\n setTimeout(() => cashOut.removeClass('crypto-switch'), 1000)\n }, 80)\n\n const selectedIndex = currentCoins.indexOf(currentCoins.find(it => it.cryptoCode === cryptoCode))\n if (currentCoins.length > 4 && selectedIndex > 2) {\n currentCoins.splice(2, 0, currentCoins.splice(selectedIndex, 1)[0])\n }\n\n setupCoinsButtons()\n}\n\n$(document).ready(function () {\n const attachFastClick = Origami.fastclick\n attachFastClick(document.body)\n\n window.addEventListener('resize', () => {\n calculateAspectRatio()\n setChooseCoinColors()\n })\n\n // Matt's anti-drag hack\n window.onclick =\n window.oncontextmenu =\n window.onmousedown =\n window.onmousemove =\n window.onmouseup =\n function () { return false }\n\n BigNumber.config({ ROUNDING_MODE: BigNumber.ROUND_HALF_EVEN })\n\n promoKeyboard = new Keyboard({\n id: 'promo-keyboard',\n inputBox: '.promo-code-input'\n }).init(function () {\n if (currentState !== 'insert_promo_code') return\n buttonPressed('cancelPromoCode')\n })\n\n usSsnKeypad = new Keypad('us-ssn-keypad', { type: 'usSsn' }, function (result) {\n if (currentState !== 'register_us_ssn') return\n buttonPressed('usSsn', result)\n })\n\n phoneKeypad = new Keypad('phone-keypad', { type: 'phoneNumber', country: 'US' }, function (result) {\n if (currentState !== 'register_phone') return\n buttonPressed('phoneNumber', result)\n })\n\n securityKeypad = new Keypad('security-keypad', { type: 'code' }, function (result) {\n if (currentState !== 'security_code') return\n buttonPressed('securityCode', result)\n })\n\n customRequirementNumericalKeypad = new Keypad('custom-requirement-numeric-keypad', {\n type: 'custom'\n }, function (result) {\n if (currentState !== 'custom_permission_screen2_numerical') return\n buttonPressed('customInfoRequestSubmit', result)\n })\n\n emailKeyboard = new Keyboard({\n id: 'email-keyboard',\n inputBox: '#email-input',\n submitButtonWrapper: '#submit-email-wrapper',\n setComplianceTimeout: setComplianceTimeout\n }).init(function (result) {\n if (currentState !== 'register_email') return\n buttonPressed('email', result)\n })\n\n customRequirementTextKeyboard = new Keyboard({\n id: 'custom-requirement-text-keyboard',\n inputBox: '.text-input-field-1',\n submitButtonWrapper: '.submit-text-requirement-button-wrapper',\n setComplianceTimeout: setComplianceTimeout\n }).init(function () {\n if (currentState !== 'custom_permission_screen2_text') return\n buttonPressed('customInfoRequestSubmit')\n })\n\n customRequirementChoiceList = new ChoiceList({\n id: 'custom-requirement-choicelist-wrapper',\n setComplianceTimeout: setComplianceTimeout\n }).init(function (result) {\n if (currentState !== 'custom_permission_screen2_choiceList') return\n buttonPressed('customInfoRequestSubmit', result)\n })\n\n if (DEBUG_MODE !== 'demo') {\n connect()\n setInterval(verifyConnection, 1000)\n }\n\n initTranslatePage()\n\n var sendCoinsButton = document.getElementById('send-coins')\n var sendCoinsButton2 = document.getElementById('send-only-send-coins')\n touchEvent(sendCoinsButton, function () {\n setState('sending_coins')\n buttonPressed('sendCoins')\n })\n\n touchEvent(sendCoinsButton2, function () {\n setState('sending_coins')\n buttonPressed('sendCoins')\n })\n\n setupButton('recycler-continue-start', 'recyclerContinue')\n setupButton('recycler-continue', 'recyclerContinue')\n setupButton('recycler-finish', 'sendCoins')\n setupButton('cash-slot-bills-removed', 'cashSlotBillsRemoved')\n setupButton('leftover-bills-removed', 'leftoverBillsRemoved')\n\n const blockedCustomerOk = document.getElementById('blocked-customer-ok')\n touchEvent(blockedCustomerOk, function () {\n buttonPressed('blockedCustomerOk')\n })\n var insertBillCancelButton = document.getElementById('insertBillCancel')\n touchImmediateEvent(insertBillCancelButton, function () {\n setBuyerAddress(null)\n buttonPressed('cancelInsertBill')\n })\n\n var insertBillCancelRecyclerButton = document.getElementById('insertBillCancelRecycler')\n touchImmediateEvent(insertBillCancelRecyclerButton, function () {\n setBuyerAddress(null)\n buttonPressed('cancelInsertBill')\n })\n\n setupImmediateButton('scanCancel', 'cancelScan')\n setupImmediateButton('completed_viewport', 'completed')\n setupImmediateButton('withdraw_failure_viewport', 'completed')\n setupImmediateButton('out_of_coins_viewport', 'completed')\n setupImmediateButton('fiat_receipt_viewport', 'completed')\n setupImmediateButton('fiat_complete_viewport', 'completed')\n setupImmediateButton('chooseFiatCancel', 'chooseFiatCancel')\n setupImmediateButton('depositCancel', 'depositCancel')\n setupImmediateButton('printer-scan-cancel', 'cancelScan')\n\n setupButton('printer-back-to-home', 'idle')\n setupButton('printer-print-again', 'printAgain')\n setupButton('printer-print-again2', 'printAgain')\n setupButton('printer-scan-again', 'printerScanAgain')\n\n setupButton('insert-first-bill-promo-button', 'insertPromoCode')\n setupButton('insert-first-recycler-bills-promo-button', 'insertPromoCode')\n setupButton('choose-fiat-promo-button', 'insertPromoCode')\n\n var promoCodeCancelButton = document.getElementById('promo-code-cancel')\n touchImmediateEvent(promoCodeCancelButton, function () {\n promoKeyboard.deactivate.bind(promoKeyboard)\n buttonPressed('cancelPromoCode')\n })\n\n var submitCodeButton = document.getElementById('submit-promo-code')\n touchEvent(submitCodeButton, function () {\n promoKeyboard.deactivate.bind(promoKeyboard)\n var code = $('.promo-code-input').data('content')\n buttonPressed('submitPromoCode', { input: code })\n })\n\n const submitEmailButton = document.getElementById('submit-email')\n const submitTextRequirementButton = document.getElementById('submit-text-requirement')\n const nextFieldTextRequirementButton = document.getElementById('next-text-requirement')\n const previousFieldTextRequirementButton = document.getElementById('previous-text-requirement')\n touchEvent(submitEmailButton, function () {\n emailKeyboard.deactivate.bind(emailKeyboard)\n var text = $('#email-input').data('content')\n buttonPressed('email', text)\n $('#email-input').data('content', '').val('')\n emailKeyboard.setInputBox('#email-input')\n })\n touchEvent(submitTextRequirementButton, function () {\n customRequirementTextKeyboard.deactivate.bind(customRequirementTextKeyboard)\n var text = `${$('.text-input-field-1').data('content')} ${$('.text-input-field-2').data('content') || ''}`\n buttonPressed('customInfoRequestSubmit', text)\n $('.text-input-field-1').removeClass('faded').data('content', '').val('')\n $('.text-input-field-2').addClass('faded').data('content', '').val('')\n customRequirementTextKeyboard.setInputBox('.text-input-field-1')\n })\n touchEvent(nextFieldTextRequirementButton, function() {\n $('.text-input-field-1').addClass('faded')\n $('.text-input-field-2').removeClass('faded')\n $('#next-text-requirement').hide()\n $('#previous-text-requirement').show()\n $('#submit-text-requirement').show()\n // changing input box changes buttons where validation works on\n customRequirementTextKeyboard.setInputBox('.text-input-field-2', ['#submit-text-requirement'])\n })\n touchEvent(previousFieldTextRequirementButton, function() {\n $('.text-input-field-1').removeClass('faded')\n $('.text-input-field-2').addClass('faded')\n $('#next-text-requirement').show()\n $('#previous-text-requirement').hide()\n $('#submit-text-requirement').hide()\n customRequirementTextKeyboard.setInputBox('.text-input-field-1', ['#next-text-requirement'])\n })\n\n setupButton('submit-promo-code', 'submitPromoCode', {\n input: $('.promo-code-input').data('content')\n })\n setupButton('promo-code-try-again', 'insertPromoCode')\n setupButton('promo-code-continue', 'cancelPromoCode')\n\n setupButton('initialize', 'initialize')\n setupButton('pairing-scan', 'pairingScan')\n setupImmediateButton('pairing-scan-cancel', 'pairingScanCancel')\n setupButton('pairing-error-ok', 'pairingErrorOk')\n setupButton('cash-out-button', 'cashOut')\n\n setupImmediateButton('scan-id-cancel', 'idDataActionCancel')\n setupImmediateButton('scan-photo-cancel', 'idPhotoActionCancel')\n setupImmediateButton('scan-photo-manual-cancel', 'idPhotoActionCancel')\n setupImmediateButton('us-ssn-cancel', 'cancelUsSsn',\n usSsnKeypad.deactivate.bind(usSsnKeypad))\n setupImmediateButton('phone-number-cancel', 'cancelPhoneNumber',\n phoneKeypad.deactivate.bind(phoneKeypad))\n setupImmediateButton('security-code-cancel', 'cancelSecurityCode',\n securityKeypad.deactivate.bind(securityKeypad))\n setupButton('id-verification-failed-ok', 'idVerificationFailedOk')\n setupButton('id-scan-failed-try-again', 'idCodeFailedRetry')\n setupButton('id-scan-failed-cancel', 'idVerificationFailedOk')\n setupButton('id-code-failed-retry', 'idCodeFailedRetry')\n setupButton('id-code-failed-cancel', 'bye')\n setupButton('id-verification-error-ok', 'idVerificationErrorOk')\n setupButton('photo-scan-failed-retry', 'retryPhotoScan')\n setupButton('photo-scan-failed-cancel', 'photoScanVerificationCancel')\n setupButton('photo-verification-failed-ok', 'cancelIdScan')\n setupButton('invalid-address-try-again', 'invalidAddressTryAgain')\n setupButton('address-reuse-start-over', 'idle')\n setupButton('suspicious-address-start-over', 'idle')\n\n setupButton('sanctions-failure-ok', 'idle')\n setupButton('limit-reached-ok', 'idle')\n setupButton('hard-limit-reached-ok', 'idle')\n setupButton('deposit-timeout-sent-yes', 'depositTimeout')\n setupButton('deposit-timeout-sent-no', 'depositTimeoutNotSent')\n setupButton('out-of-cash-ok', 'idle')\n setupButton('cash-in-disabled-ok', 'idle')\n setupButton('cash-in-only-ok', 'idle')\n\n setupButton('bad-phone-number-ok', 'badPhoneNumberOk')\n setupButton('bad-security-code-ok', 'badSecurityCodeOk')\n setupButton('max-phone-retries-ok', 'maxPhoneRetriesOk')\n //setupButton('max-email-retries-ok', 'maxEmailRetriesOk')\n setupButton('redeem-later-ok', 'idle')\n setupButton('fiat-error-ok', 'idle')\n setupButton('network-down-ok', 'idle')\n setupButton('fiat-transaction-error-ok', 'fiatReceipt')\n\n setupButton('unknown-phone-number-ok', 'idle')\n setupButton('unknown-email-ok', 'idle')\n setupButton('unconfirmed-deposit-ok', 'idle')\n setupButton('tx-not-seen-ok', 'idle')\n setupButton('wrong-dispenser-currency-ok', 'idle')\n\n setupButton('print-receipt-cash-in-button', 'printReceipt')\n setupButton('print-receipt-cash-out-button', 'printReceipt')\n setupButton('print-receipt-cash-in-fail-button', 'printReceipt')\n\n setupButton('send-sms-receipt-cash-in-button', 'sendSmsReceipt')\n setupButton('send-sms-receipt-cash-out-button', 'sendSmsReceipt')\n setupButton('send-sms-receipt-cash-in-fail-button', 'sendSmsReceipt')\n\n setupButton('terms-ok', 'termsAccepted')\n setupButton('terms-ko', 'idle')\n\n setupImmediateButton('rates-close', 'idle')\n setupButton('rates-section-button', 'ratesScreen')\n\n setupButton('maintenance_restart', 'maintenanceRestart')\n\n calculateAspectRatio()\n\n const cryptoButtons = document.getElementById('crypto-buttons')\n touchEvent(cryptoButtons, event => {\n let el = $(event.target)\n if (el.is('path') || el.is('svg') || el.is('span')) {\n el = el.closest('div')\n }\n\n if (el.data('more')) {\n openCoinDropdown()\n return\n }\n\n if (el.data('less')) {\n closeCoinDropdown()\n return\n }\n\n const cryptoCode = el.data('cryptoCode')\n if (!cryptoCode) return\n\n const wantedCoin = currentCoins.find(it => it.cryptoCode === cryptoCode)\n if (!wantedCoin) return\n\n const coin = { cryptoCode, display: wantedCoin.display === displayLN ? displayBTC : wantedCoin.display }\n switchCoin(coin)\n })\n\n var areYouSureCancel = document.getElementById('are-you-sure-cancel-transaction')\n touchEvent(areYouSureCancel, () => buttonPressed('cancelTransaction', previousState))\n\n var areYouSureContinue = document.getElementById('are-you-sure-continue-transaction')\n touchEvent(areYouSureContinue, () => buttonPressed('continueTransaction', previousState))\n\n var coinRedeem = document.getElementById('coin-redeem-button')\n touchEvent(coinRedeem, () => {\n setDirection('cashOut')\n buttonPressed('redeem')\n })\n\n setupButton('facephoto-scan-failed-retry', 'retryFacephoto')\n setupButton('id-start-verification', 'permissionIdCompliance')\n setupButton('sms-start-verification', 'permissionSmsCompliance')\n setupButton('email-start-verification', 'permissionEmailCompliance');\n setupButton('ready-to-scan-id-card-photo', 'scanIdCardPhoto')\n setupButton('facephoto-permission-yes', 'permissionPhotoCompliance')\n setupButton('us-ssn-permission-yes', 'permissionUsSsnCompliance')\n setupButton('external-permission-yes', 'permissionExternalCompliance')\n\n setupButton('send-coins-id', 'finishBeforeSms')\n setupButton('send-coins-id-2', 'finishBeforeSms')\n setupButton('send-coins-sms', 'finishBeforeSms')\n setupButton('send-coins-sms-2', 'finishBeforeSms')\n setupButton('send-coins-email', 'finishBeforeSms');\n setupButton('send-coins-email-2', 'finishBeforeSms');\n\n setupButton('facephoto-permission-no', 'finishBeforeSms')\n setupButton('us-ssn-permission-send-coins', 'finishBeforeSms')\n setupButton('us-ssn-permission-cancel', 'finishBeforeSms')\n setupButton('us-ssn-cancel', 'finishBeforeSms')\n setupButton('external-permission-send-coins', 'finishBeforeSms')\n setupButton('facephoto-scan-failed-cancel', 'finishBeforeSms')\n setupButton('facephoto-scan-failed-cancel2', 'finishBeforeSms')\n\n setupButton('custom-permission-yes', 'permissionCustomInfoRequest')\n setupButton('custom-permission-no', 'finishBeforeSms')\n setupImmediateButton('custom-permission-cancel-numerical', 'cancelCustomInfoRequest', () => {\n customRequirementNumericalKeypad.deactivate.bind(customRequirementNumericalKeypad)\n })\n setupImmediateButton('email-cancel', 'cancelEmail', () => {\n emailKeyboard.deactivate.bind(emailKeyboard)\n $('#email-input').data('content', '').val('')\n emailKeyboard.setInputBox('#email-input')\n })\n setupImmediateButton('custom-permission-cancel-text', 'cancelCustomInfoRequest', () => {\n customRequirementTextKeyboard.deactivate.bind(customRequirementTextKeyboard)\n $('.text-input-field-1').removeClass('faded').data('content', '').val('')\n $('.text-input-field-2').addClass('faded').data('content', '').val('')\n customRequirementTextKeyboard.setInputBox('.text-input-field-1')\n })\n setupImmediateButton('custom-permission-cancel-choiceList', 'cancelCustomInfoRequest', () => {\n })\n\n setupButton('custom-permission-yes', 'permissionCustomInfoRequest')\n setupButton('custom-permission-no', 'finishBeforeSms')\n setupImmediateButton('custom-permission-cancel-numerical', 'cancelCustomInfoRequest', () => {\n customRequirementNumericalKeypad.deactivate.bind(customRequirementNumericalKeypad)\n })\n\n setupButton('external-validation-ok', 'finishBeforeSms')\n\n touchEvent(document.getElementById('change-language-section'), () => {\n if (_primaryLocales.length === 2) {\n setLocale(otherLocale())\n setCryptoBuy(currentCoin)\n setCryptoSell(currentCoin)\n return\n }\n openLanguageDropdown()\n })\n\n const cashInBox = document.getElementById('cash-in-box')\n touchEvent(cashInBox, () => {\n buttonPressed('start', { cryptoCode: currentCryptoCode, direction: 'cashIn' })\n })\n\n const cashOutBox = document.getElementById('cash-out-box')\n touchEvent(cashOutBox, () => {\n buttonPressed('start', { cryptoCode: currentCryptoCode, direction: 'cashOut' })\n })\n\n var languageOverlay = document.getElementById('language-overlay')\n touchEvent(languageOverlay, function (e) {\n closeLanguageDropdown()\n })\n\n var cryptoOverlay = document.getElementById('crypto-overlay')\n touchEvent(cryptoOverlay, function (e) {\n closeCoinDropdown()\n })\n\n var languageButtons = document.getElementById('languages')\n touchEvent(languageButtons, function (e) {\n var languageButtonJ = $(e.target).closest('button')\n if (languageButtonJ.length === 0) return\n var newLocale = languageButtonJ.attr('data-locale')\n\n if (!newLocale) {\n closeLanguageDropdown()\n return\n }\n\n setLocale(newLocale)\n setCryptoBuy(currentCoin)\n setCryptoSell(currentCoin)\n closeLanguageDropdown()\n })\n\n buildCassetteButtonEvents()\n if (DEBUG_MODE === 'dev') initDebug()\n})\n\nfunction targetButton (element) {\n var classList = element.classList || []\n var special = classList.contains('button') ||\n classList.contains('circle-button') ||\n classList.contains('square-button')\n if (special) { return element }\n return targetButton(element.parentNode)\n}\n\nfunction touchEvent (element, callback) {\n function handler (e) {\n var target = targetButton(e.target)\n\n target.classList.add('active')\n\n // Wait for transition to finish\n setTimeout(function () {\n target.classList.remove('active')\n }, 300)\n\n setTimeout(function () {\n callback(e)\n }, 200)\n\n e.stopPropagation()\n e.preventDefault()\n }\n\n if (shouldEnableTouch()) {\n element.addEventListener('touchstart', handler)\n }\n element.addEventListener('mousedown', handler)\n}\n\nfunction touchImmediateEvent (element, callback) {\n function handler (e) {\n callback(e)\n e.stopPropagation()\n e.preventDefault()\n }\n if (shouldEnableTouch()) {\n element.addEventListener('touchstart', handler)\n }\n element.addEventListener('mousedown', handler)\n}\n\nfunction setupImmediateButton (buttonClass, buttonAction, callback) {\n var button = document.getElementById(buttonClass)\n touchImmediateEvent(button, function () {\n if (callback) callback()\n buttonPressed(buttonAction)\n })\n}\n\nfunction setupButton (buttonClass, buttonAction, actionData) {\n var button = document.getElementById(buttonClass)\n touchEvent(button, function () {\n buttonPressed(buttonAction, actionData)\n })\n}\n\nfunction setScreen (newScreen, oldScreen) {\n if (newScreen === oldScreen) return\n\n if (newScreen === 'insert_bills') {\n $('.js-processing-bill').html(translate('Lamassu Cryptomat'))\n $('.bill img').css({'-webkit-transform': 'none', top: 0, left: 0})\n }\n\n var newView = $('.' + newScreen + '_state')\n if (newView.length !== 1) console.log('FATAL: ' + newView.length + ' screens found of class ' + newScreen + '_state')\n\n $('.viewport').removeClass('viewport-active')\n newView.addClass('viewport-active')\n}\n\nfunction setState (state, delay) {\n if (state === currentState) return\n\n if (currentState === 'terms_screen') {\n clearTermsConditionsTimeout()\n clearTermsConditionsAcceptanceDelay()\n }\n\n setComplianceTimeout(0)\n\n previousState = currentState\n currentState = state\n\n promoKeyboard.reset()\n emailKeyboard.reset()\n customRequirementTextKeyboard.reset()\n\n if (state === 'idle') {\n $('.qr-code').empty()\n $('.qr-code-deposit').empty()\n }\n\n if (delay) {\n window.setTimeout(function () {\n setScreen(currentState, previousState)\n }, delay)\n } else setScreen(currentState, previousState)\n}\n\nfunction revertScreen () { setScreen(currentState) }\n\nfunction setUpDirectionElement (element, direction) {\n if (direction === 'cashOut') {\n element.removeClass('cash-in-color')\n element.addClass('cash-out-color')\n } else {\n element.addClass('cash-in-color')\n element.removeClass('cash-out-color')\n }\n}\n\nfunction setOperatorInfo (operator) {\n if (!operator || !operator.active) {\n $('.contacts, .contacts-compact').addClass('hide')\n } else {\n $('.contacts, .contacts-compact').removeClass('hide')\n $('.operator-name').text(operator.name)\n $('.operator-email').text(operator.email)\n $('.operator-phone').text(operator.phone)\n }\n}\n\nfunction setHardLimit (limits) {\n const component = $('#hard-limit-hours')\n if (limits.hardLimitWeeks >= 1) {\n return component.text(translate('Please come back in %s weeks', [limits.hardLimitWeeks]))\n }\n\n if (limits.hardLimitDays >= 1) {\n return component.text(translate('Please come back in %s days and %s hours', [limits.hardLimitDays, limits.hardLimitHours]))\n }\n\n component.text(translate('Please come back in %s hours', [limits.hardLimitHours]))\n}\n\nfunction setCryptomatModel (model) {\n cryptomatModel = model\n const versions = ['sintra', 'douro', 'gaia', 'tejo', 'grandola', 'aveiro', 'coincloud', 'gmuk1', 'batm7in']\n const body = $('body')\n\n versions.forEach(it => body.removeClass(it))\n $('body').addClass(model.startsWith('douro') ? 'douro' : model)\n}\n\nfunction enableRecyclerBillButtons() {\n var continueButton = document.getElementById('recycler-continue');\n var finishButton = document.getElementById('recycler-finish');\n continueButton.disabled = false;\n finishButton.disabled = false;\n}\n\nfunction disableRecyclerBillButtons() {\n var continueButton = document.getElementById('recycler-continue');\n var finishButton = document.getElementById('recycler-finish');\n continueButton.disabled = true;\n finishButton.disabled = true;\n}\n\nfunction setDirection (direction) {\n let states = [\n $('.scan_id_photo_state'),\n $('.scan_manual_id_photo_state'),\n $('.scan_id_data_state'),\n $('.security_code_state'),\n $('.register_us_ssn_state'),\n $('.us_ssn_permission_state'),\n $('.register_phone_state'),\n $('.register_email_state'),\n $('.terms_screen_state'),\n $('.verifying_id_photo_state'),\n $('.verifying_face_photo_state'),\n $('.verifying_id_data_state'),\n $('.permission_id_state'),\n $('.sms_verification_state'),\n $('.email_verification_state'),\n $('.bad_phone_number_state'),\n $('.bad_security_code_state'),\n $('.max_phone_retries_state'),\n $('.max_email_retries_state'),\n $('.failed_permission_id_state'),\n $('.failed_verifying_id_photo_state'),\n $('.blocked_customer_state'),\n $('.fiat_error_state'),\n $('.fiat_transaction_error_state'),\n $('.failed_scan_id_data_state'),\n $('.sanctions_failure_state'),\n $('.error_permission_id_state'),\n $('.scan_face_photo_state'),\n $('.retry_scan_face_photo_state'),\n $('.permission_face_photo_state'),\n $('.failed_scan_face_photo_state'),\n $('.hard_limit_reached_state'),\n $('.failed_scan_id_photo_state'),\n $('.retry_permission_id_state'),\n $('.waiting_state'),\n $('.insert_promo_code_state'),\n $('.promo_code_not_found_state'),\n $('.custom_permission_state'),\n $('.external_permission_state'),\n $('.custom_permission_screen2_numerical_state'),\n $('.custom_permission_screen2_text_state'),\n $('.custom_permission_screen2_choiceList_state'),\n $('.external_compliance_state')\n ]\n cashDirection = direction\n states.forEach(it => {\n setUpDirectionElement(it, direction)\n })\n}\n\n/**\n *\n * @param {Object} data\n * @param {boolean} data.active\n * @param {String} data.title\n * @param {String} data.text\n * @param {String} data.accept\n * @param {String} data.cancel\n */\nfunction setTermsScreen (data) {\n const $screen = $('.terms_screen_state')\n $screen.find('.js-terms-title').html(data.title)\n startPage(data.text, data.acceptDisabled)\n $screen.find('.js-terms-cancel-button').html(data.cancel)\n $screen.find('.js-terms-accept-button').html(data.accept)\n setTermsConditionsTimeout()\n setAcceptButtonDisabled($screen, data)\n setTermsConditionsAcceptanceDelay($screen, data)\n}\n\nfunction setAcceptButtonDisabled (screen, data) {\n var acceptButton = screen.find('.js-terms-accept-button');\n acceptButton.prop('disabled', Boolean(data.acceptDisabled));\n}\n\nfunction clearTermsConditionsTimeout () {\n clearTimeout(termsConditionsTimeout)\n}\n\nfunction setTermsConditionsTimeout () {\n termsConditionsTimeout = setTimeout(function () {\n if (currentState === 'terms_screen') {\n buttonPressed('idle')\n }\n }, T_C_TIMEOUT)\n}\n\nfunction setTermsConditionsAcceptanceDelay (screen, data) {\n let acceptButton = screen.find('.js-terms-accept-button')\n acceptButton.css({ 'min-width': 0 })\n\n if (!data.delay) return\n\n const delayTimer = isNaN(data.delayTimer) ? 0 : data.delayTimer\n let seconds = delayTimer / 1000\n acceptButton.prop('disabled', true)\n acceptButton.html(seconds > 0 ? `${data.accept} (${seconds})` : `${data.accept}`)\n\n var tmpbtn = acceptButton.clone().appendTo('body').css({ 'display': 'block', 'visibility': 'hidden' })\n var width = tmpbtn.outerWidth()\n tmpbtn.remove()\n acceptButton.css({ 'min-width': `${width}px` })\n termsConditionsAcceptanceInterval = setInterval(function () {\n seconds--\n if (currentState === 'terms_screen' && seconds > 0) {\n acceptButton.html(`${data.accept} (${seconds})`)\n }\n if (currentState === 'terms_screen' && seconds <= 0) {\n acceptButton.prop('disabled', false)\n acceptButton.html(`${data.accept}`)\n }\n if (seconds <= 0) {\n clearInterval(termsConditionsAcceptanceInterval)\n }\n }, 1000)\n}\n\nfunction clearTermsConditionsAcceptanceDelay () {\n clearInterval(termsConditionsAcceptanceInterval)\n}\n\nfunction resetTermsConditionsTimeout () {\n clearTermsConditionsTimeout()\n setTermsConditionsTimeout()\n}\n\n// click page up button\nfunction scrollUp () {\n resetTermsConditionsTimeout()\n const div = document.getElementById('js-terms-text-div')\n if (currentPage !== 0) {\n currentPage -= 1\n updateButtonStyles()\n updatePageCounter()\n div.scrollTo(0, currentPage * scrollSize)\n }\n}\n\n// start page\nfunction startPage (text, acceptedTerms) {\n const $screen = $('.terms_screen_state')\n $screen.find('.js-terms-text').html(text)\n if (!acceptedTerms) currentPage = 0\n totalPages = 0\n setTimeout(function () {\n const div = document.getElementById('js-terms-text-div')\n textHeightQuantity = document.getElementById('js-terms-text').offsetHeight\n scrollSize = div.offsetHeight - 40\n updateButtonStyles()\n if (text.length <= 1000 && textHeightQuantity <= div.offsetHeight) {\n document.getElementById('actions-scroll').style.display = 'none'\n } else {\n document.getElementById('actions-scroll').style.display = ''\n if (!acceptedTerms) div.scrollTo(0, 0)\n totalPages = Math.ceil(textHeightQuantity / scrollSize)\n updatePageCounter()\n }\n }, 100)\n}\n\nfunction updatePageCounter () {\n document.getElementById('terms-page-counter').textContent = `${currentPage + 1}/${totalPages}`\n}\n\n// click page up button\nfunction scrollDown () {\n resetTermsConditionsTimeout()\n const div = document.getElementById('js-terms-text-div')\n if (!(currentPage * scrollSize + scrollSize > textHeightQuantity && currentPage !== 0)) {\n currentPage += 1\n updateButtonStyles()\n updatePageCounter()\n div.scrollTo(0, currentPage * scrollSize)\n }\n}\n\nfunction updateButtonStyles () {\n textHeightQuantity = document.getElementById('js-terms-text').offsetHeight\n const buttonDown = document.getElementById('scroll-down')\n const buttonUp = document.getElementById('scroll-up')\n buttonUp.disabled = currentPage === 0;\n buttonDown.disabled = currentPage * scrollSize + scrollSize > textHeightQuantity && currentPage !== 0;\n}\n\nfunction setLocaleInfo (data) {\n phoneKeypad.setCountry(data.country)\n setPrimaryLocales(data.primaryLocales)\n setLocale(data.primaryLocale)\n}\n\nfunction otherLanguageName () {\n const lang = lookupLocaleNames(otherLocale())\n return lang && lang.nativeName\n}\n\nfunction otherLocale () {\n return _primaryLocales.find(c => c !== localeCode)\n}\n\nfunction setLocale (data) {\n if (!data || data === localeCode) return\n localeCode = data\n jsLocaleCode = data\n var lang = localeCode.split('-')[0]\n\n if (jsLocaleCode === 'fr-QC') jsLocaleCode = 'fr-CA'\n\n var isArabic = jsLocaleCode.indexOf('ar-') === 0\n var isHebrew = jsLocaleCode.indexOf('he-') === 0\n isRTL = isArabic || isHebrew\n\n setChooseCoinColors()\n\n if (isRTL) {\n $('body').addClass('i18n-rtl')\n } else {\n $('body').removeClass('i18n-rtl')\n }\n\n if (isArabic) {\n $('body').addClass('i18n-ar')\n } else {\n $('body').removeClass('i18n-ar')\n }\n\n if (isHebrew) {\n $('body').addClass('i18n-he')\n } else {\n $('body').removeClass('i18n-he')\n }\n\n if (MUSEO.indexOf(lang) !== -1) $('body').addClass('museo')\n else $('body').removeClass('museo')\n\n locale = loadI18n(localeCode)\n try { translatePage() } catch (ex) {}\n\n $('.js-two-language').html(otherLanguageName())\n\n if (lastRates) setExchangeRate(lastRates)\n}\n\nfunction setChooseCoinColors () {\n var elem = $('#bg-to-show > img')\n let img = `images/background/${isTwoWay ? '2way' : '1way'}-${aspectRatio}${isRTL ? '-rtl' : ''}.svg`\n if (img !== elem.attr('src')) {\n elem.attr('src', img)\n }\n\n if (isTwoWay) {\n $('.choose_coin_state .change-language').removeClass('cash-in-color').addClass('cash-out-color')\n } else {\n $('.choose_coin_state .change-language').removeClass('cash-out-color').addClass('cash-in-color')\n }\n}\n\nfunction areArraysEqual (arr1, arr2) {\n if (arr1.length !== arr2.length) return false\n for (var i = 0; i < arr1.length; i++) {\n if (arr1[i] !== arr2[i]) return false\n }\n return true\n}\n\nfunction lookupLocaleNames (locale) {\n if (!locale) return\n var langMap = window.languageMappingList\n var language = locale.split('-')[0]\n var localeNames = langMap[language]\n return localeNames || langMap[locale]\n}\n\nfunction setPrimaryLocales (primaryLocales) {\n if (areArraysEqual(primaryLocales, _primaryLocales)) return\n _primaryLocales = primaryLocales\n\n var languages = $('#languages')\n closeLanguageDropdown()\n languages.empty()\n var sortedPrimaryLocales = primaryLocales.filter(lookupLocaleNames).sort(function (a, b) {\n var langA = lookupLocaleNames(a)\n var langB = lookupLocaleNames(b)\n return langA.englishName.localeCompare(langB.englishName)\n })\n\n languages.append(``)\n for (var i = 0; i < sortedPrimaryLocales.length; i++) {\n var l = sortedPrimaryLocales[i]\n var lang = lookupLocaleNames(l)\n var name = lang.nativeName || lang.englishName\n var div = ``\n languages.append(div)\n }\n\n $('.js-two-language').html(otherLanguageName())\n\n $('.js-menu-language').toggleClass('hide', sortedPrimaryLocales.length <= 1)\n $('.js-multi-language').toggleClass('hide', sortedPrimaryLocales.length === 2)\n $('.js-two-language').toggleClass('hide', sortedPrimaryLocales.length > 2)\n}\n\nfunction setFiatCode (data) {\n fiatCode = data\n $('.js-currency').text(fiatCode)\n}\n\nfunction setFixedFee (_fee) {\n const fee = parseFloat(_fee)\n if (fee > 0) {\n const fixedFee = translate('Transaction Fee: %s', [formatFiat(fee, 2)])\n $('.js-i18n-fixed-fee').html(fixedFee)\n } else {\n $('.js-i18n-fixed-fee').html('')\n }\n}\n\nfunction setCredit (credit, lastBill) {\n const { fiat, cryptoAtoms, cryptoCode } = credit\n var coin = getCryptoCurrency(cryptoCode)\n\n var scale = new BigNumber(10).pow(coin.displayScale)\n var cryptoAmount = new BigNumber(cryptoAtoms).div(scale).toNumber()\n var cryptoDisplayCode = coin.displayCode\n updateCrypto('.total-crypto-rec', cryptoAmount, cryptoDisplayCode)\n $('.amount-deposited').html(translate('You deposited %s', [`${fiat} ${fiatCode}`]))\n $('.fiat .js-amount').html(fiat)\n\n var inserted = lastBill\n ? translate('You inserted a %s bill', [formatFiat(lastBill)])\n : translate('Lamassu Cryptomat')\n\n $('.js-processing-bill').html(inserted)\n\n $('.js-continue-crypto-enable').show()\n $('.js-send-crypto-enable').show()\n}\n\nfunction formatDenomination (denom) {\n return denom.toLocaleString(jsLocaleCode, {\n useGrouping: true,\n maximumFractionDigits: 0,\n minimumFractionDigits: 0\n })\n}\n\nfunction buildCassetteButtons (_cassettes, numberOfButtons) {\n var activeCassettes = _cassettes.filter(it => it.count === null || it.count > 0)\n var inactiveCassettes = _cassettes.filter(it => it.count === 0)\n\n var allCassettes = activeCassettes.concat(inactiveCassettes)\n var selectedCassettes = allCassettes.slice(0, numberOfButtons)\n var sortedCassettes = selectedCassettes.sort((a, b) => a.denomination - b.denomination)\n\n for (var i = 0; i < sortedCassettes.length; i++) {\n var denomination = formatDenomination(sortedCassettes[i].denomination || 0)\n $('.cash-button[data-denomination-index=' + i + '] .js-denomination').text(denomination)\n }\n}\n\nfunction updateCassetteButtons (activeDenoms, numberOfButtons) {\n for(var i = 0; i < numberOfButtons; i++) {\n var button = $('.choose_fiat_state .cash-button[data-denomination-index=' + i + ']')\n var denomination = button.children('.js-denomination').text()\n button.prop('disabled', !Boolean(activeDenoms[denomination]))\n }\n}\n\nfunction buildCassetteButtonEvents () {\n var fiatButtons = document.getElementById('js-fiat-buttons')\n var lastTouch = null\n\n touchImmediateEvent(fiatButtons, function (e) {\n var now = Date.now()\n if (lastTouch && now - lastTouch < 100) return\n lastTouch = now\n var cashButtonJ = $(e.target).closest('.cash-button')\n if (cashButtonJ.length === 0) return\n if (cashButtonJ.hasClass('disabled')) return\n if (cashButtonJ.hasClass('clear')) return buttonPressed('clearFiat')\n buttonPressed('fiatButton', { denomination: cashButtonJ.children('.js-denomination').text() })\n })\n}\n\nfunction updateCrypto (selector, cryptoAmount, cryptoDisplayCode) {\n $(selector).find('.crypto-amount').html(formatCrypto(cryptoAmount))\n $(selector).find('.crypto-units').html(cryptoDisplayCode)\n}\n\nfunction lookupDecimalChar (localeCode) {\n var num = 1.1\n var localized = num.toLocaleString(localeCode, {\n useGrouping: true,\n maximumFractionDigits: 1,\n minimumFractionDigits: 1\n })\n\n return localized[1]\n}\n\nfunction splitNumber (localize, localeCode) {\n var decimalChar = lookupDecimalChar(localeCode)\n var split = localize.split(decimalChar)\n\n if (split.length === 1) {\n return ['', split[0], ''].join('')\n }\n\n return [\n '', split[0], '',\n decimalChar, '', split[1], ''\n ].join('')\n}\n\nfunction formatNumber (num) {\n var localized = num.toLocaleString(jsLocaleCode, {\n useGrouping: true,\n maximumFractionDigits: 6,\n minimumFractionDigits: 3\n })\n\n return splitNumber(localized, jsLocaleCode)\n}\n\nfunction formatCrypto (amount) {\n return formatNumber(amount)\n}\n\nfunction formatFiat (amount, fractionDigits) {\n if (!fractionDigits) fractionDigits = 0\n\n const localized = amount.toLocaleString(jsLocaleCode, {\n useGrouping: true,\n maximumFractionDigits: fractionDigits,\n minimumFractionDigits: fractionDigits\n })\n return splitNumber(localized, jsLocaleCode) + ' ' + fiatCode\n}\n\nfunction setExchangeRate (_rates) {\n lastRates = _rates\n var cryptoCode = _rates.cryptoCode\n var rates = _rates.rates\n\n var coin = getCryptoCurrency(cryptoCode)\n var displayCode = coin.displayCode\n\n if (rates.cashIn) {\n var cryptoToFiat = new BigNumber(rates.cashIn)\n var rateStr = formatFiat(cryptoToFiat.round(2).toNumber(), 2)\n\n $('.crypto-rate-cash-in').html(`1 ${cryptoCode === LN ? BTC : cryptoCode} = ${rateStr}`)\n }\n\n if (rates.cashOut) {\n var cashOut = new BigNumber(rates.cashOut)\n var cashOutCryptoToFiat = cashOut && formatFiat(cashOut.round(2).toNumber(), 2)\n\n $('.crypto-rate-cash-out').html(`1 ${cryptoCode === LN ? BTC : cryptoCode} = ${cashOutCryptoToFiat}`)\n }\n\n $('.js-crypto-display-units').text(displayCode)\n}\n\nfunction qrize (text, target, color, lightning, size = 'normal') {\n const image = document.getElementById('bolt-img')\n // Hack for surf browser\n const _size = size === 'normal'\n ? document.body.clientHeight * 0.36\n : document.body.clientHeight * 0.25\n\n const opts = {\n crisp: true,\n fill: color || 'black',\n text,\n size: _size,\n render: 'canvas',\n rounded: 50,\n quiet: 2,\n mPosX: 50,\n mPosY: 50,\n mSize: 30,\n image\n }\n\n if (lightning) {\n opts.mode = 'image'\n }\n\n const el = kjua(opts)\n\n target.empty().append(el)\n}\n\nfunction setTx (tx) {\n const txId = tx.id\n const isPaperWallet = tx.isPaperWallet\n const hasBills = tx.bills && tx.bills.length > 0\n\n if (hasBills) {\n $('.js-inserted-notes').show()\n $('.js-no-inserted-notes').hide()\n } else {\n $('.js-inserted-notes').hide()\n $('.js-no-inserted-notes').show()\n }\n\n $('.js-paper-wallet').toggleClass('hide', !isPaperWallet)\n\n setCurrentDiscount(tx.discount, tx.promoCodeApplied)\n\n setTimeout(() => {\n qrize(txId, $('#cash-in-qr-code'), CASH_IN_QR_COLOR)\n qrize(txId, $('#cash-in-fail-qr-code'), CASH_IN_QR_COLOR)\n qrize(txId, $('#cash-in-no-funds-qr-code'), CASH_IN_QR_COLOR, null, 'small')\n qrize(txId, $('#qr-code-fiat-receipt'), CASH_OUT_QR_COLOR)\n qrize(txId, $('#qr-code-fiat-complete'), CASH_OUT_QR_COLOR)\n }, 1000)\n}\n\nfunction formatAddressNoBreakLines (address) {\n if (!address) return\n if (address.length > 60) {\n const firstPart = address.substring(0, 40).replace(/(.{4})/g, '$1 ')\n const secondPart = address.substring(address.length-16, address.length).replace(/(.{4})/g, '$1 ')\n return firstPart.concat('... ').concat(secondPart)\n }\n return address.replace(/(.{4})/g, '$1 ')\n}\n\nfunction formatAddress (address) {\n let toBr = formatAddressNoBreakLines(address)\n if (!toBr) return\n\n return toBr.replace(/((.{4} ){5})/g, '$1
')\n}\n\nfunction setBuyerAddress (address) {\n $('.crypto-address-no-br').html(formatAddressNoBreakLines(address))\n $('.crypto-address').html(formatAddress(address))\n}\n\nfunction highBill (highestBill, reason) {\n var reasonText = reason === 'transactionLimit'\n ? translate('Transaction limit reached.')\n : translate(\"We're a little low on crypto.\")\n\n t('high-bill-header', reasonText)\n t('highest-bill', translate('Please insert %s or less.', [formatFiat(highestBill)]))\n\n setScreen('high_bill')\n window.setTimeout(revertScreen, 3000)\n}\n\nfunction minimumTx (lowestBill) {\n t('lowest-bill', translate('Minimum first bill is %s.', [formatFiat(lowestBill)]))\n\n setScreen('minimum_tx')\n window.setTimeout(revertScreen, 3000)\n}\n\nfunction readingBills (bill) {\n $('.js-processing-bill').html(translate('Processing %s ...', [formatFiat(bill)]))\n $('.js-continue-crypto-enable').hide()\n $('.js-send-crypto-enable').hide()\n}\n\nfunction sendOnly (reason) {\n // TODO: sendOnly should be made into its own state on brain.js\n if (currentState === 'send_only') return\n\n const errorMessages = {\n transactionLimit: translate('Transaction limit reached'),\n validatorError: translate('Error in validation'),\n lowBalance: translate(\"We're out of coins!\"),\n blockedCustomer: translate('Transaction limit reached')\n }\n\n // If no reason provided defaults to lowBalance\n const reasonText = errorMessages[reason] || errorMessages.lowBalance\n $('#send-only-title').text(reasonText)\n\n if (reason === 'blockedCustomer') {\n $('.js-send-only-text').text(translate(\"Due to local regulations, you've reached your transaction limit. Please contact us if you'd like to raise your limit.\"))\n } else {\n $('.js-send-only-text').text('')\n }\n\n setState('send_only')\n}\n\nfunction t (id, str) {\n $('#js-i18n-' + id).html(str)\n}\n\nfunction translateCoin (_cryptoCode) {\n const coin = getCryptoCurrency(_cryptoCode)\n const cryptoCode = coin.cryptoCodeDisplay || _cryptoCode\n $('.js-i18n-scan-your-address').html(translate('Scan your
%s address', [cryptoCode]))\n $('.js-i18n-please-scan').html(translate('Please scan the QR code
to send us your %s.', [cryptoCode]))\n $('.js-i18n-did-send-coins').html(translate('Have you sent the %s yet?', [cryptoCode]))\n $('.js-i18n-scan-address').html(translate('Scan your %s address', [cryptoCode]))\n $('.js-i18n-invalid-address').html(translate('Invalid %s address', [cryptoCode]))\n}\n\nfunction initTranslatePage () {\n $('.js-i18n').each(function () {\n var el = $(this)\n el.data('baseTranslation', el.html().trim())\n })\n $('input[placeholder]').each(function () {\n var el = $(this)\n el.data('baseTranslation', el.attr('placeholder'))\n })\n}\n\nfunction translatePage () {\n $('.js-i18n').each(function () {\n var el = $(this)\n var base = el.data('baseTranslation')\n el.html(translate(base))\n })\n $('input[placeholder]').each(function () {\n var el = $(this)\n var base = el.data('baseTranslation')\n el.attr('placeholder', translate(base))\n })\n\n // Adjust send coins button\n var length = $('#send-coins span').text().length\n if (length > 17) $('body').addClass('i18n-long-send-coins')\n else $('body').removeClass('i18n-long-send-coins')\n}\n\nfunction loadI18n (localeCode) {\n var messages = locales[localeCode] || locales['en-US']\n\n return new Jed({\n 'missing_key_callback': function () {},\n 'locale_data': {\n 'messages': messages\n }\n })\n}\n\nfunction reachFiatLimit (rec) {\n var msg = null\n if (rec.isEmpty) msg = translate(`We're a little low, please cash out`)\n else if (rec.txLimitReached) msg = translate('Transaction limit reached, please cash out')\n\n var el = $('.choose_fiat_state .limit')\n if (msg) el.html(msg).show()\n else el.hide()\n}\n\nfunction chooseFiat (data) {\n fiatCredit(data)\n setState('choose_fiat')\n}\n\nfunction displayCrypto (cryptoAtoms, cryptoCode) {\n var coin = getCryptoCurrency(cryptoCode)\n var scale = new BigNumber(10).pow(coin.displayScale)\n // number of decimal places vary based on displayScale value\n var decimalPlaces = (coin.displayScale - coin.unitScale) + 6\n var cryptoAmount = new BigNumber(cryptoAtoms).div(scale).round(decimalPlaces).toNumber()\n return formatCrypto(cryptoAmount)\n}\n\nfunction BN (s) { return new BigNumber(s) }\n\nfunction fiatCredit (data) {\n var tx = data.tx\n var cryptoCode = tx.cryptoCode\n var activeDenominations = data.activeDenominations\n var coin = getCryptoCurrency(cryptoCode)\n const fiat = BN(tx.fiat)\n\n var fiatDisplay = BN(tx.fiat).toNumber().toLocaleString(jsLocaleCode, {\n useGrouping: true,\n maximumFractionDigits: 0,\n minimumFractionDigits: 0\n })\n\n var cryptoAtoms = BN(tx.cryptoAtoms)\n var cryptoDisplay = displayCrypto(cryptoAtoms, cryptoCode)\n\n var cryptoDisplayCode = coin.displayCode\n\n setCurrentDiscount(tx.discount, tx.promoCodeApplied)\n\n if (cryptoAtoms.eq(0) || cryptoAtoms.isNaN()) $('#js-i18n-choose-digital-amount').hide()\n else $('#js-i18n-choose-digital-amount').show()\n\n if (fiat.eq(0)) $('#cash-out-button').prop('disabled', true)\n else $('#cash-out-button').prop('disabled', false)\n\n updateCassetteButtons(activeDenominations.activeMap, NUMBER_OF_BUTTONS)\n $('.choose_fiat_state .fiat-amount').text(fiatDisplay)\n t('choose-digital-amount',\n translate(\"You'll be sending %s %s\", [cryptoDisplay, cryptoDisplayCode]))\n\n reachFiatLimit(activeDenominations)\n}\n\nfunction setDepositAddress (depositInfo) {\n $('.deposit_state .loading').hide()\n $('.deposit_state .send-notice .crypto-address').html(formatAddress(depositInfo.toAddress))\n $('.deposit_state .send-notice').show()\n\n qrize(depositInfo.depositUrl, $('#qr-code-deposit'), CASH_OUT_QR_COLOR)\n}\n\nfunction setVersion (version) {\n $('.version-number').html(`Version: ${version}`)\n}\n\nfunction deposit (tx) {\n var cryptoCode = tx.cryptoCode\n var display = displayCrypto(tx.cryptoAtoms, cryptoCode)\n\n $('.js-wallet-address').show()\n\n $('.deposit_state .digital .js-amount').html(display)\n $('.deposit_state .fiat .js-amount').text(tx.fiat)\n $('.deposit_state .send-notice').hide()\n $('#qr-code-deposit').empty()\n $('.deposit_state .loading').show()\n $('#qr-code-deposit').show()\n $('#lightning-enabled').hide()\n if (tx.cryptoCode === 'LN') $('#lightning-enabled').show()\n\n setState('deposit')\n}\n\nfunction fiatReceipt (tx) {\n var cryptoCode = tx.cryptoCode\n var display = displayCrypto(tx.cryptoAtoms, cryptoCode)\n\n $('.fiat_receipt_state .digital .js-amount').html(display)\n $('.fiat_receipt_state .fiat .js-amount').text(tx.fiat)\n $('.fiat_receipt_state .sent-coins .crypto-address').html(formatAddress(tx.toAddress))\n\n setState('fiat_receipt')\n}\n\nfunction fiatComplete (tx) {\n var cryptoCode = tx.cryptoCode\n var display = displayCrypto(tx.cryptoAtoms, cryptoCode)\n\n $('.fiat_complete_state .digital .js-amount').html(display)\n $('.fiat_complete_state .fiat .js-amount').text(tx.fiat)\n $('.fiat_complete_state .sent-coins .crypto-address').html(formatAddress(tx.toAddress))\n\n setState('fiat_complete')\n}\n\nfunction dispenseBatch (data) {\n $('.batch').css('visibility', data.of === 1 ? 'hidden' : 'visible')\n $('.batch').text(`${data.current}/${data.of}`)\n}\n\nfunction initDebug () {\n $('body').css('cursor', 'default')\n var style = document.createElement('style')\n style.type = 'text/css'\n style.innerHTML = 'button { cursor: default !important; }'\n document.getElementsByTagName('head')[0].appendChild(style)\n}\n\nfunction calculateAspectRatio () {\n const width = $('body').width()\n const height = $('body').height()\n\n function gcd (a, b) {\n return (b === 0) ? a : gcd(b, a % b)\n }\n\n const w = width\n const h = height\n const r = gcd(w, h)\n const aspectRatioPt1 = w / r\n const aspectRatioPt2 = h / r\n\n if (aspectRatioPt1 < aspectRatioPt2) {\n aspectRatio = '9:16'\n } else if (aspectRatioPt1 === 8 && aspectRatioPt2 === 5) {\n aspectRatio = '16:10'\n } else if (aspectRatioPt1 === 16 && aspectRatioPt2 === 9) {\n aspectRatio = '16:9'\n } else {\n aspectRatio = w < 1420 ? '16:10' : '16:9'\n }\n}\n\nlet background = null\n\nfunction shouldEnableTouch () {\n const ua = navigator.userAgent\n if (ua.match(/surf/ig)) return false\n\n // ACP has chromium 34 and upboard 73\n const chromiumVersion = ua.match(/chromium\\/(\\d+)/i)\n const chromeVersion = ua.match(/chrome\\/(\\d+)/i)\n const chromiumPlus73 = chromiumVersion && chromiumVersion[1] >= 73\n const chromePlus73 = chromeVersion && chromeVersion[1] >= 73\n\n return chromiumPlus73 || chromePlus73\n}\n\nfunction setAvailablePromoCodes (areThereAvailablePromoCodes) {\n if (areThereAvailablePromoCodes) {\n $('#insert-first-bill-promo-button').show()\n $('#insert-first-recycler-bills-promo-button').show()\n $('#choose-fiat-promo-button').show()\n } else {\n $('#insert-first-bill-promo-button').hide()\n $('#insert-first-recycler-bills-promo-button').hide()\n $('#choose-fiat-promo-button').hide()\n }\n}\n\nfunction setCurrentDiscount (currentDiscount, promoCodeApplied) {\n if (promoCodeApplied) {\n $('#insert-first-bill-promo-button').hide()\n $('#insert-first-recycler-bills-promo-button').hide()\n $('#choose-fiat-promo-button').hide()\n }\n\n if (!currentDiscount) {\n $('#insert-first-bill-code-added').hide()\n $('#insert-first-recycler-bills-code-added').hide()\n $('#choose-fiat-code-added').hide()\n } else if (currentDiscount > 0) {\n const successMessage = '✔ ' + translate('Discount added (%s off commissions)', [`${currentDiscount}%`])\n $('#insert-first-bill-code-added').html(successMessage)\n $('#insert-first-recycler-bills-code-added').html(successMessage)\n $('#choose-fiat-code-added').html(successMessage)\n $('#insert-first-bill-code-added').show()\n $('#insert-first-recycler-bills-code-added').show()\n $('#choose-fiat-code-added').show()\n\n } else {\n $('#insert-first-bill-promo-button').show()\n $('#insert-first-recycler-bills-promo-button').show()\n $('#choose-fiat-promo-button').show()\n $('#insert-first-bill-code-added').hide()\n $('#insert-first-recycler-bills-code-added').hide()\n $('#choose-fiat-code-added').hide()\n }\n}\n\nfunction setReceiptPrint (receiptStatus, smsReceiptStatus) {\n const status = receiptStatus ? receiptStatus : smsReceiptStatus\n\n const className = receiptStatus ? 'print-receipt' : 'send-sms-receipt'\n const printing = receiptStatus ? 'Printing receipt...' : 'Sending receipt...'\n const success = receiptStatus ? 'Receipt printed successfully!' : 'Receipt sent successfully!'\n\n switch (status) {\n case 'disabled':\n $(`#${className}-cash-in-message`).addClass('hide')\n $(`#${className}-cash-in-button`).addClass('hide')\n $(`#${className}-cash-out-message`).addClass('hide')\n $(`#${className}-cash-out-button`).addClass('hide')\n $(`#${className}-cash-in-fail-message`).addClass('hide')\n $(`#${className}-cash-in-fail-button`).addClass('hide')\n break\n case 'available':\n $(`#${className}-cash-in-message`).addClass('hide')\n $(`#${className}-cash-in-button`).removeClass('hide')\n $(`#${className}-cash-out-message`).addClass('hide')\n $(`#${className}-cash-out-button`).removeClass('hide')\n $(`#${className}-cash-in-fail-message`).addClass('hide')\n $(`#${className}-cash-in-fail-button`).removeClass('hide')\n break\n case 'printing':\n const message = locale.translate(printing).fetch()\n $(`#${className}-cash-in-button`).addClass('hide')\n $(`#${className}-cash-in-message`).html(message)\n $(`#${className}-cash-in-message`).removeClass('hide')\n $(`#${className}-cash-out-button`).addClass('hide')\n $(`#${className}-cash-out-message`).html(message)\n $(`#${className}-cash-out-message`).removeClass('hide')\n $(`#${className}-cash-in-fail-button`).addClass('hide')\n $(`#${className}-cash-in-fail-message`).html(message)\n $(`#${className}-cash-in-fail-message`).removeClass('hide')\n break\n case 'success':\n const successMessage = '✔ ' + locale.translate(success).fetch()\n $(`#${className}-cash-in-button`).addClass('hide')\n $(`#${className}-cash-in-message`).html(successMessage)\n $(`#${className}-cash-in-message`).removeClass('hide')\n $(`#${className}-cash-out-button`).addClass('hide')\n $(`#${className}-cash-out-message`).html(successMessage)\n $(`#${className}-cash-out-message`).removeClass('hide')\n $(`#${className}-cash-in-fail-button`).addClass('hide')\n $(`#${className}-cash-in-fail-message`).html(successMessage)\n $(`#${className}-cash-in-fail-message`).removeClass('hide')\n break\n case 'failed':\n const failMessage = '✖ ' + locale.translate('An error occurred, try again.').fetch()\n $(`#${className}-cash-in-button`).addClass('hide')\n $(`#${className}-cash-in-message`).html(failMessage)\n $(`#${className}-cash-in-message`).removeClass('hide')\n $(`#${className}-cash-out-button`).addClass('hide')\n $(`#${className}-cash-out-message`).html(failMessage)\n $(`#${className}-cash-out-message`).removeClass('hide')\n $(`#${className}-cash-in-fail-button`).addClass('hide')\n $(`#${className}-cash-in-fail-message`).html(failMessage)\n $(`#${className}-cash-in-fail-message`).removeClass('hide')\n break\n }\n}\n\nfunction externalCompliance (url) {\n qrize(url, $('#qr-code-external-validation'), cashDirection === 'cashIn' ? CASH_IN_QR_COLOR : CASH_OUT_QR_COLOR)\n return setScreen('external_compliance')\n}\n\nfunction setScreenOptions (opts) {\n (opts.rates && opts.rates.active) ? $('#rates-section').show() : $('#rates-section').hide()\n}\n\nfunction thousandSeparator (number, country, minimumFractionDigits) {\n const numberFormatter = Intl.NumberFormat(country, { minimumFractionDigits })\n return numberFormatter.format(number)\n}\n\nfunction setRates (allRates, fiat) {\n const ratesTable = $('.rates-content')\n const tableHeader = $(`\n
${translate('Buy')}
\n ${translate('Crypto')}
\n ${translate('Sell')}
\n`)\n const coinEntries = []\n\n Object.keys(allRates).forEach(it => {\n const cashIn = BN(allRates[it].cashIn)\n const cashOut = BN(allRates[it].cashOut)\n const biggestDecimalPlaces = Math.max(cashIn.dp(), cashOut.dp())\n\n coinEntries.push($(`\n
${thousandSeparator(BN(allRates[it].cashIn).toFixed(2), localeCode)}
\n
${it}
\n
${thousandSeparator(BN(allRates[it].cashOut).toFixed(2), localeCode)}
\n
`))\n })\n\n $('#rates-fiat-currency').text(fiat)\n ratesTable.empty().append(tableHeader).append(coinEntries)\n}\n"]}
\ No newline at end of file
diff --git a/ui/js/docker-app.js b/ui/js/docker-app.js
index ab5ea8474..9bcbee041 100644
--- a/ui/js/docker-app.js
+++ b/ui/js/docker-app.js
@@ -93,6 +93,7 @@ var LN = 'LN';
var BTC = 'BTC';
function processData(data) {
+ if (data.screenOpts) setScreenOptions(data.screenOpts);
if (data.localeInfo) setLocaleInfo(data.localeInfo);
if (data.locale) setLocale(data.locale);
if (data.supportedCoins) setCoins(data.supportedCoins);
@@ -112,7 +113,9 @@ function processData(data) {
if (data.cassettes) buildCassetteButtons(data.cassettes, NUMBER_OF_BUTTONS);
if (data.readingBills) readingBills(data.readingBills);
if (data.cryptoCode) translateCoin(data.cryptoCode);
- if (data.tx && data.tx.cashInFee) setFixedFee(data.tx.cashInFee);
+ if (data.tx) {
+ if (data.tx.cashInFee) setFixedFee(data.tx.cashInFee);else if (data.tx.cashOutFee) setFixedFee(data.tx.cashOutFee);
+ }
if (data.terms) setTermsScreen(data.terms);
if (data.dispenseBatch) dispenseBatch(data.dispenseBatch);
if (data.direction) setDirection(data.direction);
@@ -120,6 +123,7 @@ function processData(data) {
if (data.hardLimit) setHardLimit(data.hardLimit);
if (data.cryptomatModel) setCryptomatModel(data.cryptomatModel);
if (data.areThereAvailablePromoCodes !== undefined) setAvailablePromoCodes(data.areThereAvailablePromoCodes);
+ if (data.allRates && data.ratesFiat) setRates(data.allRates, data.ratesFiat);
if (data.tx && data.tx.discount) setCurrentDiscount(data.tx.discount);
if (data.receiptStatus) setReceiptPrint(data.receiptStatus, null);
@@ -298,6 +302,9 @@ function processData(data) {
clearTimeout(complianceTimeout);
externalCompliance(data.externalComplianceUrl);
break;
+ case 'rates':
+ setState('rates');
+ break;
default:
if (data.action) setState(window.snakecase(data.action));
}
@@ -843,6 +850,9 @@ $(document).ready(function () {
setupButton('terms-ok', 'termsAccepted');
setupButton('terms-ko', 'idle');
+ setupImmediateButton('rates-close', 'idle');
+ setupButton('rates-section-button', 'ratesScreen');
+
setupButton('maintenance_restart', 'maintenanceRestart');
calculateAspectRatio();
@@ -2036,4 +2046,30 @@ function externalCompliance(url) {
qrize(url, $('#qr-code-external-validation'), cashDirection === 'cashIn' ? CASH_IN_QR_COLOR : CASH_OUT_QR_COLOR);
return setScreen('external_compliance');
}
+
+function setScreenOptions(opts) {
+ opts.rates && opts.rates.active ? $('#rates-section').show() : $('#rates-section').hide();
+}
+
+function thousandSeparator(number, country, minimumFractionDigits) {
+ var numberFormatter = Intl.NumberFormat(country, { minimumFractionDigits: minimumFractionDigits });
+ return numberFormatter.format(number);
+}
+
+function setRates(allRates, fiat) {
+ var ratesTable = $('.rates-content');
+ var tableHeader = $('\n
' + translate('Buy') + '
\n ' + translate('Crypto') + '
\n ' + translate('Sell') + '
\n');
+ var coinEntries = [];
+
+ Object.keys(allRates).forEach(function (it) {
+ var cashIn = BN(allRates[it].cashIn);
+ var cashOut = BN(allRates[it].cashOut);
+ var biggestDecimalPlaces = Math.max(cashIn.dp(), cashOut.dp());
+
+ coinEntries.push($('\n
' + thousandSeparator(BN(allRates[it].cashIn).toFixed(2), localeCode) + '
\n
' + it + '
\n
' + thousandSeparator(BN(allRates[it].cashOut).toFixed(2), localeCode) + '
\n
'));
+ });
+
+ $('#rates-fiat-currency').text(fiat);
+ ratesTable.empty().append(tableHeader).append(coinEntries);
+}
//# sourceMappingURL=app.js.map
\ No newline at end of file
diff --git a/ui/main.css b/ui/main.css
index 45e592225..e625676d5 100644
--- a/ui/main.css
+++ b/ui/main.css
@@ -2219,6 +2219,10 @@ footer {
width: 30vh;
}
+.rates-section {
+ margin-left: 2em;
+}
+
#change-language-section #language-dropdown-toggle {
-webkit-box-align: center;
-webkit-align-items: center;
@@ -2976,6 +2980,10 @@ footer {
-webkit-justify-content: flex-end;
justify-content: flex-end;
}
+.i18n-rtl .rates-section {
+ margin-left: 0;
+ margin-right: 2em;
+}
.send-only-total {
margin-bottom: 6vh;
diff --git a/ui/src/app.js b/ui/src/app.js
index d519cd63c..1835906bc 100644
--- a/ui/src/app.js
+++ b/ui/src/app.js
@@ -90,6 +90,7 @@ const LN = 'LN'
const BTC = 'BTC'
function processData (data) {
+ if (data.screenOpts) setScreenOptions(data.screenOpts)
if (data.localeInfo) setLocaleInfo(data.localeInfo)
if (data.locale) setLocale(data.locale)
if (data.supportedCoins) setCoins(data.supportedCoins)
@@ -120,6 +121,7 @@ function processData (data) {
if (data.hardLimit) setHardLimit(data.hardLimit)
if (data.cryptomatModel) setCryptomatModel(data.cryptomatModel)
if (data.areThereAvailablePromoCodes !== undefined) setAvailablePromoCodes(data.areThereAvailablePromoCodes)
+ if (data.allRates && data.ratesFiat) setRates(data.allRates, data.ratesFiat)
if (data.tx && data.tx.discount) setCurrentDiscount(data.tx.discount)
if (data.receiptStatus) setReceiptPrint(data.receiptStatus, null)
@@ -298,6 +300,9 @@ function processData (data) {
clearTimeout(complianceTimeout)
externalCompliance(data.externalComplianceUrl)
break
+ case 'rates':
+ setState('rates')
+ break
default:
if (data.action) setState(window.snakecase(data.action))
}
@@ -859,6 +864,9 @@ $(document).ready(function () {
setupButton('terms-ok', 'termsAccepted')
setupButton('terms-ko', 'idle')
+ setupImmediateButton('rates-close', 'idle')
+ setupButton('rates-section-button', 'ratesScreen')
+
setupButton('maintenance_restart', 'maintenanceRestart')
calculateAspectRatio()
@@ -2088,3 +2096,37 @@ function externalCompliance (url) {
qrize(url, $('#qr-code-external-validation'), cashDirection === 'cashIn' ? CASH_IN_QR_COLOR : CASH_OUT_QR_COLOR)
return setScreen('external_compliance')
}
+
+function setScreenOptions (opts) {
+ (opts.rates && opts.rates.active) ? $('#rates-section').show() : $('#rates-section').hide()
+}
+
+function thousandSeparator (number, country, minimumFractionDigits) {
+ const numberFormatter = Intl.NumberFormat(country, { minimumFractionDigits })
+ return numberFormatter.format(number)
+}
+
+function setRates (allRates, fiat) {
+ const ratesTable = $('.rates-content')
+ const tableHeader = $(`
+
${translate('Buy')}
+ ${translate('Crypto')}
+ ${translate('Sell')}
+`)
+ const coinEntries = []
+
+ Object.keys(allRates).forEach(it => {
+ const cashIn = BN(allRates[it].cashIn)
+ const cashOut = BN(allRates[it].cashOut)
+ const biggestDecimalPlaces = Math.max(cashIn.dp(), cashOut.dp())
+
+ coinEntries.push($(`
+
${thousandSeparator(BN(allRates[it].cashIn).toFixed(2), localeCode)}
+
${it}
+
${thousandSeparator(BN(allRates[it].cashOut).toFixed(2), localeCode)}
+
`))
+ })
+
+ $('#rates-fiat-currency').text(fiat)
+ ratesTable.empty().append(tableHeader).append(coinEntries)
+}
diff --git a/ui/start-docker.html b/ui/start-docker.html
index b419e8072..b3b225276 100644
--- a/ui/start-docker.html
+++ b/ui/start-docker.html
@@ -283,6 +283,11 @@ Selling unavailable for this coin
+
@@ -1887,6 +1892,32 @@ Promo code not found
+
+
+
+
+
+
+
+
Buy
+ Crypto
+ Sell
+
+
+
+
Selling unavailable for this coin
+
@@ -1887,6 +1892,32 @@ Promo code not found
+
+
+
+
+
+
+
+
Buy
+ Crypto
+ Sell
+
+
+
+
Selling unavailable for this coin
+
@@ -1887,6 +1892,32 @@ Promo code not found
+
+
+
+
+
+
+
+
Buy
+ Crypto
+ Sell
+
+
+
+