-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwell_bookmarklet.js
More file actions
47 lines (46 loc) · 1.6 KB
/
well_bookmarklet.js
File metadata and controls
47 lines (46 loc) · 1.6 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
console.log("V8")
if (window.jQuery === undefined) {
var script = document.createElement( 'script' );
script.src = "https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js";
script.onload = function() { sendData; }
document.body.appendChild(script);
}
else {
sendData();
}
function sendData() {
var url = "//well.prehype.com/api_v1/articles.json";
data = {}
data.topic = {value: 1}
data.url = location.href
jQuery.ajax({
type: "POST",
url: url,
data: data,
success: function() {
console.log("Article Submitted");
var notification = document.createElement("div")
notification.style.position = 'absolute'
notification.style.top = "0px"
notification.style.left = "0px"
notification.style.right = "0px"
notification.style.width = "width:100%"
notification.style.height = "50px"
notification.style.width = "100%"
notification.style.background = "#1C8C53"
notification.style.lineHeight = "50px"
notification.style.textAlign = "center"
notification.style.color = "white"
notification.style.zIndex = "2147483647"
notification.style.fontSize = "22px"
notification.innerHTML = "Article Added"
notification.setAttribute("id", "prehype-notification");
document.body.insertBefore(notification, document.body.firstChild);
setTimeout(function(){
var notification = document.getElementById('prehype-notification')
notification.style.display = "none"
}, 3000);
},
error: function() { alert("Something went wrong. Ping Z please.");}
});
}