-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextension.js
More file actions
100 lines (78 loc) · 3.6 KB
/
extension.js
File metadata and controls
100 lines (78 loc) · 3.6 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
// 'use strict';
let vscode = require('vscode');
let configuration = vscode.workspace.getConfiguration('workingon');
let userToken = configuration.get('token');
let request = require("request");
// import 'lib/wo.utils.js'
// import 'lib/wo.request.js'
// let test = require('./lib/test.js');
// import 'lib/wo.token.js'
// let core = requre('./core');
// import * as commons from './common';
// import * as envir from './environmentPath';
// import {Setting} from './setting';
// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
function activate(context) {
// Use the console to output diagnostic information (console.log) and errors (console.error)
// This line of code will only be executed once when your extension is activated
let updateTokenDisposable = vscode.commands.registerCommand('extension.updateToken', () => {
vscode.window.showInformationMessage('Update token Initiated.')
});
context.subscriptions.push(updateTokenDisposable);
let updateWorkingOnDisposable = vscode.commands.registerCommand('extension.updateWorkingOn', () => {
return new Promise(resolve => {
if(!userToken)
{
vscode.window.showInformationMessage('token undefined.');
}
else
{
let workOptions = {
source: 'vscode',
task: ''
};
vscode.window.showInputBox({ prompt: "What are you working on?" })
.then(value => {
workOptions.task = value;
})
.then(() => {
return request({
url: 'https://api.workingon.co/hooks/incoming?token='+userToken,
method: 'POST',
json: workOptions
}, function (error, response, body) {
console.log('request complete.');
console.log('response is: ', response.statusCode );
console.log('body is: ', body);
console.log('token is: ', userToken);
if(response.statusCode != 200){
if(response.statusCode == 403) {
console.log('response is 403');
body = JSON.parse(body);
vscode.window.showInformationMessage('There seems to be a problem. '+ body.message + ' Error Code: ' + body.code);
return(123);
}
}
if (!error && response.statusCode == 200) {
console.log(body) // Show the HTML for the Google homepage.
vscode.window.showInformationMessage(body);
vscode.window.showInformationMessage('Task updated.');
return(123);
}
else if(error) {
console.log('error: ', error);
}
});
});
}
console.log("Command is now finished");
});
});
context.subscriptions.push(updateWorkingOnDisposable);
}
exports.activate = activate;
// this method is called when your extension is deactivated
function deactivate() {
}
exports.deactivate = deactivate;