mozilla/dxr — pull request #319 by vedadux (2014-08-22 17:37:41+00:00)
Title: Redoing code-highlighter.js and dxr.css for better file display 

Fixes bugs: 1006108 and 1055142
Here is how things used to work:
The file would be displayed as a table with two overlaying columns. Clicking the line number would change that line numbers background color, making it seem as if the user highlighted the code.
That lead following problems:
- long lines would be only partially highlighted
- line numbers with more than 3 digits aren't displayed properly
I fixed the above problems by standardisning the columns in a similar fashion like search results and tweaking the js to highlight both line number and code.
The auto scrolling didn't work properly because of bad handling of strings and integers. I cleared that up and changed the way the url's are changed and processed.
-----Changes to code-highlighter.js-----
Added function sortRangeAsc which sorts selection ranges both as strings or arrays.
In function generateSelectedArrays:
Changed the way multiSelected and singleSelected get their value (employed jQuery).
Made the function return sortedsingleLinesArray and rangesArray.
In function setWindowHash:
Removed variables singles and ranges, which are no longer used for the display of the hash.
Added a loop that eliminates singleLines which are already a part of a range.
Added a loop that adds lines and ranges to the hash in order
- example now: #12-15,17,20-25,30-33,42
- example before: #17,42,12-15,20-25,30-33
In function getSortedHashLines:
Seperated reCleanup. Added cleaning of whitespace upfront.
Changed the way ranges are sorted form string sorting to newly added function sortRangeAsc.
Changed the way a range is added to rangesArray in order to account for backward ranges (150-120 and such).
Made firstRange take an array as value instead of a string so that it's value can be compared and scrolling made possible.
Modified the way highlights is cleaned form trash.
If something slips through the process above added testing for NaN in highlights.
Repaired the if block that determines the position to be scrolled to.
Made the function return singleLinesArray and rangesArray for later convenience.
Big changes to the .line-number onClick events:
Moved the value assignment for variables to take place before the if block to avoid repetition.
lastSelected is now lastSelectedLine and includes both a .line-number and code element.
selected is replaced by selectedLineNums and selectedLineCode.