This repository has been archived by the owner on Dec 13, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.min.js
1 lines (1 loc) · 2.52 KB
/
app.min.js
1
function events(){$("#save").click(function(){player1.persist(),player2.persist()}),$("#load").click(function(){player1.loadData(1),player2.loadData(2)}),$("#typedPlayerName1").click(function(){$("#typedPlayerName1").val("")}),$("#typedPlayerName2").click(function(){$("#typedPlayerName2").val("")}),$("#typedPlayerName1").keyup(function(){player1.setName($("#typedPlayerName1").val()),player1.showData(1)}),$("#typedPlayerName2").keyup(function(){player2.setName($("#typedPlayerName2").val()),player2.showData(2)}),$("#panelplay1").bind("touchstart",function(){$(this).css("background-color","lightblue"),activePane=1}),$("#panelplay1").bind("touchend",function(){$(this).css("background-color","#eee")}),$("#panelplay2").bind("touchstart",function(){$(this).css("background-color","lightblue"),activePane=2}),$("#panelplay2").bind("touchend",function(){$(this).css("background-color","#eee")}),$("#true").click(function(){1===activePane?player1.addPoint():2===activePane&&player2.addPoint(),player1.showData(1),player2.showData(2)}),$("#jinx").click(function(){1===activePane?player1.points--:2===activePane&&player2.points--,player1.showData(1),player2.showData(2)})}function Player(e,t){this.name=e,this.points=t,this.setName=function(e){this.name=e},this.setPoints=function(e){this.points=e},this.addPoint=function(){this.points++},this.persist=function(e){1===e?"undefined"!=typeof Storage?(localStorage.setItem("player1_name",this.name),localStorage.setItem("player1_points",this.points)):alert("Sorry, your browser does not support Web Storage..."):2===e&&("undefined"!=typeof Storage?(localStorage.setItem("player1_name",this.name),localStorage.setItem("player1_points",this.points)):alert("Sorry, your browser does not support Web Storage..."))},this.loadData=function(e){1===e?"undefined"!=typeof Storage?(this.name=localStorage.getItem("player1_name"),this.points=localStorage.getItem("player1_points")):alert("Sorry, your browser does not support Web Storage..."):2===e?(this.name=localStorage.getItem("player1_name"),this.points=localStorage.getItem("player1_points")):alert("Sorry, your browser does not support Web Storage...")},this.showData=function(e){1===e?($("#1name").empty().append(this.name),$("#p1points").empty().append(this.points)):2===e&&($("#2name").empty().append(this.name),$("#p2points").empty().append(this.points))}}function playerSelectorAddPoints(){1===activePane?player1.events():2===activePane&&player2.events()}jQuery(document).ready(function(){events()});var player1=new Player("Player 1",0),player2=new Player("Player 2",0),activePane=1;