Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Michael Schreiber
passwordgrey
Commits
c80aa4e4
Commit
c80aa4e4
authored
Oct 31, 2019
by
Michael Schreiber
Browse files
copy to clipboard added
parent
1ee0e2bf
Changes
2
Hide whitespace changes
Inline
Side-by-side
script.js
View file @
c80aa4e4
...
...
@@ -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
);
}
syntax.php
View file @
c80aa4e4
...
...
@@ -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
;
}
}
?>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment