mirror of
https://github.com/git/git.git
synced 2025-03-30 19:10:25 +00:00
gitweb.js: fix padLeftStr() and its usage
It seems that in Firefox-3.5 inserting with javascript inserts the literal instead of a space. Fix this by inserting the unicode representation for instead. Also fix the off-by-one error in the padding calculation that was causing one less space to be inserted than was requested by the caller. Signed-off-by: Stephen Boyd <bebarino@gmail.com> Cc: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
6aa2de5151
commit
6821dee9a9
@ -64,19 +64,19 @@ function fixLinks() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* pad number N with nonbreakable spaces on the left, to WIDTH characters
|
* pad number N with nonbreakable spaces on the left, to WIDTH characters
|
||||||
* example: padLeftStr(12, 3, ' ') == ' 12'
|
* example: padLeftStr(12, 3, '\u00A0') == '\u00A012'
|
||||||
* (' ' is nonbreakable space)
|
* ('\u00A0' is nonbreakable space)
|
||||||
*
|
*
|
||||||
* @param {Number|String} input: number to pad
|
* @param {Number|String} input: number to pad
|
||||||
* @param {Number} width: visible width of output
|
* @param {Number} width: visible width of output
|
||||||
* @param {String} str: string to prefix to string, e.g. ' '
|
* @param {String} str: string to prefix to string, e.g. '\u00A0'
|
||||||
* @returns {String} INPUT prefixed with (WIDTH - INPUT.length) x STR
|
* @returns {String} INPUT prefixed with (WIDTH - INPUT.length) x STR
|
||||||
*/
|
*/
|
||||||
function padLeftStr(input, width, str) {
|
function padLeftStr(input, width, str) {
|
||||||
var prefix = '';
|
var prefix = '';
|
||||||
|
|
||||||
width -= input.toString().length;
|
width -= input.toString().length;
|
||||||
while (width > 1) {
|
while (width > 0) {
|
||||||
prefix += str;
|
prefix += str;
|
||||||
width--;
|
width--;
|
||||||
}
|
}
|
||||||
@ -192,7 +192,7 @@ function updateProgressInfo() {
|
|||||||
|
|
||||||
if (div_progress_info) {
|
if (div_progress_info) {
|
||||||
div_progress_info.firstChild.data = blamedLines + ' / ' + totalLines +
|
div_progress_info.firstChild.data = blamedLines + ' / ' + totalLines +
|
||||||
' (' + padLeftStr(percentage, 3, ' ') + '%)';
|
' (' + padLeftStr(percentage, 3, '\u00A0') + '%)';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (div_progress_bar) {
|
if (div_progress_bar) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user