Browse Source

Migrate some inline JS

spaghetti 7 years ago
parent
commit
cef83063a2

+ 1
- 1
classes/mediainfo.class.php View File

88
         if (!isset($this->parsers['general'])) return $string;
88
         if (!isset($this->parsers['general'])) return $string;
89
 
89
 
90
         $midiv_start = '<div class="spoilerContainer hideContainer">
90
         $midiv_start = '<div class="spoilerContainer hideContainer">
91
-            <input type="button" class="spoilerButton" onclick="BBCode.spoiler(this);" value="Show '.
91
+            <input type="button" class="spoilerButton" value="Show '.
92
             $this->parsers['general'][0]->filename.
92
             $this->parsers['general'][0]->filename.
93
             '" /><blockquote class="spoiler hidden">';
93
             '" /><blockquote class="spoiler hidden">';
94
         $midiv_end = "</blockquote></div>";
94
         $midiv_end = "</blockquote></div>";

+ 3
- 15
classes/text.class.php View File

4
    * Array of valid tags; tag => max number of attributes
4
    * Array of valid tags; tag => max number of attributes
5
    * @var array $ValidTags
5
    * @var array $ValidTags
6
    */
6
    */
7
-  private static $ValidTags = array('b'=>0, 'u'=>0, 'i'=>0, 's'=>0, '*'=>0, '#'=>0, 'ch'=>0, 'uch'=>0, 'artist'=>0, 'user'=>0, 'n'=>0, 'inlineurl'=>0, 'inlinesize'=>1, 'headline'=>1, 'align'=>1, 'color'=>1, 'colour'=>1, 'size'=>1, 'url'=>1, 'img'=>1, 'quote'=>1, 'pre'=>1, 'code'=>1, 'tex'=>0, 'hide'=>1, 'spoiler' => 1, 'plain'=>0, 'important'=>0, 'torrent'=>0, 'rule'=>0, 'mature'=>1, 'embed'=>0,
7
+  private static $ValidTags = array('b'=>0, 'u'=>0, 'i'=>0, 's'=>0, '*'=>0, '#'=>0, 'ch'=>0, 'uch'=>0, 'artist'=>0, 'user'=>0, 'n'=>0, 'inlineurl'=>0, 'inlinesize'=>1, 'headline'=>1, 'align'=>1, 'color'=>1, 'colour'=>1, 'size'=>1, 'url'=>1, 'img'=>1, 'quote'=>1, 'pre'=>1, 'code'=>1, 'tex'=>0, 'hide'=>1, 'spoiler' => 1, 'plain'=>0, 'important'=>0, 'torrent'=>0, 'rule'=>0, 'embed'=>0,
8
   );
8
   );
9
 
9
 
10
   /**
10
   /**
563
         case 'hide':
563
         case 'hide':
564
           $Array[$ArrayPos] = array('Type'=>'hide', 'Attr'=>$Attrib, 'Val'=>self::parse($Block));
564
           $Array[$ArrayPos] = array('Type'=>'hide', 'Attr'=>$Attrib, 'Val'=>self::parse($Block));
565
           break;
565
           break;
566
-        case 'mature':
567
-          $Array[$ArrayPos] = array('Type'=>'mature', 'Attr'=>$Attrib, 'Val'=>self::parse($Block));
568
-          break;
569
         case 'embed':
566
         case 'embed':
570
           $Array[$ArrayPos] = array('Type'=>'embed', 'Val'=>$Block);
567
           $Array[$ArrayPos] = array('Type'=>'embed', 'Val'=>$Block);
571
           break;
568
           break;
820
           self::$NoImg++; // No images inside quote tags
817
           self::$NoImg++; // No images inside quote tags
821
           self::$InQuotes++;
818
           self::$InQuotes++;
822
           if (self::$InQuotes == self::$NestsBeforeHide) { //Put quotes that are nested beyond the specified limit in [hide] tags.
819
           if (self::$InQuotes == self::$NestsBeforeHide) { //Put quotes that are nested beyond the specified limit in [hide] tags.
823
-            $Str .= '<strong>Older quotes</strong>: <a href="javascript:void(0);" onclick="BBCode.spoiler(this);">Show</a>';
820
+            $Str .= '<strong>Older quotes</strong>: <a class="spoilerButton">Show</a>';
824
             $Str .= '<blockquote class="hidden spoiler">';
821
             $Str .= '<blockquote class="hidden spoiler">';
825
           }
822
           }
826
           if (!empty($Block['Attr'])) {
823
           if (!empty($Block['Attr'])) {
842
           self::$InQuotes--;
839
           self::$InQuotes--;
843
           break;
840
           break;
844
         case 'hide':
841
         case 'hide':
845
-          $Str .= '<strong>'.(($Block['Attr']) ? $Block['Attr'] : 'Hidden text').'</strong>: <a href="javascript:void(0);" onclick="BBCode.spoiler(this);">Show</a>';
842
+          $Str .= '<strong>'.(($Block['Attr']) ? $Block['Attr'] : 'Hidden text').'</strong>: <a class="spoilerButton">Show</a>';
846
           $Str .= '<blockquote class="hidden spoiler">'.self::to_html($Block['Val']).'</blockquote>';
843
           $Str .= '<blockquote class="hidden spoiler">'.self::to_html($Block['Val']).'</blockquote>';
847
           break;
844
           break;
848
-        case 'mature':
849
-          if (!empty($Block['Attr'])) {
850
-            $Str .= '<strong class="mature" style="font-size: 1.2em;">Mature content:</strong><strong> ' . $Block['Attr'] . '</strong><br /> <a href="javascript:void(0);" onclick="BBCode.spoiler(this);">Show</a>';
851
-            $Str .= '<blockquote class="hidden spoiler">'.self::to_html($Block['Val']).'</blockquote>';
852
-          }
853
-          else {
854
-            $Str .= '<strong>Use of the [mature] tag requires a description.</strong> The correct format is as follows: <strong>[mature=description] ...content... [/mature]</strong>, where "description" is a mandatory description of the post. Misleading descriptions will be penalized. For further information on our mature content policies, please refer to this <a href="wiki.php?action=article&amp;id=1063">wiki</a>.';
855
-          }
856
-          break;
857
         case 'img':
845
         case 'img':
858
           if (self::$NoImg > 0 && self::valid_url($Block['Val'])) {
846
           if (self::$NoImg > 0 && self::valid_url($Block['Val'])) {
859
             $Str .= '<a rel="noreferrer" target="_blank" href="'.$Block['Val'].'">'.$Block['Val'].'</a> (image)';
847
             $Str .= '<a rel="noreferrer" target="_blank" href="'.$Block['Val'].'">'.$Block['Val'].'</a> (image)';

+ 8
- 8
classes/torrent_form.class.php View File

234
           foreach ($Torrent['Artists'] as $Num => $Artist) { ?>
234
           foreach ($Torrent['Artists'] as $Num => $Artist) { ?>
235
             <input type="text" id="idols_<?=$Num?>" name="idols[]" size="45" value="<?=display_str($Artist['name'])?>" <?=$this->Disabled?>/>
235
             <input type="text" id="idols_<?=$Num?>" name="idols[]" size="45" value="<?=display_str($Artist['name'])?>" <?=$this->Disabled?>/>
236
             <? if ($Num == 0) { ?>
236
             <? if ($Num == 0) { ?>
237
-              <a href="#" onclick="AddArtistField(); return false;" class="brackets">+</a> <a href="#" onclick="RemoveArtistField(); return false;" class="brackets">&minus;</a>
237
+              <a class="add_artist_button brackets">+</a> <a class="remove_artist_button brackets">&minus;</a>
238
             <? }
238
             <? }
239
             }
239
             }
240
           } else { ?>
240
           } else { ?>
241
             <input type="text" id="idols_0" name="idols[]" size="45" value="" <?=$this->Disabled?> />
241
             <input type="text" id="idols_0" name="idols[]" size="45" value="" <?=$this->Disabled?> />
242
-            <a href="#" onclick="AddArtistField(); return false;" class="brackets">+</a> <a href="#" onclick="RemoveArtistField(); return false;" class="brackets">&minus;</a>
242
+            <a class="add_artist_button brackets">+</a> <a class="remove_artist_button brackets">&minus;</a>
243
 <?        } ?>
243
 <?        } ?>
244
         </td>
244
         </td>
245
       </tr>
245
       </tr>
496
           foreach ($Torrent['Artists'] as $Num => $Artist) { ?>
496
           foreach ($Torrent['Artists'] as $Num => $Artist) { ?>
497
             <input type="text" id="idols_<?=$Num?>" name="idols[]" size="45" value="<?=display_str($Artist['name'])?>" <?=$this->Disabled?> />
497
             <input type="text" id="idols_<?=$Num?>" name="idols[]" size="45" value="<?=display_str($Artist['name'])?>" <?=$this->Disabled?> />
498
             <? if ($Num == 0) { ?>
498
             <? if ($Num == 0) { ?>
499
-              <a href="#" onclick="AddArtistField(); return false;" class="brackets">+</a> <a href="#" onclick="RemoveArtistField(); return false;" class="brackets">&minus;</a>
499
+              <a class="add_artist_button brackets">+</a> <a class="remove_artist_button brackets">&minus;</a>
500
             <? }
500
             <? }
501
             }
501
             }
502
           } else { ?>
502
           } else { ?>
503
             <input type="text" id="idols_0" name="idols[]" size="45" value="" <?=$this->Disabled?> />
503
             <input type="text" id="idols_0" name="idols[]" size="45" value="" <?=$this->Disabled?> />
504
-            <a href="#" onclick="AddArtistField(); return false;" class="brackets">+</a> <a href="#" onclick="RemoveArtistField(); return false;" class="brackets">&minus;</a>
504
+            <a class="add_artist_button brackets">+</a> <a class="remove_artist_button brackets">&minus;</a>
505
 <?        } ?>
505
 <?        } ?>
506
         </td>
506
         </td>
507
       </tr>
507
       </tr>
749
           foreach ($Torrent['Artists'] as $Num => $Artist) { ?>
749
           foreach ($Torrent['Artists'] as $Num => $Artist) { ?>
750
             <input type="text" id="idols_<?=$Num?>" name="idols[]" size="45" value="<?=display_str($Artist['name'])?>" <?=$this->Disabled?> />
750
             <input type="text" id="idols_<?=$Num?>" name="idols[]" size="45" value="<?=display_str($Artist['name'])?>" <?=$this->Disabled?> />
751
             <? if ($Num == 0) { ?>
751
             <? if ($Num == 0) { ?>
752
-              <a href="#" onclick="AddArtistField(); return false;" class="brackets">+</a> <a href="#" onclick="RemoveArtistField(); return false;" class="brackets">&minus;</a>
752
+              <a class="add_artist_button brackets">+</a> <a class="remove_artist_button brackets">&minus;</a>
753
             <? }
753
             <? }
754
             }
754
             }
755
           } else { ?>
755
           } else { ?>
756
             <input type="text" id="idols_0" name="idols[]" size="45" value="" <?=$this->Disabled?> />
756
             <input type="text" id="idols_0" name="idols[]" size="45" value="" <?=$this->Disabled?> />
757
-            <a href="#" onclick="AddArtistField(); return false;" class="brackets">+</a> <a href="#" onclick="RemoveArtistField(); return false;" class="brackets">&minus;</a>
757
+            <a class="add_artist_button brackets">+</a> <a class="remove_artist_button brackets">&minus;</a>
758
 <?        } ?>
758
 <?        } ?>
759
         </td>
759
         </td>
760
       </tr>
760
       </tr>
995
           foreach ($Torrent['Artists'] as $Num => $Artist) { ?>
995
           foreach ($Torrent['Artists'] as $Num => $Artist) { ?>
996
             <input type="text" id="idols_<?=$Num?>" name="idols[]" size="45" value="<?=display_str($Artist['name'])?>" <?=$this->Disabled?> />
996
             <input type="text" id="idols_<?=$Num?>" name="idols[]" size="45" value="<?=display_str($Artist['name'])?>" <?=$this->Disabled?> />
997
             <? if ($Num == 0) { ?>
997
             <? if ($Num == 0) { ?>
998
-              <a href="#" onclick="AddArtistField(); return false;" class="brackets">+</a> <a href="#" onclick="RemoveArtistField(); return false;" class="brackets">&minus;</a>
998
+              <a class="add_artist_button brackets">+</a> <a class="remove_artist_button brackets">&minus;</a>
999
             <? }
999
             <? }
1000
             }
1000
             }
1001
           } else { ?>
1001
           } else { ?>
1002
             <input type="text" id="idols_0" name="idols[]" size="45" value="" <?=$this->Disabled?> />
1002
             <input type="text" id="idols_0" name="idols[]" size="45" value="" <?=$this->Disabled?> />
1003
-            <a href="#" onclick="AddArtistField(); return false;" class="brackets">+</a> <a href="#" onclick="RemoveArtistField(); return false;" class="brackets">&minus;</a>
1003
+            <a class="add_artist_button brackets">+</a> <a class="remove_artist_button brackets">&minus;</a>
1004
 <?        } ?>
1004
 <?        } ?>
1005
         </td>
1005
         </td>
1006
       </tr>
1006
       </tr>

+ 2
- 2
sections/requests/new_edit.php View File

155
       foreach ($ArtistForm as $Artist) {
155
       foreach ($ArtistForm as $Artist) {
156
 ?>
156
 ?>
157
             <input type="text" id="artist_0" name="artists[]"<? Users::has_autocomplete_enabled('other'); ?> size="45" value="<?=display_str($Artist['name']) ?>" <?=$Disabled?>/>
157
             <input type="text" id="artist_0" name="artists[]"<? Users::has_autocomplete_enabled('other'); ?> size="45" value="<?=display_str($Artist['name']) ?>" <?=$Disabled?>/>
158
-            <? if (empty($Disabled)) { if ($First) { ?><a href="#" onclick="AddArtistField(); return false;" class="brackets">+</a> <a href="#" onclick="RemoveArtistField(); return false;" class="brackets">&minus;</a><? } $First = false; } ?>
158
+            <? if (empty($Disabled)) { if ($First) { ?><a class="add_artist_button brackets">+</a> <a class="remove_artist_button brackets">&minus;</a><? } $First = false; } ?>
159
             <br />
159
             <br />
160
 <?
160
 <?
161
       }
161
       }
162
     } else {
162
     } else {
163
 ?>            <input type="text" id="artist_0" name="artists[]"<? Users::has_autocomplete_enabled('other'); ?> size="45" onblur="CheckVA();" <?=$Disabled?>/>
163
 ?>            <input type="text" id="artist_0" name="artists[]"<? Users::has_autocomplete_enabled('other'); ?> size="45" onblur="CheckVA();" <?=$Disabled?>/>
164
 <? if (empty($Disabled)) { ?>
164
 <? if (empty($Disabled)) { ?>
165
-            <a href="#" onclick="AddArtistField(); return false;" class="brackets">+</a> <a href="#" onclick="RemoveArtistField(); return false;" class="brackets">&minus;</a>
165
+            <a class="add_artist_button brackets">+</a> <a class="remove_artist_button brackets">&minus;</a>
166
 <? } ?>
166
 <? } ?>
167
 <?
167
 <?
168
     }
168
     }

+ 1
- 1
sections/torrents/details.php View File

598
       } else {
598
       } else {
599
 ?>
599
 ?>
600
   <div class="spoilerContainer hideContainer">
600
   <div class="spoilerContainer hideContainer">
601
-    <input type="button" class="spoilerButton" onclick="BBCode.spoiler(this);" value="Show MediaInfo" /><blockquote class="spoiler hidden">
601
+    <input type="button" class="spoilerButton" value="Show MediaInfo" /><blockquote class="spoiler hidden">
602
 <?
602
 <?
603
         echo Text::full_format($MediaInfo);
603
         echo Text::full_format($MediaInfo);
604
 ?>
604
 ?>

+ 1
- 1
sections/torrents/editgroup.php View File

200
         </td>
200
         </td>
201
         <td id="idolfields">
201
         <td id="idolfields">
202
           <input type="text" id="idol_0" name="idols[]" size="45" value="<?=$Artists[0]['name']?>"/>
202
           <input type="text" id="idol_0" name="idols[]" size="45" value="<?=$Artists[0]['name']?>"/>
203
-          <a onclick="AddArtistField()" class="brackets">+</a> <a onclick="RemoveArtistField()" class="brackets">&minus;</a>
203
+          <a class="add_artist_button brackets">+</a> <a class="remove_artist_button brackets">&minus;</a>
204
 <?
204
 <?
205
   for ($i = 1; $i < count($Artists); $i++) {
205
   for ($i = 1; $i < count($Artists); $i++) {
206
     print '<br><input type="text" id="idol_'.$i.'" name="idols[]" size="45" value="'.$Artists[$i]['name'].'"/>';
206
     print '<br><input type="text" id="idol_'.$i.'" name="idols[]" size="45" value="'.$Artists[$i]['name'].'"/>';

+ 20
- 23
static/functions/bbcode.js View File

1
-var BBCode = {
2
-  spoiler: function(link) {
3
-    if ($(link.nextSibling).has_class('hidden')) {
4
-      $(link.nextSibling).gshow();
5
-      $(link).html('Hide');
6
-      if ($(link).attr("value")) {
7
-        $(link).attr("value", "Hide" + $(link).attr("value").substring(4))
8
-      }
9
-    } else {
10
-      $(link.nextSibling).ghide();
11
-      $(link).html('Show');
12
-      if ($(link).attr("value")) {
13
-        $(link).attr("value", "Show" + $(link).attr("value").substring(4))
14
-      }
1
+function BBSpoiler(link) {
2
+  if ($(link.nextSibling).has_class('hidden')) {
3
+    $(link.nextSibling).gshow();
4
+    $(link).html('Hide');
5
+    if ($(link).attr("value")) {
6
+      $(link).attr("value", "Hide" + $(link).attr("value").substring(4))
7
+    }
8
+  } else {
9
+    $(link.nextSibling).ghide();
10
+    $(link).html('Show');
11
+    if ($(link).attr("value")) {
12
+      $(link).attr("value", "Show" + $(link).attr("value").substring(4))
15
     }
13
     }
16
   }
14
   }
17
-};
15
+}
18
 
16
 
19
 function wrapSelected(box, wrap, offset) {
17
 function wrapSelected(box, wrap, offset) {
20
   if (!Array.isArray(wrap)) wrap = [wrap, wrap]
18
   if (!Array.isArray(wrap)) wrap = [wrap, wrap]
21
   if (wrap.length < 2) wrap[1] = wrap[0]
19
   if (wrap.length < 2) wrap[1] = wrap[0]
22
-  let s = box.selectionStart
23
-  let e = box.selectionEnd
24
-  let v = box.value
20
+  var s = box.selectionStart
21
+  var e = box.selectionEnd
22
+  var v = box.value
25
   box.value = v.slice(0,s)+wrap[0]+v.slice(s,e)+wrap[1]+v.slice(e)
23
   box.value = v.slice(0,s)+wrap[0]+v.slice(s,e)+wrap[1]+v.slice(e)
26
   box.focus()
24
   box.focus()
27
   box.selectionEnd = (offset!==undefined?s+offset:e+wrap[0].length)
25
   box.selectionEnd = (offset!==undefined?s+offset:e+wrap[0].length)
71
   box.parentNode.insertBefore(bar, box)
69
   box.parentNode.insertBefore(bar, box)
72
 }
70
 }
73
 
71
 
74
-if (document.readyState == 'complete') {
72
+$(function() {
75
   $('.bbcode_editor').each(function(i, el) { BBEditor(el) })
73
   $('.bbcode_editor').each(function(i, el) { BBEditor(el) })
76
-} else {
77
-  document.addEventListener("DOMContentLoaded", function() {
78
-    $('.bbcode_editor').each(function(i, el) { BBEditor(el) })
74
+  $('.spoilerButton').each(function(i, el) {
75
+    el.addEventListener("click", ()=>BBSpoiler(el))
79
   })
76
   })
80
-}
77
+})

+ 2
- 0
static/functions/browse.js View File

317
     var a = $('a[data-cover]')[0]
317
     var a = $('a[data-cover]')[0]
318
     if (a) preload(a.attributes['data-cover'].value)
318
     if (a) preload(a.attributes['data-cover'].value)
319
   }
319
   }
320
+  $('.add_artist_button').each(function(i, el) {el.addEventListener('click', AddArtistField)})
321
+  $('.remove_artist_button').each(function(i, el) {el.addEventListener('click', RemoveArtistField)})
320
 })
322
 })

+ 1
- 1
static/functions/reportsv2.js View File

232
   }
232
   }
233
 }
233
 }
234
 
234
 
235
-if (document.readyState == 'complete') {
235
+if (document.readyState != 'loading') {
236
   ReportSelectorInit();
236
   ReportSelectorInit();
237
 } else {
237
 } else {
238
   document.addEventListener("DOMContentLoaded", ReportSelectorInit);
238
   document.addEventListener("DOMContentLoaded", ReportSelectorInit);

+ 2
- 0
static/functions/requests.js View File

239
       ({'jav':JavAutofill})[el.attributes['autofill'].value]()
239
       ({'jav':JavAutofill})[el.attributes['autofill'].value]()
240
     })
240
     })
241
   })
241
   })
242
+  $('.add_artist_button').each(function(i, el) {el.addEventListener('click', AddArtistField)})
243
+  $('.remove_artist_button').each(function(i, el) {el.addEventListener('click', RemoveArtistField)})
242
 })
244
 })

+ 5
- 5
static/functions/upload.js View File

517
   })
517
   })
518
 }
518
 }
519
 
519
 
520
-function initAutofill() {
521
-  document.querySelectorAll('[autofill]').forEach(function(el) {
520
+$(function() {
521
+  $('[autofill]').each(function(i, el) {
522
     el.addEventListener('click', function(event) {
522
     el.addEventListener('click', function(event) {
523
       ({'douj':DoujAutofill, 'anime':AnidbAutofill, 'jav':JavAutofill})[el.attributes['autofill'].value]()
523
       ({'douj':DoujAutofill, 'anime':AnidbAutofill, 'jav':JavAutofill})[el.attributes['autofill'].value]()
524
     })
524
     })
525
   })
525
   })
526
-}
527
-
528
-$(initAutofill)
526
+  $('.add_artist_button').each(function(i, el) {el.addEventListener('click', AddArtistField)})
527
+  $('.remove_artist_button').each(function(i, el) {el.addEventListener('click', RemoveArtistField)})
528
+})

+ 1
- 0
static/styles/global.css View File

125
 }
125
 }
126
 
126
 
127
 .spoilerButton {
127
 .spoilerButton {
128
+  cursor: pointer;
128
   overflow: hidden;
129
   overflow: hidden;
129
   text-overflow: ellipsis;
130
   text-overflow: ellipsis;
130
 }
131
 }

Loading…
Cancel
Save