Skip to content

Commit

Permalink
Added google analytics to ext and application
Browse files Browse the repository at this point in the history
Fixed more bug fixes and synth mouse improvments
  • Loading branch information
Chris Sita committed Sep 9, 2013
1 parent 2df7dcf commit 457dd52
Show file tree
Hide file tree
Showing 9 changed files with 113 additions and 35 deletions.
32 changes: 30 additions & 2 deletions chromeExt/backgroundApp/background.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//PRODUCTION_
//var socketserver = 'http://chromeconnect.nodejitsu.com:80';
var socketserver = 'http://10.0.1.42:8080';
var socketserver = 'http://chromeconnect.nodejitsu.com:80';
var channelTabs = [];
var activeTab;
var storage = chrome.storage.local;
Expand Down Expand Up @@ -39,6 +38,26 @@ chrome.tabs.onActivated.addListener(function(info) {
}
});

var enableMouseNotification = {
type: "list",
title: "Enabling pointer control",
message: "Press your ESC key to exit mouse control",
iconUrl: "../icons/icon.png",
items: [{ title: "Step 1", message: "Click anywhere in browser."},
{ title: "Step 2", message: "Click 'Allow' if prompted."},
{ title: "Step 3", message: "A red cursor will appear."}]
}

var gesterHelp = {
type: "list",
title: "Types of Gesters Supported",
message: "Currently support the following: mouse control, swiping and zooming",
iconUrl: "../icons/icon.png",
items: [{ title: "Mouse Control", message: "One Finger drag"},
{ title: "Swiping", message: "Two Finger swipe up/down"},
{ title: "Zooming", message: "Pinch in/out on Pinch Tab"}]
}


// coming from the popup
chrome.extension.onMessage.addListener(function(request, sender, sendResponse) {
Expand All @@ -59,6 +78,9 @@ chrome.extension.onMessage.addListener(function(request, sender, sendResponse) {

case "enableMouseControl":
storage.set({"synthMouse":1});
chrome.notifications.create("enableMouse", enableMouseNotification, function (id){
console.log("enableMouseControl notification sucess");
})
socketConnection(request.type, request.tabID, request.windowID);
break;

Expand Down Expand Up @@ -87,6 +109,12 @@ chrome.extension.onMessage.addListener(function(request, sender, sendResponse) {
});
break;

case "gesterHelp":
chrome.notifications.create("gesterHelp", gesterHelp, function (id){
console.log("gesterHelp notification sucess");
})
break;

}
return true;
});
Expand Down
12 changes: 12 additions & 0 deletions chromeExt/browseraction/popup.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ h1.chromeConnect{
font-family: arial;
}

a#gesterHelp{
color: black;
text-decoration: underline;
font-family: "arial";
}

a:hover#gesterHelp{
color: black;
text-decoration: none;
font-family: "arial";
}

#qrcode{
width:100px;
height:100px;
Expand Down
5 changes: 3 additions & 2 deletions chromeExt/browseraction/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ <h1 class="chromeConnect">ChromeConnect</h1>
</div>
<div id="centerBtn">
<div id="connectID"></div>
<button type="button" id="mouseControl" class="mouseControl-btn">Pointer On</button>
<button type="button" id="mouseControlOff" class="mouseControl-btn">Pointer Off</button>
<button type="button" id="mouseControl" class="mouseControl-btn">Turn Pointer On</button>
<button type="button" id="mouseControlOff" class="mouseControl-btn">Turn Pointer Off</button>
<div><a href="#" id="gesterHelp">Gester Command Help</a></div>
</div>
</div>
</div>
Expand Down
31 changes: 28 additions & 3 deletions chromeExt/browseraction/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ window.onload = function() {
}
});

document.getElementById("socket-connect-btn").onclick = function() {
document.getElementById("socket-connect-btn").onclick = function(e) {
if($('#socket-connect-btn').hasClass('on')){
_gaq.push(['_trackEvent', e.target.id, 'clicked']);
$('#qrcode_container').css("visibility", "hidden");
// Sends to background script
chrome.extension.sendMessage({
Expand Down Expand Up @@ -100,6 +101,21 @@ window.onload = function() {
});
});
};

document.getElementById("gesterHelp").onclick = function() {
chrome.tabs.query({active:true, currentWindow:true}, function(tabs){
var current = tabs[0];
var tabID = current.id;
var windowID = current.windowId;

// Sends to background script
chrome.extension.sendMessage({
"type": "gesterHelp",
"windowID": windowID,
"tabID": tabID
});
});
};
};

var qrcode = new QRCode("qrcode", {
Expand All @@ -110,8 +126,7 @@ var qrcode = new QRCode("qrcode", {
// jQuery
var makeCode = function (token) {
//PRODUCTION_
//var url = "http://chromeconnect.nodejitsu.com/";
var url = "http://10.0.1.42:8080/"
var url = "http://chromeconnect.jit.su/";
var newUrl = url + token;
qrcode.makeCode(newUrl);
$('#connectID').text(newUrl);
Expand Down Expand Up @@ -143,6 +158,16 @@ chrome.extension.onMessage.addListener(function(request, sender, sendResponse) {
}
});

// Google Analytics Tracker
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-43870655-1']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = 'https://ssl.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();



Expand Down
15 changes: 7 additions & 8 deletions chromeExt/manifest.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
{
"name": "ChromeConnect",

"version": "0.1",

"manifest_version": 2,

"description": "Web based Browser Navigation Control",
"description": "Turn your touchable phone or tablet device into a mouse to control browsing in Chrome.",

"browser_action": {
"default_title": "Chrome Connect Settings",
"default_icon": "icons/icon.png",
"default_title": "chromeConnect",
"default_icon": "icons/icon.png",
"default_popup": "browseraction/popup.html"
},

Expand All @@ -18,15 +15,17 @@
"persistent": true
},

"permissions": ["tabs","activeTab","storage"],
"permissions": ["tabs","activeTab","storage","notifications"],

"content_scripts":[
{
"matches": ["http://*/*", "https://*/*"],
"css": ["pointer_chromeConnect.css"],
"js": ["script.js", "zoom.js"]
}
],
],

"content_security_policy": "script-src 'self' https://ssl.google-analytics.com; object-src 'self'",

"web_accessible_resources": ["backgroundApp/socketio.js", "backgroundApp/background.js", "icons/arrow-cursor.png"]
}
17 changes: 5 additions & 12 deletions chromeExt/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
var port = chrome.runtime.connect();
var tempX;
var tempY;
var tempClientX = 10;
var tempClientY = 10;
var tempClientX = window.outerWidth / 2;
var tempClientY = window.outerHeight / 2;
var currentX = 10;
var currentY = 10;
var windowWidth = document.body.scrollWidth;
Expand Down Expand Up @@ -32,7 +32,7 @@ chrome.extension.onMessage.addListener(function(request, sender, sendResponse) {
} else if(request.type === "swipe" && request.fingerCount === 3){
pageToporBottom(request.swipeDirection, request.swipDistance, request.swipeDuration);
} else if (request.type === "navigation"){
movePointer(request.xVal, request.yVal, "syntheticDirection");
movePointer(request.xVal * 2, request.yVal * 2, "syntheticDirection");
} else if (request.type === "fixedPointerOn"){
fixedPointerOn();
} else if (request.type === "fixedPointerOff"){
Expand Down Expand Up @@ -215,13 +215,6 @@ element.addEventListener("click", function (e) {
}
});

// var forcePointer = function(){
// var pointer = document.getElementById("newPointer_chromeConnect");
// makePointer();
// document.addEventListener('webkitpointerlockchange', changeCallback, false);
// document.addEventListener('webkitpointerlockerror', errorCallback, false);
// }

var makePointer = function() {
var chromeConnectPointer = chrome.extension.getURL('icons/arrow-cursor.png');
var image = document.createElement('image');
Expand Down Expand Up @@ -309,7 +302,7 @@ var createClick = function(){
}
};

function changeCallback() {
var changeCallback = function() {
//Check for element whether locked is expected element or not
if (document.webkitPointerLockElement == element) {
// Pointer was just locked
Expand All @@ -324,7 +317,7 @@ function changeCallback() {
}
}

function errorCallback(e) {
var errorCallback = function (e) {
//Log Errors
console.log(e);
}
14 changes: 13 additions & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

</head>

<body class="iOCSS ">
<body class="iOCSS">
<div class="frame striped">
<div class="header">
<h1>Chrome Connect</h1>
Expand Down Expand Up @@ -43,4 +43,16 @@ <h1>Chrome Connect</h1>
</div>

</body>

<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-43870655-1', 'chromeconnect.us');
ga('send', 'pageview');

</script>

</html>
2 changes: 1 addition & 1 deletion public/javascripts/chromeConnect.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
jQuery.event.props.push("touches");
//PRODUCTION_
var socketUrl = 'http://' + location.hostname + ':8080';
var socketUrl = 'http://' + location.hostname + ':80';
var isMobileDevice = Modernizr.touch;
var socket = io.connect(socketUrl);

Expand Down
20 changes: 14 additions & 6 deletions public/splash.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<title>Chrome Connect - Alpha</title>
<title>Chrome Connect (Alpha)</title>
<meta name="description" content="">
<meta name="keywords" content="websockets, chromeConnect, Chrome, webstore, extension">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
Expand All @@ -13,10 +13,6 @@
<!--[if lt IE 9]>
<script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link rel="shortcut icon" href="/bootstrap/img/favicon.ico">
<link rel="apple-touch-icon" href="/bootstrap/img/apple-touch-icon.png">
<link rel="apple-touch-icon" sizes="72x72" href="/bootstrap/img/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" sizes="114x114" href="/bootstrap/img/apple-touch-icon-114x114.png">
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
Expand Down Expand Up @@ -128,5 +124,17 @@ <h2 class="featurette-heading">And lastly, this one. <span class="text-muted">Fl
<script type='text/javascript' src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/js/bootstrap.min.js"></script>


</body>
</body>

<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-43870655-1', 'chromeconnect.us');
ga('send', 'pageview');

</script>

</html>

0 comments on commit 457dd52

Please sign in to comment.