fix linter errors

This commit is contained in:
Florian Dold 2017-05-29 15:18:48 +02:00
parent 2e9ecf952d
commit d0e0c6baf2
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
10 changed files with 234 additions and 212 deletions

View File

@ -51,7 +51,7 @@ function toI18nString(strings: ReadonlyArray<string>) {
for (let i = 0; i < strings.length; i++) { for (let i = 0; i < strings.length; i++) {
str += strings[i]; str += strings[i];
if (i < strings.length - 1) { if (i < strings.length - 1) {
str += "%"+ (i+1) +"$s"; str += `%${i + 1}$s`;
} }
} }
return str; return str;
@ -196,8 +196,8 @@ export class TranslatePlural extends React.Component<TranslationPluralProps,void
let tr = jed.ngettext(s, s, 1).split(/%(\d+)\$s/).filter((e: any, i: number) => i % 2 == 0); let tr = jed.ngettext(s, s, 1).split(/%(\d+)\$s/).filter((e: any, i: number) => i % 2 == 0);
let childArray = React.Children.toArray(this.props.children!); let childArray = React.Children.toArray(this.props.children!);
for (let i = 0; i < childArray.length - 1; ++i) { for (let i = 0; i < childArray.length - 1; ++i) {
if ((typeof childArray[i]) == "string" && (typeof childArray[i+1]) == "string") { if ((typeof childArray[i]) == "string" && (typeof childArray[i + 1]) == "string") {
childArray[i+i] = childArray[i] as string + childArray[i+1] as string; childArray[i+i] = childArray[i] as string + childArray[i + 1] as string;
childArray.splice(i,1); childArray.splice(i,1);
} }
} }
@ -228,8 +228,8 @@ export class TranslateSingular extends React.Component<TranslationPluralProps,vo
let tr = jed.ngettext(s, s, 1).split(/%(\d+)\$s/).filter((e: any, i: number) => i % 2 == 0); let tr = jed.ngettext(s, s, 1).split(/%(\d+)\$s/).filter((e: any, i: number) => i % 2 == 0);
let childArray = React.Children.toArray(this.props.children!); let childArray = React.Children.toArray(this.props.children!);
for (let i = 0; i < childArray.length - 1; ++i) { for (let i = 0; i < childArray.length - 1; ++i) {
if ((typeof childArray[i]) == "string" && (typeof childArray[i+1]) == "string") { if ((typeof childArray[i]) == "string" && (typeof childArray[i + 1]) == "string") {
childArray[i+i] = childArray[i] as string + childArray[i+1] as string; childArray[i+i] = childArray[i] as string + childArray[i + 1] as string;
childArray.splice(i,1); childArray.splice(i,1);
} }
} }

View File

@ -197,91 +197,91 @@ msgstr ""
msgid "Fatal error: \"%1$s\"." msgid "Fatal error: \"%1$s\"."
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:160 #: src/webex/pages/popup.tsx:163
#, c-format #, c-format
msgid "Balance" msgid "Balance"
msgstr "Saldo" msgstr "Saldo"
#: src/webex/pages/popup.tsx:163 #: src/webex/pages/popup.tsx:166
#, c-format #, c-format
msgid "History" msgid "History"
msgstr "Verlauf" msgstr "Verlauf"
#: src/webex/pages/popup.tsx:166 #: src/webex/pages/popup.tsx:169
#, c-format #, c-format
msgid "Debug" msgid "Debug"
msgstr "Debug" msgstr "Debug"
#: src/webex/pages/popup.tsx:238 #: src/webex/pages/popup.tsx:241
#, c-format #, c-format
msgid "help" msgid "help"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:243 #: src/webex/pages/popup.tsx:246
#, fuzzy, c-format #, fuzzy, c-format
msgid "" msgid ""
"You have no balance to show. Need some\n" "You have no balance to show. Need some\n"
" %1$s getting started?\n" " %1$s getting started?\n"
msgstr "Sie haben kein Digitalgeld. Wollen Sie %1$s? abheben?" msgstr "Sie haben kein Digitalgeld. Wollen Sie %1$s? abheben?"
#: src/webex/pages/popup.tsx:260 #: src/webex/pages/popup.tsx:263
#, c-format #, c-format
msgid "%1$s incoming\n" msgid "%1$s incoming\n"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:273 #: src/webex/pages/popup.tsx:276
#, c-format #, c-format
msgid "%1$s being spent\n" msgid "%1$s being spent\n"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:299 #: src/webex/pages/popup.tsx:302
#, c-format #, c-format
msgid "Error: could not retrieve balance information." msgid "Error: could not retrieve balance information."
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:340 #: src/webex/pages/popup.tsx:343
#, fuzzy, c-format #, fuzzy, c-format
msgid "Bank requested reserve (%1$s) for%2$s.\n" msgid "Bank requested reserve (%1$s) for%2$s.\n"
msgstr "Bank bestätig anlegen der Reserve (%1$s) bei %2$s" msgstr "Bank bestätig anlegen der Reserve (%1$s) bei %2$s"
#: src/webex/pages/popup.tsx:349 #: src/webex/pages/popup.tsx:352
#, fuzzy, c-format #, fuzzy, c-format
msgid "" msgid ""
"Started to withdraw\n" "Started to withdraw\n"
" %1$s from%2$s(%3$s).\n" " %1$s from%2$s(%3$s).\n"
msgstr "Reserve (%1$s) mit %2$s bei %3$s erzeugt" msgstr "Reserve (%1$s) mit %2$s bei %3$s erzeugt"
#: src/webex/pages/popup.tsx:361 #: src/webex/pages/popup.tsx:364
#, c-format #, c-format
msgid "Merchant%1$soffered contract%2$s;\n" msgid "Merchant%1$soffered contract%2$s;\n"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:371 #: src/webex/pages/popup.tsx:374
#, fuzzy, c-format #, fuzzy, c-format
msgid "Withdrew%1$sfrom%2$s(%3$s).\n" msgid "Withdrew%1$sfrom%2$s(%3$s).\n"
msgstr "Reserve (%1$s) mit %2$s bei %3$s erzeugt" msgstr "Reserve (%1$s) mit %2$s bei %3$s erzeugt"
#: src/webex/pages/popup.tsx:381 #: src/webex/pages/popup.tsx:384
#, fuzzy, c-format #, fuzzy, c-format
msgid "Paid%1$sto merchant%2$s. (%3$s)\n" msgid "Paid%1$sto merchant%2$s. (%3$s)\n"
msgstr "Reserve (%1$s) mit %2$s bei %3$s erzeugt" msgstr "Reserve (%1$s) mit %2$s bei %3$s erzeugt"
#: src/webex/pages/popup.tsx:388 #: src/webex/pages/popup.tsx:391
#, c-format #, c-format
msgid "Unknown event (%1$s)" msgid "Unknown event (%1$s)"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:431 #: src/webex/pages/popup.tsx:434
#, c-format #, c-format
msgid "Error: could not retrieve event history" msgid "Error: could not retrieve event history"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:465 #: src/webex/pages/popup.tsx:468
#, c-format #, c-format
msgid "Your wallet has no events recorded." msgid "Your wallet has no events recorded."
msgstr "Ihre Geldbörse verzeichnet keine Vorkommnisse." msgstr "Ihre Geldbörse verzeichnet keine Vorkommnisse."
#: src/webex/renderHtml.tsx:49 #: src/webex/renderHtml.tsx:51
#, fuzzy, c-format #, fuzzy, c-format
msgid "The merchant%1$swants to enter a contract over%2$s with you.\n" msgid "The merchant%1$swants to enter a contract over%2$s with you.\n"
msgstr "" msgstr ""
@ -289,7 +289,7 @@ msgstr ""
" möchte einen Vertrag über %2$s\n" " möchte einen Vertrag über %2$s\n"
" mit Ihnen abschließen." " mit Ihnen abschließen."
#: src/webex/renderHtml.tsx:54 #: src/webex/renderHtml.tsx:56
#, fuzzy, c-format #, fuzzy, c-format
msgid "You are about to purchase:" msgid "You are about to purchase:"
msgstr "Sie sind dabei, Folgendes zu kaufen:" msgstr "Sie sind dabei, Folgendes zu kaufen:"

View File

@ -197,96 +197,96 @@ msgstr ""
msgid "Fatal error: \"%1$s\"." msgid "Fatal error: \"%1$s\"."
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:160 #: src/webex/pages/popup.tsx:163
#, c-format #, c-format
msgid "Balance" msgid "Balance"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:163 #: src/webex/pages/popup.tsx:166
#, c-format #, c-format
msgid "History" msgid "History"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:166 #: src/webex/pages/popup.tsx:169
#, c-format #, c-format
msgid "Debug" msgid "Debug"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:238 #: src/webex/pages/popup.tsx:241
#, c-format #, c-format
msgid "help" msgid "help"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:243 #: src/webex/pages/popup.tsx:246
#, c-format #, c-format
msgid "" msgid ""
"You have no balance to show. Need some\n" "You have no balance to show. Need some\n"
" %1$s getting started?\n" " %1$s getting started?\n"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:260 #: src/webex/pages/popup.tsx:263
#, c-format #, c-format
msgid "%1$s incoming\n" msgid "%1$s incoming\n"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:273 #: src/webex/pages/popup.tsx:276
#, c-format #, c-format
msgid "%1$s being spent\n" msgid "%1$s being spent\n"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:299 #: src/webex/pages/popup.tsx:302
#, c-format #, c-format
msgid "Error: could not retrieve balance information." msgid "Error: could not retrieve balance information."
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:340 #: src/webex/pages/popup.tsx:343
#, c-format #, c-format
msgid "Bank requested reserve (%1$s) for%2$s.\n" msgid "Bank requested reserve (%1$s) for%2$s.\n"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:349 #: src/webex/pages/popup.tsx:352
#, c-format #, c-format
msgid "" msgid ""
"Started to withdraw\n" "Started to withdraw\n"
" %1$s from%2$s(%3$s).\n" " %1$s from%2$s(%3$s).\n"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:361 #: src/webex/pages/popup.tsx:364
#, c-format #, c-format
msgid "Merchant%1$soffered contract%2$s;\n" msgid "Merchant%1$soffered contract%2$s;\n"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:371 #: src/webex/pages/popup.tsx:374
#, c-format #, c-format
msgid "Withdrew%1$sfrom%2$s(%3$s).\n" msgid "Withdrew%1$sfrom%2$s(%3$s).\n"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:381 #: src/webex/pages/popup.tsx:384
#, c-format #, c-format
msgid "Paid%1$sto merchant%2$s. (%3$s)\n" msgid "Paid%1$sto merchant%2$s. (%3$s)\n"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:388 #: src/webex/pages/popup.tsx:391
#, c-format #, c-format
msgid "Unknown event (%1$s)" msgid "Unknown event (%1$s)"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:431 #: src/webex/pages/popup.tsx:434
#, c-format #, c-format
msgid "Error: could not retrieve event history" msgid "Error: could not retrieve event history"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:465 #: src/webex/pages/popup.tsx:468
#, c-format #, c-format
msgid "Your wallet has no events recorded." msgid "Your wallet has no events recorded."
msgstr "" msgstr ""
#: src/webex/renderHtml.tsx:49 #: src/webex/renderHtml.tsx:51
#, c-format #, c-format
msgid "The merchant%1$swants to enter a contract over%2$s with you.\n" msgid "The merchant%1$swants to enter a contract over%2$s with you.\n"
msgstr "" msgstr ""
#: src/webex/renderHtml.tsx:54 #: src/webex/renderHtml.tsx:56
#, c-format #, c-format
msgid "You are about to purchase:" msgid "You are about to purchase:"
msgstr "" msgstr ""

View File

@ -197,96 +197,96 @@ msgstr ""
msgid "Fatal error: \"%1$s\"." msgid "Fatal error: \"%1$s\"."
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:160 #: src/webex/pages/popup.tsx:163
#, c-format #, c-format
msgid "Balance" msgid "Balance"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:163 #: src/webex/pages/popup.tsx:166
#, c-format #, c-format
msgid "History" msgid "History"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:166 #: src/webex/pages/popup.tsx:169
#, c-format #, c-format
msgid "Debug" msgid "Debug"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:238 #: src/webex/pages/popup.tsx:241
#, c-format #, c-format
msgid "help" msgid "help"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:243 #: src/webex/pages/popup.tsx:246
#, c-format #, c-format
msgid "" msgid ""
"You have no balance to show. Need some\n" "You have no balance to show. Need some\n"
" %1$s getting started?\n" " %1$s getting started?\n"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:260 #: src/webex/pages/popup.tsx:263
#, c-format #, c-format
msgid "%1$s incoming\n" msgid "%1$s incoming\n"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:273 #: src/webex/pages/popup.tsx:276
#, c-format #, c-format
msgid "%1$s being spent\n" msgid "%1$s being spent\n"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:299 #: src/webex/pages/popup.tsx:302
#, c-format #, c-format
msgid "Error: could not retrieve balance information." msgid "Error: could not retrieve balance information."
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:340 #: src/webex/pages/popup.tsx:343
#, c-format #, c-format
msgid "Bank requested reserve (%1$s) for%2$s.\n" msgid "Bank requested reserve (%1$s) for%2$s.\n"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:349 #: src/webex/pages/popup.tsx:352
#, c-format #, c-format
msgid "" msgid ""
"Started to withdraw\n" "Started to withdraw\n"
" %1$s from%2$s(%3$s).\n" " %1$s from%2$s(%3$s).\n"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:361 #: src/webex/pages/popup.tsx:364
#, c-format #, c-format
msgid "Merchant%1$soffered contract%2$s;\n" msgid "Merchant%1$soffered contract%2$s;\n"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:371 #: src/webex/pages/popup.tsx:374
#, c-format #, c-format
msgid "Withdrew%1$sfrom%2$s(%3$s).\n" msgid "Withdrew%1$sfrom%2$s(%3$s).\n"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:381 #: src/webex/pages/popup.tsx:384
#, c-format #, c-format
msgid "Paid%1$sto merchant%2$s. (%3$s)\n" msgid "Paid%1$sto merchant%2$s. (%3$s)\n"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:388 #: src/webex/pages/popup.tsx:391
#, c-format #, c-format
msgid "Unknown event (%1$s)" msgid "Unknown event (%1$s)"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:431 #: src/webex/pages/popup.tsx:434
#, c-format #, c-format
msgid "Error: could not retrieve event history" msgid "Error: could not retrieve event history"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:465 #: src/webex/pages/popup.tsx:468
#, c-format #, c-format
msgid "Your wallet has no events recorded." msgid "Your wallet has no events recorded."
msgstr "" msgstr ""
#: src/webex/renderHtml.tsx:49 #: src/webex/renderHtml.tsx:51
#, c-format #, c-format
msgid "The merchant%1$swants to enter a contract over%2$s with you.\n" msgid "The merchant%1$swants to enter a contract over%2$s with you.\n"
msgstr "" msgstr ""
#: src/webex/renderHtml.tsx:54 #: src/webex/renderHtml.tsx:56
#, c-format #, c-format
msgid "You are about to purchase:" msgid "You are about to purchase:"
msgstr "" msgstr ""

View File

@ -197,96 +197,96 @@ msgstr ""
msgid "Fatal error: \"%1$s\"." msgid "Fatal error: \"%1$s\"."
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:160 #: src/webex/pages/popup.tsx:163
#, c-format #, c-format
msgid "Balance" msgid "Balance"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:163 #: src/webex/pages/popup.tsx:166
#, c-format #, c-format
msgid "History" msgid "History"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:166 #: src/webex/pages/popup.tsx:169
#, c-format #, c-format
msgid "Debug" msgid "Debug"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:238 #: src/webex/pages/popup.tsx:241
#, c-format #, c-format
msgid "help" msgid "help"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:243 #: src/webex/pages/popup.tsx:246
#, c-format #, c-format
msgid "" msgid ""
"You have no balance to show. Need some\n" "You have no balance to show. Need some\n"
" %1$s getting started?\n" " %1$s getting started?\n"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:260 #: src/webex/pages/popup.tsx:263
#, c-format #, c-format
msgid "%1$s incoming\n" msgid "%1$s incoming\n"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:273 #: src/webex/pages/popup.tsx:276
#, c-format #, c-format
msgid "%1$s being spent\n" msgid "%1$s being spent\n"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:299 #: src/webex/pages/popup.tsx:302
#, c-format #, c-format
msgid "Error: could not retrieve balance information." msgid "Error: could not retrieve balance information."
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:340 #: src/webex/pages/popup.tsx:343
#, c-format #, c-format
msgid "Bank requested reserve (%1$s) for%2$s.\n" msgid "Bank requested reserve (%1$s) for%2$s.\n"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:349 #: src/webex/pages/popup.tsx:352
#, c-format #, c-format
msgid "" msgid ""
"Started to withdraw\n" "Started to withdraw\n"
" %1$s from%2$s(%3$s).\n" " %1$s from%2$s(%3$s).\n"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:361 #: src/webex/pages/popup.tsx:364
#, c-format #, c-format
msgid "Merchant%1$soffered contract%2$s;\n" msgid "Merchant%1$soffered contract%2$s;\n"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:371 #: src/webex/pages/popup.tsx:374
#, c-format #, c-format
msgid "Withdrew%1$sfrom%2$s(%3$s).\n" msgid "Withdrew%1$sfrom%2$s(%3$s).\n"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:381 #: src/webex/pages/popup.tsx:384
#, c-format #, c-format
msgid "Paid%1$sto merchant%2$s. (%3$s)\n" msgid "Paid%1$sto merchant%2$s. (%3$s)\n"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:388 #: src/webex/pages/popup.tsx:391
#, c-format #, c-format
msgid "Unknown event (%1$s)" msgid "Unknown event (%1$s)"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:431 #: src/webex/pages/popup.tsx:434
#, c-format #, c-format
msgid "Error: could not retrieve event history" msgid "Error: could not retrieve event history"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:465 #: src/webex/pages/popup.tsx:468
#, c-format #, c-format
msgid "Your wallet has no events recorded." msgid "Your wallet has no events recorded."
msgstr "" msgstr ""
#: src/webex/renderHtml.tsx:49 #: src/webex/renderHtml.tsx:51
#, c-format #, c-format
msgid "The merchant%1$swants to enter a contract over%2$s with you.\n" msgid "The merchant%1$swants to enter a contract over%2$s with you.\n"
msgstr "" msgstr ""
#: src/webex/renderHtml.tsx:54 #: src/webex/renderHtml.tsx:56
#, c-format #, c-format
msgid "You are about to purchase:" msgid "You are about to purchase:"
msgstr "" msgstr ""

View File

@ -197,96 +197,96 @@ msgstr ""
msgid "Fatal error: \"%1$s\"." msgid "Fatal error: \"%1$s\"."
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:160 #: src/webex/pages/popup.tsx:163
#, c-format #, c-format
msgid "Balance" msgid "Balance"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:163 #: src/webex/pages/popup.tsx:166
#, c-format #, c-format
msgid "History" msgid "History"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:166 #: src/webex/pages/popup.tsx:169
#, c-format #, c-format
msgid "Debug" msgid "Debug"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:238 #: src/webex/pages/popup.tsx:241
#, c-format #, c-format
msgid "help" msgid "help"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:243 #: src/webex/pages/popup.tsx:246
#, c-format #, c-format
msgid "" msgid ""
"You have no balance to show. Need some\n" "You have no balance to show. Need some\n"
" %1$s getting started?\n" " %1$s getting started?\n"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:260 #: src/webex/pages/popup.tsx:263
#, c-format #, c-format
msgid "%1$s incoming\n" msgid "%1$s incoming\n"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:273 #: src/webex/pages/popup.tsx:276
#, c-format #, c-format
msgid "%1$s being spent\n" msgid "%1$s being spent\n"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:299 #: src/webex/pages/popup.tsx:302
#, c-format #, c-format
msgid "Error: could not retrieve balance information." msgid "Error: could not retrieve balance information."
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:340 #: src/webex/pages/popup.tsx:343
#, c-format #, c-format
msgid "Bank requested reserve (%1$s) for%2$s.\n" msgid "Bank requested reserve (%1$s) for%2$s.\n"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:349 #: src/webex/pages/popup.tsx:352
#, c-format #, c-format
msgid "" msgid ""
"Started to withdraw\n" "Started to withdraw\n"
" %1$s from%2$s(%3$s).\n" " %1$s from%2$s(%3$s).\n"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:361 #: src/webex/pages/popup.tsx:364
#, c-format #, c-format
msgid "Merchant%1$soffered contract%2$s;\n" msgid "Merchant%1$soffered contract%2$s;\n"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:371 #: src/webex/pages/popup.tsx:374
#, c-format #, c-format
msgid "Withdrew%1$sfrom%2$s(%3$s).\n" msgid "Withdrew%1$sfrom%2$s(%3$s).\n"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:381 #: src/webex/pages/popup.tsx:384
#, c-format #, c-format
msgid "Paid%1$sto merchant%2$s. (%3$s)\n" msgid "Paid%1$sto merchant%2$s. (%3$s)\n"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:388 #: src/webex/pages/popup.tsx:391
#, c-format #, c-format
msgid "Unknown event (%1$s)" msgid "Unknown event (%1$s)"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:431 #: src/webex/pages/popup.tsx:434
#, c-format #, c-format
msgid "Error: could not retrieve event history" msgid "Error: could not retrieve event history"
msgstr "" msgstr ""
#: src/webex/pages/popup.tsx:465 #: src/webex/pages/popup.tsx:468
#, c-format #, c-format
msgid "Your wallet has no events recorded." msgid "Your wallet has no events recorded."
msgstr "" msgstr ""
#: src/webex/renderHtml.tsx:49 #: src/webex/renderHtml.tsx:51
#, c-format #, c-format
msgid "The merchant%1$swants to enter a contract over%2$s with you.\n" msgid "The merchant%1$swants to enter a contract over%2$s with you.\n"
msgstr "" msgstr ""
#: src/webex/renderHtml.tsx:54 #: src/webex/renderHtml.tsx:56
#, c-format #, c-format
msgid "You are about to purchase:" msgid "You are about to purchase:"
msgstr "" msgstr ""

View File

@ -22,18 +22,21 @@
* @author Florian Dold * @author Florian Dold
*/ */
/**
"use strict"; * Imports.
*/
import { amountToPretty } from "../../helpers";
import * as i18n from "../../i18n";
import { import {
AmountJson, AmountJson,
Amounts, Amounts,
WalletBalance, WalletBalance,
WalletBalanceEntry WalletBalanceEntry,
} from "../../types"; } from "../../types";
import { HistoryRecord, HistoryLevel } from "../../wallet"; import {
import { amountToPretty } from "../../helpers"; HistoryLevel,
import * as i18n from "../../i18n"; HistoryRecord,
} from "../../wallet";
import { abbrev } from "../renderHtml"; import { abbrev } from "../renderHtml";
@ -42,18 +45,18 @@ import * as ReactDOM from "react-dom";
import URI = require("urijs"); import URI = require("urijs");
function onUpdateNotification(f: () => void): () => void { function onUpdateNotification(f: () => void): () => void {
let port = chrome.runtime.connect({name: "notifications"}); const port = chrome.runtime.connect({name: "notifications"});
let listener = (msg: any, port: any) => { const listener = () => {
f(); f();
}; };
port.onMessage.addListener(listener); port.onMessage.addListener(listener);
return () => { return () => {
port.onMessage.removeListener(listener); port.onMessage.removeListener(listener);
} };
} }
class Router extends React.Component<any,any> { class Router extends React.Component<any, any> {
static setRoute(s: string): void { static setRoute(s: string): void {
window.location.hash = s; window.location.hash = s;
} }
@ -66,21 +69,21 @@ class Router extends React.Component<any,any> {
static onRoute(f: any): () => void { static onRoute(f: any): () => void {
Router.routeHandlers.push(f); Router.routeHandlers.push(f);
return () => { return () => {
let i = Router.routeHandlers.indexOf(f); const i = Router.routeHandlers.indexOf(f);
this.routeHandlers = this.routeHandlers.splice(i, 1); this.routeHandlers = this.routeHandlers.splice(i, 1);
} };
} }
static routeHandlers: any[] = []; private static routeHandlers: any[] = [];
componentWillMount() { componentWillMount() {
console.log("router mounted"); console.log("router mounted");
window.onhashchange = () => { window.onhashchange = () => {
this.setState({}); this.setState({});
for (let f of Router.routeHandlers) { for (const f of Router.routeHandlers) {
f(); f();
} }
} };
} }
componentWillUnmount() { componentWillUnmount() {
@ -89,27 +92,27 @@ class Router extends React.Component<any,any> {
render(): JSX.Element { render(): JSX.Element {
let route = window.location.hash.substring(1); const route = window.location.hash.substring(1);
console.log("rendering route", route); console.log("rendering route", route);
let defaultChild: React.ReactChild|null = null; let defaultChild: React.ReactChild|null = null;
let foundChild: React.ReactChild|null = null; let foundChild: React.ReactChild|null = null;
React.Children.forEach(this.props.children, (child) => { React.Children.forEach(this.props.children, (child) => {
let childProps: any = (child as any).props; const childProps: any = (child as any).props;
if (!childProps) { if (!childProps) {
return; return;
} }
if (childProps["default"]) { if (childProps.default) {
defaultChild = child; defaultChild = child;
} }
if (childProps["route"] == route) { if (childProps.route === route) {
foundChild = child; foundChild = child;
} }
}) });
let child: React.ReactChild | null = foundChild || defaultChild; const child: React.ReactChild | null = foundChild || defaultChild;
if (!child) { if (!child) {
throw Error("unknown route"); throw Error("unknown route");
} }
Router.setRoute((child as any).props["route"]); Router.setRoute((child as any).props.route);
return <div>{child}</div>; return <div>{child}</div>;
} }
} }
@ -122,10 +125,10 @@ interface TabProps {
function Tab(props: TabProps) { function Tab(props: TabProps) {
let cssClass = ""; let cssClass = "";
if (props.target == Router.getRoute()) { if (props.target === Router.getRoute()) {
cssClass = "active"; cssClass = "active";
} }
let onClick = (e: React.MouseEvent<HTMLAnchorElement>) => { const onClick = (e: React.MouseEvent<HTMLAnchorElement>) => {
Router.setRoute(props.target); Router.setRoute(props.target);
e.preventDefault(); e.preventDefault();
}; };
@ -137,8 +140,8 @@ function Tab(props: TabProps) {
} }
class WalletNavBar extends React.Component<any,any> { class WalletNavBar extends React.Component<any, any> {
cancelSubscription: any; private cancelSubscription: any;
componentWillMount() { componentWillMount() {
this.cancelSubscription = Router.onRoute(() => { this.cancelSubscription = Router.onRoute(() => {
@ -171,21 +174,25 @@ class WalletNavBar extends React.Component<any,any> {
function ExtensionLink(props: any) { function ExtensionLink(props: any) {
let onClick = (e: React.MouseEvent<HTMLAnchorElement>) => { const onClick = (e: React.MouseEvent<HTMLAnchorElement>) => {
chrome.tabs.create({ chrome.tabs.create({
"url": chrome.extension.getURL(props.target) url: chrome.extension.getURL(props.target),
}); });
e.preventDefault(); e.preventDefault();
}; };
return ( return (
<a onClick={onClick} href={props.target}> <a onClick={onClick} href={props.target}>
{props.children} {props.children}
</a>) </a>
);
} }
export function bigAmount(amount: AmountJson): JSX.Element { /**
let v = amount.value + amount.fraction / Amounts.fractionalBase; * Render an amount as a large number with a small currency symbol.
*/
function bigAmount(amount: AmountJson): JSX.Element {
const v = amount.value + amount.fraction / Amounts.fractionalBase;
return ( return (
<span> <span>
<span style={{fontSize: "300%"}}>{v}</span> <span style={{fontSize: "300%"}}>{v}</span>
@ -196,10 +203,10 @@ export function bigAmount(amount: AmountJson): JSX.Element {
} }
class WalletBalanceView extends React.Component<any, any> { class WalletBalanceView extends React.Component<any, any> {
balance: WalletBalance; private balance: WalletBalance;
gotError = false; private gotError = false;
canceler: (() => void) | undefined = undefined; private canceler: (() => void) | undefined = undefined;
unmount = false; private unmount = false;
componentWillMount() { componentWillMount() {
this.canceler = onUpdateNotification(() => this.updateBalance()); this.canceler = onUpdateNotification(() => this.updateBalance());
@ -233,7 +240,7 @@ class WalletBalanceView extends React.Component<any, any> {
} }
renderEmpty(): JSX.Element { renderEmpty(): JSX.Element {
let helpLink = ( const helpLink = (
<ExtensionLink target="/src/webex/pages/help/empty-wallet.html"> <ExtensionLink target="/src/webex/pages/help/empty-wallet.html">
{i18n.str`help`} {i18n.str`help`}
</ExtensionLink> </ExtensionLink>
@ -281,20 +288,20 @@ class WalletBalanceView extends React.Component<any, any> {
); );
} }
let l = [incoming, payment].filter((x) => x !== undefined); const l = [incoming, payment].filter((x) => x !== undefined);
if (l.length == 0) { if (l.length === 0) {
return <span />; return <span />;
} }
if (l.length == 1) { if (l.length === 1) {
return <span>({l})</span> return <span>({l})</span>;
} }
return <span>({l[0]}, {l[1]})</span>; return <span>({l[0]}, {l[1]})</span>;
} }
render(): JSX.Element { render(): JSX.Element {
let wallet = this.balance; const wallet = this.balance;
if (this.gotError) { if (this.gotError) {
return i18n.str`Error: could not retrieve balance information.`; return i18n.str`Error: could not retrieve balance information.`;
} }
@ -303,9 +310,9 @@ class WalletBalanceView extends React.Component<any, any> {
} }
console.log(wallet); console.log(wallet);
let paybackAvailable = false; let paybackAvailable = false;
let listing = Object.keys(wallet).map((key) => { const listing = Object.keys(wallet).map((key) => {
let entry: WalletBalanceEntry = wallet[key]; const entry: WalletBalanceEntry = wallet[key];
if (entry.paybackAmount.value != 0 || entry.paybackAmount.fraction != 0) { if (entry.paybackAmount.value !== 0 || entry.paybackAmount.fraction !== 0) {
paybackAvailable = true; paybackAvailable = true;
} }
return ( return (
@ -316,10 +323,10 @@ class WalletBalanceView extends React.Component<any, any> {
</p> </p>
); );
}); });
let link = chrome.extension.getURL("/src/webex/pages/auditors.html"); const link = chrome.extension.getURL("/src/webex/pages/auditors.html");
let linkElem = <a className="actionLink" href={link} target="_blank">Trusted Auditors and Exchanges</a>; const linkElem = <a className="actionLink" href={link} target="_blank">Trusted Auditors and Exchanges</a>;
let paybackLink = chrome.extension.getURL("/src/webex/pages/payback.html"); const paybackLink = chrome.extension.getURL("/src/webex/pages/payback.html");
let paybackLinkElem = <a className="actionLink" href={link} target="_blank">Trusted Auditors and Exchanges</a>; const paybackLinkElem = <a className="actionLink" href={link} target="_blank">Trusted Auditors and Exchanges</a>;
return ( return (
<div> <div>
{listing.length > 0 ? listing : this.renderEmpty()} {listing.length > 0 ? listing : this.renderEmpty()}
@ -339,13 +346,15 @@ function formatHistoryItem(historyItem: HistoryRecord) {
case "create-reserve": case "create-reserve":
return ( return (
<i18n.Translate wrap="p"> <i18n.Translate wrap="p">
Bank requested reserve (<span>{abbrev(d.reservePub)}</span>) for <span>{amountToPretty(d.requestedAmount)}</span>. Bank requested reserve (<span>{abbrev(d.reservePub)}</span>) for
{" "}
<span>{amountToPretty(d.requestedAmount)}</span>.
</i18n.Translate> </i18n.Translate>
); );
case "confirm-reserve": { case "confirm-reserve": {
// FIXME: eventually remove compat fix // FIXME: eventually remove compat fix
let exchange = d.exchangeBaseUrl ? (new URI(d.exchangeBaseUrl)).host() : "??"; const exchange = d.exchangeBaseUrl ? (new URI(d.exchangeBaseUrl)).host() : "??";
let pub = abbrev(d.reservePub); const pub = abbrev(d.reservePub);
return ( return (
<i18n.Translate wrap="p"> <i18n.Translate wrap="p">
Started to withdraw Started to withdraw
@ -355,9 +364,9 @@ function formatHistoryItem(historyItem: HistoryRecord) {
); );
} }
case "offer-contract": { case "offer-contract": {
let link = chrome.extension.getURL("view-contract.html"); const link = chrome.extension.getURL("view-contract.html");
let linkElem = <a href={link}>{abbrev(d.contractHash)}</a>; const linkElem = <a href={link}>{abbrev(d.contractHash)}</a>;
let merchantElem = <em>{abbrev(d.merchantName, 15)}</em>; const merchantElem = <em>{abbrev(d.merchantName, 15)}</em>;
return ( return (
<i18n.Translate wrap="p"> <i18n.Translate wrap="p">
Merchant <em>{abbrev(d.merchantName, 15)}</em> offered contract <a href={link}>{abbrev(d.contractHash)}</a>; Merchant <em>{abbrev(d.merchantName, 15)}</em> offered contract <a href={link}>{abbrev(d.contractHash)}</a>;
@ -365,9 +374,9 @@ function formatHistoryItem(historyItem: HistoryRecord) {
); );
} }
case "depleted-reserve": { case "depleted-reserve": {
let exchange = d.exchangeBaseUrl ? (new URI(d.exchangeBaseUrl)).host() : "??"; const exchange = d.exchangeBaseUrl ? (new URI(d.exchangeBaseUrl)).host() : "??";
let amount = amountToPretty(d.requestedAmount); const amount = amountToPretty(d.requestedAmount);
let pub = abbrev(d.reservePub); const pub = abbrev(d.reservePub);
return ( return (
<i18n.Translate wrap="p"> <i18n.Translate wrap="p">
Withdrew <span>{amount}</span> from <span>{exchange}</span> (<span>{pub}</span>). Withdrew <span>{amount}</span> from <span>{exchange}</span> (<span>{pub}</span>).
@ -375,12 +384,14 @@ function formatHistoryItem(historyItem: HistoryRecord) {
); );
} }
case "pay": { case "pay": {
let url = d.fulfillmentUrl; const url = d.fulfillmentUrl;
let merchantElem = <em>{abbrev(d.merchantName, 15)}</em>; const merchantElem = <em>{abbrev(d.merchantName, 15)}</em>;
let fulfillmentLinkElem = <a href={url} onClick={openTab(url)}>view product</a>; const fulfillmentLinkElem = <a href={url} onClick={openTab(url)}>view product</a>;
return ( return (
<i18n.Translate wrap="p"> <i18n.Translate wrap="p">
Paid <span>{amountToPretty(d.amount)}</span> to merchant <span>{merchantElem}</span>. (<span>{fulfillmentLinkElem}</span>) Paid <span>{amountToPretty(d.amount)}</span> to merchant <span>{merchantElem}</span>.
{" "}
(<span>{fulfillmentLinkElem}</span>)
</i18n.Translate> </i18n.Translate>
); );
} }
@ -391,9 +402,9 @@ function formatHistoryItem(historyItem: HistoryRecord) {
class WalletHistory extends React.Component<any, any> { class WalletHistory extends React.Component<any, any> {
myHistory: any[]; private myHistory: any[];
gotError = false; private gotError = false;
unmounted = false; private unmounted = false;
componentWillMount() { componentWillMount() {
this.update(); this.update();
@ -426,7 +437,7 @@ class WalletHistory extends React.Component<any, any> {
render(): JSX.Element { render(): JSX.Element {
console.log("rendering history"); console.log("rendering history");
let history: HistoryRecord[] = this.myHistory; const history: HistoryRecord[] = this.myHistory;
if (this.gotError) { if (this.gotError) {
return i18n.str`Error: could not retrieve event history`; return i18n.str`Error: could not retrieve event history`;
} }
@ -436,18 +447,18 @@ class WalletHistory extends React.Component<any, any> {
return <span />; return <span />;
} }
let subjectMemo: {[s: string]: boolean} = {}; const subjectMemo: {[s: string]: boolean} = {};
let listing: any[] = []; const listing: any[] = [];
for (let record of history.reverse()) { for (const record of history.reverse()) {
if (record.subjectId && subjectMemo[record.subjectId]) { if (record.subjectId && subjectMemo[record.subjectId]) {
continue; continue;
} }
if (record.level != undefined && record.level < HistoryLevel.User) { if (record.level !== undefined && record.level < HistoryLevel.User) {
continue; continue;
} }
subjectMemo[record.subjectId as string] = true; subjectMemo[record.subjectId as string] = true;
let item = ( const item = (
<div className="historyItem"> <div className="historyItem">
<div className="historyDate"> <div className="historyDate">
{(new Date(record.timestamp)).toString()} {(new Date(record.timestamp)).toString()}
@ -462,7 +473,7 @@ class WalletHistory extends React.Component<any, any> {
if (listing.length > 0) { if (listing.length > 0) {
return <div className="container">{listing}</div>; return <div className="container">{listing}</div>;
} }
return <p>{i18n.str`Your wallet has no events recorded.`}</p> return <p>{i18n.str`Your wallet has no events recorded.`}</p>;
} }
} }
@ -513,24 +524,24 @@ function WalletDebug(props: any) {
function openExtensionPage(page: string) { function openExtensionPage(page: string) {
return function() { return () => {
chrome.tabs.create({ chrome.tabs.create({
"url": chrome.extension.getURL(page) url: chrome.extension.getURL(page),
}); });
} };
} }
function openTab(page: string) { function openTab(page: string) {
return function() { return () => {
chrome.tabs.create({ chrome.tabs.create({
"url": page url: page,
}); });
} };
} }
let el = ( const el = (
<div> <div>
<WalletNavBar /> <WalletNavBar />
<div style={{margin: "1em"}}> <div style={{margin: "1em"}}>
@ -545,4 +556,4 @@ let el = (
document.addEventListener("DOMContentLoaded", () => { document.addEventListener("DOMContentLoaded", () => {
ReactDOM.render(el, document.getElementById("content")!); ReactDOM.render(el, document.getElementById("content")!);
}) });

View File

@ -34,9 +34,15 @@ import {
import { ImplicitStateComponent, StateHolder } from "../components"; import { ImplicitStateComponent, StateHolder } from "../components";
import { import {
getReserves, getExchanges, getCoins, getPreCoins, getCoins,
refresh, getDenoms, payback, getDenoms,
getExchanges,
getPreCoins,
getReserves,
payback,
refresh,
} from "../wxApi"; } from "../wxApi";
import * as React from "react"; import * as React from "react";
import * as ReactDOM from "react-dom"; import * as ReactDOM from "react-dom";
@ -46,7 +52,7 @@ interface ReserveViewProps {
class ReserveView extends React.Component<ReserveViewProps, void> { class ReserveView extends React.Component<ReserveViewProps, void> {
render(): JSX.Element { render(): JSX.Element {
let r: ReserveRecord = this.props.reserve; const r: ReserveRecord = this.props.reserve;
return ( return (
<div className="tree-item"> <div className="tree-item">
<ul> <ul>
@ -71,11 +77,11 @@ interface ToggleProps {
class Toggle extends ImplicitStateComponent<ToggleProps> { class Toggle extends ImplicitStateComponent<ToggleProps> {
renderButton() { renderButton() {
let show = () => { const show = () => {
this.props.expanded(true); this.props.expanded(true);
this.setState({}); this.setState({});
}; };
let hide = () => { const hide = () => {
this.props.expanded(false); this.props.expanded(false);
this.setState({}); this.setState({});
}; };
@ -104,7 +110,7 @@ interface RefreshDialogProps {
} }
class RefreshDialog extends ImplicitStateComponent<RefreshDialogProps> { class RefreshDialog extends ImplicitStateComponent<RefreshDialogProps> {
refreshRequested = this.makeState<boolean>(false); private refreshRequested = this.makeState<boolean>(false);
render(): JSX.Element { render(): JSX.Element {
if (!this.refreshRequested()) { if (!this.refreshRequested()) {
return ( return (
@ -125,7 +131,7 @@ class RefreshDialog extends ImplicitStateComponent<RefreshDialogProps> {
class CoinView extends React.Component<CoinViewProps, void> { class CoinView extends React.Component<CoinViewProps, void> {
render() { render() {
let c = this.props.coin; const c = this.props.coin;
return ( return (
<div className="tree-item"> <div className="tree-item">
<ul> <ul>
@ -143,14 +149,13 @@ class CoinView extends React.Component<CoinViewProps, void> {
} }
interface PreCoinViewProps { interface PreCoinViewProps {
precoin: PreCoinRecord; precoin: PreCoinRecord;
} }
class PreCoinView extends React.Component<PreCoinViewProps, void> { class PreCoinView extends React.Component<PreCoinViewProps, void> {
render() { render() {
let c = this.props.precoin; const c = this.props.precoin;
return ( return (
<div className="tree-item"> <div className="tree-item">
<ul> <ul>
@ -166,8 +171,8 @@ interface CoinListProps {
} }
class CoinList extends ImplicitStateComponent<CoinListProps> { class CoinList extends ImplicitStateComponent<CoinListProps> {
coins = this.makeState<CoinRecord[] | null>(null); private coins = this.makeState<CoinRecord[] | null>(null);
expanded = this.makeState<boolean>(false); private expanded = this.makeState<boolean>(false);
constructor(props: CoinListProps) { constructor(props: CoinListProps) {
super(props); super(props);
@ -175,7 +180,7 @@ class CoinList extends ImplicitStateComponent<CoinListProps> {
} }
async update(props: CoinListProps) { async update(props: CoinListProps) {
let coins = await getCoins(props.exchangeBaseUrl); const coins = await getCoins(props.exchangeBaseUrl);
this.coins(coins); this.coins(coins);
} }
@ -205,8 +210,8 @@ interface PreCoinListProps {
} }
class PreCoinList extends ImplicitStateComponent<PreCoinListProps> { class PreCoinList extends ImplicitStateComponent<PreCoinListProps> {
precoins = this.makeState<PreCoinRecord[] | null>(null); private precoins = this.makeState<PreCoinRecord[] | null>(null);
expanded = this.makeState<boolean>(false); private expanded = this.makeState<boolean>(false);
constructor(props: PreCoinListProps) { constructor(props: PreCoinListProps) {
super(props); super(props);
@ -214,7 +219,7 @@ class PreCoinList extends ImplicitStateComponent<PreCoinListProps> {
} }
async update() { async update() {
let precoins = await getPreCoins(this.props.exchangeBaseUrl); const precoins = await getPreCoins(this.props.exchangeBaseUrl);
this.precoins(precoins); this.precoins(precoins);
} }
@ -243,8 +248,8 @@ interface ExpanderTextProps {
} }
class ExpanderText extends ImplicitStateComponent<ExpanderTextProps> { class ExpanderText extends ImplicitStateComponent<ExpanderTextProps> {
expanded = this.makeState<boolean>(false); private expanded = this.makeState<boolean>(false);
textArea: any = undefined; private textArea: any = undefined;
componentDidUpdate() { componentDidUpdate() {
if (this.expanded() && this.textArea) { if (this.expanded() && this.textArea) {
@ -258,10 +263,10 @@ class ExpanderText extends ImplicitStateComponent<ExpanderTextProps> {
return ( return (
<span onClick={() => { this.expanded(true); }}> <span onClick={() => { this.expanded(true); }}>
{(this.props.text.length <= 10) {(this.props.text.length <= 10)
? this.props.text ? this.props.text
: ( : (
<span> <span>
{this.props.text.substring(0,10)} {this.props.text.substring(0, 10)}
<span style={{textDecoration: "underline"}}>...</span> <span style={{textDecoration: "underline"}}>...</span>
</span> </span>
) )
@ -282,8 +287,8 @@ class ExpanderText extends ImplicitStateComponent<ExpanderTextProps> {
} }
class DenominationList extends ImplicitStateComponent<DenominationListProps> { class DenominationList extends ImplicitStateComponent<DenominationListProps> {
expanded = this.makeState<boolean>(false); private expanded = this.makeState<boolean>(false);
denoms = this.makeState<undefined|DenominationRecord[]>(undefined); private denoms = this.makeState<undefined|DenominationRecord[]>(undefined);
constructor(props: DenominationListProps) { constructor(props: DenominationListProps) {
super(props); super(props);
@ -291,7 +296,7 @@ class DenominationList extends ImplicitStateComponent<DenominationListProps> {
} }
async update() { async update() {
let d = await getDenoms(this.props.exchange.baseUrl); const d = await getDenoms(this.props.exchange.baseUrl);
this.denoms(d); this.denoms(d);
} }
@ -316,7 +321,7 @@ class DenominationList extends ImplicitStateComponent<DenominationListProps> {
} }
render(): JSX.Element { render(): JSX.Element {
let denoms = this.denoms() const denoms = this.denoms();
if (!denoms) { if (!denoms) {
return ( return (
<div className="tree-item"> <div className="tree-item">
@ -340,9 +345,10 @@ class DenominationList extends ImplicitStateComponent<DenominationListProps> {
} }
} }
class ReserveList extends ImplicitStateComponent<ReserveListProps> { class ReserveList extends ImplicitStateComponent<ReserveListProps> {
reserves = this.makeState<ReserveRecord[] | null>(null); private reserves = this.makeState<ReserveRecord[] | null>(null);
expanded = this.makeState<boolean>(false); private expanded = this.makeState<boolean>(false);
constructor(props: ReserveListProps) { constructor(props: ReserveListProps) {
super(props); super(props);
@ -350,7 +356,7 @@ class ReserveList extends ImplicitStateComponent<ReserveListProps> {
} }
async update() { async update() {
let reserves = await getReserves(this.props.exchangeBaseUrl); const reserves = await getReserves(this.props.exchangeBaseUrl);
this.reserves(reserves); this.reserves(reserves);
} }
@ -376,7 +382,7 @@ interface ExchangeProps {
class ExchangeView extends React.Component<ExchangeProps, void> { class ExchangeView extends React.Component<ExchangeProps, void> {
render(): JSX.Element { render(): JSX.Element {
let e = this.props.exchange; const e = this.props.exchange;
return ( return (
<div className="tree-item"> <div className="tree-item">
<ul> <ul>
@ -399,7 +405,7 @@ interface ExchangesListState {
class ExchangesList extends React.Component<any, ExchangesListState> { class ExchangesList extends React.Component<any, ExchangesListState> {
constructor() { constructor() {
super(); super();
let port = chrome.runtime.connect(); const port = chrome.runtime.connect();
port.onMessage.addListener((msg: any) => { port.onMessage.addListener((msg: any) => {
if (msg.notify) { if (msg.notify) {
console.log("got notified"); console.log("got notified");
@ -411,26 +417,26 @@ class ExchangesList extends React.Component<any, ExchangesListState> {
} }
async update() { async update() {
let exchanges = await getExchanges(); const exchanges = await getExchanges();
console.log("exchanges: ", exchanges); console.log("exchanges: ", exchanges);
this.setState({ exchanges }); this.setState({ exchanges });
} }
render(): JSX.Element { render(): JSX.Element {
let exchanges = this.state.exchanges; const exchanges = this.state.exchanges;
if (!exchanges) { if (!exchanges) {
return <span>...</span>; return <span>...</span>;
} }
return ( return (
<div className="tree-item"> <div className="tree-item">
Exchanges ({exchanges.length.toString()}): Exchanges ({exchanges.length.toString()}):
{exchanges.map(e => <ExchangeView exchange={e} />)} {exchanges.map((e) => <ExchangeView exchange={e} />)}
</div> </div>
); );
} }
} }
export function main() { function main() {
ReactDOM.render(<ExchangesList />, document.getElementById("container")!); ReactDOM.render(<ExchangesList />, document.getElementById("container")!);
} }

View File

@ -24,17 +24,19 @@
/** /**
* Imports. * Imports.
*/ */
import { amountToPretty } from "../helpers";
import * as i18n from "../i18n";
import { import {
AmountJson, AmountJson,
Amounts, Amounts,
Contract, Contract,
} from "../types"; } from "../types";
import * as i18n from "../i18n";
import { amountToPretty } from "../helpers";
import * as React from "react"; import * as React from "react";
/**
* Render contract terms for the end user to view.
*/
export function renderContract(contract: Contract): JSX.Element { export function renderContract(contract: Contract): JSX.Element {
let merchantName; let merchantName;
if (contract.merchant && contract.merchant.name) { if (contract.merchant && contract.merchant.name) {
@ -42,7 +44,7 @@ export function renderContract(contract: Contract): JSX.Element {
} else { } else {
merchantName = <strong>(pub: {contract.merchant_pub})</strong>; merchantName = <strong>(pub: {contract.merchant_pub})</strong>;
} }
let amount = <strong>{amountToPretty(contract.amount)}</strong>; const amount = <strong>{amountToPretty(contract.amount)}</strong>;
return ( return (
<div> <div>

View File

@ -33,6 +33,9 @@ module.exports = function (env) {
if (env.prod) { if (env.prod) {
base.plugins.push(new webpack.optimize.UglifyJsPlugin()); base.plugins.push(new webpack.optimize.UglifyJsPlugin());
base.plugins.push(new webpack.LoaderOptionsPlugin({minimize: true})); base.plugins.push(new webpack.LoaderOptionsPlugin({minimize: true}));
base.plugins.push(new webpack.DefinePlugin({
"process.env.NODE_ENV": JSON.stringify("production")
}));
} }
const configWebWorker = { const configWebWorker = {
entry: {"cryptoWorker": "./src/crypto/cryptoWorker.ts"}, entry: {"cryptoWorker": "./src/crypto/cryptoWorker.ts"},