Feature Select all from this group [DENIED]

old granted and denied feature requests

Moderator: AniDB

cgfluffy
Posts: 3
Joined: Wed Feb 09, 2005 6:28 pm
Location: Denmark

Feature Select all from this group [DENIED]

Post by cgfluffy »

Hi

Under show anime when have exspanded all entrys, I would like a feature(button?) that could selecting all entrys from a specific group.

Cgfluffy
Jacob
PetriW
AniDB Staff
Posts: 1522
Joined: Sat May 24, 2003 2:34 pm

Post by PetriW »

This feature request has been denied MANY times in the past, I suggest using the forum search function for further details.
Lupin III.
Posts: 10
Joined: Fri Dec 31, 2004 1:39 am

Post by Lupin III. »

May I ask why has it been denied so many times? It would be _really_ useful!

It's just a few simple lines of JS together with small changes in the listing-output.

I'm currently trying to implement it for the Firefox-Greasemonkey-Extension. It already seems to work, but it's also a dirty hack that is only working in Firefox. I have to parse the HTML-source to get the group-IDs and find corresponding the checkboxes. But the actual JS-code doing the work is just 5 lines! Selecting 30 files with a single click is convenient!
Der Idiot
AniDB Staff
Posts: 1227
Joined: Fri Mar 21, 2003 10:19 am

Post by Der Idiot »

because you are suposed to check if a) you really have that file and b) your file really crc correct is.

just hash your files with aom. fastest way to add things anyway
Lupin III.
Posts: 10
Joined: Fri Dec 31, 2004 1:39 am

Post by Lupin III. »

That is no reason to not implement such a feature. I have to check them anyway. And people, who don't, won't do it, just because they have to click every file separatly.

There could be some help in finding these files. Selecting one file of a group out of 20 for an episode and this 20, 30 or even more times depending on the length of a series is tedious (also due to that fact that the files are not sorted by group and the column, which the group is in, is also far from the checkbox/link you have to click). If all the corresponding checkboxes would be selected by the click of only one checkbox, it would help alot.

Btw, there are other ways, too: instead of selecting all the checkboxes you could for example mark the lines with another color via css and js.

It's all just to further improve the useability of the pages for everyone (for my part, I have already done it with the extension mentioned earlier, that's quite buggy, but working, and does exactly the thing described above)
DonGato
Posts: 1296
Joined: Sun Nov 17, 2002 9:08 pm
Location: The Pampas, The land of the Gaucho!
Contact:

Post by DonGato »

You might want to share it then. :P
Lupin III.
Posts: 10
Joined: Fri Dec 31, 2004 1:39 am

Post by Lupin III. »

Yes, I will of course. After I have build in some more checks. It's still spitting out some warning and error messages in some circumstances.
Der Idiot
AniDB Staff
Posts: 1227
Joined: Fri Mar 21, 2003 10:19 am

Post by Der Idiot »

like said manually massadding files via the webinterface is deeply silly anyway. aom/webaom are meant for such cases
DonGato
Posts: 1296
Joined: Sun Nov 17, 2002 9:08 pm
Location: The Pampas, The land of the Gaucho!
Contact:

Post by DonGato »

Well, I'm silly and you're Idiot. :D

EDIT: webaom is really nice. :)
Lupin III.
Posts: 10
Joined: Fri Dec 31, 2004 1:39 am

Post by Lupin III. »

But it is a frequent request, so it seems to be wanted.

So for everyone using Firefox, try this:
first install the greasemonkey extension http://greasemonkey.mozdev.org/

Then copy this code into a file called something.user.js (the .user.js is important!)

Code: Select all

// ==UserScript==
// @name           select_all_of_a_group
// @namespace      lupin_sanseis_scripts
// @description    selects all files of a release group
// @include        http://anidb.info/*
// ==/UserScript==

(function() {

	// 2D-array containing all the checkbox names corresponding to a group
	checkbox_names = new Array();

	function initialize() {

		var gids = new Array();
		// walk through all tbodies (they are created by the browser DOM internally, they don't have to be in source)
		for (var i=0; i < document.getElementsByTagName("tbody").length; i++) {
			var tbody = document.getElementsByTagName("tbody")[i];

			// the group-listing-table contains no inner table, so it's the wrong tbody if a table is found inside
			match = tbody.innerHTML.match(/table/i);
			if (match) { continue; }

			// search for "Group Info"
			match = tbody.innerHTML.match(/Group&nbsp;Info:/i);
			if (match) {
				// found the right table
				var regexp = /gid=(\d+)"/;
				var tr = tbody.firstChild;

				// walk through all rows of the table
				while (tr.nextSibling) {
					if (tr.nodeType == 1
					 && tr.nodeName == 'TR')
					{
						// create an adittional column to add to the end of the row
						var td = document.createElement("td");
						if (match = regexp.exec(tr.innerHTML)) {
							// found a group-id, so create the subarray for the checkboxnames and the checkbox
							var gid = match[1];
							gids.push(gid);
							checkbox_names[gid] = new Array();
							var input = document.createElement('input');
							input.setAttribute('type', 'checkbox');
							input.setAttribute('id', 'toggle_gid_'+gid);
							input.setAttribute('onclick', 'toggle('+gid+')');
							td.appendChild(input);
						} else
						if (tr.innerHTML.match(/Group&nbsp;Info:/i)) {
							td.setAttribute('bgcolor', '#b0b0b0');
							td.appendChild(document.createTextNode('toggle all'));
						}
						tr.appendChild(td);
					}
					tr = tr.nextSibling;
				}
			}
		}

		// if checkbox_names still contains no elements, it's no animelisting --> exit function
		if (checkbox_names.length == 0) { return; }

		// walk through all checkboxes in the page
		for (var i=0; i < document.getElementsByTagName("input").length; i++) {
			var input = document.getElementsByTagName("input")[i];
			if (input.type == 'checkbox'
			 && input.name.search(/^madd\.f\.\d+$/) != -1) {
				var regexp = /gid=(\d+)/;

				// if the checkboxname is like madd.f.xyz, try to find the gid in the same table-row
				// and add the checkboxname to the corresponding array
				var tr = input.parentNode.parentNode;
				if (match = regexp.exec(tr.innerHTML)) {
					var gid = match[1];
					if (checkbox_names[gid]) {
						checkbox_names[gid].push(input.name);
					}
				}
			}
		}

		// add a title attribute to the created checkboxes
		for (var i=0; i < gids.length; i++) {
			document.getElementById('toggle_gid_'+gids[i]).setAttribute('title', 'Toggle all files of this anime-group ('+checkbox_names[gids[i]].length+' files)');
			document.getElementById('toggle_gid_'+gids[i]).parentNode.appendChild(document.createTextNode('('+checkbox_names[gids[i]].length+')'));
		}

		// expand the grouplist too when expanding all file-entries (change href of plus icon)
		for (var i=0; i < document.getElementsByTagName("a").length; i++) {
			var a = document.getElementsByTagName("a")[i];
			if (a.href.match(/expandall/)
			 && a.innerHTML.match(/all entries/)) {
				a.href += '&showallag=1';
				break;
			}
		}

		// finally add the function for the checkbox onclick-handler to the document
		// has to be done this way, because of scoping of function names
		var script = document.createElement('script');
		script.type = 'text/javascript';
		script.appendChild(document.createTextNode("\
		function toggle(_gid) {\
			for (var i=0; i < checkbox_names[_gid].length; i++) {\
				document.getElementsByName(checkbox_names[_gid][i])[0].checked = document.getElementById('toggle_gid_'+_gid).checked;\
			}\
			if (document.getElementById('toggle_gid_'+_gid).checked) {\
				alert('Selected ' + checkbox_names[_gid].length + ' files. Please check for correctness!');\
			} else {\
				alert('Removed all checkmarks for this group!');\
			}\
		}"));

		document.getElementsByTagName("head")[0].appendChild(script);
	}


	window.addEventListener("load", initialize(), false);

})();
Open the file in Firefox and select "Install userscript" from the tools menu.

Now when you view the listing of an anime there should be an extra column with checkboxes in the group listing. Choose "expand all entries" and then click on one of the checkboxes. Voila, all checkboxes of this group should be selected.

Please still check that the files selected are the ones you have/want to add!!

btw.: no garantee of any kind (functioning, damaging, ... you know these)
(tested on Mozilla 1.7.10 with an homebrew cvs-build of greasemonkey)
Last edited by Lupin III. on Fri Aug 05, 2005 6:23 pm, edited 1 time in total.
TechNiko
Posts: 38
Joined: Thu Jun 30, 2005 5:07 am
Location: Quebec, Canada
Contact:

Post by TechNiko »

Works perfectly, thank you! Though it would be much easier if you uploaded the script somewhere. I'll put it on my ISP freespace temporarily.

So Quicklink/quickguide for the lazy:
Just install Greasemonkey, click that link and do Tools->Install User Script
http://www3.sympatico.ca/techniko/anidb.user.js

(updated with expand all/show all addition)

-TechNiko
Last edited by TechNiko on Fri Aug 05, 2005 6:42 pm, edited 2 times in total.
TechNiko
Posts: 38
Joined: Thu Jun 30, 2005 5:07 am
Location: Quebec, Canada
Contact:

Post by TechNiko »

Actually there's a bug. If alot of groups worked on a particular anime and the one you have files from is hidden and you need to click "show all" to display it, there's no way to expant both the groups list and the file entries.
Lupin III.
Posts: 10
Joined: Fri Dec 31, 2004 1:39 am

Post by Lupin III. »

I wouldn't call it a bug, it's something I can't change (or maybe I could with some additional JS). There isn't a link for it, but that doesn't mean it's possible ;-)

Just expand all files with the +-icon and then add "&showallag=1" to the url in the adressbar. Or click "show all" in the groups table and add "&expandall=1".
You now should have both lists fully expanded! :-D

Thanks for hosting the file (even if it's temporarily). I don't have a space to upload to.

[edit]
btw. which browser/greasemonkey-version are you using?
TechNiko
Posts: 38
Joined: Thu Jun 30, 2005 5:07 am
Location: Quebec, Canada
Contact:

Post by TechNiko »

Thanks for the workaround, I didn't think of doing it that way.
FFox 1.0.6 Gmoneky 0.3.5
Lupin III.
Posts: 10
Joined: Fri Dec 31, 2004 1:39 am

Post by Lupin III. »

I have changed the script above so the "expand all" icon also expands the group list.
Locked