forked from nitral/Arista
-
Notifications
You must be signed in to change notification settings - Fork 0
/
submitStory.js
81 lines (60 loc) · 3.28 KB
/
submitStory.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
document.getElementById("submit-story-submit").addEventListener("click", submitStory, false);
document.getElementById("submit-story-trigger").addEventListener("click", showSubmitStoryForm, false);
document.getElementById("back-sbumit-story").addEventListener("click", backSubmitStory, false);
document.getElementById("submitStory-to-mainMenu").addEventListener("click", hideSubmitStoryForm, false);
var submitBaseURL = "http://www.google.com/search?q=";
function showSubmitStoryForm() {
// Hide Menu
mainMenu.style.display = "none";
// Show Form
document.getElementById("submit-story").style.display = "block";
}
function hideSubmitStoryForm() {
// Clean Form
var inputFields = document.getElementsByTagName("input");
for(i = 0; i < inputFields.length; i++) {
inputFields[i].value = "";
}
document.getElementById("submit-story-story").value="";
// Hide Form
document.getElementById("submit-story").style.display = "none";
// Show Main Menu
mainMenu.style.display = "block";
}
function submitStory() {
// Show AJAX Loader
showAJAXLoader();
// Show Submission Message
document.getElementById("submit-story-progress-message").style.display = "block";
var xmlHTTPRequest = new XMLHttpRequest({
mozSystem: true
});
// Make Submit URL
var name = document.getElementById("submit-story-name");
var category = document.getElementById("submit-story-category").options[document.getElementById("submit-story-category").selectedIndex].value;
var story = document.getElementById("submit-story-story").value;
var submitURL = submitBaseURL + "?name=" + name + "&category=" + category + "&story=" + story;
xmlHTTPRequest.onreadystatechange = function() {
if (xmlHTTPRequest.readyState == 4 && xmlHTTPRequest.status == 200) {
// Hide AJAX Loader
hideAJAXLoader();
// Show Notification Overlay
document.getElementById("notification-overlay").style.display = "block";
document.getElementById("notification").style.display = "block";
// Show Success Sign
document.getElementById("success").style.display = "block";
// Hide Submission Progress Message
document.getElementById("submit-story-progress-message").style.display = "none";
// Show Submission Success Message and Back to Main Menu Button
document.getElementById("submit-story-success-message").style.display = "block";
}
}
xmlHTTPRequest.open("GET", submitURL, true);
xmlHTTPRequest.send();
}
function backSubmitStory() {
document.getElementById("success").style.display = "none";
document.getElementById("submit-story-success-message").style.display = "none";
document.getElementById("notification-overlay").style.display = "none";
document.getElementById("notification").style.display = "none";
}