Created
March 23, 2010 10:39
-
-
Save fjakobs/341039 to your computer and use it in GitHub Desktop.
bookmarklet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" | |
"http://www.w3.org/TR/html4/strict.dtd"> | |
<html lang="en"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
<title>Container</title> | |
<meta name="author" content="Fabian Jakobs"> | |
<!-- Date: 2008-12-18 --> | |
</head> | |
<body> | |
<a id="bookmarklet">bookmarklet (bookmark me)</a><br> | |
<script type="text/javascript" charset="utf-8"> | |
function loadBookmarklet() { | |
var widgetId = "bookmarkletWidget"; | |
var widgetElement = document.getElementById(widgetId); | |
if (widgetElement) { | |
widgetElement.style.display = "block"; | |
return; | |
} | |
var script = document.createElement("script"); | |
script.src = "http://juhukinners.appspot.com/static/bookmarklet/widget/widget.js"; | |
script.type = "text/javascript"; | |
document.body.appendChild(script); | |
}; | |
document.getElementById("bookmarklet").href = | |
"javascript:(" + | |
loadBookmarklet.toString() + | |
")();" | |
</script> | |
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. | |
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#bookmarkletWidget { | |
position: absolute; | |
left: 10px; | |
top: 10px; | |
padding: 10px; | |
background-color: lime; | |
border: 1px solid black; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
var ROOT_URL = "http://juhukinners.appspot.com/static/bookmarklet/widget"; | |
var Widget = function(id) { | |
this.element = document.createElement("div"); | |
this.element.id = id; | |
this.element.innerHTML = "<h1>Juhu Kinners!</h1>click to hide"; | |
this.element.style.top = (document.documentElement.scrollTop + 30) + "px" | |
var that = this; | |
this.element.onclick = function() { that.element.style.display = "none"; }; | |
}; | |
function loadCss(url) { | |
var el = document.createElement("link"); | |
el.type = "text/css"; | |
el.rel = "stylesheet"; | |
el.href = url; | |
var head = document.getElementsByTagName("head")[0]; | |
head.appendChild(el); | |
}; | |
function main() { | |
var widgetId = "bookmarkletWidget"; | |
loadCss(ROOT_URL + "/style.css"); | |
var widget = new Widget(widgetId); | |
document.body.appendChild(widget.element); | |
} | |
main(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What does it do?