1
2/* EDITOR BUTTON */
3
4function addBtnActionDirtylittlehelper($btn, props, edid) {
5	$btn.click(function() {
6	jQuery('#dirtylittlehelper_overlay').toggle();
7		return true;
8	});
9}
10
11
12
13
14/* DLH FUNCTIONS */
15
16
17function dlh_call_mermaid(source_obj = false){
18
19	thecode = '';
20
21	if( source_obj !== false ){
22
23		if( document.getElementById( source_obj ) ){
24
25			the_code = dlh_objectValueGet(source_obj).replace(/\n/g,'\\n').match(/<dlh.mm>(.*?)<\/dlh.mm>/g);
26
27			if( Array.isArray( the_code ) ){
28
29				the_code = btoa('{"code":"' + the_code[0].replace('<dlh.mm>','').replace('<\/dlh.mm>','') + '","mermaid":{},"updateEditor":false}');
30
31			}else{
32
33				the_code = '';
34
35			}
36
37		}
38	}
39
40	if( the_code == '' ){
41		the_code = 'eyJjb2RlIjoiZ3JhcGggVEQgXG5JLS0tTElLRS0tLURPS1VXSUtJXG4iLCJtZXJtYWlkIjp7fSwidXBkYXRlRWRpdG9yIjpmYWxzZX0';
42	}
43
44	window.open(JSINFO['dlh']['DOKU_URL']+'lib/plugins/dirtylittlehelper/mermaid/editor/#/edit/'+the_code);
45	return true;
46
47
48} //function dlh_call_mermaid
49
50
51
52function dlh_objectValueGet(dlh_source){
53    var dlh_source_obj = document.getElementById(dlh_source);
54
55    if( dlh_source_obj ){
56        dlh_value = dlh_source_obj.value;
57        if( dlh_value !== undefined){
58            return dlh_value;
59        }
60    }
61    return false;
62
63}//function dlh_objectValueGet
64
65
66
67
68function dlh_objectValueSet(dlh_target , dlh_value ){
69
70    var dlh_target_obj = document.getElementById(dlh_target);
71
72    if( dlh_target_obj ){
73        dlh_target_obj.value = dlh_value;
74    return true;
75    }
76    return false;
77
78}//function dlh_objectValueSet
79
80
81
82
83function dlh_open_wiki_link(dlh_wikilink){
84   dlh_loc = window.location.href;
85   dlh_loc = dlh_loc.substring(0, dlh_loc.indexOf('.php')+4);
86   dlh_loc = dlh_loc + '/' + dlh_wikilink + '?' + Math.random();
87
88   window.open(dlh_loc);
89
90   return true;
91} //function dlh_open_wiki_link
92
93
94
95
96function dlh_fullcreen_edit(){
97
98	if ( JSINFO['dlh']['dlh_edit_maximized'] === true){
99		jQuery('#dokuwiki__content').css({'position':'','top':'','left':'','right':'','bottom':'','overflow':'', 'max-width':''});
100		JSINFO['dlh']['dlh_edit_maximized'] = false ;
101	}else{
102		jQuery('#dokuwiki__content').css({'position':'fixed','top':'10px','left':'10px','right':'10px','bottom':'10px','overflow':'scroll','max-width':'1700px'});
103		JSINFO['dlh']['dlh_edit_maximized'] = true ;
104	}
105
106} // function dlh_fullcreen_edit
107
108
109
110
111function dlh_timeid(dlh_tenthofsec = false){
112
113    if(dlh_tenthofsec === false){
114        var dlh_arr_replace =[ 'a' , 'b' , 'c' , 'd' , 'e' , 'f' , 'g' , 'h' , 'k' , 'm' , 'n' , 'p' , 'r' , 's' , 't' , 'u' , 'v' , 'w'  ];
115        var dlh_div_seconds = 1000;
116        var dlh_base = 18;
117    }else{
118        var dlh_arr_replace =[ 'a' , 'b' , '1' , 'c' , 'd' , '2' , 'e' , 'f' , '3' , 'g' , 'h' , '4' , 'k' , 'm' , '5' , 'n' , 'p' , '6' , 'r' , 's' , '7' , 't' , 'u' , '8' , 'v' , 'w' , '9' ];
119        var dlh_div_seconds = 100;
120        var dlh_base = 27;
121    }
122
123    var dlh_dateNow = new Date();
124    var dlh_secNow = dlh_dateNow.getTime()/dlh_div_seconds|0;
125
126    var dlh_dateYear = new Date(dlh_dateNow.getFullYear(),0,1,0,0,0,0);
127    var dlh_secYear = dlh_dateYear.getTime()/dlh_div_seconds|0;
128
129    var dlh_sec = dlh_secNow - dlh_secYear;
130    var dlh_rest = dlh_sec;
131    var dlh_expo = 5;
132    var dlh_return = 'x';
133    var dlh_div = 0;
134    var dlh_floor = 0;
135
136    while ( dlh_rest > 0 && dlh_expo > 0 ) {
137
138		dlh_div = dlh_base**dlh_expo;
139        dlh_floor = Math.floor( dlh_rest / dlh_div );
140        dlh_return = dlh_return + dlh_arr_replace[dlh_floor];
141        dlh_rest = dlh_rest % dlh_div;
142        dlh_expo--;
143
144	}//while
145
146    dlh_return = dlh_return + dlh_arr_replace[dlh_rest];
147    dlh_return = dlh_return.replace("x","");
148
149    return ((''+dlh_dateNow.getFullYear()).substr(-2))+ dlh_return
150
151}//function dlh_timeid
152
153
154
155
156function dlh_renew_dlhid(dlh_target_id){
157
158    var dlh_target_obj = document.getElementById(dlh_target_id);
159
160    if(dlh_target_obj){
161       dlh_target_obj.value = dlh_timeid();
162        return true;
163    }
164
165    return false;
166
167}//dlh_renew_dlhid
168
169
170
171
172function dlh_copyme(dlh_source_id){
173
174    var dlh_source_obj = document.getElementById(dlh_source_id);
175
176    if(dlh_source_obj){
177        var dlh_value = dlh_source_obj.value;
178        dlh_source_obj.select();
179        dlh_source_obj.setSelectionRange(0, dlh_value.length); /* For mobile devices */
180        document.execCommand("copy");
181
182		console.log('SUCCESS javascript dlh_copyme - copied to clipboard: '.dlh_value);
183
184	}else{
185      console.log("ERROR javascript dlh_copyme - source not found:" + dlh_source_id);
186    }
187
188} //function dlh_copyme
189
190
191
192
193function dlh_edit_tb_select(){
194
195	if( JSINFO['dlh']['dlh_fields'] && JSINFO['dlh']['dlh_fields'].length > 0 ){
196		for( i=0; i< JSINFO['dlh']['dlh_fields'].length; ++i ){
197			jQuery( '#'+JSINFO['dlh']['dlh_fields'][i]).css('display','none');
198		}
199		jQuery( '#' + jQuery('#dlh_edit_tb_select').val() ).css('display','inline');
200	}
201
202} //function dlh_edit_tb_select
203
204
205
206
207function dlh_sb_toggle(force=''){
208
209	if ( dlh_objectValueGet('dlh_left_tmp_sb') == "x"){dlh_objectValueSet('dlh_left_tmp_sb',jQuery('#dokuwiki__aside').css('width').replace('px',''));}
210	if ( dlh_objectValueGet('dlh_left_tmp_content') == "x"){dlh_objectValueSet('dlh_left_tmp_content',jQuery('.showSidebar #dokuwiki__content > .pad').css('margin-left').replace('px',''));}
211
212	if( dlh_objectValueGet('dlh_left_tmp_status')=='show' || force == 'hide'){
213		jQuery('#dokuwiki__aside').css({'width': '0px'});
214		jQuery('.showSidebar #dokuwiki__content > .pad').css({'margin-left': '0px'});
215		dlh_objectValueSet( 'dlh_left_tmp_status','hide');
216		return true;
217	}
218
219	if( dlh_objectValueGet('dlh_left_tmp_status')=='hide' || force == 'show'){
220		jQuery('#dokuwiki__aside').css({'width': dlh_objectValueGet('dlh_left_tmp_sb')+'px' });
221		jQuery('.showSidebar #dokuwiki__content > .pad').css({'margin-left': dlh_objectValueGet('dlh_left_tmp_content')+'px' });
222		dlh_objectValueSet( 'dlh_left_tmp_status','show');
223		return true;
224	}
225
226} //function dlh_sb_toggle
227
228
229
230
231/* DLH INI */
232
233function dlh_ini(count=0){
234
235	if(count>100){
236		return false;
237	}
238
239	++count;
240
241	if(! JSINFO){
242		setTimeout(dlh_ini, 100, count);
243		return false;
244	}
245
246	if(! JSINFO['dlh']['ini_step_done']){
247		JSINFO['dlh']['ini_step_done']=0;
248	}
249
250
251	var dlh_ini_step_at = 1;
252
253
254	//OVERLAY
255	if( dlh_ini_step_at > JSINFO['dlh']['ini_step_done'] ){
256
257		if(JSINFO && JSINFO['dlh']['act_edit'] && JSINFO['dlh']['edit_active']) {
258
259			JSINFO['dlh']['dlh_theUserposition']= {'x':200,'y':200,'position':'absolute'};
260
261			jQuery( document ).ready(function() {
262				jQuery( "#dirtylittlehelper_overlay" ).draggable({
263					drag: function(event,ui){
264					var position = jQuery(this).position();
265					JSINFO['dlh']['dlh_theUserposition'].y = position.top;
266					JSINFO['dlh']['dlh_theUserposition'].x =position.left;
267					},
268					stop: function(){
269					var position = jQuery(this).position();
270					JSINFO['dlh']['dlh_theUserposition'].y = position.top;
271					JSINFO['dlh']['dlh_theUserposition'].x =position.left;
272					jQuery(this).css('left',position.left);
273					jQuery(this).css('top',position.top);
274					},
275				});
276			});
277
278			jQuery(window).on("load", function(){
279				pleft = 'auto';
280				ptop = '40px' ;
281				pright = '40px';
282				pwidth = '500px';
283				pheight = '450px';
284				ptype= 'fixed' ;
285				jQuery("#dirtylittlehelper_overlay" ).css({top: ptop, right: pright,  left: pleft, position:ptype, width: pwidth, height: pheight });
286			});
287
288		} //if overlay
289
290		++JSINFO['dlh']['ini_step_done'];
291	} //OVERLAY
292	++dlh_ini_step_at;
293
294
295
296	//EDITOR
297	if( dlh_ini_step_at > JSINFO['dlh']['ini_step_done'] ){
298
299		if( document.getElementById('tool__bar') && JSINFO['dlh']['act_edit']){
300
301			if( JSINFO['dlh']['edit_active'] ){
302
303				//dlh has to wait till the toolbar is finished...
304				dlh_toolbar_icon_pos = document.getElementById('tool__bar').innerHTML.indexOf('dirtylittlehelper_ovl_sprite.png')>-1;
305
306				if( dlh_toolbar_icon_pos !== true){
307					if( count > 60){
308						console.log('dlh cant find the dlh icon in the toolbar');
309						return false;
310					}else{
311						setTimeout(dlh_ini, 100, count);
312						return;
313					}
314				} //toolbaricon
315
316				//walk the form...
317				i = 0;
318				var dlh_labels = [];
319				var dlh_ids = [];
320				var dlh_fields = [];
321				var this_label = false;
322				var this_id = false;
323
324				var this_comeback = false;
325
326				jQuery('#dirtylittlehelper_overlay fieldset').contents().each(
327					function(){
328						this_label = jQuery(this).contents().filter('label').text();
329						this_id = jQuery(this).contents().filter('span.input').contents().filter('input').attr('id');
330
331						if( this_label && this_id && jQuery(this).prop('tagName') == 'DIV'){
332
333							//if the input fields arent ready we have to try again later!
334							if( jQuery(this).contents().filter('span.input').contents().filter('input').data('uiAutocomplete') === undefined){
335								this_comeback = true;
336							}else{
337								dlh_labels.push(this_label);
338								dlh_ids.push(this_id.replace('.','\\.') );
339								jQuery(this).attr('id','dlh_dirty_form_'+i);
340								dlh_fields.push('dlh_dirty_form_'+i);
341							}
342						}//found something
343
344						++i;
345						this_label = false;
346						this_id = false;
347
348					}//function each in ....
349				);//jQuery('#dirtylittlehelper_overlay fieldset').contents().each(
350
351				if( this_comeback === true){
352					setTimeout(dlh_ini, 100, count);
353					return;
354				}
355
356
357				JSINFO['dlh']['dlh_labels'] = dlh_labels;
358				JSINFO['dlh']['dlh_ids'] = dlh_ids;
359				JSINFO['dlh']['dlh_fields'] = dlh_fields ;
360
361				JSINFO['dlh']['dlh_edit_maximized'] = false;
362
363				//append to the toolbar...
364				dlh_append = '<div id="dlh_mytoolbar_hack" style="margin-top:5px;margin-bottom:5px;">';
365
366				if( JSINFO['dlh']['edit_tb_min_max'] ){
367
368					dlh_append += '<button class="dlh_button_32_32" title="FULLSCREEN EDIT" '
369						+ 'onClick="dlh_fullcreen_edit();">'
370						+ '<img src="'+JSINFO['dlh']['DOKU_URL']+'lib/plugins/dirtylittlehelper/images/dlh_max.png" width="32px" height="32px">'
371						+ ' </button>'
372						+ '<div class="dlh_sep"></div>';
373
374				}
375
376				if( JSINFO['dlh']['edit_tb_code'] ){
377
378					dlh_append += '<button class="dlh_button_36_32" title="CODE tags" '
379						+ 'onClick="insertTags(\'wiki__text\' , '
380						+ '   \'<code [enable_line_numbers=\'+JSINFO[\'dlh\'][\'QUOT\']+\'true\'+JSINFO[\'dlh\'][\'QUOT\']+\']>\',\'</code>\',\' \\n \\n \\n \'        '
381						+ ');'
382						+ '"><img src="'+JSINFO['dlh']['DOKU_URL']+'lib/plugins/dirtylittlehelper/images/dlh_code.png" width="32px" height="32px">'
383						+ ' </button>'
384
385						+ '<button class="dlh_button_36_32" title="CODE SQL tags" '
386						+ 'onClick="insertTags(\'wiki__text\' , '
387						+ '   \'<code sql [enable_line_numbers=\'+JSINFO[\'dlh\'][\'QUOT\']+\'true\'+JSINFO[\'dlh\'][\'QUOT\']+\']>\',\'</code>\',\'\\n /* CODE */ \\n \\n \\n \'        '
388						+ ');"><img src="'+JSINFO['dlh']['DOKU_URL']+'lib/plugins/dirtylittlehelper/images/dlh_code_sql.png" width="32px" height="32px">'
389						+ ' </button>'
390
391						+ '<button class="dlh_button_36_32" title="CODE bash tags" '
392						+ 'onClick="insertTags(\'wiki__text\' , '
393						+ '   \'<code bash [enable_line_numbers=\'+JSINFO[\'dlh\'][\'QUOT\']+\'true\'+JSINFO[\'dlh\'][\'QUOT\']+\']>\',\'</code>\',\'\\n # CODE \\n \\n \\n \'        '
394						+ ');"><img src="'+JSINFO['dlh']['DOKU_URL']+'lib/plugins/dirtylittlehelper/images/dlh_code_bash.png" width="32px" height="32px">'
395						+ ' </button>'
396
397						+ '<button class="dlh_button_36_32" title="CODE shell tags" '
398						+ 'onClick="insertTags(\'wiki__text\' , '
399						+ '   \'<code shell [enable_line_numbers=\'+JSINFO[\'dlh\'][\'QUOT\']+\'true\'+JSINFO[\'dlh\'][\'QUOT\']+\']>\',\'</code>\',\'\\n REM CODE \\n \\n \\n \'        '
400						+ ');"><img src="'+JSINFO['dlh']['DOKU_URL']+'lib/plugins/dirtylittlehelper/images/dlh_code_shell.png" width="32px" height="32px">'
401						+ ' </button>'
402
403						+ '<button class="dlh_button_36_32" title="CODE php tags" '
404						+ 'onClick="insertTags(\'wiki__text\' , '
405						+ '   \'<code php [enable_line_numbers=\'+JSINFO[\'dlh\'][\'QUOT\']+\'true\'+JSINFO[\'dlh\'][\'QUOT\']+\']>\',\'</code>\',\'\\n /* CODE */ \\n \\n \\n \'        '
406						+ ');"><img src="'+JSINFO['dlh']['DOKU_URL']+'lib/plugins/dirtylittlehelper/images/dlh_code_php.png" width="32px" height="32px">'
407						+ ' </button>'
408
409						+ '<button class="dlh_button_36_32" title="CODE html tags" '
410						+ 'onClick="insertTags(\'wiki__text\' , '
411						+ '   \'<code html [enable_line_numbers=\'+JSINFO[\'dlh\'][\'QUOT\']+\'true\'+JSINFO[\'dlh\'][\'QUOT\']+\']>\',\'</code>\',\'\\n <!-- CODE --> \\n \\n \\n \'        '
412						+ ');"><img src="'+JSINFO['dlh']['DOKU_URL']+'lib/plugins/dirtylittlehelper/images/dlh_code_html.png" width="32px" height="32px">'
413						+ ' </button>'
414
415
416						+ '<button class="dlh_button_36_32" title="CODE javascript tags" '
417						+ 'onClick="insertTags(\'wiki__text\' , '
418						+ '   \'<code javascript [enable_line_numbers=\'+JSINFO[\'dlh\'][\'QUOT\']+\'true\'+JSINFO[\'dlh\'][\'QUOT\']+\']>\',\'</code>\',\'\\n /* CODE */ \\n \\n \\n \'        '
419						+ ');"><img src="'+JSINFO['dlh']['DOKU_URL']+'lib/plugins/dirtylittlehelper/images/dlh_code_javascript.png" width="32px" height="32px">'
420						+ ' </button>'
421
422						+ '<button class="dlh_button_36_32"  title="<dlh.*> COMMENT </dlh.*>" accesskey="*" '
423						+ 'onClick="insertTags(\'wiki__text\' , '
424						+ '   \'<dlh.*> \',\' </dlh>\',\' YOU WILL NOT SEE ME \'     '
425						+  ');"><img src="'+JSINFO['dlh']['DOKU_URL']+'lib/plugins/dirtylittlehelper/images/dlh_comment.png" width="32px" height="32px">'
426						+ '</button> '
427
428						+ '<div class="dlh_sep"></div>'
429
430						+ '<button class="dlh_button_36_32"  title="<dlh.table.html>..." accesskey="*" '
431						+ 'onClick="insertAtCarret(\'wiki__text\' , '
432						+ '   \'\\n<dlh.table.html> \\n <tr> \\n  <td> A </td> \\n  <td> B </td> \\n </tr> \\n</dlh.table.html>\');">'
433						+  '<img src="'+JSINFO['dlh']['DOKU_URL']+'lib/plugins/dirtylittlehelper/images/dlh_table_html.png" width="32px" height="32px">'
434						+ '</button> '
435
436						+ '<button class="dlh_button_36_32"  title="<dlh.table.wiki>..." accesskey="*" '
437						+ 'onClick="insertAtCarret(\'wiki__text\' , '
438						+ '   \'\\n<dlh.table.wiki> \\n <dlh.tr.wiki> \\n  <dlh.td.wiki> WIKI_CONTENT_A </dlh.td.wiki> \\n  <dlh.td.wiki> WIKI_CONTENT_B </dlh.td.wiki> \\n </dlh.tr.wiki> \\n</dlh.table.wiki>\');">'
439						+  '<img src="'+JSINFO['dlh']['DOKU_URL']+'lib/plugins/dirtylittlehelper/images/dlh_table_wiki.png" width="32px" height="32px">'
440						+ '</button> '
441
442						+ '<div class="dlh_sep"></div>'
443
444						+ '<button class="dlh_button_36_32"  title="<dlh.div.html>..." accesskey="*" '
445						+ 'onClick="insertTags(\'wiki__text\' , '
446						+ '   \'<dlh.div.html>\\n\',\'\\n</dlh.div.html>\', \' HTML CONTENT \');">'
447						+  '<img src="'+JSINFO['dlh']['DOKU_URL']+'lib/plugins/dirtylittlehelper/images/dlh_div_html.png" width="32px" height="32px">'
448						+ '</button> '
449
450						+ '<button class="dlh_button_36_32"  title="<dlh.div.wiki>..." accesskey="*" '
451						+ 'onClick="insertTags(\'wiki__text\' , '
452						+ '   \'<dlh.div.wiki> \\n\' , \'\\n</dlh.div.wiki>\',\' WIKI_CONTENT \');">'
453						+  '<img src="'+JSINFO['dlh']['DOKU_URL']+'lib/plugins/dirtylittlehelper/images/dlh_div_wiki.png" width="32px" height="32px">'
454						+ '</button> '
455						;
456
457				}
458
459				if(JSINFO['dlh']['edit_tb_mermaid']){
460					dlh_append = dlh_append
461						+ '<div class="dlh_sep"></div>'
462						+ '<button class="dlh_button_36_32" title="mermaid code" '
463						+ 'onClick="insertTags(\'wiki__text\' , '
464						+ '   \'<dlh.mm> \',\' </dlh.mm>\',\' \\n graph TD \\n A---B\\n \'     '
465						+ ');"><img src="'+JSINFO['dlh']['DOKU_URL']+'lib/plugins/dirtylittlehelper/images/dlh_mermaid_code.png" width="32px" height="32px"></button>'
466						+ '<button class="dlh_button_36_32" '
467						+ 'onClick="dlh_call_mermaid(\'wiki__text\');" '
468						+ 'title="mermaid live editor">'
469						+ '<img src="'+JSINFO['dlh']['DOKU_URL']+'lib/plugins/dirtylittlehelper/images/dlh_mermaid.png" width="32px" height="32px">'
470						+ '</button>'
471						;
472				}
473
474
475				if(JSINFO['dlh']['edit_tb_drawio']){
476					dlh_append = dlh_append
477						+'<div class="dlh_sep"></div>'
478						+ '<button class="dlh_button_36_32"  title="insert DRAW.IO - ID into wikieditor at cursor pos"'
479						+ 'onClick="insertAtCarret(\'wiki__text\' , '
480						+ '\'{{drawio>\'+getImageName().substr(0,getImageName().lastIndexOf(\':\')+1)+ \'drawio_\'+ ((new Date()).getTime()) +\'.svg}} \''
481						+  ');"><img src="'+JSINFO['dlh']['DOKU_URL']+'lib/plugins/dirtylittlehelper/images/dlh_drawio.png" width="32px" height="32px">'
482						+ '</button> '
483						;
484				}
485
486
487				if(JSINFO['dlh']['edit_tb_dlhid']){
488					dlh_append += ''
489						+ '<div class="dlh_sep"></div>'
490						+ '<input id="dlh_edit_tb_dlhid" type="text" title="DLH timeID">'
491						+ '<button class="dlh_button_36_32" onClick="dlh_renew_dlhid(\'dlh_edit_tb_dlhid\');" '
492						+ 'title="renew dlhID"><img src="'+JSINFO['dlh']['DOKU_URL']+'lib/plugins/dirtylittlehelper/images/dlh_id_renew.png" width="32px" height="32px">'
493						+ '</button>'
494						+ '<button class="dlh_button_36_32" onClick="insertAtCarret(\'wiki__text\', dlh_objectValueGet(\'dlh_edit_tb_dlhid\') );" '
495						+ ' title="paste dlhID at current position">'
496						+ '<img src="'+JSINFO['dlh']['DOKU_URL']+'lib/plugins/dirtylittlehelper/images/dlh_id_insert.png" width="32px" height="32px">'
497						+ '</button>';
498				}
499
500
501				if(  JSINFO['dlh']['edit_dlh_wikiid'] && JSINFO['dlh']['edit_tb_struct'] && JSINFO['dlh']['dlh_fields'].length > 0) {
502					dlh_append += '<br>'
503						+ '<select id="dlh_edit_tb_select" '
504						+ ' class="dlh_edit_tb_select" '
505						+ ' onChange="dlh_edit_tb_select();" '
506						+ ' onClick="dlh_edit_tb_select();" '
507						+ ' style="width:200px;margin-right:10px;">'
508						;
509
510					for( i=0; i< JSINFO['dlh']['dlh_ids'].length; ++i ){
511						dlh_append += '<option value="'+ JSINFO['dlh']['dlh_fields'][i] +'">' + JSINFO['dlh']['dlh_labels'][i] +'</option>';
512					}
513
514					dlh_append += '</select></div>';
515
516				}
517				jQuery('#tool__bar').append(dlh_append);
518
519
520					if(JSINFO['dlh']['edit_tb_dlhid']){
521						dlh_renew_dlhid('dlh_edit_tb_dlhid');
522					}
523
524
525					for( i=0; i< JSINFO['dlh']['dlh_ids'].length; ++i ){
526
527						jQuery('#' + JSINFO['dlh']['dlh_ids'][i]).css({'width':'350px','height':'32px','font-size':'16px'});
528
529						insert_this_html = ''
530							+ '<button title="open in new window" class="dlh_button_36_32" '
531							+ 'onClick="dlh_open_wiki_link( dlh_objectValueGet(\''
532							+ JSINFO['dlh']['dlh_ids'][i]  +'\') );">'
533							+ '<img src="'+JSINFO['dlh']['DOKU_URL']+'lib/plugins/dirtylittlehelper/images/dlh_open_window.png" width="32px" height="32px">'
534							+ '</button> ';
535
536						if(JSINFO['dlh']['edit_tb_dlhid']){
537						insert_this_html += ''
538							+ '<button title=add :TimeID" class="dlh_button_36_32" '
539							+ 'onClick="dlh_objectValueSet(\''
540							+ JSINFO['dlh']['dlh_ids'][i] +'\', (dlh_objectValueGet(\''
541							+ JSINFO['dlh']['dlh_ids'][i]+'\') + \':\' + dlh_objectValueGet(\'dlh_edit_tb_dlhid\')+\':\').replace(/::/i, \':\')   );">'
542							+ '<img src="'+JSINFO['dlh']['DOKU_URL']+'lib/plugins/dirtylittlehelper/images/dlh_add_id.png" width="32px" height="32px">'
543							+ '</button> ';
544						}
545
546
547						jQuery('#'+JSINFO['dlh']['dlh_ids'][i]).before(
548							insert_this_html
549						);
550
551
552						jQuery('#'+JSINFO['dlh']['dlh_ids'][i]).after(''
553							+ '<button title="insert into wikieditor at cursor pos" class="dlh_button_36_32" '
554							+ 'onClick="insertAtCarret(\'wiki__text\' , '
555							+ '\'[[\' + dlh_objectValueGet(\''+ JSINFO['dlh']['dlh_ids'][i] +'\') + \'|]]\'  );">'
556							+ '<img src="'+JSINFO['dlh']['DOKU_URL']+'lib/plugins/dirtylittlehelper/images/dlh_link_insert.png" width="32px" height="32px">'
557							+ '</button> '
558						);
559
560						jQuery('#dlh_mytoolbar_hack').append(
561							jQuery('#' + JSINFO['dlh']['dlh_fields'][i] )
562						);
563
564						jQuery( '#'+JSINFO['dlh']['dlh_fields'][i] ).contents().filter('label').css('display','none');
565
566					}//walk the input elements
567
568					dlh_edit_tb_select();
569
570				//}//if struct...
571
572
573				if( JSINFO['dlh']['edit_tb_maximize'] && JSINFO['dlh']['edit_tb_min_max'] ){
574					dlh_fullcreen_edit();
575				}
576
577			} // edit_active?
578		} // act_edit?
579
580		++JSINFO['dlh']['ini_step_done'];
581	} // EDITOR
582	++dlh_ini_step_at;
583
584
585
586	// TOP BAR
587	if( dlh_ini_step_at > JSINFO['dlh']['ini_step_done'] ){
588
589		// STRUCT SERIAL
590		if( JSINFO['dlh']['top_active'] && document.getElementById('dlh_top_struct_c') ){
591			JSINFO['dlh']['top_skip'] = false;
592
593			if( jQuery('#dlh_top_struct_c').prop('tagName')!== undefined && jQuery('#dlh_top_struct_c div.struct_entry_form div.field input.struct_page').prop("tagName") == 'INPUT'){
594
595				if( jQuery('#dlh_top_struct_c div.struct_entry_form div.field input.struct_page').data('uiAutocomplete') === undefined){
596
597					if( count < 80 ){
598						setTimeout(dlh_ini, 100, count);
599						return false;
600					}else{
601						JSINFO['dlh']['top_skip'] = true;
602					}
603
604				}
605
606				if( JSINFO['dlh']['top_skip'] == false ){
607					jQuery('#dlh_top_struct_c div.struct_entry_form div.field span.label').css({'display':'none'});
608					jQuery('#dlh_top_struct_c div.struct_entry_form div.field input.struct_page').prop('title','STRUCT SEARCH');
609
610					JSINFO['dlh']['top_struct_id'] =  jQuery('#dlh_top_struct_c div.struct_entry_form div.field input.struct_page').attr('id') ;
611
612					dlh_objectValueSet( JSINFO['dlh']['top_struct_id'] , JSINFO['namespace']);
613
614					jQuery('#dlh_top_struct_b').append( jQuery('#dlh_top_struct_c div.struct_entry_form div.field') );
615					jQuery('#dlh_top_struct_b').append( '<button title="call struct in new window" onClick="dlh_top_call(\''+ JSINFO['dlh']['top_struct_id'] + '\');">&GT;</button>' );
616
617					jQuery('#dlh_top_struct_c div.structaggregation').css({'display':'none'});
618					jQuery('#dlh_top_struct_c div.structaggregationeditor').css({'display':'none'});
619					jQuery('#dlh_top_struct_c').css({'display':'none'});
620					jQuery('#dlh_top_struct_b').css({'display':'inline'});
621
622				}
623			// STRUCT SERIAL FOUND
624
625			}else if( jQuery('#dlh_top_struct_c').prop('tagName')!== undefined && jQuery('#dlh_top_struct_c form.bureaucracy__plugin div.field input.struct_page').prop("tagName") == 'INPUT'){
626
627				if( jQuery('#dlh_top_struct_c form.bureaucracy__plugin div.field input.struct_page').data('uiAutocomplete') === undefined){
628
629					if( count < 80 ){
630						setTimeout(dlh_ini, 100, count);
631						return false;
632					}else{
633						JSINFO['dlh']['top_skip'] = true;
634					}
635
636				}
637
638				if( JSINFO['dlh']['top_skip'] == false ){
639					jQuery('#dlh_top_struct_c form.bureaucracy__plugin div.field span.label').css({'display':'none'});
640					jQuery('#dlh_top_struct_c form.bureaucracy__plugin div.field input.struct_page').prop('title','STRUCT SEARCH');
641
642					JSINFO['dlh']['top_struct_id'] =  jQuery('#dlh_top_struct_c form.bureaucracy__plugin div.field input.struct_page').attr('id') ;
643
644					dlh_objectValueSet( JSINFO['dlh']['top_struct_id'] , JSINFO['namespace']);
645
646					jQuery('#dlh_top_struct_b').append( jQuery('#dlh_top_struct_c form.bureaucracy__plugin div.field') );
647					jQuery('#dlh_top_struct_b').append( '<button title="call struct in new window" onClick="dlh_top_call(\''+ JSINFO['dlh']['top_struct_id'] + '\');">&GT;</button>' );
648
649					jQuery('#dlh_top_struct_c').css({'display':'none'});
650					jQuery('#dlh_top_struct_b').css({'display':'inline'});
651
652				}
653
654			} // STRUCT FOUND
655
656		} // STRUCT
657
658
659		// PAGE SUGGEST
660		if( JSINFO['dlh']['top_active'] && document.getElementById('dlh_top_pagesuggest_input') ) {
661
662			jQuery(function () {
663				$editor = jQuery('#dlh_top_pagesuggest_input');
664				$editor.textcomplete([
665					{ //page search
666						appendTo: 'body',
667						match:    /\[{2}([\w\-\.:]*)$/,
668						maxCount: 50,
669						search:   function (term, callback) {
670							if ($editor.data('linksuggest_off') === 1) {
671								callback([]);
672								return;
673							}
674							jQuery.post(
675								DOKU_BASE + 'lib/exe/ajax.php',
676								{
677									call: 'plugin_linksuggest',
678									q:    term,
679									ns:   JSINFO['namespace'],
680									id:   JSINFO['id'],
681								},
682								function (data) {
683									data = JSON.parse(data);
684									callback(jQuery.map(data.data, function (item) {
685										let id = item.id;
686
687										if (item.type === 'd') {
688											id = id + ':';
689										}
690
691										return {
692											id:     id,
693											ns:     item.ns,
694											title:  item.title,
695											type:   item.type,
696											rootns: item.rootns
697										};
698									}));
699								}
700							);
701						},
702						template: function (item) { //dropdown list
703							let image;
704							let title = item.title ? ' (' + linksuggest_escape(item.title) + ')' : '';
705							let value = item.id;
706
707							if (item.rootns) { //page is in root namespace
708								value = ':' + value;
709							}
710							if (item.type === 'd') { //namespace
711								image = 'ns.png';
712							} else { //file
713								image = 'page.png';
714							}
715							return '<img src="' + DOKU_BASE + 'lib/images/' + image + '"> ' + linksuggest_escape(value) + title;
716						},
717						index:    1,
718						replace:  function (item) { //returns what will be put to editor
719							let id = item.id;
720							if (item.ns === ':') { //absolute link
721								id = item.ns + id;
722							} else if (JSINFO['namespace'] !== '' && item.rootns && item.type === 'f') {
723								id = ':' + id
724							} else if (item.ns) { //relative link
725								id = item.ns + ':' + id;
726							}
727							if (item.type === 'd') { //namespace
728								setTimeout(function () {
729									$editor.trigger('keyup');
730								}, 200);
731								return '[[' + id;
732							} else { //file
733								$editor.data('linksuggest_off', 1);
734
735								setTimeout(function () {
736									$editor.data('linksuggest_off', 0);
737								}, 500);
738			//                    return ['[[' + id, '|' + (item.title ? item.title : '') + ']]'];
739								return ['[[' + id, ''];
740							}
741
742						},
743						//header:'test',
744						footer: 'schließen',
745						cache:  false
746					}, { //Page Section Search
747						appendTo: 'body',
748						match:    /\[\[([\w\-\.:]+#[\w\.:]*)$/,
749						index:    1,
750						search:   function (term, callback) {
751							if ($editor.data('linksuggest_off') === 1) {
752								callback([]);
753								return;
754							}
755							jQuery.post(
756								DOKU_BASE + 'lib/exe/ajax.php',
757								{
758									call: 'plugin_linksuggest',
759									q:    term,
760									ns:   JSINFO['namespace'],
761									id:   JSINFO['id'],
762								},
763								function (data) {
764									data = JSON.parse(data);
765									callback(jQuery.map(data.data, function (item) {
766										return {
767											'link': data.link,
768											'toc': item
769										};
770									}));
771								}
772							);
773						},
774						template: function (item) { //dropdown list
775							let toc = item.toc;
776							let title = toc.title ? ' (' + linksuggest_escape(toc.title) + ')' : '';
777
778							return linksuggest_escape(toc.hid) + title;
779						},
780
781						replace: function (item) { //returns what will be put to editor
782							let link = item.link;
783							let toc = item.toc;
784
785							$editor.data('linksuggest_off', 1);
786							setTimeout(function () {
787								$editor.data('linksuggest_off', 0);
788							}, 500);
789
790							return '[[' + link + '#' + toc.hid;
791						},
792						cache:   false
793					}, { //media search
794						appendTo: 'body',
795						match:    /\{{2}([\w\-\.:]*)$/,
796						maxCount: 50,
797						search:   function (term, callback) {
798							if ($editor.data('linksuggest_off') === 1) {
799								callback([]);
800								return;
801
802							}
803							jQuery.post(
804								DOKU_BASE + 'lib/exe/ajax.php',
805								{
806									call: 'plugin_imglinksuggest',
807									q:    term,
808									ns:   JSINFO['namespace'],
809									id:   JSINFO['id'],
810								},
811								function (data) {
812									data = JSON.parse(data);
813									callback(jQuery.map(data.data, function (item) {
814										let id = item.id;
815
816										if (item.type === 'd')
817											id = id + ':';
818
819										return {
820											id:     id,
821											ns:     item.ns,
822											type:   item.type,
823											rootns: item.rootns
824										};
825									}));
826								}
827							);
828						},
829						template: function (item) { //dropdown list
830							let image;
831							let value = item.id;
832
833							if (item.rootns) { //page is in root namespace
834								value = ':' + value;
835							}
836							if (item.type === 'd') { //namespace
837								image = 'ns.png';
838							} else { //file
839								image = 'media_link_nolnk.png';
840							}
841							return '<img src="' + DOKU_BASE + 'lib/images/' + image + '"> ' + linksuggest_escape(value);
842						},
843						index:    1,
844						replace:  function (item) { //returns what will be put to editor
845							let id = item.id;
846							if (item.rootns) {
847								id = ":" + id;
848							}
849							if (item.ns === ':') { //absolute link
850								id = item.ns + id;
851							} else if (item.ns) { //relative link
852								id = item.ns + ':' + id;
853							}
854							if (item.type === 'd') { //namespace
855								setTimeout(function () {
856									$editor.trigger('keyup');
857								}, 200);
858								return '{{' + id;
859							} else { //file
860								$editor.data('linksuggest_off', 1);
861
862								setTimeout(function () {
863									$editor.data('linksuggest_off', 0);
864								}, 500);
865								return ['{{' + id, '}}'];
866							}
867
868						},
869						//header:'test',
870						footer: 'schließen',
871						cache:  false
872					}]);
873			});	// jQuery function autocomplete pageSuggest
874
875			dlh_objectValueSet( 'dlh_top_pagesuggest_input', '[[' + JSINFO['namespace']);
876
877		} // page suggest
878
879		// DLH ID
880		if( JSINFO['dlh']['top_active'] && document.getElementById( 'dlh_top_dlhid_input' ) ) {
881			dlh_renew_dlhid('dlh_top_dlhid_input');
882		}
883
884		if( JSINFO['dlh']['top_active'] && JSINFO['dlh']['isadmin']  && JSINFO['dlh']['isauth'] ) {
885			jQuery('body').css({'margin-top':'30px'});
886			jQuery('#dokuwiki__usertools').css({'margin-top':'30px'});
887		}
888
889		++JSINFO['dlh']['ini_step_done'];
890	} // TOP BAR
891	++dlh_ini_step_at;
892
893
894	//STYLING
895	if( dlh_ini_step_at > JSINFO['dlh']['ini_step_done'] ){
896
897		/* ALL */
898		// wider...
899		jQuery('#dokuwiki__site').css({
900			'border':' 1px solid #DDDDDD',
901			'resize':' horizontal',
902			'overflow':' auto',
903			'display':' block',
904			'padding-right':' 10px',
905			'max-width':'1300px' });
906
907		// logo home button...
908		jQuery('#dokuwiki__header div.pad div.headings a span').css({'display':'inline-flex'});
909		jQuery('#dokuwiki__header div.pad div.headings').css({'width':(jQuery('#dokuwiki__header div.pad div.headings a img').width() + jQuery('#dokuwiki__header div.pad div.headings a span').width() + 20)+'px'});
910
911
912		//EDITOR
913		if( JSINFO['dlh']['act_edit']  && JSINFO['dlh']['isadmin']  && JSINFO['dlh']['isauth']  ){
914			jQuery('button.toolbutton').css({'height':'32px','width':'32px'});
915			jQuery('#dokuwiki__site').css( {'max-width':'1700px','width':'' } );
916			jQuery('.preview').css({'width':'900px','border':'1px solid #AAAAAA','resize':'both','display':'block','overflow':'scroll'});
917
918			jQuery('#wiki__text').css('height','');
919			jQuery('#wiki__text').css('min-height','300px');
920			jQuery('#wiki__text').css('height',window.innerHeight-400 + 'px');
921			jQuery('#wiki__text').css('max-width','1500px');
922
923
924
925			}
926
927		/* ADVANCED CONFIG */
928		if( jQuery('#plugin_advanced_config').length ){
929			jQuery('#dokuwiki__site').css( {'max-width':'1700px','width':'' } );
930			jQuery('textarea').css({'height':'500px'});
931		}
932
933		++JSINFO['dlh']['ini_step_done'];
934
935	} //STYLE
936	++dlh_ini_step_at;
937
938
939} //function dlh_ini
940
941
942
943
944
945function dlh_top_call(the_source){
946
947	var this_namespace = dlh_objectValueGet(the_source);
948	var this_template = dlh_objectValueGet('dlh_top_template');
949
950	this_namespace = this_namespace.replace('[[','');
951	this_namespace = this_namespace.replace('**','*');
952	this_namespace = this_namespace.replace('*',':*');
953	this_namespace = this_namespace.replace('::*',':*');
954	this_namespace = this_namespace.replace('*',dlh_objectValueGet('dlh_top_dlhid_input'));
955
956	if( this_template && this_template.length > 3){
957		dlh_open_wiki_link(this_namespace+'?do=edit&newpagetemplate='+this_template+'&')
958	}else{
959		dlh_open_wiki_link(this_namespace+'?do=edit&')
960	}
961
962}//function dlh_top_call
963
964
965function dlh_ajax_wikiid_body(the_wikiid=':',the_targetid){
966
967	jQuery.ajax({url: "?id="+the_wikiid+"&do=export_xhtmlbody", success: function(result){
968		jQuery("#"+the_targetid).html(result);
969	}});
970
971} //function dlh_ajax_wikiid_body
972
973
974document.addEventListener("DOMContentLoaded", function(event) {
975  dlh_ini();
976 }); //event listener
977