forked from TobiasMue91/tobiasmue91.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotification.js
50 lines (45 loc) · 1.9 KB
/
notification.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
function loadScript(url, callback) {
const script = document.createElement('script');
script.type = 'text/javascript';
script.src = url;
script.onload = callback;
document.head.appendChild(script);
}
function loadStylesheet(url) {
const link = document.createElement('link');
link.rel = 'stylesheet';
link.href = url;
document.head.appendChild(link);
}
function getCurrentScriptPath() {
const script = Array.from(document.scripts).find(s => s.src.includes('notification.js'));
return script ? new URL(script.src).pathname.replace(/\/[^/]+$/, '') : null;
}
document.addEventListener('DOMContentLoaded', function() {
loadStylesheet('https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.css');
loadStylesheet(getCurrentScriptPath() + '/notification.css');
loadScript('https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.3/jquery.min.js', function() {
loadScript('https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js', function() {
// Configure toastr options
toastr.options = {
closeButton: true,
debug: false,
newestOnTop: false,
progressBar: true,
positionClass: 'toast-custom-bottom-center',
preventDuplicates: false,
onclick: null,
showDuration: '300',
hideDuration: '10000',
timeOut: '20000',
extendedTimeOut: '2000',
showEasing: 'swing',
hideEasing: 'linear',
showMethod: 'fadeIn',
hideMethod: 'fadeOut',
};
// Display the notification
toastr.warning('Due to hitting the usage limit for the OpenAI API, our AI powered tools are temporarily unavailable. We are working on a solution. We apologize for any inconvenience.');
});
});
});