Skip to content

Instantly share code, notes, and snippets.

@pmarkun
Created March 27, 2013 06:25
Show Gist options
  • Save pmarkun/5252145 to your computer and use it in GitHub Desktop.
Save pmarkun/5252145 to your computer and use it in GitHub Desktop.
Preparando bookmarklet para as anotações do regimento interno
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