aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2016-09-23 23:29:54 +0200
committerFlorian Dold <florian.dold@gmail.com>2016-09-23 23:29:58 +0200
commit6b8833e7662a5a0a0dd82c0b6bb87ebd82f2b65a (patch)
treeafd2f639c263a832331442ff82ef3c7d27bbdec7
parent9305ae23843f6c8ee69ed7c2bea9079f5ceb9013 (diff)
downloadwallet-core-6b8833e7662a5a0a0dd82c0b6bb87ebd82f2b65a.tar.xz
playground files
-rw-r--r--lib/wallet/chromeBadge.ts18
-rw-r--r--playground/README1
-rw-r--r--playground/animation.html34
3 files changed, 46 insertions, 7 deletions
diff --git a/lib/wallet/chromeBadge.ts b/lib/wallet/chromeBadge.ts
index a6e17c3d9..3d1f816d9 100644
--- a/lib/wallet/chromeBadge.ts
+++ b/lib/wallet/chromeBadge.ts
@@ -44,8 +44,9 @@ export class ChromeBadge implements Badge {
rotationAngle: number = 0;
static rotationAngleMax = 1000;
- constructor() {
- let bg = chrome.extension.getBackgroundPage();
+ constructor(window?: Window) {
+ // Allow injecting another window for testing
+ let bg = window || chrome.extension.getBackgroundPage();
this.canvas = bg.document.createElement("canvas");
this.canvas.width = 32;
this.canvas.height = 32;
@@ -76,11 +77,14 @@ export class ChromeBadge implements Badge {
this.talerLogo.height,
0, 0, this.canvas.width, this.canvas.height);
- let imageData = this.ctx.getImageData(0,
- 0,
- this.canvas.width,
- this.canvas.height);
- chrome.browserAction.setIcon({imageData});
+ // Allow running outside the extension for testing
+ if (chrome && chrome.browserAction) {
+ let imageData = this.ctx.getImageData(0,
+ 0,
+ this.canvas.width,
+ this.canvas.height);
+ chrome.browserAction.setIcon({imageData});
+ }
}
private animate() {
diff --git a/playground/README b/playground/README
new file mode 100644
index 000000000..9c3d9704a
--- /dev/null
+++ b/playground/README
@@ -0,0 +1 @@
+Contains files with small experiments / prototypes for designers.
diff --git a/playground/animation.html b/playground/animation.html
new file mode 100644
index 000000000..eec913c65
--- /dev/null
+++ b/playground/animation.html
@@ -0,0 +1,34 @@
+<!doctype html>
+<html>
+ <head>
+ <title>Spinner playground</title>
+ <script src="../lib/vendor/system-csp-production.src.js"></script>
+ </head>
+ <html>
+ <div style="display: none;">
+ <img src="../img/icon.png" id="taler-logo" style="display:hidden;">
+ </div>
+ <br />
+ <div id="container"></div>
+ <script>
+ "use strict";
+
+ System.config({
+ defaultJSExtensions: true,
+ });
+
+ System.import("../lib/wallet/chromeBadge")
+ .then((badge) => {
+ let b = new badge.ChromeBadge(window);
+ window.badge = b;
+ document.getElementById("container").appendChild(b.canvas);
+ })
+ .catch((e) => {
+ console.error(e.stack);
+ });
+ </script>
+ <br />
+ <button onclick="badge.startBusy()">start</button>
+ <button onclick="badge.stopBusy()">stop</button>
+ </html>
+</html>