-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindexScript.js
62 lines (53 loc) · 2.07 KB
/
indexScript.js
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
$(document).ready(function() {
/*
$.ajax({
type: 'GET',
dataType: 'jsonp',
contentType: "application/json; charset=utf-8",
data:"{}",
url: "http://analyzereadsserverphp-env.us-west-2.elasticbeanstalk.com/?func=setupOauth&callback=?", // The server URL
error: function (jqXHR, textStatus, errorThrown) {
console.log(jqXHR, textStatus, errorThrown)
},
success: function (msg) {
console.log(msg["data"]);
saved = msg["data"];
//window.location.href = saved;
}
});
*/
//delay text appearance
var timeDelay = 1000;
$("#title").hide().fadeIn(timeDelay);
$("#title_border").hide().fadeIn(timeDelay);
$("#text").hide().delay(timeDelay/2).fadeIn(timeDelay);
});
//triggered by the button in home.html
function modalButton() {
//open a popup window
var saved ='';
var authWindow = window.open('about:blank', '', 'left=20,top=20,width=400,height=400,toolbar=0,resizable=1');
//make ajax request to php-server file
$.ajax({
type: 'GET',
dataType: 'jsonp',
contentType: "application/json; charset=utf-8",
data:"{}",
url: "http://analyzereadsserverphp-env.us-west-2.elasticbeanstalk.com/?func=setupOauth&callback=?", // The server URL
error: function (jqXHR, textStatus, errorThrown) {
//log failure
console.log(jqXHR, textStatus, errorThrown)
return saved;
},
success: function (msg) {
//on success, replace the link of the popup window the link returned
saved = msg["data"];
authWindow.location.replace(saved);
/*
add new script to popup to redirect to the window openner's location
and close window
*/
$(authWindow.document.body).append("<script>window.addEventListener('hashchange',myFunc); function myFunc(){alert('blah');window.opener.location = '/redirect.html';window.close();}</script>");
}
});
};