var QueryString = function() { // This function is anonymous, is executed immediately and // the return value is assigned to QueryString! var query_string = {}; var query = window.location.search.substring(1); var vars = query.split("&"); for ( var i = 0; i < vars.length; i++) { var pair = vars[i].split("="); // If first entry with this name if (typeof query_string[pair[0]] === "undefined") { query_string[pair[0]] = pair[1]; // If second entry with this name } else if (typeof query_string[pair[0]] === "string") { var arr = [ query_string[pair[0]], pair[1] ]; query_string[pair[0]] = arr; // If third or later entry with this name } else { query_string[pair[0]].push(pair[1]); } } return query_string; }(); function getParameterByName(name) { name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); var regexS = "[\\?&]" + name + "=([^&#]*)"; var regex = new RegExp(regexS); var results = regex.exec(window.location.search); if (results == null) return ""; else return decodeURIComponent(results[1].replace(/\+/g, " ")); } function addBookmarklet() { var bookmarkletElement = document.getElementById("bookmarklet"); var text = "You can use a bookmarklet to quickly send the webpage you're on to your Android device. Drag "; var text2 = "the following link to your bookmark toolbar and click the bookmark when you're on a page you want to send: "; var link = document.createElement('a'); link .setAttribute( 'href', "javascript:(function(){ var img = new Image(1,1); img.src = 'http://autoremotejoaomgcd.appspot.com/sendintent?intent=' + encodeURIComponent(document.URL) + '&key=" + getParameterByName('key') + "'; })();"); var textnode = document.createTextNode(text); var textnode2 = document.createTextNode(text2); var linkTextNode = document.createTextNode("Open in AutoRemote"); link.appendChild(linkTextNode); bookmarklet.appendChild(textnode); bookmarklet.appendChild(textnode2); bookmarklet.appendChild(link); } var down; var up; var buttonOnmousedown = function() { var timings = document.getElementById("vibration"); down = new Date(); var diff = down - up; if (!diff) diff = 0; timings.value += diff + ","; window.onmouseup = function() { up = new Date(); var diff = up - down; timings.value += diff + ","; window.onmouseup = null; }; }; var writeTopLinks = function() { writeTopLink('AutoRemoteServer', 'Send Message'); writeTopLink('AutoRemoteNotification', 'Send Notification'); } var writeTopLink = function(page, text) { document.write('' + text + ''); }