From de77e4a07253750288ede3c1454c73cd55a41631 Mon Sep 17 00:00:00 2001 From: CytoDev Date: Tue, 12 Jul 2016 23:05:10 +0200 Subject: [PATCH] Adds a safety check. --- mock/LightDMMock.js | 5 ++++- readme.md | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/mock/LightDMMock.js b/mock/LightDMMock.js index 96159a6..e2abc7b 100644 --- a/mock/LightDMMock.js +++ b/mock/LightDMMock.js @@ -11,7 +11,10 @@ * Include the file in your theme that needs mocking * * Create a new instance of LightDMMock - * var lightdm = lightdm || new LightDMMock(autofill, timeout, autoGuest); + * if(!("lightdm" in window)) { + * var LightDMMock = LightDMMock || {}; + * window.lightdm = new LightDMMock(autofill, timeout, autoGuest); + * } * * @param {boolean} autofill [wether or not the arrays for users, languages, * layouts, and sessions need to be filled with mock diff --git a/readme.md b/readme.md index 884801b..7735a77 100644 --- a/readme.md +++ b/readme.md @@ -12,7 +12,10 @@ git clone git@github.com:CytoDev/LightDMMock.git ```` 3. Create a new instance of LightDMMock ````javascript -var lightdm = lightdm || new LightDMMock(autofill, timeout, autoGuest); +if(!("lightdm" in window)) { + var LightDMMock = LightDMMock || {}; + window.lightdm = new LightDMMock(autofill, timeout, autoGuest); +} ```` ##Parameters of LightDMMock()