-
Notifications
You must be signed in to change notification settings - Fork 41
/
visitors.rhtml
120 lines (102 loc) · 4.21 KB
/
visitors.rhtml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<script>
VisitorViewer = {
selectedEntry:null,
clear_detail: function() {
if(VisitorViewer.selectedEntry) {
Element.removeClassName('entry_' + VisitorViewer.selectedEntry,'selected_row');
}
},
detail: function(entry_id) {
VisitorViewer.clear_detail();
new Ajax.Updater('visitor_detail',
"<%= url_for :action => 'visitor_detail' %>/" + entry_id);
Element.addClassName('entry_' + entry_id,'selected_row');
VisitorViewer.selectedEntry = entry_id;
},
loadStatistics: function() {
if(!$('site_statistics_details')) {
new Ajax.Updater('site_statistics',
"<%= url_for :action => 'site_statistics' %>/" );
}
},
googleRadios: function() {
if($('options_google_analytics_disabled').checked) {
$('options_analytics_code').disabled = true;
Element.hide('analytics_enabled');
Element.show('analytics_disabled');
}
else if($('options_google_analytics_enabled').checked) {
$('options_analytics_code').disabled = false;
Element.show('analytics_enabled');
Element.hide('analytics_disabled');
}
},
saveOptions: function(frm) {
params = Form.serialize(frm);
$('submit_options').disabled = true;
new Ajax.Request("<%= url_for :action=>'options_update' %>",
{
parameters: params,
onComplete: function(req) {
$('submit_options').disabled = false;
new Effect.Appear('options_updated');
}
});
return false;
}
}
<%= active_table_javascript %>
</script>
<% action_panel :handler => 'visitors', :more => true do |p| -%>
<% end -%>
<% more_action_panel :handler => 'visitors' do |p| -%>
<%= p.link "Visitors", {:url => "javascript:void(0);"}, :"j-action" => 'swap', :swap => '#visitors,#google_analytics' %>
<%= p.link "Google Analytics", {:url => "javascript:void(0);"}, :"j-action" => 'swap', :swap => '#google_analytics,#visitors' %>
<% end -%>
<hr/>
<div id="visitors">
<table>
<tr>
<td style='padding-right:10px;' width='450' valign='top'>
<div id='entries_table'>
<%= render :partial => 'visitor_table' %>
</div>
</td>
<td style='padding-left:10px;' valign='top'>
<div id='visitor_detail'>
</div>
</td>
</tr>
</table>
</div>
<div id="google_analytics" style="display:none;" class="visitor_container">
<div class="heading"><h2>Google Analytics</h2></div>
<div class="visitor_container_body" style="width:600px;">
<div id='options_updated' style='display:none;'><b><%= "Options Updated".t %></b></div>
<% tabled_form_for :options, @options, :html => { :onsubmit => 'return VisitorViewer.saveOptions(this);' } do |f| %>
<%= f.radio_buttons :google_analytics, [ [ 'Enabled' , 'enabled' ], [ 'Disabled', 'disabled'] ], :label => "Google Analytics", :onchange => 'VisitorViewer.googleRadios()' %>
<%= f.text_field :analytics_code, :disabled => @options.google_analytics == 'enabled' ? false : true %>
<%= f.spacer %>
<%= f.submit_tag 'Update', :id => 'submit_options' %>
<% end -%>
<br/>
<div id='analytics_disabled' <%= "style='display:none;'" if @options.google_analytics == 'enabled'%>>
<%= "Google Analytics is a free service that tracks visitors to your website and allows you to analyze your traffic.".t %>
<%= "You must first".t %> <a target='_blank' href='<%= "http://www.google.com/analytics/".t %>'><%= "Register for Google Analytics".t %></a>.
<%="Once you are registered, please click enabled and enter your analytics code from the code block as highlighted below. ".t %>
<pre>
<%= h('
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">') %>
_uacct = "<b>UA-XXXXXXX-X</b>";
<%= h('
urchinTracker();
</script> ') %>
</pre>
</div>
<div id='analytics_enabled' <%= "style='display:none;'" unless @options.google_analytics == 'enabled'%>>
<%= "Goto".t %><a target='_blank' href='http://www.google.com/analytics/'><%= "Your Google Analytics Account".t %></a>
</div>
</div>
</div>