Scripts:Animepage:Sourcecode2: Difference between revisions

m
Firefox Script:Sourcecode2 moved to Scripts:Animepage:Sourcecode2
No edit summary
m (Firefox Script:Sourcecode2 moved to Scripts:Animepage:Sourcecode2)
 
(3 intermediate revisions by one other user not shown)
Line 1: Line 1:
<pre>
<pre>
// AniDB-Site-Enhancer-Mass-Select
// AniDB-Site-Enhancements: Mass Select
// - Select all files of a group
// - Select all files of a group
//
//
// Version 20050809.02
// Version 20051210.01
// works with FF1.5 and greasemonkey 0.6.4
// Copyright (c) 2005, Lupin III.
// Copyright (c) 2005, Lupin III.
// Released under the GPL license
// Released under the GPL license
// http://www.gnu.org/copyleft/gpl.html
// http://www.gnu.org/copyleft/gpl.html
//
//
// Thanks to
// TechNiko for the webspace
// visnu for some advice on speedups for long animelists
//
//
// ==UserScript==
// ==UserScript==
// @name          AniDB-Site-Enhancer-Mass-Select
// @name          AniDB-Site-Enhancer: Mass Select
// @namespace  lupin_sanseis_scripts
// @namespace  lupin_sanseis_scripts
// @description  selects all files of a release group
// @description  selects all files of a release group, replaces vote dropdowns with textfields
// @include        http://anidb.info/perl-bin/animedb.pl?show=anime*
// @include        http://anidb.info/perl-bin/animedb.pl?show=anime&*
// ==/UserScript==
// ==/UserScript==


Line 22: Line 26:


   function initialize() {
   function initialize() {
      // use '//' to disable unwanted functions
       group_selects();
       group_selects();
   }
   }


   function group_selects () {
   function group_selects () {
      // look up the grouplist table (using the bold "Group Info:" as an anchor, as it's fast to find)
      var group_table = document.evaluate("//b/text()[starts-with(.,'Group') and contains(., 'Info:')]/../../../..", document, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue;
      if (group_table == null){
        return;
      }
       // search for trs of the group-list-table
       // search for trs of the group-list-table
       var trs = document.evaluate("//tr[not(.//table) and ..//text()[contains(., 'Group')] and ..//text()[contains(., 'Info:')]]", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
       var trs = document.evaluate(".//tr", group_table, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);


       var regexp = /gid=(\d+)"/;
       var regexp = /gid=(\d+)"/;
Line 44: Line 57:
             input.setAttribute('type', 'checkbox');
             input.setAttribute('type', 'checkbox');
             input.setAttribute('id', 'toggle_gid_'+gid);
             input.setAttribute('id', 'toggle_gid_'+gid);
             input.setAttribute('onclick', 'toggle('+gid+')');
             input.setAttribute('value', gid);
            input.addEventListener('click', toggle, false);
             td.appendChild(input);
             td.appendChild(input);
         } else
         } else
Line 87: Line 101:


       // finally add the function for the checkbox onclick-handler to the document
       // finally add the function for the checkbox onclick-handler to the document
       window.toggle =
       function toggle(_gid) {
      function(_gid) {
        var _gid = this.getAttribute('value');
 
         for (var i=0; i < checkbox_names[_gid].length; i++) {
         for (var i=0; i < checkbox_names[_gid].length; i++) {
             document.getElementsByName(checkbox_names[_gid][i])[0].checked = document.getElementById('toggle_gid_'+_gid).checked;
             document.getElementsByName(checkbox_names[_gid][i])[0].checked = document.getElementById('toggle_gid_'+_gid).checked;
Line 102: Line 117:
   window.addEventListener("load", initialize(), false);
   window.addEventListener("load", initialize(), false);


})();</pre>
})(); </pre>
MediaWiki spam blocked by CleanTalk.
MediaWiki spam blocked by CleanTalk.