Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dokuwiki
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BRIC
dokuwiki
Commits
80997d21
Commit
80997d21
authored
14 years ago
by
Michal Rezler
Browse files
Options
Downloads
Patches
Plain Diff
locktimer.js is jQueryfied
parent
b29919f7
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/exe/js.php
+1
-1
1 addition, 1 deletion
lib/exe/js.php
lib/scripts/locktimer.js
+72
-50
72 additions, 50 deletions
lib/scripts/locktimer.js
with
73 additions
and
51 deletions
lib/exe/js.php
+
1
−
1
View file @
80997d21
...
@@ -122,7 +122,7 @@ function js_out(){
...
@@ -122,7 +122,7 @@ function js_out(){
js_runonstart
(
"initSizeCtl('size__ctl','wiki__text')"
);
js_runonstart
(
"initSizeCtl('size__ctl','wiki__text')"
);
js_runonstart
(
"initToolbar('tool__bar','wiki__text',toolbar)"
);
js_runonstart
(
"initToolbar('tool__bar','wiki__text',toolbar)"
);
if
(
$conf
[
'locktime'
]
!=
0
){
if
(
$conf
[
'locktime'
]
!=
0
){
js_runonstart
(
"
l
ocktimer
.init
("
.
(
$conf
[
'locktime'
]
-
60
)
.
",'"
.
js_escape
(
$lang
[
'willexpire'
])
.
"',"
.
$conf
[
'usedraft'
]
.
")"
);
js_runonstart
(
"
initL
ocktimer("
.
(
$conf
[
'locktime'
]
-
60
)
.
",'"
.
js_escape
(
$lang
[
'willexpire'
])
.
"',"
.
$conf
[
'usedraft'
]
.
")"
);
}
}
js_runonstart
(
'scrollToMarker()'
);
js_runonstart
(
'scrollToMarker()'
);
js_runonstart
(
'focusMarker()'
);
js_runonstart
(
'focusMarker()'
);
...
...
This diff is collapsed.
Click to expand it.
lib/scripts/locktimer.js
+
72
−
50
View file @
80997d21
/**
/**
* Class managing the timer to display a warning on a expiring lock
* Class managing the timer to display a warning on a expiring lock
*/
*/
var
locktimer
=
{
sack
:
null
,
timeout
:
0
,
timerID
:
null
,
lasttime
:
null
,
msg
:
''
,
pageid
:
''
,
init
:
function
(
timeout
,
msg
,
draft
){
// must be global variables, they are called from outside too
var
initLocktimer
,
expWarning
;
(
function
(
$
)
{
var
reset
,
clear
,
refresh
,
refreshed
;
var
locktimer
=
{
timeout
:
0
,
timerID
:
null
,
lasttime
:
null
,
msg
:
''
,
pageid
:
''
,
};
initLocktimer
=
function
(
timeout
,
msg
,
draft
){
// init values
// init values
locktimer
.
timeout
=
timeout
*
1000
;
locktimer
.
timeout
=
timeout
*
1000
;
locktimer
.
msg
=
msg
;
locktimer
.
msg
=
msg
;
locktimer
.
draft
=
draft
;
locktimer
.
draft
=
draft
;
locktimer
.
lasttime
=
new
Date
();
locktimer
.
lasttime
=
new
Date
();
if
(
!
$
(
'
dw__editform
'
))
return
;
if
(
$
(
'
#dw__editform
'
).
length
==
0
)
return
;
locktimer
.
pageid
=
$
(
'
dw__editform
'
).
elements
.
id
.
value
;
locktimer
.
pageid
=
$
(
'
#dw__editform input[name=id]
'
).
val
();
if
(
!
locktimer
.
pageid
)
return
;
if
(
!
locktimer
.
pageid
)
return
;
if
(
$
(
'
wiki__text
'
).
readOnly
)
return
;
if
(
$
(
'
#wiki__text
'
).
attr
(
'
readonly
'
))
return
;
// init ajax component
locktimer
.
sack
=
new
sack
(
DOKU_BASE
+
'
lib/exe/ajax.php
'
);
locktimer
.
sack
.
AjaxFailedAlert
=
''
;
locktimer
.
sack
.
encodeURIString
=
false
;
locktimer
.
sack
.
onCompletion
=
locktimer
.
refreshed
;
// register refresh event
// register refresh event
addEvent
(
$
(
'
dw__editform
'
),
'
keypress
'
,
function
(){
locktimer
.
refresh
();});
$
(
'
#dw__editform
'
).
keypress
(
function
()
{
refresh
();
}
);
// start timer
// start timer
locktimer
.
reset
();
reset
();
}
,
}
;
/**
/**
* (Re)start the warning timer
* (Re)start the warning timer
*/
*/
reset
:
function
(){
reset
=
function
(){
locktimer
.
clear
();
clear
();
locktimer
.
timerID
=
window
.
setTimeout
(
"
locktimer.w
arning()
"
,
locktimer
.
timeout
);
locktimer
.
timerID
=
window
.
setTimeout
(
"
expW
arning()
"
,
locktimer
.
timeout
);
}
,
}
;
/**
/**
* Display the warning about the expiring lock
* Display the warning about the expiring lock
*/
*/
w
arning
:
function
(){
expW
arning
=
function
(){
locktimer
.
clear
();
clear
();
alert
(
locktimer
.
msg
);
alert
(
locktimer
.
msg
);
}
,
}
;
/**
/**
* Remove the current warning timer
* Remove the current warning timer
*/
*/
clear
:
function
(){
clear
=
function
(){
if
(
locktimer
.
timerID
!==
null
){
if
(
locktimer
.
timerID
!==
null
){
window
.
clearTimeout
(
locktimer
.
timerID
);
window
.
clearTimeout
(
locktimer
.
timerID
);
locktimer
.
timerID
=
null
;
locktimer
.
timerID
=
null
;
}
}
}
,
}
;
/**
/**
* Refresh the lock via AJAX
* Refresh the lock via AJAX
*
*
* Called on keypresses in the edit area
* Called on keypresses in the edit area
*/
*/
refresh
:
function
(){
refresh
=
function
(){
var
now
=
new
Date
();
var
now
=
new
Date
();
// refresh every minute only
var
params
=
{};
// refresh every minute only
if
(
now
.
getTime
()
-
locktimer
.
lasttime
.
getTime
()
>
30
*
1000
){
if
(
now
.
getTime
()
-
locktimer
.
lasttime
.
getTime
()
>
30
*
1000
){
var
params
=
'
call=lock&id=
'
+
encodeURIComponent
(
locktimer
.
pageid
);
var
dwform
=
$
(
'
dw__editform
'
);
params
[
'
call
'
]
=
'
lock
'
;
if
(
locktimer
.
draft
&&
dwform
.
elements
.
wikitext
){
params
[
'
id
'
]
=
locktimer
.
pageid
;
params
+=
'
&prefix=
'
+
encodeURIComponent
(
dwform
.
elements
.
prefix
.
value
);
params
+=
'
&wikitext=
'
+
encodeURIComponent
(
dwform
.
elements
.
wikitext
.
value
);
if
(
locktimer
.
draft
&&
$
(
'
#dw__editform textarea[name=wikitext]
'
).
length
>
0
){
params
+=
'
&suffix=
'
+
encodeURIComponent
(
dwform
.
elements
.
suffix
.
value
);
params
[
'
prefix
'
]
=
$
(
'
#dw__editform input[name=prefix]
'
).
val
();
if
(
dwform
.
elements
.
date
){
params
[
'
wikitext
'
]
=
$
(
'
#dw__editform textarea[name=wikitext]
'
).
val
();
params
+=
'
&date=
'
+
encodeURIComponent
(
dwform
.
elements
.
date
.
value
);
params
[
'
suffix
'
]
=
$
(
'
#dw__editform input[name=suffix]
'
).
val
();
if
(
$
(
'
#dw__editform input[name=date]
'
).
length
>
0
){
params
[
'
date
'
]
=
$
(
'
#dw__editform input[name=id]
'
).
val
();
}
}
}
}
locktimer
.
sack
.
runAJAX
(
params
);
$
.
post
(
DOKU_BASE
+
'
lib/exe/ajax.php
'
,
params
,
function
(
data
)
{
refreshed
(
data
);
},
'
html
'
);
locktimer
.
lasttime
=
now
;
locktimer
.
lasttime
=
now
;
}
}
}
,
}
;
/**
/**
* Callback. Resets the warning timer
* Callback. Resets the warning timer
*/
*/
refreshed
:
function
(){
refreshed
=
function
(
data
){
var
data
=
this
.
response
;
var
error
=
data
.
charAt
(
0
);
var
error
=
data
.
charAt
(
0
);
data
=
data
.
substring
(
1
);
data
=
data
.
substring
(
1
);
$
(
'
draft__status
'
).
innerHTML
=
data
;
$
(
'
#
draft__status
'
).
html
(
data
)
;
if
(
error
!=
'
1
'
)
return
;
// locking failed
if
(
error
!=
'
1
'
)
return
;
// locking failed
locktimer
.
reset
();
reset
();
}
}
;
};
}(
jQuery
));
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment