-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaster.js
76 lines (61 loc) · 1.85 KB
/
master.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
$("#link-field").on("click", function () {
$(this).select();
document.execCommand("copy");
});
function copyLink() {
/* Get the text field */
var copyText = document.getElementById("copy-btn");
/* Select the text field */
copyText.select();
/* Copy the text inside the text field */
document.execCommand("copy");
/* Alert the copied text */
alert("Copied the text: " + copyText.value);
}
// funciton by: https://stackoverflow.com/a/9964945/3578289
$.fn.enterKey = function (fnc) {
return this.each(function () {
$(this).keypress(function (ev) {
var keycode = (ev.keyCode ? ev.keyCode : ev.which);
if (keycode == '13') {
fnc.call(this, ev);
}
})
})
}
$("#academiaEmail").enterKey(function () {
console.log('academiaEmail here');
submitEmail('#academiaEmail');
})
$("#developerEmail").enterKey(function () {
console.log('developerEmail here');
submitEmail('#developerEmail');
})
function submitEmail (id) {
// var url = 'https://script.google.com/macros/s/AKfycbwTQWLE5P8j1J2QX_GuefVF6u3I-cuOl1wubXbQP8TqPE8XIsM/exec'
var url = 'https://script.google.com/macros/s/AKfycbwj51UBnjABNjHUasL_v_HQGg-MPH6pkDmvftR_Rdy1jN9VBKtQ/exec';
var email = $(id).val()
email = email.trim()
if (email === "") return;
$(id).attr("disabled", true);
var data = {Email: email, CreatedAt: new Date(), Type: id};
// console.log(data);
var jqxhr = $.ajax({
url: url,
method: "GET",
dataType: "json",
// data: $form.serializeObject()
data: data
})
.done(() => {
// do something
console.log('saved');
$(id).val('');
$(id).attr("disabled", false);
$(id).attr("placeholder", 'Thank you!');
});
}
$("#downloadBtn").on("click", function() {
// chrome.webstore.install(url, successCallback, failureCallback);
chrome.webstore.install()
});