diff --git a/bower.json b/bower.json index 0868374..2257b6b 100644 --- a/bower.json +++ b/bower.json @@ -1,12 +1,12 @@ { - "name": "dueljs", + "name": "duel", "version": "1.0.0", "homepage": "http://dueljs.studentivan.ru", "authors": [ "Maslov Ivan " ], "description": "JavaScript HTML5 Master/Slave Browser Tabs Helper", - "main": "lib/duel.js", + "main": "public/lib/duel.js", "keywords": [ "dueljs", "duel", @@ -15,7 +15,8 @@ "window", "javascript", "onfocus", - "broadcasting" + "broadcasting", + "document.hidden" ], "license": "MIT", "ignore": [ diff --git a/example.html b/example.html deleted file mode 100644 index 3678f88..0000000 --- a/example.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - Duel page - - - - - - - \ No newline at end of file diff --git a/package.json b/package.json index 5ca46cb..533b19a 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,14 @@ { - "name": "dueljs", + "name": "duel", "version": "1.0.0", "description": "DuelJS - JavaScript HTML5 Master/Slave Browser Tabs Helper", - "main": "lib/duel.js", + "main": "public/lib/duel.js", "devDependencies": { - + "http-server": "^0.6.1" }, "scripts": { - "test": "test" + "pretest": "npm install", + "test": "http-server -a localhost -p 8624 -o -c-1" }, "repository": { "type": "git", @@ -21,7 +22,8 @@ "window", "javascript", "onfocus", - "broadcasting" + "broadcasting", + "document.hidden" ], "author": "Maslov Ivan ", "license": "MIT", diff --git a/public/index.html b/public/index.html new file mode 100644 index 0000000..b69861e --- /dev/null +++ b/public/index.html @@ -0,0 +1,35 @@ + + + + + Duel page + + + + + +
+

Window ...

+
Open new window  +
+
+ Hint: open the developer console before broadcasting. +
+
+ + + \ No newline at end of file diff --git a/lib/duel.js b/public/lib/duel.js similarity index 94% rename from lib/duel.js rename to public/lib/duel.js index 456fdb6..988661a 100644 --- a/lib/duel.js +++ b/public/lib/duel.js @@ -57,21 +57,21 @@ duel.DuelAbstractChannel = (function () { * @returns {string} */ DuelAbstractChannel.prototype.getName = function () { - return this._name + return this._name; }; /** * @returns {boolean} */ DuelAbstractChannel.prototype.setCurrentWindowAsMaster = function () { - return true + return true; }; /** * @returns {boolean} */ DuelAbstractChannel.prototype.currentWindowIsMaster = function () { - return true + return true; }; /** @@ -82,7 +82,7 @@ duel.DuelAbstractChannel = (function () { this.executeTrigger({ name: trigger, args: Array.prototype.slice.call(arguments, 1) - }) + }); } }; @@ -122,7 +122,7 @@ duel.DuelAbstractChannel = (function () { */ duel._generateWindowID = function () { this._windowID = +Math.random().toString().split('.')[1]; - return this._windowID + return this._windowID; }; /** @@ -130,7 +130,7 @@ duel._generateWindowID = function () { * @returns {number} */ duel.getWindowID = function () { - return this._windowID ? this._windowID : this._generateWindowID() + return this._windowID ? this._windowID : this._generateWindowID(); }; /** @@ -170,13 +170,13 @@ duel.DuelLocalStorageChannel.prototype.setCurrentWindowAsMaster = function () { } else { ch[wIndex].master = true } - localStorage.setItem(chName, JSON.stringify(ch)) + localStorage.setItem(chName, JSON.stringify(ch)); } else { localStorage.setItem(chName, JSON.stringify([ {id: wID, master: true} - ])) + ])); } - return true + return true; }; /** @@ -192,9 +192,9 @@ duel.DuelLocalStorageChannel.prototype.currentWindowIsMaster = function () { break; } } - return (wIndex === -1) ? false : ch[wIndex].master + return (wIndex === -1) ? false : ch[wIndex].master; } else { - return false + return false; } }; @@ -250,7 +250,7 @@ duel.channel = function (name) { var channel = this.isLocalStorageAvailable() ? new this.DuelLocalStorageChannel(name) : new this.DuelFakeChannel(name); duel.activeChannels.push(channel); - return channel + return channel; }; /** @@ -260,7 +260,7 @@ duel.channel = function (name) { duel.makeCurrentWindowMaster = function () { for (var i = duel.activeChannels.length - 1; i >= 0; i--) { try { - duel.activeChannels[i].setCurrentWindowAsMaster() + duel.activeChannels[i].setCurrentWindowAsMaster(); } catch (e) { // stop to exceptions } @@ -271,7 +271,7 @@ duel.makeCurrentWindowMaster = function () { * Makes tab focus trigger for special browsers */ window.onfocus = function () { - duel.makeCurrentWindowMaster() + duel.makeCurrentWindowMaster(); }; /** @@ -280,7 +280,7 @@ window.onfocus = function () { */ window.isMaster = function () { return duel.activeChannels.length ? - duel.activeChannels[0].currentWindowIsMaster() : false + duel.activeChannels[0].currentWindowIsMaster() : false; }; /** @@ -333,7 +333,7 @@ duel.storageEvent = function (event) { for (var i = duel.activeChannels.length - 1; i >= 0; i--) { try { if (duel.activeChannels[i].getName() == eventDetails.channelName) { - duel.activeChannels[i].executeTrigger(eventDetails.triggerDetails) + duel.activeChannels[i].executeTrigger(eventDetails.triggerDetails); } } catch (e) { // stop to exceptions diff --git a/lib/duel.min.js b/public/lib/duel.min.js similarity index 100% rename from lib/duel.min.js rename to public/lib/duel.min.js