Opened 12 years ago

Closed 7 years ago

#9418 closed enhancement (fixed)

In user guide the list of languages should be sorted alphabetically

Reported by: mks Owned by: waddlesplash
Priority: normal Milestone:
Component: Website/Userguide Translator Version:
Keywords: Cc:
Blocked By: Blocking:
Platform: All

Description

The language drop down list in the top left of the online user guide seems to have no particular order. With any such list getting longer it gets harder to find a particular entry. Alphabetically sorted lists are much easier to skim.

Attachments (2)

unsorted.jpg (20.3 KB ) - added by dsjonny 10 years ago.
sorted.jpg (20.8 KB ) - added by dsjonny 10 years ago.

Download all attachments as: .zip

Change History (11)

comment:1 by nielx, 12 years ago

Owner: changed from nielx to humdinger
Status: newassigned

I would suspect that these are already sorted, but only in the English language. Humdinger, do you know?

comment:2 by humdinger, 12 years ago

Owner: changed from humdinger to nobody

No idea... In any case the sorting should be somewhere deep in the bowels of the online tool code. Out of my hands...

comment:3 by luroh, 10 years ago

Type: bugenhancement

comment:4 by dsjonny, 10 years ago

This code can help (added to the header and start it after the page loaded):

	<script type="text/javascript">
	<!--
		function sortItems() {
			arrOptions = [];

			items = document.getElementsByTagName("ul")[0].getElementsByTagName("a");
			for (i = 0; i < items.length; i++) {
				arrOptions[i] = [];
				arrOptions[i][0] = items[i].lastChild.nodeValue;
				arrOptions[i][1] = items[i].outerHTML;
			}

			arrOptions.sort(function(a, b) {return (a[0] < b[0]) ? -1 : ((b[0] < a[0]) ? 1 : 0);});

			for (i = -1; i < items.length; i++) {
				if (arrOptions[i]) items[i].outerHTML = arrOptions[i][1];
			}
		}
	//-->
	</script>

I have tried it and it sorted the language menu fine.

Before: No image "unsorted.png" attached to Ticket #9418 After: No image "sorted.png" attached to Ticket #9418

Version 0, edited 10 years ago by dsjonny (next)

by dsjonny, 10 years ago

Attachment: unsorted.jpg added

by dsjonny, 10 years ago

Attachment: sorted.jpg added

comment:5 by humdinger, 10 years ago

I have never done any javascript, but have tried the above and couldn't get it to work...
I've put this into the <head> of a userguide page:

<script src="../sort.js" type="text/javascript"></script>

and put the follwing in a file "sort.js" that's located one level above the user guide page, so it should be found:

function sortItems() {
	arrOptions = [];

	items = document.getElementsByTagName("ul")[0].getElementsByTagName("a");
	for (i = 0; i < items.length; i++) {
		arrOptions[i] = [];
		arrOptions[i][0] = items[i].lastChild.nodeValue;
		arrOptions[i][1] = items[i].outerHTML;
	}

	arrOptions.sort(function(a, b) {return (a[0] < b[0]) ? -1 : ((b[0] < a[0]) ? 1 : 0);});

	for (i = -1; i < items.length; i++) {
		if (arrOptions[i]) items[i].outerHTML = arrOptions[i][1];
	}
}

Doesn't work. What am I doing wrong?

comment:6 by humdinger, 8 years ago

Owner: changed from nobody to waddlesplash

@waddlesplash, as you are the reluctant keeper of the onlne tool... :)
This could be done statically when exporting instead of dynamically on every page. You see where to twiddle the code?

comment:8 by waddlesplash, 8 years ago

Component: DocumentationWebsite/Userguide Translator

Sounds about right. I'll have a look later.

comment:9 by waddlesplash, 7 years ago

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.