include/include-script.js   A
last analyzed

Complexity

Total Complexity 1
Complexity/F 1

Size

Lines of Code 15
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 8
mnd 0
bc 0
fnc 1
dl 0
loc 15
rs 10
bpm 0
cpm 1
noi 0
c 0
b 0
f 0
1
// includeScript = function (src) {
2
//     var head = document.getElementsByTagName('head')[0];
3
//     var script = document.createElement('script');
4
//     script.type = 'text/javascript';
5
//     script.src = src;
6
//     head.appendChild(script);
7
// };
8
// var script = document.createElement('script');
9
// script.onload = function () {
10
//     //do stuff with the script
11
// };
12
// script.src = something;
13
//
14
// document.head.appendChild(script); //or something of the likes
15
16
17
var includeScript = function(url, target, success, error){
18
    //url is URL of external file, success is the code
19
    //to be called from the file, location is the location to
20
    //insert the <script> element
21
22
    var scriptTag = document.createElement('script');
23
    scriptTag.src = url;
24
    scriptTag.type = 'text/javascript';
25
26
    scriptTag.onerror = error;
27
    scriptTag.onload = success;
28
    scriptTag.onreadystatechange = success;
29
30
    target.appendChild(scriptTag);
31
};
32