Commit c80aa4e4 authored by Michael Schreiber's avatar Michael Schreiber
Browse files

copy to clipboard added

parent 1ee0e2bf
......@@ -9,10 +9,27 @@ if(window.toolbar != undefined) {
"title":"Password",
"icon":color_icobase+"lock_light_gray.png",
"open":"<pwd>",
"close":"</pwd><copyClip onClick=\"copyClip();\"/>"
"close":"</pwd>"
};
}
function copyClip(){
alert('test');
}
\ No newline at end of file
function copyClip(id){
var copyText = document.getElementById(id);
text = copyText.textContent;
var el = document.createElement('textarea');
el.value = text;
document.body.appendChild(el);
el.select();
document.execCommand('copy');
document.body.removeChild(el);
el = document.createElement("div");
el.setAttribute("style","font-size: 2em;text-align:center;vertical-alignment:middle;position:absolute;top:10%;left:10%;width:80%;height:80%;background-color:white;");
el.innerHTML = "Copied to clipboard!";
setTimeout(function(){
el.parentNode.removeChild(el);
},1000);
document.body.appendChild(el);
}
......@@ -12,7 +12,8 @@ if(!defined('DOKU_INC')) die();
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
require_once(DOKU_PLUGIN.'syntax.php');
/**
* All DokuWiki plugins to extend the parser/rendering mechanism
* need to inherit from this class
......@@ -44,15 +45,17 @@ class syntax_plugin_passwordgrey extends DokuWiki_Syntax_Plugin {
* Create output
*/
function render($mode, Doku_Renderer $renderer, $data) {
if($mode == 'xhtml'){
list($state, $match) = $data;
if($mode == 'xhtml'){
$r = rand(0,100000);
list($state, $match) = $data;
switch ($state) {
case DOKU_LEXER_ENTER :
list($color, $background) = $match;
$renderer->doc .= "<span style='$color $background'>";
$renderer->doc .= "<span id='clipID_$r' onclick=\"javaScript:copyClip('clipID_".$r."');\" style='$color $background'>";
break;
case DOKU_LEXER_UNMATCHED : $renderer->doc .= $renderer->_xmlEntities($match); break;
//case DOKU_LEXER_EXIT : $renderer->doc .= "<img src='./lib/plugins/passwordgrey/images/copyClipboard.png'/></span>"; break;
case DOKU_LEXER_EXIT : $renderer->doc .= "</span>"; break;
}
return true;
......@@ -63,7 +66,7 @@ class syntax_plugin_passwordgrey extends DokuWiki_Syntax_Plugin {
case DOKU_LEXER_ENTER :
list($color, $background) = $match;
if (class_exists('ODTDocument')) {
$renderer->_odtSpanOpenUseCSS (NULL, 'style="'.$color.$background.'"');
$renderer->_odtSpanOpenUseCSS (NULL, 'style="'.$color.' '.$background.'"');
}
break;
......@@ -82,4 +85,3 @@ class syntax_plugin_passwordgrey extends DokuWiki_Syntax_Plugin {
return false;
}
}
?>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment