Created
October 13, 2016 07:08
-
-
Save quentinproust/723cb055efc3ac8e9d50b3a676d667a4 to your computer and use it in GitHub Desktop.
Javascript popup to debug : add a small popup to the window with a value. I use it in a bookmark after minifying it.
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() { | |
var text = "Somme des salaires : "; | |
// popup | |
var x = document.createElement("div"); | |
x.appendChild(document.createTextNode(text)); | |
x.setAttribute("style", "border: 3px solid black; background: white; height: 30px; width: 200px; padding: 15px; position: fixed; top: 20%; right: 2%;"); | |
var close = document.createElement("a"); | |
close.appendChild(document.createTextNode("X")); | |
close.addEventListener("click", function() { document.body.removeChild(x); }); | |
close.style.position = "absolute"; | |
close.style.right = "5px"; | |
close.style.top = "5px"; | |
x.appendChild(close); | |
document.body.appendChild(x); | |
x.addEventListener ("mousedown", eleMouseDown); | |
function eleMouseDown (ev) { | |
document.addEventListener ("mousemove", eleMouseMove); | |
} | |
function eleMouseMove (ev) { | |
x.style.position = "absolute"; | |
x.style.left = ev.pageX + "px"; | |
x.style.top = ev.pageY + "px"; | |
document.addEventListener ("mouseup" , eleMouseUp , false); | |
} | |
function eleMouseUp () { | |
document.removeEventListener ("mousemove" , eleMouseMove , false); | |
document.removeEventListener ("mouseup" , eleMouseUp , false); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment