//(function(){ var _mdm = {}; _mdm.element = document.activeElement; window.addEventListener('message', function(event){ _mdm.element.value = event.data; _mdm.close(); }); _mdm.page = '//bphogan.com/markdownmark/bookmarklet.html'; // Save the _mdm.inject = function(){ var iframe = document.getElementById("mdm_iframe"); iframe.contentWindow.postMessage("inject", "*"); }; _mdm.close = function(){ s = document.getElementById("mdm_bookmarklet"); document.body.removeChild(s); }; _mdm.showdeadcenterdiv = function(divid, Xwidth,Yheight) { // First, determine how much the visitor has scrolled var scrolledX, scrolledY; if( self.pageYOffset ) { scrolledX = self.pageXOffset; scrolledY = self.pageYOffset; } else if( document.documentElement && document.documentElement.scrollTop ) { scrolledX = document.documentElement.scrollLeft; scrolledY = document.documentElement.scrollTop; } else if( document.body ) { scrolledX = document.body.scrollLeft; scrolledY = document.body.scrollTop; } // Next, determine the coordinates of the center of browser's window var centerX, centerY; if( self.innerHeight ) { centerX = self.innerWidth; centerY = self.innerHeight; } else if( document.documentElement && document.documentElement.clientHeight ) { centerX = document.documentElement.clientWidth; centerY = document.documentElement.clientHeight; } else if( document.body ) { centerX = document.body.clientWidth; centerY = document.body.clientHeight; } // Xwidth is the width of the div, Yheight is the height of the // div passed as arguments to the function: var leftOffset = scrolledX + (centerX - Xwidth) / 2; var topOffset = scrolledY + (centerY - Yheight) / 2; // The initial width and height of the div can be set in the // style sheet with display:none; divid is passed as an argument to // the function var o=document.getElementById(divid); var r=o.style; r.position='absolute'; r.top = topOffset + 'px'; r.left = leftOffset + 'px'; r.display = "block"; }; _mdm.div = document.createElement("div"); _mdm.div.id = "mdm_bookmarklet"; _mdm.div.setAttribute("draggable", true); _mdm.div.style.zIndex = 10000000000; _mdm.div.style.width = "50%"; _mdm.div.style.height = "75%" _mdm.div.style.border = "2px solid #214b70"; _mdm.div.style.backgroundColor = "#fff"; _mdm.div.style.position = "fixed"; _mdm.div.style.right = 0; _mdm.div.style.top = "10px"; _mdm.content = "" _mdm.content += ''; if(_mdm.element.value != undefined){ _mdm.content += ""; } _mdm.content += "Cancel"; _mdm.div.innerHTML = _mdm.content; document.body.insertBefore(_mdm.div, document.body.firstChild); //_mdm.showdeadcenterdiv("mdm_bookmarklet", 300, 400); // })();