Browse Source

Async JS: Load reports on demand

spaghetti 8 years ago
parent
commit
bbfda00825
2 changed files with 6 additions and 6 deletions
  1. 2
    6
      sections/reportsv2/static.php
  2. 4
    0
      static/functions/reportsv2.js

+ 2
- 6
sections/reportsv2/static.php View File

@@ -307,7 +307,7 @@ if (count($Reports) === 0) {
307 307
         WHERE ID = $ReportID");
308 308
       $Cache->decrement('num_torrent_reportsv2');
309 309
 ?>
310
-  <div id="report<?=$ReportID?>" class="report box pad center">
310
+  <div id="report<?=$ReportID?>" class="report box pad center" data-load-report="<?=$ReportID?>">
311 311
     <a href="reportsv2.php?view=report&amp;id=<?=$ReportID?>">Report <?=$ReportID?></a> for torrent <?=$TorrentID?> (deleted) has been automatically resolved. <input type="button" value="Hide" onclick="ClearReport(<?=$ReportID?>);" />
312 312
   </div>
313 313
 <?
@@ -349,7 +349,7 @@ if (count($Reports) === 0) {
349 349
         $BBName = "[url=artist.php?id=$ArtistID]".$ArtistName."[/url] - [url=torrents.php?id=$GroupID]$GroupName".($Year ? " ($Year)" : '')."[/url] [url=torrents.php?torrentid=$TorrentID][$Media][/url] ".' ('.number_format($Size / (1024 * 1024), 2).' MB)';
350 350
 //      }
351 351
 ?>
352
-  <div id="report<?=$ReportID?>">
352
+  <div id="report<?=$ReportID?>" data-load-report="<?=$ReportID?>">
353 353
     <form class="manage_form" name="report" id="reportform_<?=$ReportID?>" action="reports.php" method="post">
354 354
 <?
355 355
 /*
@@ -726,10 +726,6 @@ if (count($Reports) === 0) {
726 726
       </div>
727 727
     </form>
728 728
   </div>
729
-  <script type="text/javascript">//<![CDATA[
730
-    Load(<?=$ReportID?>);
731
-  //]]>
732
-  </script>
733 729
 <?
734 730
     }
735 731
   }

+ 4
- 0
static/functions/reportsv2.js View File

@@ -220,3 +220,7 @@ function Switch(reportid, torrentid, otherid) {
220 220
     }
221 221
   );
222 222
 }
223
+
224
+document.querySelectorAll('[data-load-report]').forEach(function(el) {
225
+  Load(+el.attributes['data-load-report'].value);
226
+})

Loading…
Cancel
Save