Repository navigation
Expand file tree
/
Copy pathscript.js
More file actions
80 lines (56 loc) · 1.84 KB
/
Copy pathscript.js
File metadata and controls
80 lines (56 loc) · 1.84 KB
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
APP = {
survey: null,
surveys:{},
responses:[],
contactlists:[]
};
// Listen for any attempts to call changePage().
$(document).bind( "pagebeforechange", function( e, data ) {
// We only want to handle changePage() calls where the caller is
// asking us to load a page by URL.
if ( typeof data.toPage === "string" ) {
// We are being asked to load a page by URL, but we only
// want to handle URLs that request the data for a specific
// survey.
var u = $.mobile.path.parseUrl( data.toPage ),
re = /^#surveylist/;
if ( u.hash.search(re) !== -1 ) {
// We're being asked to display the items for a specific survey.
// Call our internal method that builds the content for the survey
// on the fly based on our in-memory survey data structure.
showSurvey( u, data.options );
// Make sure to tell changePage() we've handled this call so it doesn't
// have to do anything.
e.preventDefault();
}
if (u.hash.search(/^#responses/) !== -1 ) {
console.log('show responses');
showResponses(u, data.options);
e.preventDefault();
}
if (u.hash.search(/^#invite_/) !== -1 ) {
console.log('SHOW INVITE');
showInvite(u, data.options);
e.preventDefault();
}
if (u.hash.search(/^#send/) !== -1 ) {
console.log('SEND MAIL');
//find checked contact lists
var checked = $(':checked','#contactListSelectors');
APP.selected_list_ids = [];
checked.each(function(i,el){
//add each list ID to the array of selected lists
APP.selected_list_ids.push(+el.id.substring(9));
});
//create the email:
createEmail();
//sendEmail(u, data.options);
e.preventDefault();
}
}
});
$(document).ready(function(){
//fire the missles!
callAPI('GET','/surveys/',false,loadSurveys);
callAPI('GET','/contact-lists/',false,loadContactLists);
}); //end of document ready.