-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathextension.js
85 lines (75 loc) ยท 2.53 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
/**
* developer: @mohamedSaber
* desginer: @yahyaTizza
*/
const vscode = require("vscode");
const axios = require("axios").default;
const getRandomHadith = async () => {
let hadith =
"โจ ุฅูููู ุงูููููู ููู
ููุงุฆูููุชููู ููุตููููููู ุนูููู ุงููููุจูููู ููุง ุฃููููููุง ุงูููุฐูููู ุขู
ููููุง ุตูููููุง ุนููููููู ููุณููููู
ููุง ุชูุณููููู
ูุง";
try {
const { data } = await axios.get(
`https://api.sunnah.com/v1/hadiths/random`,
{
headers: {
"X-API-Key": "SqD712P3E82xnwOAEOkGd5JZH8s9wRR24TqNFzjk",
},
}
);
// Select Muslim language
const muslimLanguage = vscode.workspace
.getConfiguration("hadith")
.get("language");
muslimLanguage === "Arabic"
? (hadith = `โจ ${data.hadith[1].body.slice(3, -4)}`)
: (hadith = `โจ ${data.hadith[0].body.slice(3, -4)}`);
} catch (error) {}
return hadith;
};
function activate() {
const repeatedEveryMinute = vscode.workspace
.getConfiguration("hadith")
.get("repeatedEveryMinute");
const convertMinutesToMs = repeatedEveryMinute * 60000;
setInterval(async function () {
getRandomHadith()
.then(function (response) {
vscode.window.withProgress(
{
location: vscode.ProgressLocation.Notification,
title: response,
cancellable: true,
},
async (progress) => {
progress.report({ increment: 0 });
await new Promise((resolve) =>
setTimeout(resolve, convertMinutesToMs)
);
progress.report({ increment: 100, message: "Done!" });
}
);
})
.catch(() => {
vscode.window.withProgress(
{
location: vscode.ProgressLocation.Notification,
title:
"โจ ุฅูููู ุงูููููู ููู
ููุงุฆูููุชููู ููุตููููููู ุนูููู ุงููููุจูููู ููุง ุฃููููููุง ุงูููุฐูููู ุขู
ููููุง ุตูููููุง ุนููููููู ููุณููููู
ููุง ุชูุณููููู
ูุง",
cancellable: true,
},
async (progress) => {
progress.report({ increment: 0 });
await new Promise((resolve) =>
setTimeout(resolve, convertMinutesToMs)
);
progress.report({ increment: 100, message: "Done!" });
}
);
});
}, convertMinutesToMs);
}
function deactivate() {}
module.exports = {
activate,
deactivate,
};