forked from svn2github/AniDB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinputbox.js
1257 lines (1205 loc) · 41.9 KB
/
inputbox.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!-- global vars -->
var sel_text;
var begin,selection,end;
var myArea, hiddenArea;
var asel_text;
var tag1, tag2;
var usageMode;
var intCC;
<!-- toggle flags -->
var isBr = false;
var isP = false;
var isBold = false;
var isItalic = false;
var isUnderline = false;
var isStrikeout = false;
var isuList = false;
var isoList = false;
var isiList = false;
var isImg = false;
var isLink = false;
var isQuote = false;
var isCode = false;
var isAnime = false;
var isEp = false;
var isFile = false;
var isGroup = false;
var isReview = false;
var isCompany = false;
var isUser = false;
var isVotes = false;
var isCreq = false;
var isHTML = false;
var isConvert = false;
var allowOut = false;
var isSel = false;
<!-- Help line messages -->
html_d_help = "Line Break: <br \/> (alt+d)";
html_e_help = "Paragraph: <p>text<\/p> (alt+e)";
html_b_help = "Bold text: <b>text<\/b> (alt+b)";
html_i_help = "Italic text: <i>text<\/i> (alt+i)";
html_u_help = "Underline text: <span style=\"text-decoration: underline\">text<\/span> (alt+u)";
html_ul_help = "List: <ul>list<\/ul> (alt+l)";
html_ol_help = "Ordered list: <ol>list<\/ol> (alt+l)";
html_li_help = "List item: <li>element<\/li> (alt+k)";
html_p_help = "Insert Image: <img src=\"http:\/\/url\" alt=\"\"> (alt+p)";
html_w_help = "Insert URL: <a href=\"http:\/\/url\">text<\/a> (alt+w)";
html_q_help = "Quote text: <span style=\"class: quote\">text<\/span> (alt+q)";
html_c_help = "Code display: <span style=\"class: code\">text<\/span> (alt+c)";
html_s_help = "Font color: <span style=\"color: red\">text<\/span> Tip: you can also use color: #FF0000";
html_f_help = "Font size: <span style=\"font-size: x-small\">small text<\/span>";
bb_d_help = "Line Break: not used (alt+d)";
//bb_e_help = "Paragraph: not used (alt+e)";
bb_b_help = "Bold text: [b]text[/b] (alt+b)";
bb_i_help = "Italic text: [i]text[/i] (alt+i)";
bb_u_help = "Underline text: [u]text[/u] (alt+u)";
bb_u_help = "Line-through text: [s]text[/s] (alt+h)";
bb_ul_help = "List: [ul]text[/ul] (alt+l)";
bb_ol_help = "Ordered list: [ol]text[/ol] (alt+o)";
bb_li_help = "List item: [li]element[/li] (alt+k)";
bb_p_help = "Insert image: [img]http://image_url[/img] (alt+p)";
bb_url_help = "Insert URL: [url]http://url[/url] or [url=http://url]text[/url] (alt+t)";
bb_q_help = "Quote text: [quote]text[/quote] (alt+q)";
bb_w_help = "Code display: [code]code[/code] (alt+w)";
bb_s_help = "Font color: [color=red]text[/color] or [color=#FF0000]text[/color]";
bb_f_help = "Font size: [size=x-small]small text[/size]";
bb_anime_help = "Link an anime: [anime=AID]text[/anime] (alt+a)";
bb_ep_help = "Link an episode: [ep=EID]text[/ep] (alt+e)";
bb_file_help = "Link a file: [file=FID]text[/file] (alt+f)";
bb_group_help = "Link a group: [group=GID]text[/group] (alt+g)";
bb_company_help = "Link a company: [company=PRID]text[/company] (alt+c)";
bb_user_help = "Link to a user mylist: [user=UID]text[/user] (alt+y)";
bb_votes_help = "Link to a user votes: [votes=UID]text[/votes] (alt+v)";
bb_review_help = "Link a review: [review=AID#REVIEWID]text[/review] (alt+r)";
bb_creq_help = "Link a creq: [creq=CREQID]text[/creq] (alt+d)";
<!-- general functions -->
function change_mode(mode){
if (!mode)
mode = document.getElementById('sel_mode').value;
if (mode == 'basic'){ // Basic mode
document.getElementById('bold').className = '';
document.getElementById('italic').className = '';
document.getElementById('underline').className = '';
document.getElementById('strikeout').className = '';
document.getElementById('ilist').className = '';
document.getElementById('ulist').className = '';
document.getElementById('olist').className = '';
} else if (mode == 'full') { // Extended mode
document.getElementById('br').className = '';
document.getElementById('pr').className = '';
document.getElementById('olist').className = '';
document.getElementById('quote').className = '';
document.getElementById('code').className = '';
document.getElementById('font_controls').className = '';
document.getElementById('link').className = '';
document.getElementById('img').className = '';
} else if (mode == 'pm') { // pm mode
change_mode('basic');
document.getElementById('quote').className = '';
document.getElementById('code').className = '';
document.getElementById('anime').className = '';
document.getElementById('file').className = '';
document.getElementById('ep').className = '';
document.getElementById('group').className = '';
document.getElementById('review').className = '';
document.getElementById('creq').className = '';
document.getElementById('user').className = '';
document.getElementById('votes').className = '';
document.getElementById('company').className = '';
} else if (mode == 'review') { // review mode
change_mode('basic');
document.getElementById('anime').className = '';
document.getElementById('review').className = '';
document.getElementById('company').className = '';
} else if (mode == 'news') { // news mode
change_mode('basic');
document.getElementById('font_controls').className = '';
document.getElementById('quote').className = '';
document.getElementById('code').className = '';
document.getElementById('anime').className = '';
document.getElementById('file').className = '';
document.getElementById('ep').className = '';
document.getElementById('group').className = '';
document.getElementById('link').className = '';
document.getElementById('company').className = '';
} else if (mode == 'anime') { // anime mode
change_mode('basic');
} else if (mode == 'company') { // company mode
change_mode('basic');
document.getElementById('link').className = '';
document.getElementById('company').className = '';
}
}
function change_layout()
{
layout = document.getElementById('sel_layout').value;
if (layout == 'bb'){
isHTML = false;
} else {
isHTML = true;
}
}
function change_convert()
{
convert = document.getElementById('sel_convert').value;
if (convert == '1'){
isConvert = true;
} else {
isConvert = false;
}
}
function show_help(text)
{
var mode;
if (isHTML){ mode = 'html'; } else { mode = 'bb' }
document.getElementById('help_line').innerHTML = eval(mode+'_'+text);
}
function insertAtCursor(myField, myValue) {
if (document.selection) {
//IE support
myField.focus();
sel = document.selection.createRange();
sel.text = myValue;
myField.focus();
} else if (myField.selectionStart || myField.selectionStart == '0') {
//MOZILLA/NETSCAPE support
var startPos = myField.selectionStart;
var endPos = myField.selectionEnd;
myField.value = myField.value.substring(0, startPos)
+ myValue
+ myField.value.substring(endPos, myField.value.length);
myField.focus();
myField.selectionStart = startPos + myValue.length;
myField.selectionEnd = startPos + myValue.length;
} else {
myField.value += myValue;
myField.focus();
}
}
function insertTagsAtSelection(myField, myValue, tag1, tag2) {
if (document.selection) {
//IE support
myField.focus();
sel = document.selection.createRange();
sel.text = tag1+myValue+tag2;
myField.focus();
} else if (myField.selectionStart || myField.selectionStart == '0') {
//MOZILLA/NETSCAPE support
var startPos = myField.selectionStart;
var endPos = myField.selectionEnd;
myField.value = myField.value.substring(0, startPos)
+ tag1+ myValue + tag2
+ myField.value.substring(endPos, myField.value.length);
myField.focus();
myField.selectionStart = startPos + tag1.length + myValue.length + tag2.length;
myField.selectionEnd = startPos + tag1.length + myValue.length + tag2.length;
} else {
myField.value += tag1+myValue+tag2;
myField.focus();
}
}
function getSel(myArea)
{
var myField = eval(myArea);
var local_set_text = '';
var selText = false;
if (window.getSelection) {
local_sel_text = window.getSelection();
selText = (local_sel_text != ''); // if true we have text selected outside of myArea
if (!selText && myArea.selectionStart!= undefined) {
begin = myField.value.substr(0, myField.selectionStart);
local_sel_text = myField.value.substr(myField.selectionStart, myField.selectionEnd - myField.selectionStart);
end = myField.value.substr(myField.selectionEnd);
}
} else if (document.getSelection) {
local_sel_text = document.getSelection();
selText = (local_sel_text != ''); // if true we have text selected outside of myArea
if (!selText && myArea.selectionStart!= undefined) {
begin = myField.value.substr(0, myField.selectionStart);
local_sel_text = myField.value.substr(myField.selectionStart, myField.selectionEnd - myField.selectionStart);
end = myField.value.substr(myField.selectionEnd);
}
} else if (document.selection) {
local_sel_text = document.selection.createRange().text;
}
else return;
sel_text = local_sel_text;
if (selText && allowOut){
isSel = true;
if (isHTML){
tag1 = '<span class="quote">';
tag2 = '</span>';
} else {
tag1 = '[quote=""]';
tag2 = '[/quote]';
}
insertTagsAtSelection(myArea, sel_text, tag1, tag2);
} else { isSel = false; }
myArea.focus();
}
function escapeVal(textarea,replaceWith){
textarea.value = escape(textarea.value)
for (i=0; i<textarea.value.length; i++){
if (textarea.value.indexOf("%0D%0A") > -1) {
textarea.value=textarea.value.replace("%0D%0A",replaceWith)
} else if (textarea.value.indexOf("%0A") > -1) {
textarea.value=textarea.value.replace("%0A",replaceWith)
} else if (textarea.value.indexOf("%0D") > -1) {
textarea.value=textarea.value.replace("%0D",replaceWith)
}
}
textarea.value=unescape(textarea.value);
}
function convertHTMLText(textarea) {
var li_regExp = /\<br \/\>\<li\>(.+?)\<\/li\>/mgi;
var ul_regExp = /\<ul\>(.+?)\\<br \/\><\/ul\>/mgi;
var ol_regExp = /\<ol\>(.+?)\<br \/\>\<\/ol\>/mgi;
textarea.value = textarea.value.replace(li_regExp,"<li>$1</li>");
textarea.value = textarea.value.replace(ul_regExp,"<ul>$1</ul>");
textarea.value = textarea.value.replace(ol_regExp,"<ol>$1</ol>");
}
function convertBBText(textarea) {
var b_regExp = /\[b\](.+?)\[\/b\]/mgi;
var i_regExp = /\[i\](.+?)\[\/i\]/mgi;
var u_regExp = /\[u\](.+?)\[\/u\]/mgi;
var s_regExp = /\[s\](.+?)\[\/s\]/mgi;
var ul_regExp1 = /\[ul\](.+?)\[\/ul\]/mgi;
var ul_regExp2 = /((^\*.*(\n)?)+)/mgi;
var ol_regExp1 = /\[ol\](.+?)\[\/ol\]/mgi;
//var ol_regExp2 = /((^\#.*(\n)?)+)/mgi;
var li_regExp0 = /\<br \/\>\[li\](.+?)\[\/li\]/mgi;
var li_regExp1 = /\[li\](.+?)\[\/li\]/mgi;
var li_regExp2 = /\* *(.*)$/mgi;
//var li_regExp3 = /\# *(.*)$/mgi;
var quote_regExp = /\[quote\](.+?)\[\/quote\]/mgi;
var quoteUsr_regExp = /\[quote=([^[]*)\](.+?)\[\/quote\]/mgi;
var code_regExp = /\[code\](.+?)\[\/code\]/mgi;
var anime_regExp = /\[anime=(\d+)\](.+?)\[\/anime\]/mgi;
var ep_regExp = /\[ep=(\d+)\](.+?)\[\/ep\]/mgi;
var file_regExp = /\[file=(\d+)\](.+?)\[\/file\]/mgi;
var group_regExp = /\[group=(\d+)\](.+?)\[\/group\]/mgi;
var company_regExp = /\[company=(\d+)\](.+?)\[\/company\]/mgi;
var user_regExp = /\[user=(\d+)\](.+?)\[\/user\]/mgi;
var votes_regExp = /\[votes=(\d+)\](.+?)\[\/votes\]/mgi;
var review_regExp = /\[review=(\d+\#?\d*)\](.+?)\[\/review\]/mgi;
var creq_regExp = /\[creq=(\d+)\](.+?)\[\/creq\]/mgi;
var url_regExp = /\[url=(.+?)\](.+?)\[\/url\]/mgi;
var urlLink_regExp = /\[url\](.+?)\[\/url\]/mgi;
var size_regExp = /\[size=(.+?)\](.+?)\[\/size\]/mgi;
var color_regExp = /\[color=(.+?)\](.+?)\[\/color\]/mgi;
textarea.value = textarea.value.replace(b_regExp,"<b>$1</b>");
textarea.value = textarea.value.replace(i_regExp,"<i>$1</i>");
textarea.value = textarea.value.replace(u_regExp,"<span style=\"text-decoration: underline;\">$1</span>");
textarea.value = textarea.value.replace(s_regExp,"<span style=\"text-decoration: line-through;\">$1</span>");
textarea.value = textarea.value.replace(ul_regExp1,"<ul>$1</ul>");
textarea.value = textarea.value.replace(ul_regExp2,"<ul>$1</ul>");
textarea.value = textarea.value.replace(ol_regExp1,"<ol>$1</ol>");
//textarea.value = textarea.value.replace(ol_regExp2,"<ol>$1</ol>");
textarea.value = textarea.value.replace(li_regExp0,"<li>$1</li>");
textarea.value = textarea.value.replace(li_regExp1,"<li>$1</li>");
textarea.value = textarea.value.replace(li_regExp2,"<li>$1</li>");
//textarea.value = textarea.value.replace(li_regExp3,"<li>$1</li>");
textarea.value = textarea.value.replace(quote_regExp,"<div class=\"quotebody\"><div class=\"quoteof\">Quote:</div><div class=\"quote\">$1</div></div>");
textarea.value = textarea.value.replace(quoteUsr_regExp, "<div class=\"quotebody\"><div class=\"quoteof\">$1 wrote:</div><div class=\"quote\">$2</div></div>");
textarea.value = textarea.value.replace(code_regExp,"<div class=\"codebody\"><div class=\"codeof\">Code:</div><div class=\"code\">$1</div></div>");
textarea.value = textarea.value.replace(anime_regExp,"<a href=\"animedb.pl?show=anime&aid=$1\" target=\"blank\">$2</a>");
textarea.value = textarea.value.replace(ep_regExp,"<a href=\"animedb.pl?show=ep&eid=$1\" target=\"blank\">$2</a>");
textarea.value = textarea.value.replace(file_regExp,"<a href=\"animedb.pl?show=file&fid=$1\" target=\"blank\">$2</a>");
textarea.value = textarea.value.replace(group_regExp,"<a href=\"animedb.pl?show=group&gid=$1\" target=\"blank\">$2</a>");
textarea.value = textarea.value.replace(company_regExp,"<a href=\"animedb.pl?show=producer&prid=$1\" target=\"blank\">$2</a>");
textarea.value = textarea.value.replace(user_regExp,"<a href=\"animedb.pl?show=mylist&uid=$1\" target=\"blank\">$2</a>");
textarea.value = textarea.value.replace(votes_regExp,"<a href=\"animedb.pl?show=myvotes&uid=$1\" target=\"blank\">$2</a>");
textarea.value = textarea.value.replace(review_regExp,"<a href=\"animedb.pl?show=animeatt&aid=$1\" target=\"blank\">$2</a>");
textarea.value = textarea.value.replace(creq_regExp,"<a href=\"animedb.pl?show=creq&do.showhist=1&creq.id=$1\" target=\"blank\">$2</a>");
textarea.value = textarea.value.replace(url_regExp,"<a href=\"$1\" target=\"blank\">$2</a>");
textarea.value = textarea.value.replace(urlLink_regExp,"<a href=\"$1\" target=\"blank\">$1</a>");
textarea.value = textarea.value.replace(color_regExp,"<span style=\"color: $1;\">$2</span>");
textarea.value = textarea.value.replace(size_regExp,"<span style=\"font-size: $1;\">$2</span>");
}
function preview_output() {
hiddenArea.value = myArea.value;
if (!isHTML) // convert bb code to html to display
convertBBText(hiddenArea);
escapeVal(hiddenArea,'<br \/>');
convertHTMLText(hiddenArea);
if (!isHTML) // convert bb code to html to display
convertBBText(hiddenArea);
convertHTMLText(hiddenArea);
if (!document.getElementById('preview')) {
var table;
if (usageMode == 'pm')
table = document.getElementById('msg.send').parentNode.parentNode.parentNode;
if (usageMode == 'review')
table = document.getElementById('review.add').parentNode.parentNode.parentNode;
if (usageMode == 'news')
table = document.getElementById('addn.add').parentNode.parentNode.parentNode;
if (usageMode == 'anime')
table = document.getElementById('anime.add').parentNode.parentNode.parentNode;
if (usageMode == 'company')
table = document.getElementById('company.add').parentNode.parentNode.parentNode;
var nRow = document.createElement('TR');
var nCol = document.createElement('TD');
nCol.vAlign = 'top';
nCol.appendChild(document.createTextNode(' Preview: '));
nRow.appendChild(nCol);
nCol = document.createElement('TD');
var nSpan = document.createElement('SPAN');
nSpan.id = "preview";
nCol.appendChild(nSpan);
nRow.appendChild(nCol);
table.appendChild(nRow);
}
var out;
if (usageMode == 'pm')
out = '<table class="msg_preview">'+
'<tbody><tr><td><b>To:</b></td><td><a href="#">'+document.getElementById('msg.to').value+'</a> (uid)</td></tr>'+
'<tr><td><b>Date:</b></td><td>'+new Date()+'</td></tr>'+
'<tr><td><b>Title:</b></td><td>'+document.getElementById('msg.title').value+'</td></tr>'+
'<tr><td valign="top"><b>Body:</b></td><td>'+hiddenArea.value+'</td></tr>'+
'</tbody></table>';
else
out = hiddenArea.value;
document.getElementById('preview').innerHTML = out;
}
<!-- control functions -->
function make_br() {
allowOut = false;
if (isHTML){
tag1 = '<br />';
tag2 = '';
} else {
tag1 = '';
tag2 = '';
}
getSel(myArea);
if (sel_text.length > 0){ // we have text
insertTagsAtSelection(myArea, sel_text, tag1, tag2);
}
}
function make_p() {
allowOut = false;
if (isHTML){
tag1 = '<p>';
tag2 = '</p>';
} else {
tag1 = '';
tag2 = '';
}
getSel(myArea);
if (sel_text.length > 0){ // we have text
insertTagsAtSelection(myArea, sel_text, tag1, tag2);
} else {
if (!isP) {
insertAtCursor(myArea,tag1);
isP = true;
document.getElementById('pr').value = ' p* ';
} else {
insertAtCursor(myArea,tag2);
isP = false;
document.getElementById('pr').value = ' p ';
}
}
}
function make_bold() {
allowOut = false;
if (isHTML){
tag1 = '<b>';
tag2 = '</b>';
} else {
tag1 = '[b]';
tag2 = '[/b]';
}
getSel(myArea);
if (sel_text.length > 0){ // we have text
insertTagsAtSelection(myArea, sel_text, tag1, tag2);
} else {
if (!isBold) {
insertAtCursor(myArea,tag1);
isBold = true;
document.getElementById('bold').value = ' B* ';
} else {
insertAtCursor(myArea,tag2);
isBold = false;
document.getElementById('bold').value = ' B ';
}
}
}
function make_italic() {
allowOut = false;
if (isHTML){
tag1 = '<i>';
tag2 = '</i>';
} else {
tag1 = '[i]';
tag2 = '[/i]';
}
getSel(myArea);
if (sel_text.length > 0){ // we have text
insertTagsAtSelection(myArea, sel_text, tag1, tag2);
} else {
if (!isItalic) {
insertAtCursor(myArea,tag1);
isItalic = true;
document.getElementById('italic').value = ' i* ';
} else {
insertAtCursor(myArea,tag2);
isItalic = false;
document.getElementById('italic').value = ' i ';
}
}
}
function make_underline() {
allowOut = false;
if (isHTML){
tag1 = '<span style="text-decoration: underline;">';
tag2 = '</span>';
} else {
tag1 = '[u]';
tag2 = '[/u]';
}
getSel(myArea);
if (sel_text.length > 0){ // we have text
insertTagsAtSelection(myArea, sel_text, tag1, tag2);
} else {
if (!isUnderline) {
insertAtCursor(myArea,tag1);
isUnderline = true;
document.getElementById('underline').value = ' u* ';
} else {
insertAtCursor(myArea,tag2);
isUnderline = false;
document.getElementById('underline').value = ' u ';
}
}
}
function make_strikeout() {
allowOut = false;
if (isHTML){
tag1 = '<span style="text-decoration: line-through;">';
tag2 = '</span>';
} else {
tag1 = '[s]';
tag2 = '[/s]';
}
getSel(myArea);
if (sel_text.length > 0){ // we have text
insertTagsAtSelection(myArea, sel_text, tag1, tag2);
} else {
if (!isStrikeout) {
insertAtCursor(myArea,tag1);
isStrikeout = true;
document.getElementById('strikeout').value = ' s* ';
} else {
insertAtCursor(myArea,tag2);
isStrikeout = false;
document.getElementById('strikeout').value = ' s ';
}
}
}
function make_quote() {
allowOut = true;
if (isHTML){
tag1 = '<span class="quote">';
tag2 = '</span>';
} else {
tag1 = '[quote]';
tag2 = '[/quote]';
}
getSel(myArea);
if (!isSel) {
if (sel_text.length > 0){ // we have text
insertTagsAtSelection(myArea, sel_text, tag1, tag2);
} else {
if (!isQuote) {
insertAtCursor(myArea,tag1);
isQuote = true;
document.getElementById('quote').value = ' quote* ';
} else {
insertAtCursor(myArea,tag2);
isQuote = false;
document.getElementById('quote').value = ' quote ';
}
}
}
}
function make_code() {
allowOut = false;
if (isHTML){
tag1 = '<span class="code">';
tag2 = '</span>';
} else {
tag1 = '[code]';
tag2 = '[/code]';
}
getSel(myArea);
if (sel_text.length > 0){ // we have text
insertTagsAtSelection(myArea, sel_text, tag1, tag2);
} else {
if (!isCode) {
insertAtCursor(myArea,tag1);
isCode = true;
document.getElementById('code').value = ' code* ';
} else {
insertAtCursor(myArea,tag2);
isCode = false;
document.getElementById('code').value = ' code ';
}
}
}
function make_ulist() {
allowOut = false;
if (isHTML){
tag1 = '<ul>';
tag2 = '</ul>';
} else {
tag1 = '[ul]';
tag2 = '[/ul]';
}
getSel(myArea);
if (sel_text.length > 0){ // we have text
insertTagsAtSelection(myArea, sel_text, tag1, tag2);
} else {
if (!isuList) {
insertAtCursor(myArea,tag1);
isuList = true;
document.getElementById('ulist').value = ' ul* ';
} else {
insertAtCursor(myArea,tag2);
isuList = false;
document.getElementById('ulist').value = ' ul ';
}
}
}
function make_olist() {
allowOut = false;
if (isHTML){
tag1 = '<ol>';
tag2 = '</ol>';
} else {
tag1 = '[ol]';
tag2 = '[/ol]';
}
getSel(myArea);
if (sel_text.length > 0){ // we have text
insertTagsAtSelection(myArea, sel_text, tag1, tag2);
} else {
if (!isoList) {
insertAtCursor(myArea,tag1);
isoList = true;
document.getElementById('olist').value = ' ol* ';
} else {
insertAtCursor(myArea,tag2);
isoList = false;
document.getElementById('olist').value = ' ol ';
}
}
}
function make_ilist() {
allowOut = false;
if (isHTML){
tag1 = '<li>';
tag2 = '</li>';
} else {
tag1 = '[li]';
tag2 = '[/li]';
}
getSel(myArea);
if (sel_text.length > 0){ // we have text
insertTagsAtSelection(myArea, sel_text, tag1, tag2);
} else {
if (!isiList) {
insertAtCursor(myArea,tag1);
isiList = true;
document.getElementById('ilist').value = ' li* ';
} else {
insertAtCursor(myArea,tag2);
isiList = false;
document.getElementById('ilist').value = ' li ';
}
}
}
function make_img() {
allowOut = false;
if (isHTML){
tag1 = '<img src=\"';
tag2 = '\" alt=\"\" />';
} else {
tag1 = '[img]';
tag2 = '[/img]';
}
getSel(myArea);
if (sel_text.length > 0){ // we have text
insertTagsAtSelection(myArea, sel_text, tag1, tag2);
}
}
function make_link() {
allowOut = false;
if (isHTML){
tag1 = '<a href=\"';
tag1a = '\">';
tag2 = '</a>';
} else {
tag1 = '[url=';
tag1a = ']';
tag2 = '[/url]';
}
getSel(myArea);
if (sel_text.length > 0){ // we have text
var link = prompt("Please enter the url", "http://");
insertTagsAtSelection(myArea, sel_text, (tag1 + link + tag1a), tag2);
} else {
if (!isLink) {
insertAtCursor(myArea,(tag1 + tag1a));
isLink = true;
document.getElementById('link').value = ' url* ';
} else {
insertAtCursor(myArea,tag2);
isLink = false;
document.getElementById('link').value = ' url ';
}
}
}
function make_color() {
allowOut = false;
if (isHTML){
tag1 = '<span style="color: ';
tag1a = ';\">';
tag2 = '</span>';
} else {
tag1 = '[color=';
tag1a = ']';
tag2 = '[/color]';
}
color = document.getElementById('sel_color').value;
getSel(myArea);
insertTagsAtSelection(myArea, sel_text, (tag1 + color + tag1a), tag2);
}
function make_size() {
allowOut = false;
if (isHTML){
tag1 = '<span style="font-size: ';
tag1a = ';\">';
tag2 = '</span>';
} else {
tag1 = '[size=';
tag1a = ']';
tag2 = '[/size]';
}
size = document.getElementById('sel_size').value;
getSel(myArea);
insertTagsAtSelection(myArea, sel_text, (tag1 + size + tag1a), tag2);
}
function make_anime() {
allowOut = false;
if (isHTML){
tag1 = '<a href="animedb.pl?show=anime&aid=" target="_blank">';
tag2 = '</a>';
} else {
tag1 = '[anime=]';
tag2 = '[/anime]';
}
getSel(myArea);
if (!isSel) {
if (sel_text.length > 0){ // we have text
insertTagsAtSelection(myArea, sel_text, tag1, tag2);
} else {
if (!isAnime) {
insertAtCursor(myArea,tag1);
isAnime = true;
document.getElementById('anime').value = ' anime* ';
} else {
insertAtCursor(myArea,tag2);
isAnime = false;
document.getElementById('anime').value = ' anime ';
}
}
}
}
function make_ep() {
allowOut = false;
if (isHTML){
tag1 = '<a href="animedb.pl?show=ep&eid=" target="_blank">';
tag2 = '</a>';
} else {
tag1 = '[ep=]';
tag2 = '[/ep]';
}
getSel(myArea);
if (!isSel) {
if (sel_text.length > 0){ // we have text
insertTagsAtSelection(myArea, sel_text, tag1, tag2);
} else {
if (!isEp) {
insertAtCursor(myArea,tag1);
isEp = true;
document.getElementById('ep').value = ' ep* ';
} else {
insertAtCursor(myArea,tag2);
isEp = false;
document.getElementById('ep').value = ' ep ';
}
}
}
}
function make_file() {
allowOut = false;
if (isHTML){
tag1 = '<a href="animedb.pl?show=file&fid=" target="_blank">';
tag2 = '</a>';
} else {
tag1 = '[file=]';
tag2 = '[/file]';
}
getSel(myArea);
if (!isSel) {
if (sel_text.length > 0){ // we have text
insertTagsAtSelection(myArea, sel_text, tag1, tag2);
} else {
if (!isFile) {
insertAtCursor(myArea,tag1);
isFile = true;
document.getElementById('file').value = ' file* ';
} else {
insertAtCursor(myArea,tag2);
isFile = false;
document.getElementById('file').value = ' file ';
}
}
}
}
function make_group() {
allowOut = false;
if (isHTML){
tag1 = '<a href="animedb.pl?show=group&gid=" target="_blank">';
tag2 = '</a>';
} else {
tag1 = '[group=]';
tag2 = '[/group]';
}
getSel(myArea);
if (!isSel) {
if (sel_text.length > 0){ // we have text
insertTagsAtSelection(myArea, sel_text, tag1, tag2);
} else {
if (!isGroup) {
insertAtCursor(myArea,tag1);
isGroup = true;
document.getElementById('group').value = ' group* ';
} else {
insertAtCursor(myArea,tag2);
isGroup = false;
document.getElementById('group').value = ' group ';
}
}
}
}
function make_company() {
allowOut = false;
if (isHTML){
tag1 = '<a href="animedb.pl?show=producer&prid=" target="_blank">';
tag2 = '</a>';
} else {
tag1 = '[company=]';
tag2 = '[/company]';
}
getSel(myArea);
if (!isSel) {
if (sel_text.length > 0){ // we have text
insertTagsAtSelection(myArea, sel_text, tag1, tag2);
} else {
if (!isCompany) {
insertAtCursor(myArea,tag1);
isCompany = true;
document.getElementById('company').value = ' company* ';
} else {
insertAtCursor(myArea,tag2);
isCompany = false;
document.getElementById('company').value = ' company ';
}
}
}
}
function make_user() {
allowOut = false;
if (isHTML){
tag1 = '<a href="animedb.pl?show=mylist&uid=" target="_blank">';
tag2 = '</a>';
} else {
tag1 = '[user=]';
tag2 = '[/user]';
}
getSel(myArea);
if (!isSel) {
if (sel_text.length > 0){ // we have text
insertTagsAtSelection(myArea, sel_text, tag1, tag2);
} else {
if (!isUser) {
insertAtCursor(myArea,tag1);
isUser = true;
document.getElementById('user').value = ' user* ';
} else {
insertAtCursor(myArea,tag2);
isUser = false;
document.getElementById('user').value = ' user ';
}
}
}
}
function make_votes() {
allowOut = false;
if (isHTML){
tag1 = '<a href="animedb.pl?show=myvotes&uid=" target="_blank">';
tag2 = '</a>';
} else {
tag1 = '[votes=]';
tag2 = '[/votes]';
}
getSel(myArea);
if (!isSel) {
if (sel_text.length > 0){ // we have text
insertTagsAtSelection(myArea, sel_text, tag1, tag2);
} else {
if (!isVotes) {
insertAtCursor(myArea,tag1);
isVotes = true;
document.getElementById('votes').value = ' votes* ';
} else {
insertAtCursor(myArea,tag2);
isVotes = false;
document.getElementById('votes').value = ' votes ';
}
}
}
}
function make_review() {
allowOut = false;
if (isHTML){
tag1 = '<a href="animedb.pl?show=animeatt&aid=" target="_blank">';
tag2 = '</a>';
} else {
tag1 = '[review=]';
tag2 = '[/review]';
}
getSel(myArea);
if (!isSel) {
if (sel_text.length > 0){ // we have text
insertTagsAtSelection(myArea, sel_text, tag1, tag2);
} else {
if (!isReview) {
insertAtCursor(myArea,tag1);
isReview = true;
document.getElementById('review').value = ' review* ';
} else {
insertAtCursor(myArea,tag2);
isReview = false;
document.getElementById('review').value = ' review ';
}
}
}
}
function make_creq() {
allowOut = false;
if (isHTML){
tag1 = '<a href="animedb.pl?show=creq&do.showhist=1&creq.id=" target="_blank">';
tag2 = '</a>';
} else {
tag1 = '[creq=]';
tag2 = '[/creq]';
}
getSel(myArea);
if (!isSel) {
if (sel_text.length > 0){ // we have text
insertTagsAtSelection(myArea, sel_text, tag1, tag2);
} else {
if (!isCreq) {
insertAtCursor(myArea,tag1);
isCreq = true;
document.getElementById('creq').value = ' creq* ';
} else {
insertAtCursor(myArea,tag2);
isCreq = false;
document.getElementById('creq').value = ' creq ';
}
}
}
}
function updateCharCount() {
var charCount = document.getElementById('charCount');
var wordCount = document.getElementById('wordCount');
var limit;
if (usageMode == 'news') {
cc = charCount.value = myArea.value.length;
} else if (usageMode == 'review') {
limit = 50000;
if (myArea.value.length > limit) myArea.value = myArea.value.substring(0,limit);
wc = wordCount.value = myArea.value.split(' ').length + myArea.value.split('\n').length - 2;
cc = charCount.value = myArea.value.length;
charCount.style.backgroundColor = "";
if (cc <= 500)
charCount.style.color = "grey";
if (cc > 45000 && cc <= 49990)
charCount.style.color = "red";
if (cc > 49990) {
charCount.style.backgroundColor = "red";
charCount.style.color = "white";
}
if (wc <= 500)
wordCount.style.color = "green";
if (wc > 500 && wc <= 1250)
wordCount.style.color = "orange";
if (wc > 1250)
wordCount.style.color = "red";
} else {
limit = 5000;
if (myArea.value.length > limit) myArea.value = myArea.value.substring(0,limit);
cc = charCount.value = myArea.value.length;
charCount.style.backgroundColor = "";
if (cc <= 4500)
charCount.style.color = "grey";