From 4b1755bd15d9e5427c81f638e2b06d4716cd8642 Mon Sep 17 00:00:00 2001 From: Adrian Lang <mail@adrianlang.de> Date: Thu, 21 Apr 2011 09:18:05 +0200 Subject: [PATCH] Make locktimer more robust If no HTML element with the id wiki__text exists, locktimer.init led to a JavaScript error. --- lib/exe/js.php | 2 +- lib/scripts/locktimer.js | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/exe/js.php b/lib/exe/js.php index 645ab3cc4..5f376ee24 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -113,7 +113,7 @@ function js_out(){ js_runonstart("initSizeCtl('size__ctl','wiki__text')"); js_runonstart("initToolbar('tool__bar','wiki__text',toolbar)"); if($conf['locktime'] != 0){ - js_runonstart("locktimer.init(".($conf['locktime'] - 60).",'".js_escape($lang['willexpire'])."',".$conf['usedraft'].")"); + js_runonstart("locktimer.init(".($conf['locktime'] - 60).",'".js_escape($lang['willexpire'])."',".$conf['usedraft'].", 'wiki__text')"); } js_runonstart('scrollToMarker()'); js_runonstart('focusMarker()'); diff --git a/lib/scripts/locktimer.js b/lib/scripts/locktimer.js index f5ba1c60d..0db7d2b15 100644 --- a/lib/scripts/locktimer.js +++ b/lib/scripts/locktimer.js @@ -9,7 +9,11 @@ var locktimer = { msg: '', pageid: '', - init: function(timeout,msg,draft){ + init: function(timeout,msg,draft,edid){ + var edit = $(edid); + if(!edit) return; + if(edit.readOnly) return; + // init values locktimer.timeout = timeout*1000; locktimer.msg = msg; @@ -19,7 +23,6 @@ var locktimer = { if(!$('dw__editform')) return; locktimer.pageid = $('dw__editform').elements.id.value; if(!locktimer.pageid) return; - if($('wiki__text').readOnly) return; // init ajax component locktimer.sack = new sack(DOKU_BASE + 'lib/exe/ajax.php'); -- GitLab