diff --git a/numpad.json b/numpad.json old mode 100644 new mode 100755 index dab1186d23855e45a7e187de9cd2255e4315fb00..be8ea4330e03a09ea077abf88bffab8a73a295d0 --- 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/package-lock.json b/package-lock.json index c81f2d8d7c8b69ec321e2c55f2b462cea2fe4635..8468591e62ebbbdaea41646e13ed3e999e43e5fe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1005,6 +1005,11 @@ "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=", "dev": true }, + "is-wsl": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-1.1.0.tgz", + "integrity": "sha1-HxbkqiKwTRM2tmGIpmrzxgDDpm0=" + }, "isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", @@ -1267,10 +1272,13 @@ "wrappy": "1.0.2" } }, - "openurl": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/openurl/-/openurl-1.1.1.tgz", - "integrity": "sha1-OHW0sO96UsFW8NtB1GCduw+Us4c=" + "opn": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/opn/-/opn-5.2.0.tgz", + "integrity": "sha512-Jd/GpzPyHF4P2/aNOVmS3lfMSWV9J7cOhCG1s08XCEAsPkB7lp6ddiU0J7XzyQRDUh8BqJ7PchfINjR8jyofRQ==", + "requires": { + "is-wsl": "1.1.0" + } }, "options": { "version": "0.0.6", diff --git a/package.json b/package.json index e1659e95fa8e894d50aff54bdcede68d3f271bd3..7b74c244da22243eee712d555b72b1b60ebc9e51 100755 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "chromium-args": "--child-clean-exit", "dependencies": { "express": "^4.13.3", - "openurl": "^1.1.1", + "opn": "^5.2.0", "robotjs": "^0.4.7", "socket.io": "^1.3.6" }, diff --git a/public/.DS_Store b/public/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..f4636617fb7770a57452b94eb231413725f2f010 Binary files /dev/null and b/public/.DS_Store differ diff --git a/public/client.html b/public/client.html index 68673e6d8ee9eb40642dbbf7876ed7ed1dfd62c2..5fb9a9f767c2ddb3ee805df393cba0b77d4f60ce 100755 --- a/public/client.html +++ b/public/client.html @@ -30,6 +30,15 @@ <div class = "custom swiper-slide" id="custom"> </div> </div> </div> + + + <div class="touchpad" id="touchpad"> + <div class="touchpad" id="leftClick"> </div> + <div class="touchpad" id="scrollWheel"> </div> + <div class="touchpad" id="rightClick"> </div> + <div class="touchpad" id="mousepad"> </div> + </div> + <div class = "navbar" id="navbar"> <div class = "icon-selection" id="s0"> <i class="material-icons">keyboard</i> @@ -43,10 +52,14 @@ <div class = "icon-selection" id="s3"> <i class="material-icons">build</i> </div> + <div class = "icon-selection" id="swap"> + <i class="material-icons">swap_vert</i> + </div> <div class = "icon-selection" id= "settings-select"> <i class="material-icons">settings</i> </div> </div> + </div> <!-- The Modal --> diff --git a/public/js/client.js b/public/js/client.js index 358bc68b93123d0ed46182bb0870b9068278a72f..dc02cf5856798b66c03f19d0ff8617f0fb93a771 100755 --- a/public/js/client.js +++ b/public/js/client.js @@ -75,14 +75,31 @@ socket.on('updateUrls', function(newVals) { var ele = $('#url' + (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", width: '20%', 'text-indent': '-9999px'}); - ele.append('<button id="url-icon' +(i+1).toString() +'"> </button>') + ele.append('<button class="url-icon" id="url-icon' +(i+1).toString() +'"> </button>') var urlIcon = $('#url-icon' + (i+1).toString()) - var favicon_url = getFavicon(newVals.k[i]); + try { + var favicon_url = getFavicon(newVals.k[i]); + } + catch(err) { + var favicon_url = '' + } urlIcon.css({position: 'absolute', left: '35%', bottom: '20%', width: '30%', height: '60%', background: 'url(' + favicon_url + ')', 'background-size': 'contain', 'border-radius': '0px', border:'0px', 'background-repeat': 'no-repeat'}); } $('#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) { @@ -94,8 +111,8 @@ var emitKey = function(str) { var emitUrl = function(str) { if (move === false){ - socket.emit('url', str); console.log(str); + socket.emit('url', str); } }; @@ -141,14 +158,13 @@ interact('.key-button').on('tap', function (event) { }); interact('.url-button').on('tap', function (event) { - emitUrl(event.target.innerText); - }).on('hold', function (event) { - if (move == true){ - modal.style.display = "block"; //Allows the modal to be displayed to User - updateKey = event.target - inputModal.value = updateKey.innerText + if(event.target.id.indexOf("url-icon") != -1){ + emitUrl($("#" + event.target.id).parent().text().trim()) } -}); + else{ + emitUrl(event.target.innerText); + } + }); //Purpose: Updates button with textbox value $('#modal-save').click(function() { @@ -291,17 +307,33 @@ mcLc.on('doubleclick', function(e) { /* -----------SWIPING FUNCTIONALITY--------------- */ + var swiper = new Swiper('.swiper-container', { }); var swipeIndex = 0; $('#s0').css("background-color", "green") +var mousePos = true; + $('.icon-selection').click(function() { + if (this.id == 'swap') { + if (mousePos){ + $('#touchpad').insertBefore('.swiper-container'); + mousePos = false; + } + else { + $('.swiper-container').insertBefore('#touchpad'); + mousePos = true; + } + return; + } + if (this.id == 'settings-select') { // Bring up setting menu return; } + var newId = parseInt(this.id[1]) if (newId == swipeIndex) { return; diff --git a/public/style/main.css b/public/style/main.css index 98c70db102de12abd4bf81f05370d9898f36afad..b888b307883c642112adc8567a45ef72632caece 100755 --- a/public/style/main.css +++ b/public/style/main.css @@ -150,16 +150,25 @@ mark { .icon-selection{ float: left; min-height: 100%; - min-width: 20%; + min-width: 16%; position: relative; transition: background-color 300ms linear; } +#settings-select{ + min-width: 18%; + background-color: grey +} + +#swap{ + min-width: 18%; + background-color: grey +} .material-icons{ position: absolute; - top: 40%; - left: 40%; + top: 35%; + left: 35%; } .modal { diff --git a/server.js b/server.js index c45e2c339663e55f28bb860cbe5d7e4b665ec368..1462bdc07ec35de68a67f1af0e26bc65bd72e9ad 100755 --- a/server.js +++ b/server.js @@ -8,7 +8,7 @@ var http = require('http').Server(app); var io = require('socket.io')(http); var robot = require('robotjs'); var config = require('./public/js/config.js'); -var url = require("openurl"); +var url = require("opn"); var fs = require("fs"); //---------GLOBAL STATE VARIABLES ----// @@ -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 @@ -120,7 +132,8 @@ io.on('connection', function(socket) { socket.on('url', function(str) { console.log("Trying to open url") - url.open(str) + console.log(str) + url(str) }); diff --git a/url.json b/url.json index fc63680f95b98bf6c6fc79b854403b132988a2fc..e9bb164068ec7ead10872370c197ceeb57ec45af 100644 --- a/url.json +++ b/url.json @@ -15,7 +15,7 @@ "0" ], "url4": [ - "https://www.umich.instructure.com", + "https://www.google.com", "75", "0" ],