Skip to content

Commit 00eed0c

Browse files
author
kuivenhoven1
committed
work from today
1 parent a00caac commit 00eed0c

File tree

18 files changed

+1008
-138
lines changed

18 files changed

+1008
-138
lines changed

stats/urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
urlpatterns = patterns('stats.views',
88
url(r'^session/?$', 'get_session'),
9-
url(r'^doesthis/?$', 'doesthis'),
9+
url(r'^take_survey/?$', 'take_survey'),
1010

1111
# /log/add/
1212
url(r'^add/?$', 'log_event'),

stats/views.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,26 @@ def get_session(request):
128128
session = retrieve_session(request.GET, request)
129129
return JsonResponse({"token": str(session.token)})
130130

131-
def doesthis(request):
132-
return render_to_response('doesthis.html', {}, context_instance=RequestContext(request))
131+
def take_survey(request):
132+
json_keyfile_name = 'account_secret.json'
133+
scopes = [
134+
'https://www.googleapis.com/auth/surveys',
135+
'https://www.googleapis.com/auth/surveys.readonly',
136+
'https://www.googleapis.com/auth/userinfo.email',
137+
]
138+
139+
try:
140+
credentials = ServiceAccountCredentials.from_json_keyfile_name(json_keyfile_name, scopes)
141+
http = httplib2.Http()
142+
auth_http = credentials.authorize(http)
143+
except clientsecrets.InvalidClientSecretsError, e:
144+
print ('Unable to setup authorization with the given credentials. %s'
145+
% e)
146+
return
147+
148+
surveys_service = build('surveys', 'v2', http=auth_http)
149+
150+
return render_to_response('take_survey.html', {'surveys_service': surveys_service}, context_instance=RequestContext(request))
133151

134152
# exempt logEvent from CSRF protection, or programs will not be able to
135153
# submit their statistics!
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Carousel Auto-Cycle
2+
$(document).ready(function() {
3+
$('.carousel').carousel({
4+
interval: 6000
5+
})
6+
});
7+
Lines changed: 168 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,170 @@
1-
/*function myFunction(h) {
2-
document.getElementById('hide_cities' + h).style.visibility="hidden";
3-
}*/
1+
var change_r, change_c, change_t;
42

5-
function myStuff(h) {
6-
alert(h);
3+
function show_regions(){
4+
var regions = document.getElementsByClassName("toggle_regions");
5+
if(!change_r){
6+
for(var i=0; i<regions.length; i++){
7+
regions[i].style.display = 'none';
8+
}
9+
change_r = 1;
10+
}
11+
else if(change_r == 1){
12+
for(var i=0; i<regions.length; i++){
13+
regions[i].style.display = 'block';
14+
}
15+
change_r = 0;
16+
}
717
}
18+
19+
function show_countries(){
20+
var countries = document.getElementsByClassName("toggle_countries");
21+
if(!change_c){
22+
for(var i=0; i<countries.length; i++){
23+
countries[i].style.display = 'block';
24+
}
25+
change_c = 1;
26+
}
27+
else if(change_c == 1){
28+
for(var i=0; i<countries.length; i++){
29+
countries[i].style.display = 'none';
30+
}
31+
change_c = 0;
32+
}
33+
}
34+
35+
function show_cities(){
36+
var cities = document.getElementsByClassName("toggle_cities");
37+
if(!change_t){
38+
for(var i=0; i<cities.length; i++){
39+
cities[i].style.display = 'block';
40+
}
41+
change_t = 1;
42+
}
43+
else if(change_t == 1){
44+
for(var i=0; i<cities.length; i++){
45+
cities[i].style.display = 'none';
46+
}
47+
change_t = 0;
48+
}
49+
}
50+
51+
function get_regions(){
52+
var waypts = [];
53+
var checked = document.getElementById('waypoints_regions');
54+
for(var i=0; i < checked.length; i++){
55+
if(checked.options[i].selected){
56+
waypts.push(checked[i].value);
57+
}
58+
}
59+
60+
for(var j=0; j < waypts.length; j++){
61+
var tmp = document.getElementsByClassName(waypts[j]);
62+
for(var k=0; k<tmp.length; k++){
63+
tmp[k].style.display = 'block';
64+
}
65+
}
66+
}
67+
68+
69+
function get_countries(){
70+
var waypts = [];
71+
var checked = document.getElementById('waypoints_countries');
72+
for(var i=0; i < checked.length; i++){
73+
if(checked.options[i].selected){
74+
waypts.push(checked[i].value);
75+
}
76+
}
77+
78+
for(var j=0; j < waypts.length; j++){
79+
var tmp = document.getElementsByClassName(waypts[j]);
80+
for(var k=0; k<tmp.length; k++){
81+
tmp[k].style.display = 'block';
82+
}
83+
}
84+
}
85+
86+
87+
function get_cities(){
88+
var waypts = [];
89+
var checked = document.getElementById('waypoints_cities');
90+
for(var i=0; i < checked.length; i++){
91+
if(checked.options[i].selected){
92+
waypts.push(checked[i].value);
93+
}
94+
}
95+
96+
for(var j=0; j < waypts.length; j++){
97+
var tmp = document.getElementsByClassName(waypts[j]);
98+
for(var k=0; k<tmp.length; k++){
99+
tmp[k].style.display = 'block';
100+
}
101+
}
102+
}
103+
104+
function add_vals(what){
105+
var tooshay = document.getElementsByClassName(what.value);
106+
//alert(what.selectedIndex);
107+
//console.log(what.value);
108+
for(var k=0; k < what.length; k++){
109+
if(what.options[k].selected){
110+
console.log(what[k].value);
111+
}
112+
}
113+
for(var g=0; g < tooshay.length; g++){
114+
tooshay[g].style.display = 'block';
115+
}
116+
}
117+
118+
$(function() {
119+
$('#waypoints_regions').on('hidden.bs.select', function (e) {
120+
alert("what a stressful meeting");
121+
});
122+
});
123+
124+
/*$(function() {
125+
$('#selectpicker-container').on('hide.bs.dropdown', function () {
126+
alert('hide.bs.dropdown');
127+
})
128+
});*/
129+
130+
/*$(function() {
131+
$('#waypoints_regions').multiselect({
132+
onDropdownHidden: function(event){
133+
alert('hi');
134+
//window.location.reload();
135+
},
136+
enableFiltering: true,
137+
enableCaseInsensitiveFiltering: true,
138+
selectedClass: null,
139+
nonSelectedText: 'All Clients',
140+
includeSelectAllOption: true,
141+
buttonWidth: '100%',
142+
maxHeight: 250
143+
});
144+
});*/
145+
146+
/*$('.selectpicker').selectpicker({
147+
style: 'btn-info',
148+
size: 4
149+
});*/
150+
151+
152+
153+
154+
155+
156+
157+
158+
159+
160+
161+
162+
163+
164+
165+
166+
167+
168+
169+
170+

statsPage/templates/action_stats/most_used_pie.html

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
</div>
2020
</div>
2121

22-
23-
2422
<div id="chart_div" style="width:1000; height:500;"></div>
2523

2624
<script>
@@ -62,9 +60,9 @@
6260
trigger: 'focus',
6361
showColorCode:'true',
6462
text:'percentage'
65-
},
63+
},
6664
'slices':{}
67-
};
65+
};
6866

6967
// Instantiate and draw our chart, passing in some options.
7068
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
@@ -107,40 +105,6 @@
107105
$("text:contains(" + "Retirement Investments" + ")").attr({'x':'276', 'y':'67'})
108106
}
109107

110-
111-
112-
/*google.charts.load('current', {'packages':['corechart']});
113-
google.charts.setOnLoadCallback(drawChart);
114-
115-
function drawChart() {
116-
117-
var outer_len = cool_data.length;
118-
var inner_len = cool_data[0].length;
119-
var outer_array = [];
120-
var i;
121-
var j;
122-
for(i = 0; i < outer_len; i++)
123-
{
124-
var inner_array = [];
125-
for(j = 0; j < inner_len; j++)
126-
{
127-
inner_array.push(cool_data[i][j]);
128-
}
129-
outer_array.push(inner_array);
130-
}
131-
132-
var data = google.visualization.arrayToDataTable(outer_array);
133-
134-
var options = {
135-
title: 'Action functions'
136-
};
137-
138-
var chart = new google.visualization.PieChart(document.getElementById('piechart'));
139-
140-
chart.draw(data, options);
141-
}*/
142-
143-
144108
</script>
145109

146110
{% endblock content %}

statsPage/templates/base.html

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,30 @@
11
{% load staticfiles %}
2+
<head>
23
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" type="text/css">
4+
<!--script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script-->
5+
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
6+
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
7+
<!--script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
8+
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script-->
9+
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.13/js/bootstrap-multiselect.min.js"></script>
10+
11+
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
12+
13+
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.7.2/js/bootstrap-select.min.js"></script>
14+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.7.2/css/bootstrap-select.min.css" type="text/css"/>
15+
16+
<!--script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.6.3/js/bootstrap-select.min.js"></script>
17+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.6.3/css/bootstrap-select.min.css" type="text/css"/-->
18+
19+
<!--link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.13/css/bootstrap-multiselect.css" type="text/css">
20+
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.13/js/bootstrap-multiselect.js"></script>
21+
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.13/js/bootstrap-multiselect.min.js"></script-->
22+
323
<link href="{% static 'css/base/footer.css' %}" rel="stylesheet">
424
<link href="{% static 'css/base/social.css' %}" rel="stylesheet">
525

6-
<!-- JavaScript -->
7-
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
8-
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
926
<script type="text/javascript" src="{% static 'js/base/social.js' %}"></script>
27+
</head>
1028
<!-- http://stackoverflow.com/questions/14720464/django-project-base-template -->
1129
<!-- http://bootsnipp.com/snippets/featured/social-buttons-for-bootstrap -->
1230
<!-- http://lipis.github.io/bootstrap-social/ -->
@@ -32,6 +50,7 @@
3250
<ul role="menu" class="dropdown-menu">
3351
<li><a href="/stats/world_stats/">World Stats</a></li>
3452
<li><a href="/stats/geo_stats/">Geo Stats</a></li>
53+
<li><a href="/stats/table/">Table Stats</a></li>
3554
</ul>
3655
</li>
3756

@@ -62,21 +81,21 @@
6281

6382
<li class="dropdown">
6483
<a data-toggle="dropdown" class="dropdown-toggle" href="#">Testing Page<b class="caret"></b></a>
65-
<ul role="menu" class="dropdown-menu">
66-
<!--li><a href="/stats/testing/">Testing Page</a></li-->
84+
<ul role="menu" class="dropdown-menu"-->
85+
<li><a href="/stats/testing/">Testing Page</a></li>
6786
<!--li><a href="/stats/nested_chart/">Nested Chart Page</a></li-->
68-
<!--li><a href="/stats/k_bro/">K Bro Page</a></li-->
87+
<li><a href="/stats/k_bro/">K Bro Page</a></li>
6988
</ul>
7089
</li>
7190

7291
</ul>
7392
<ul class="nav navbar-nav navbar-right">
7493
<li><a href="/logout/">Logout</a></li>
7594
</ul>
76-
<ul class="nav navbar-nav navbar-right">
77-
<li><a href="/log/doesthis/">Survey</a></li>
78-
<!--li><a href="/stats/survey/">Survey</a></li-->
79-
</ul>
95+
<!--ul class="nav navbar-nav navbar-right">
96+
<li><a href="/log/take_survey/">Survey</a></li>
97+
<-li><a href="/stats/survey/">Survey</a></li->
98+
</ul-->
8099
<ul class="nav navbar-nav navbar-right">
81100
<li><a href="/stats/help/">Help</a></li>
82101
</ul>
@@ -85,10 +104,10 @@
85104
<ul class="nav navbar-nav navbar-left">
86105
<li><a href="/stats">Home</a></li>
87106
</ul>
88-
<ul class="nav navbar-nav navbar-right">
107+
<!--ul class="nav navbar-nav navbar-right">
89108
<li><a href="/log/doesthis/">Survey</a></li>
90-
<!--li><a href="/stats/survey/">Survey</a></li-->
91-
</ul>
109+
<-li><a href="/stats/survey/">Survey</a></li->
110+
</ul-->
92111
<ul class="nav navbar-nav navbar-right">
93112
<li><a href="/stats/help/">Help</a></li>
94113
</ul>

0 commit comments

Comments
 (0)