-
Notifications
You must be signed in to change notification settings - Fork 0
/
extension.js
132 lines (103 loc) · 3.31 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
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
const vscode = require('vscode');
const path = require('path');
const fs = require('fs');
/**
* @param {vscode.ExtensionContext} context
*/
function activate(context) {
console.log('Congratulations, your extension "easy-jquery" is now active!');
let disposable = vscode.commands.registerCommand('easy-jquery.jquery', function () {
const FolderPath= vscode.workspace.workspaceFolders[0].uri.path.toString().split(":")[1];
var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
vscode.window.showInformationMessage("creating Jquery Files");
var xhrHTMLTemplate= new XMLHttpRequest();
xhrHTMLTemplate.open("GET", "https://raw.githubusercontent.com/Mohmad-Naser-alnakeshbandi/easy-jquery/main/index.html", true);
xhrHTMLTemplate.onreadystatechange = function()
{
if(xhrHTMLTemplate.readyState==4)
{
fs.writeFile(path.join(FolderPath, "index.html"), this.responseText, err=>{
if(err){
console.error(err);
return vscode.window.showErrorMessage("Error");
}
});
fs.writeFile(path.join(FolderPath, "style.css"), "" , err=>{
if(err){
console.error(err);
}
});
}
}
xhrHTMLTemplate.send();
var xhrJSTemplate= new XMLHttpRequest();
xhrJSTemplate.open("GET", "https://raw.githubusercontent.com/Mohmad-Naser-alnakeshbandi/easy-jquery/main/app.js", true);
xhrJSTemplate.onreadystatechange = function()
{
if(xhrJSTemplate.readyState==4)
{
fs.writeFile(path.join(FolderPath, "app.js"), this.responseText, err=>{
if(err){
console.error(err);
return vscode.window.showErrorMessage("Error");
}
});
}
}
xhrJSTemplate.send();
var xhrJS1 = new XMLHttpRequest();
xhrJS1.open("GET", "https://code.jquery.com/jquery-3.6.0.min.js", true);
xhrJS1.onreadystatechange = function()
{
if(xhrJS1.readyState==4)
{
fs.mkdirSync(FolderPath+"/Jquery-JS-Folder");
fs.writeFile(path.join(FolderPath+"/Jquery-JS-Folder", "jquery-3.6.0.js"), this.responseText, err=>{
if(err){
console.error(err);
return vscode.window.showErrorMessage("Error");
}
});
}
}
xhrJS1.send();
var xhrJS2 = new XMLHttpRequest();
xhrJS2.open("GET", "https://code.jquery.com/ui/1.13.1/jquery-ui.js", true);
xhrJS2.onreadystatechange = function()
{
if(xhrJS2.readyState==4)
{
fs.writeFile(path.join(FolderPath+"/Jquery-JS-Folder", "jquery-ui.js"), this.responseText, err=>{
if(err){
console.error(err);
return vscode.window.showErrorMessage("Error");
}
});
}
}
xhrJS2.send();
var xhrcss1 = new XMLHttpRequest();
xhrcss1.open("GET", "https://code.jquery.com/ui/1.13.1/themes/base/jquery-ui.css", true);
xhrcss1.onreadystatechange = function()
{
if(xhrcss1.readyState==4)
{
fs.mkdirSync(FolderPath+"/Jquery-CSS-Folder");
fs.writeFile(path.join(FolderPath+"/Jquery-CSS-Folder", "jquery-ui.css"), this.responseText, err=>{
if(err){
console.error(err);
return vscode.window.showErrorMessage("Error");
}
});
}
}
xhrcss1.send()
});
context.subscriptions.push(disposable);
}
// this method is called when your extension is deactivated
function deactivate() {}
module.exports = {
activate,
deactivate
}