Prevent multi init()

This commit is contained in:
Amauri CHAMPEAUX 2014-12-12 17:04:23 +01:00
parent c186089797
commit 57cc4c87f4
1 changed files with 9 additions and 5 deletions

View File

@ -3,7 +3,8 @@
// define correct path for files inclusion
var scripts = document.getElementsByTagName('script'),
path = scripts[scripts.length - 1].src.split('?')[0],
cdn = path.split('/').slice(0, -1).join('/') + '/';
cdn = path.split('/').slice(0, -1).join('/') + '/',
alreadyLaunch = (alreadyLaunch === undefined) ? 0 : alreadyLaunch;
var tarteaucitron = {
"cdn": cdn,
@ -14,10 +15,13 @@ var tarteaucitron = {
"launch": [],
"init": function (params) {
"use strict";
if (window.addEventListener) {
window.addEventListener("load", tarteaucitron.load(params), false);
} else {
window.attachEvent('onload', tarteaucitron.load(params));
if (alreadyLaunch === 0) {
alreadyLaunch = 1;
if (window.addEventListener) {
window.addEventListener("load", tarteaucitron.load(params), false);
} else {
window.attachEvent('onload', tarteaucitron.load(params));
}
}
},
"load": function (params) {