From 8b7d85654a417f696a6705788fa9b98c0e955c52 Mon Sep 17 00:00:00 2001 From: Jeremy Levin <Jeremy@Lindas-MacBook-Pro.local> Date: Mon, 12 Mar 2018 17:25:28 -0400 Subject: [PATCH] added numpad page --- numpad.json | 112 ++++++++++++++++++++++---------------------- public/.DS_Store | Bin 0 -> 6148 bytes public/js/client.js | 12 +++++ server.js | 12 +++++ 4 files changed, 80 insertions(+), 56 deletions(-) mode change 100644 => 100755 numpad.json create mode 100644 public/.DS_Store diff --git a/numpad.json b/numpad.json old mode 100644 new mode 100755 index dab1186..be8ea43 --- a/numpad.json +++ b/numpad.json @@ -1,146 +1,146 @@ { - "button1": [ - "q", + "pad1": [ + "0", "0", "0" ], - "button2": [ - "w", + "pad2": [ + "1", "10", "0" ], - "button3": [ - "e", + "pad3": [ + "2", "20", "0" ], - "button4": [ - "r", + "pad4": [ + "3", "30", "0" ], - "button5": [ - "t", + "pad5": [ + "4", "40", "0" ], - "button6": [ - "y", + "pad6": [ + "5", "50", "0" ], - "button7": [ - "u", + "pad7": [ + "6", "60", "0" ], - "button8": [ - "i", + "pad8": [ + "7", "70", "0" ], - "button9": [ - "o", + "pad9": [ + "8", "80", "0" ], - "button10": [ - "p", + "pad10": [ + "9", "90", "0" ], - "button11": [ - "a", + "pad11": [ + "-", "0", "30" ], - "button12": [ - "s", + "pad12": [ + "/", "10", "30" ], - "button13": [ - "d", + "pad13": [ + ":", "20", "30" ], - "button14": [ - "f", + "pad14": [ + ";", "30", "30" ], - "button15": [ - "g", + "pad15": [ + "(", "40", "30" ], - "button16": [ - "h", + "pad16": [ + ")", "50", "30" ], - "button17": [ - "j", + "pad17": [ + "$", "60", "30" ], - "button18": [ - "k", + "pad18": [ + "&", "70", "30" ], - "button19": [ - "l", + "pad19": [ + "@", "80", "30" ], - "button20": [ - "z", + "pad20": [ + "\"", "0", "60" ], - "button21": [ - "x", + "pad21": [ + ".", "10", "60" ], - "button22": [ - "c", + "pad22": [ + ",", "20", "60" ], - "button23": [ - "v", + "pad23": [ + "?", "30", "60" ], - "button24": [ - "b", + "pad24": [ + "!", "40", "60" ], - "button25": [ - "n", + "pad25": [ + "'", "50", "60" ], - "button26": [ - "m", + "pad26": [ + "#", "60", "60" ], - "button27": [ - "#", + "pad27": [ + "%", "70", "60" ], "button28": [ - "@", + "*", "80", "60" ], "button29": [ - "*", + "=", "90", "60" ] diff --git a/public/.DS_Store b/public/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..f4636617fb7770a57452b94eb231413725f2f010 GIT binary patch literal 6148 zcmeH~JqiLr422WjLa^D=avBfd4F=H@cmYu>S+EfMIl3=Dh_2Qm@&d`rWF{>86+0Ud z(e>@L66r-`1~-+Zg^?-N6FJNEbUhA-%Vl`lpJZ-l;Ju9YpN=vm0TLhq5+DH*_z?nj zZ^LHuP(~6U0TOr+u<t{Go7U78>Yok-9|52p%5KPgmVg#3Kx=9XMFpnO3XN9vF~sWL z4lQ}Ernb;%7tP^A^T}#c3{0b4v|s_#>cT(*BrqZ{jdgGL{}%pf{vWk)NdhGBX9Tp{ z>^5t>RNk#`uV?jrRxNLEs2@jo`3b<nuHpsU4g19sXiaUQsKEFm;20Q4;Hw1gSlbXd literal 0 HcmV?d00001 diff --git a/public/js/client.js b/public/js/client.js index a89ab99..3caf812 100755 --- a/public/js/client.js +++ b/public/js/client.js @@ -56,6 +56,18 @@ socket.on('updateUrls', function(newVals) { $('#loading').html(''); }); +//Purpose: Receives information from the server to update the presentation of the keys on the client +socket.on('updateNumPad', function(newVals) { + console.log(newVals); + for (var i = 0; i < newVals.x.length; i++){ + $('#numpad').append('<button class = "draggable key-button" id="pad' + (i+1).toString() + '">' + newVals.k[i] + '</button>'); + var ele = $('#pad' + (i+1).toString()) + ele.text(newVals.k[i]) + ele.css({position:'absolute', left:newVals.x[i] + '%', top:(newVals.y[i]) + '%', minHeight: (keyboardWidth*.02).toString() + "px"}); + } + $('#loading').html(''); + }); + //Purpose: Emits the key of keyboard upon click var emitKey = function(str) { diff --git a/server.js b/server.js index f7e342a..c948af7 100755 --- a/server.js +++ b/server.js @@ -76,6 +76,18 @@ io.on('connection', function(socket) { ypos.push(content[key][2]); } socket.emit('updateKeys', {k: keys, x: xpos, y: ypos}); + + content = [] + //Load default numpad + var file = fs.readFileSync("numpad.json") + var content = JSON.parse(file) + + for (var key in content) { + keys.push(content[key][0]); + xpos.push(content[key][1]); + ypos.push(content[key][2]); + } + socket.emit('updateNumPad', {k: keys, x: xpos, y: ypos}); content = [] //Load default urls -- GitLab