forked from publiclab/plots2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
research-notify.js
52 lines (41 loc) · 1.7 KB
/
research-notify.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
//Bookmarklet: javascript:(function(){document.body.appendChild(document.createElement('script')).src='https://gist.githubusercontent.com/jywarren/c21a3d6beb5f1e8d4f50/raw/115c2459f2c4d6e43dd1e1f369a4f2d0313601e9/research-notify.js';})()
//Nice tips on jquery inclusion etc here: http://www.smashingmagazine.com/2010/05/23/make-your-own-bookmarklets-with-jquery/
function getSelText() {
var SelText = '';
if (window.getSelection) {
SelText = window.getSelection();
} else if (document.getSelection) {
SelText = document.getSelection();
} else if (document.selection) {
SelText = document.selection.createRange().text;
}
return SelText;
}
(function(){
// the minimum version of jQuery we want
var v = "1.3.2";
// check prior inclusion and version
if (window.jQuery === undefined || window.jQuery.fn.jquery < v) {
var done = false;
var script = document.createElement("script");
script.src = "http://ajax.googleapis.com/ajax/libs/jquery/" + v + "/jquery.min.js";
script.onload = script.onreadystatechange = function(){
if (!done && (!this.readyState || this.readyState == "loaded" || this.readyState == "complete")) {
done = true;
initMyBookmarklet();
}
};
document.getElementsByTagName("head")[0].appendChild(script);
} else {
initMyBookmarklet();
}
function initMyBookmarklet() {
(window.myBookmarklet = function() {
// your JavaScript code goes here!
$('body')[0].onmouseup = function(e) {
window.location = "http://publiclab.org/post?title="+$('#title').text()+"&body="+getSelText()
}
alert("Drag to select the content you want to open source at PublicLab.org")
})();
}
})();