Skip to content

Commit

Permalink
For GOTO>user, replaced user with "user" as wildcard for replacement …
Browse files Browse the repository at this point in the history
…in javascript redirect
  • Loading branch information
turnermm committed Mar 16, 2019
1 parent 10a13a1 commit ae03743
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
8 changes: 6 additions & 2 deletions script.js
@@ -1,8 +1,9 @@
/*
*@author Myron Turner <turnermm02@shaw.ca>
*/
function goto_redirect(which,extern) {
if(extern == 'extern') {
function goto_redirect(which,mode) {

if(mode == 'extern') {
location.href = which;
return;
}
Expand All @@ -11,6 +12,9 @@ function goto_redirect(which,extern) {
return;
}
clearTimeout(goto_tm);
if(mode == 'user') {
which = which.replace(/user/, user);
}
location.href = which;
setGotoCookie("DOKU_GOTO", "") ;

Expand Down
7 changes: 4 additions & 3 deletions syntax.php
Expand Up @@ -38,8 +38,8 @@ function handle($match, $state, $pos, Doku_Handler $handler){
$message = "<strong>".$this->getLang('redirect')."</strong>";
$matches = explode("?", substr($match,7,-2));
if($matches[0] == 'user') {
$matches[0] = ": $userid";
$is_usr = true;
$matches[0] = "user"; // wildcard replaced in javascript goto_redirect()
$is_usr = 'user';
$seconds = 1;
}
else if (preg_match("#^\s*https?:\/\/#",$matches[0])) {
Expand Down Expand Up @@ -88,7 +88,8 @@ function render($mode, Doku_Renderer $renderer, $data) {
}
else{
$tm =($data[1]*1000);
$renderer->doc .= "<script>var goto_tm= setTimeout(function(){goto_redirect('$url','$data[4]');},$tm);</script>";
if($data[3] == 'user') $data[4] = 'user';
$renderer->doc .= "<script>var goto_tm= setTimeout(function(){goto_redirect('$url', '$data[4]');},$tm);</script>";
}
}
return true;
Expand Down

0 comments on commit ae03743

Please sign in to comment.