Repository navigation
Expand file tree
/
Copy pathpopup.js
More file actions
58 lines (52 loc) · 2.43 KB
/
Copy pathpopup.js
File metadata and controls
58 lines (52 loc) · 2.43 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
window.onload = function() {
$("#authorIn .error").hide();
$("#timeIn .error").hide();
document.getElementById("convertButton").onclick = function() {
var name = document.getElementById("poster").value;
var time = document.getElementById("timeofPost").value;
// Format:
// 2001-01-01T08:19
// 2001-01-01T20:19
chrome.runtime.sendMessage(
{type: "convert", post_name: name, timestamp: time}, function(response) {
if (response.isValid) {
console.log("Got message back to display in extension.\n" +
"Response: " + response.time + " " + response.content);
$("#resInstr").html(
"<span id=\"instrs\">Copy and paste the following into " +
"your e-mail!</span>");
$("#res").html("On " + response.time + ", <b>" + name +
"</b> wrote:<br /><br />" + response.content);
$("#res").css("border-style", "solid");
$("#res").css("color", "initial");
$("#poster").css("border-color", "initial");
$("#timeofPost").css("border-color", "initial");
}
else {
$("#res").css("color", "initial");
$("#poster").css("border-color", "initial");
$("#timeofPost").css("border-color", "initial");
if (response.content == "") {
$("#resInstr").html("<b>Post Not Found</b>");
} else { // User did not enter at least one of the fields
$("#resInstr").html("<b>" + response.content + "</b>");
if ($("#poster").val() == "") {
$("#poster").css("border-color", "red");
$("#authorIn .error").show();
} else {
$("#poster").css("border-color", "initial");
$("#authorIn .error").hide();
}
if ($("#timeofPost").val() == "") {
$("#timeofPost").css("border-color", "red");
$("#timeIn .error").show();
} else {
$("#timeofPost").css("border-color", "initial");
$("#timeIn .error").hide();
}
$("#resInstr").css("color", "red");
}
}
});
}
}