Skip to content

Commit

Permalink
Added gaq push logic for some event tracking.
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrian Bravo committed Mar 25, 2011
1 parent 8be4a10 commit ab26ae3
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 63 deletions.
25 changes: 13 additions & 12 deletions public/index.html
Expand Up @@ -22,18 +22,6 @@
<script src="/socket.io/socket.io.js"></script>
<script src="/javascripts/message_processor.js"></script>
<script src="/javascripts/main.js"></script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-22300133-1']);
_gaq.push(['_trackPageview']);

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

</head>

<body>
Expand Down Expand Up @@ -109,5 +97,18 @@ <h3 class="inactive">Settings</h3>
<div id='canvas'>&nbsp;</div>
<div id='growl'></div>
</body>

<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-22300133-1']);
_gaq.push(['_trackPageview']);

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

</html>

103 changes: 52 additions & 51 deletions public/javascripts/main.js
Expand Up @@ -96,6 +96,7 @@ $(document).ready(function(){


$('#mockup_pages .delete').live('click', function() {
try { _gaq.push(['_trackEvent', 'click', 'Page Delete']); } catch(err) {}
if ($('#mockup_pages .delete').length == 1) {
alert("You can't delete the last page on a project.");
} else {
Expand All @@ -104,6 +105,7 @@ $(document).ready(function(){
});

$('#add_page').live('click', function() {
try { _gaq.push(['_trackEvent', 'click', 'Page Create']); } catch(err) {}
env.socket.send({ page_create: true });
});

Expand Down Expand Up @@ -277,64 +279,63 @@ $(document).ready(function(){
});

});
get_canvas_object_content = function(canvas_object_id){
var canvas_object = env.project.canvas_object(canvas_object_id);
return canvas_object.content ? canvas_object.content : templates[canvas_object.template_id].default_content;
};

show_connected_screen = function(override){
if (!($.cookie('skipconnect') == 'true') || override) {
var panel_pos = $('#floatingpanel').position(),
settings_pos = { left: 180, top: 30 },
tools_pos = { left: 115, top: 160 };

// Force tab on tools
// TODO This 'tab' logic should really be abstracted. (check jquery ui)
$('#tabs h3:first').click();

if ($('#expandcollapse').hasClass('collapsed')) $('#expandcollapse').click();
$('#canvas .canvas_object').hide();
$connected = $(Views.connected());


$connected.dialog({
resizable: false,
minHeight: 50,
closeOnEscape: true,
title: 'Welcome',
modal: true,
zIndex: 10001,
minWidth: 550,
dialogClass: 'welcome',
close: close_connected_dialog
}).find('form').submit(function() {
var checked = $(this).find('input[type=checkbox]').attr('checked');
if (checked) $.cookie('skipconnect', true);
else $.cookie('skipconnect',false);
close_connected_dialog();
return false;
});
$('.fourth').css('left', settings_pos.left + panel_pos.left);
$('.fourth').css('top', settings_pos.top + panel_pos.top);
$('.second').css('left', tools_pos.left + panel_pos.left);
$('.second').css('top', tools_pos.top + panel_pos.top);
}
};

function close_connected_dialog(){
$('#canvas .canvas_object').show();
$('.connected').remove();
$('.ui-dialog').remove();
$('.instructional_marker').hide().remove();
function get_canvas_object_content(canvas_object_id) {
var canvas_object = env.project.canvas_object(canvas_object_id);
return canvas_object.content ? canvas_object.content : templates[canvas_object.template_id].default_content;
};

function show_connected_screen(override) {
if (!($.cookie('skipconnect') == 'true') || override) {
var panel_pos = $('#floatingpanel').position(),
settings_pos = { left: 180, top: 30 },
tools_pos = { left: 115, top: 160 };

$('#tabs h3:first').click();
if ($('#expandcollapse').hasClass('collapsed')) $('#expandcollapse').click();

$('#canvas .canvas_object').hide();
$connected = $(Views.connected());


$connected.dialog({
resizable: false,
minHeight: 50,
closeOnEscape: true,
title: 'Welcome',
modal: true,
zIndex: 10001,
minWidth: 550,
dialogClass: 'welcome',
close: close_connected_dialog
}).find('form').submit(function() {
if ($(this).find('input[type=checkbox]').attr('checked')) $.cookie('skipconnect', true);
else $.cookie('skipconnect',false);

try { _gaq.push(['_trackEvent', 'click', 'Start Mocking']); } catch(err) {}
close_connected_dialog();
return false;
});
$('.fourth').css('left', settings_pos.left + panel_pos.left);
$('.fourth').css('top', settings_pos.top + panel_pos.top);
$('.second').css('left', tools_pos.left + panel_pos.left);
$('.second').css('top', tools_pos.top + panel_pos.top);
}
}

function close_connected_dialog() {
$('#canvas .canvas_object').show();
$('.connected').remove();
$('.ui-dialog').remove();
$('.instructional_marker').hide().remove();
}

// TODO move to User
function reset_display_name() {
$('#display_name').val(env.display_name);
}

initialize_name = function(){
if($.cookie('display_name')){
function initialize_name() {
if ($.cookie('display_name')) {
$('#display_name').val($.cookie('display_name'));
$('#name_change').submit();
}
Expand Down

0 comments on commit ab26ae3

Please sign in to comment.