Created
March 27, 2013 06:25
-
-
Save pmarkun/5252145 to your computer and use it in GitHub Desktop.
Preparando bookmarklet para as anotações do regimento interno
This file contains 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 getSelectionHtml() { | |
var html = ""; | |
if (typeof window.getSelection != "undefined") { | |
var sel = window.getSelection(); | |
if (sel.rangeCount) { | |
var container = document.createElement("div"); | |
for (var i = 0, len = sel.rangeCount; i < len; ++i) { | |
container.appendChild(sel.getRangeAt(i).cloneContents()); | |
} | |
html = container.innerHTML; | |
} | |
} else if (typeof document.selection != "undefined") { | |
if (document.selection.type == "Text") { | |
html = document.selection.createRange().htmlText; | |
} | |
} | |
return html; | |
} | |
var highlight = getSelectionHtml(); | |
$("body").append("<div style='border:5;height:200px;width:400px;position:fixed;left:20px;top:20px;z-index:101;background-color:#fff;'><h2>Envie um novo Issue</h2><form><textarea>"+highlight+"</textarea><button>Enviar</button></form></div>"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment