forked from gkrid/dokuwiki-plugin-bez
-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
82 lines (70 loc) · 1.82 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
var bez = {};
//increase before each commit to invalidate the cache
bez.scriptVersion = 2;
bez.ctl = {};
/* DOKUWIKI:include scripts/thread.js */
/* DOKUWIKI:include scripts/thread_report.js */
/* DOKUWIKI:include scripts/threads.js */
/* DOKUWIKI:include scripts/task_form.js */
/* DOKUWIKI:include scripts/task.js */
/* DOKUWIKI:include scripts/tasks.js */
/* DOKUWIKI:include scripts/projects.js */
/* DOKUWIKI:include scripts/activity_report.js */
/* DOKUWIKI:include scripts/start.js */
/* DOKUWIKI:include scripts/report.js */
jQuery(function () {
'use strict';
var getUrlVars = function() {
var vars = {},
parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi,
function(m,key,value) {
vars[key] = value;
});
return vars;
};
var getNparams = function(value) {
var nparams = [],
params = value.split(':');
//lang
if (params[0] !== 'bez') {
params.shift();
}
for (var i = 0; i < params.length; i += 2) {
var k = params[i],
v = params[i+1];
nparams[k] = v;
}
return nparams;
};
bez.rich_text_editor = function($textarea, $header) {
//clone
var tb = toolbar.filter(function (button) {
if (button.type === 'autohead' ||
button.class === 'pk_hl' ||
button.icon === 'sig.png' ||
button.icon === 'strike.png') {
return false;
}
return true;
});
initToolbar($header, $textarea.attr('id'), tb);
};
jQuery.validate({
form: '.bez_form, .bez_form_blank',
lang: 'pl'
});
var urlParams = getUrlVars();
//userewrite == '0'
if ('id' in urlParams) {
var id = urlParams['id'];
//userewrite == '1', '2'
} else {
var found = window.location.href.match(/([^?\/]*)\??[^?\/]*$/);
var id = found[1];
}
var nparams = getNparams(id),
ctl = nparams['bez'];
if (typeof bez.ctl[ctl] === 'function') {
bez.ctl[ctl].call(ctl);
}
});