forked from InfotelGLPI/printercounters
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprintercounters_load_scripts.js
38 lines (33 loc) · 1.09 KB
/
printercounters_load_scripts.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
/**
* Load plugin scripts on page start
*/
(function ($) {
$.fn.printercounters_load_scripts = function () {
init();
// Start the plugin
function init() {
// $(document).ready(function () {
var path = 'plugins/printercounters/';
var url = window.location.href.replace(/front\/.*/, path);
if (window.location.href.indexOf('plugins') > 0) {
url = window.location.href.replace(/plugins\/.*/, path);
}
// Send data
$.ajax({
url: url + 'ajax/loadscripts.php',
type: "POST",
dataType: "html",
data: 'action=load',
success: function (response, opts) {
var scripts, scriptsFinder = /<script[^>]*>([\s\S]+?)<\/script>/gi;
while (scripts = scriptsFinder.exec(response)) {
eval(scripts[1]);
}
}
});
// });
}
return this;
}
}(jQuery));
$(document).printercounters_load_scripts();