Opened 7 years ago

Closed 2 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:
Has a Patch: no 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 5 years ago.
sorted.jpg (20.8 KB) - added by dsjonny 5 years ago.

Download all attachments as: .zip

Change History (11)

comment:1 Changed 7 years ago by nielx

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 Changed 7 years ago by humdinger

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 Changed 5 years ago by luroh

Type: bugenhancement

comment:4 Changed 5 years ago by dsjonny

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 5 years ago by dsjonny (next)

Changed 5 years ago by dsjonny

Attachment: unsorted.jpg added

Changed 5 years ago by dsjonny

Attachment: sorted.jpg added

comment:5 Changed 5 years ago by humdinger

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 Changed 2 years ago by humdinger

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 Changed 2 years ago by waddlesplash

Component: DocumentationWebsite/Userguide Translator

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

comment:9 Changed 2 years ago by waddlesplash

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