Skip to content

Commit

Permalink
accommodates hogfather's deferred javascript output
Browse files Browse the repository at this point in the history
  • Loading branch information
turnermm committed Jan 24, 2021
1 parent c3ff6c9 commit 167a93e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 10 deletions.
9 changes: 7 additions & 2 deletions action.php
Expand Up @@ -8,9 +8,14 @@
require_once(DOKU_PLUGIN.'action.php');
class action_plugin_goto extends DokuWiki_Action_Plugin {
public function register(Doku_Event_Handler $controller) {
$controller->register_hook('ACTION_ACT_PREPROCESS', 'BEFORE', $this, 'handle_act',array('before'));
$controller->register_hook('ACTION_ACT_PREPROCESS', 'BEFORE', $this, 'handle_act',array('before'));
$controller->register_hook('DOKUWIKI_STARTED', 'AFTER', $this, 'started',array('after'));
}

function started(Doku_Event $event, $param) {
global $JSINFO,$updateVersion;
$JSINFO['update_version'] = $updateVersion;
}

function handle_act(Doku_Event $event, $param) {
global $conf,$USERINFO,$INPUT;
$act = act_clean($event->data);
Expand Down
4 changes: 2 additions & 2 deletions plugin.info.txt
@@ -1,7 +1,7 @@
base goto
author Allen Ormond,cziehr, turnermm
email turnermm02@shaw.ca
date 2021-01-21
date 2021-01-24
name GOTO
desc Easily red>irect to other pages in your wiki.
desc Easily redirect to other pages in your wiki.
url https://www.dokuwiki.org/plugin:goto
14 changes: 11 additions & 3 deletions script.js
Expand Up @@ -18,7 +18,7 @@ function goto_redirect(which,mode) {
location.href = which;

clearTimeout(goto_tm);
setGotoCookie("GOTO_LOGIN", "") ;
setGotoCookie("GOTO_LOGIN", "") ;
}
function goto_getCookie(name) {
var re = new RegExp(name + "=([^;]+)");
Expand All @@ -34,12 +34,20 @@ function setGotoCookie(cname, cvalue) {
}

jQuery( document ).ready(function() {

if(JSINFO['update_version'] > 50) {
var domval = window.document.getElementById("goto_go").innerHTML;
var ar = domval.split(';');
if(ar) {
var url = ar[0]; var delay = ar[1];
setTimeout(function(){ location.href = url; }, delay,url);
return;
}
}
var which = goto_getCookie("GOTO_LOGIN");

if(!which) {
return;
}
location.href = DOKU_BASE + 'doku.php?id=' + decodeURIComponent(which) ;
location.href = DOKU_BASE + 'doku.php?id=' + decodeURIComponent(which) ;
setGotoCookie("GOTO_LOGIN", "") ;
});
15 changes: 12 additions & 3 deletions syntax.php
Expand Up @@ -61,12 +61,15 @@ function handle($match, $state, $pos, Doku_Handler $handler){
return array($matches[0], $seconds, $message,$is_usr,$is_extern);
}

function render($mode, Doku_Renderer $renderer, $data) {
function render($mode, Doku_Renderer $renderer, $data) {
if($mode != 'xhtml') return false;
global $ACT;
global $updateVersion;
global $ACT;
$internal_link = false;
if(!$data[3]) {
if(!$data[4]) {
$message = str_replace("%d",$renderer->internallink($data[0], $data[0],'', true),$data[2]);
$internal_link = true;
}
else {
$message = str_replace("%d",$data[0],$data[2]);
Expand All @@ -84,7 +87,13 @@ function render($mode, Doku_Renderer $renderer, $data) {
}
if ($ACT != 'preview') {
if(!$data[3] && !$data[4]) {
$renderer->doc .= '<script>url="'.$url.'";setTimeout("location.href=url",'.($data[1]*1000).');</script>';
$tm= $data[1]*1000;
if($updateVersion > 50) {
$renderer->doc .= '<span id = "goto_go">'.$url .';'.$tm.'</span>';
}
else {
$renderer->doc .= "<script>var goto_tm= setTimeout(function(){goto_redirect('$url', '$data[4]');},$tm);</script>";
}
}
else{
$tm =($data[1]*1000);
Expand Down

0 comments on commit 167a93e

Please sign in to comment.