-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextension.js
71 lines (59 loc) · 1.82 KB
/
extension.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// The module 'vscode' contains the VS Code extensibility API
// Import the module and reference it with the alias vscode in your code below
const vscode = require('vscode');
// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
/**
* @param {vscode.ExtensionContext} context
*/
var request = require('request');
var options = {
'method': 'GET',
'url': 'https://api.huobi.pro/market/history/kline?symbol=filusdt&period=1min&size=1',
'headers': {
}
};
let myStatusBarItem;
let presentCoin = "FIL/USDT";
function activate({ subscriptions }) {
myStatusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, 100);
myStatusBarItem.show()
const myCommandId = 'sample.showSelectionCount';
subscriptions.push(vscode.commands.registerCommand(myCommandId, () => {
showInputBox()
}));
myStatusBarItem.command = myCommandId;
setInterval(function () {
console.log(123123)
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
const obj = JSON.parse(response.body);
myStatusBarItem.text = `${presentCoin}:${obj.data[0].close}`
console.log(myStatusBarItem.text)
});
// myStatusBarItem.text = `${i}`
}, 3000)
}
async function showInputBox() {
let result = await vscode.window.showInputBox({
value: '',
valueSelection: [0, 3],
placeHolder: 'input coin name',
});
presentCoin = result.toUpperCase()
result = result.replace("/", "")
vscode.window.showInformationMessage(`Got: ${result}`);
options = {
'method': 'GET',
'url': `https://api.huobi.pro/market/history/kline?symbol=${result}&period=1min&size=1`,
'headers': {
}
};
}
// this method is called when your extension is deactivated
function deactivate() { }
module.exports = {
activate,
deactivate
}