chore: jslint style fixes

This commit is contained in:
Joshua Seigler 2020-01-14 21:08:08 -05:00
parent 1f09e5d682
commit e8f6b78fbe

View file

@ -1,11 +1,10 @@
'use strict';
require('babel-polyfill');
import io from 'socket.io-client';
import ColorScheme from 'color-scheme';
import { PSDENOMINATIONS, COLORS, PAINT } from './constants';
require('babel-polyfill');
export default class App {
constructor () {
this.blockList = document.getElementById('blockList');
@ -20,16 +19,15 @@ export default class App {
if (block != null) { // display one block
this.hero.classList.add('solo');
this.connectionStatus.className = 'is-loading';
var txs = [];
var pages = 1;
var prevHash = null;
const txListener = this.onTransactionBuilder(this.hero, false);
for (let i = 0; i < pages; ++i) {
await fetch(`https://insight.dash.org/insight-api/txs?block=${block}&pageNum=${i}`)
await window.fetch(`https://insight.dash.org/insight-api/txs?block=${block}&pageNum=${i}`)
.then(resp => resp.json())
.then(thisBlockData => {
if (!prevHash && thisBlockData.txs.length > 0) {
return fetch('https://insight.dash.org/insight-api/block-index/'+(thisBlockData.txs[0].blockheight - 1))
return window.fetch('https://insight.dash.org/insight-api/block-index/' + (thisBlockData.txs[0].blockheight - 1))
.then(resp => resp.json())
.then(prevBlockData => {
prevHash = prevBlockData.blockHash;
@ -49,19 +47,19 @@ export default class App {
}
this.connectionStatus.className = 'is-loaded';
} else { // live display
await fetch('https://insight.dash.org/api/status?q=getLastBlockHash')
await window.fetch('https://insight.dash.org/api/status?q=getLastBlockHash')
.then(resp => resp.json())
.then(data => {
this.blockColors = App.generateColors(data.lastblockhash);
this.applyColors(this.hero);
});
this.socket = io.connect("https://insight.dash.org:443/");
this.socket = io.connect('https://insight.dash.org:443/');
this.socket.on('connect', () => {
this.connectionStatus.className = 'is-connected';
// Join the room.
this.socket.emit('subscribe', 'inv');
})
});
this.socket.on('tx', this.onTransactionBuilder(this.hero, true).bind(this));
this.socket.on('block', this.onBlock.bind(this));
this.socket.on('disconnect', () => {
@ -105,7 +103,7 @@ export default class App {
blockLink.appendChild(document.createTextNode('🗗'));
setTimeout(() => { // to prevent 404 when WS is ahead of regular API
fetch('https://insight.dash.org/insight-api/block/' + data)
window.fetch('https://insight.dash.org/insight-api/block/' + data)
.then(resp => {
if (resp.ok) {
return resp.json();
@ -117,7 +115,7 @@ export default class App {
if (data) {
for (var i in data.tx) {
const txid = data.tx[i];
let paint = document.getElementById(txid);
const paint = document.getElementById(txid);
if (paint) {
completedBlock.insertBefore(paint, completedBlock.firstChild);
}
@ -146,7 +144,7 @@ export default class App {
static isPrivateSend (components) {
return components.every(i => {
let value = Object.values(i)[0];
if (typeof value == 'string') {
if (typeof value === 'string') {
value = 100000000 * value;
}
return PSDENOMINATIONS.includes(value);
@ -166,8 +164,8 @@ export default class App {
y: parseInt(data.txid.slice(4, 8), 16) / 65536,
rotation: parseInt(data.txid.slice(16, 17), 16) / 16,
paintIndex: parseInt(data.txid.slice(17, 21), 16) / 65536,
color: isMixing ? COLORS.black : isComplex ? COLORS.white :
'var(--color-'+
color: isMixing ? COLORS.black : isComplex ? COLORS.white
: 'var(--color-' +
Math.floor(parseInt(data.txid.slice(21, 23), 16) / 256 * this.blockColors.length) +
')'
};
@ -175,9 +173,9 @@ export default class App {
var paint = document.createElement('div');
paint.id = tx.id;
paint.classList.add('paint');
paint.style.maskImage = 'url(assets/paint/' + (tx.value > 10 ?
PAINT.big[Math.floor(tx.paintIndex * 12)] :
PAINT.small[Math.floor(tx.paintIndex * 11)]
paint.style.maskImage = 'url(assets/paint/' + (tx.value > 10
? PAINT.big[Math.floor(tx.paintIndex * 12)]
: PAINT.small[Math.floor(tx.paintIndex * 11)]
) + ')';
paint.style.setProperty('-webkit-mask-image', paint.style.maskImage);
paint.style.setProperty('--x', tx.x);
@ -186,6 +184,6 @@ export default class App {
paint.style.setProperty('--rotation', tx.rotation * 360 + 'deg');
paint.style.setProperty('--color', tx.color);
target.appendChild(paint);
}
}
};
}
}