Skip to content

Commit

Permalink
Up Kun Extension version and some change of Makeup
Browse files Browse the repository at this point in the history
  • Loading branch information
m-tymchyk committed Oct 15, 2017
1 parent 1441d8e commit 09d412a
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 101 deletions.
2 changes: 1 addition & 1 deletion resources/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "Kuna.io Exchange Ticker",
"version": "0.3.0",
"version": "0.3.1",
"short_name": "Kuna Ticker",
"description": "Лучший способ следить за ценой Bitcoin к Гривне.",
"content_security_policy": "script-src 'self' https://www.google-analytics.com; object-src 'self'",
Expand Down
39 changes: 39 additions & 0 deletions src/Background/BadgeController.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import * as Numeral from 'numeral';

import ExtensionPlatform from 'Core/Extension';
import {TickerInterface} from 'Core/Interfaces/TickerInterface';

const browserAction = ExtensionPlatform.getExtension().browserAction;

export default class BadgeController {

static formatTickerPrice(price: number): string {
let priceNumeral = Numeral(price);

if (price < 10) {
return '' + priceNumeral.format('0.[00]');
} else if (price < 100) {
return '' + priceNumeral.format('0,0.[0]');
} else if (price < 1000) {
return '' + priceNumeral.format('0,0.[0]');
} else if (price < 10000) {
return '' + priceNumeral.format('0.0a');
} else if (price < 1000000) {
return '' + priceNumeral.format('0a');
}

return '' + price;
}

static updateBudgetTexts(ticker: TickerInterface) {
browserAction.setBadgeText({
text: BadgeController.formatTickerPrice(ticker.price)
});

browserAction.setTitle({
title: 'Kuna Ticker: ' +
`${ticker.baseCurrency} / ${ticker.quoteCurrency}` +
` - ${Numeral(ticker.price).format(ticker.format)}`
});
}
}
Empty file added src/Background/TickerStorage.ts
Empty file.
1 change: 0 additions & 1 deletion src/Background/elseFiles.js

This file was deleted.

94 changes: 0 additions & 94 deletions src/Style/modules/dropdown.scss

This file was deleted.

1 change: 0 additions & 1 deletion src/Style/popup.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
@import "fonts";
@import "variable";
@import "cleaner";
@import "modules/dropdown";

html {
width: 300px;
Expand Down
19 changes: 19 additions & 0 deletions src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {Events} from 'Core/EventProtocol/Events';
import KunaApiClient from 'Core/Kuna/ApiClient';
import KunaTickerMap from 'Core/Kuna/TickerMap';

import BadgeController from 'Background/BadgeController';


const TickerStorage = {};

Expand Down Expand Up @@ -61,9 +63,14 @@ const updateTicker = (key) => {
event: Events.UPDATE_TICKER,
ticker: currentTicker
});

if (currentTickerKey === currentTicker.key) {
BadgeController.updateBudgetTexts(TickerStorage[key]);
}
});
};


const tickerUpdater = () => {
_.each(TickerStorage, (ticker) => updateTicker(ticker.key));
};
Expand Down Expand Up @@ -98,6 +105,14 @@ const extensionEventListener = (request, sender, sendResponse) => {
sendResponse({
currentTicker: currentTickerKey
});


try {
BadgeController.updateBudgetTexts(TickerStorage[currentTickerKey]);
} catch (error) {
console.log(error);
}

break;
}

Expand All @@ -115,6 +130,10 @@ const initBackground = () => {

tickerUpdater();
setInterval(tickerUpdater, 30000);

ExtensionPlatform.getExtension().browserAction.setBadgeBackgroundColor({
color: '#11a0ff'
});
};

document.addEventListener('DOMContentLoaded', initBackground);
5 changes: 1 addition & 4 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,7 @@ const WebpackConfig = {
alias: {
Core: Path.join(__dirname, 'src/Core'),
Popup: Path.join(__dirname, 'src/Popup'),
Background: Path.join(__dirname, 'src/Background'),

// @depracated
Library: Path.join(__dirname, 'src/Library')
Background: Path.join(__dirname, 'src/Background')
}
},
devtool: 'inline-source-map',
Expand Down

0 comments on commit 09d412a

Please sign in to comment.