diff -r 5e8fd89c02ea -r a38876c0793c includes/clientside/static/paginate.js --- a/includes/clientside/static/paginate.js Sun Jun 22 18:13:59 2008 -0400 +++ b/includes/clientside/static/paginate.js Tue Jun 24 23:37:23 2008 -0400 @@ -11,7 +11,7 @@ var pagin_objects = new Object(); -function paginator(data, callback, offset, perpage, passer) +window.paginator = function(data, callback, offset, perpage, passer) { if ( !perpage || typeof(perpage) != 'number' || ( typeof(perpage) == 'number' && perpage < 1 ) ) { @@ -65,7 +65,7 @@ * @access private */ -function _build_paginator(this_page) +window._build_paginator = function(this_page) { var div_styling = ( IE ) ? 'width: 1px; margin: 10px auto 10px 0;' : 'display: table; margin: 10px 0 0 auto;'; var begin = '
' + $lang.get('paginate_lbl_page') + ' | '; @@ -195,7 +195,7 @@ var __paginateLock = false; -function jspaginator_goto(pagin_id, jump_to) +window.jspaginator_goto = function(pagin_id, jump_to) { if ( __paginateLock ) return false; @@ -267,7 +267,7 @@ } } -function paginator_goto(parentobj, this_page, num_pages, perpage, url_string) +window.paginator_goto = function(parentobj, this_page, num_pages, perpage, url_string) { var height = $dynano(parentobj).Height(); var width = $dynano(parentobj).Width(); @@ -312,7 +312,7 @@ div.style.left = left_pos + 'px'; } -function paginator_submit(obj, max, perpage, formatstring) +window.paginator_submit = function(obj, max, perpage, formatstring) { var userinput = obj.previousSibling.previousSibling.value; userinput = parseInt(userinput); @@ -335,3 +335,57 @@ } } +// This code is in the public domain. Feel free to link back to http://jan.moesen.nu/ +function sprintf() +{ + if (!arguments || arguments.length < 1 || !RegExp) + { + return; + } + var str = arguments[0]; + var re = /([^%]*)%('.|0|\x20)?(-)?(\d+)?(\.\d+)?(%|b|c|d|u|f|o|s|x|X)(.*)/; + var a = b = [], numSubstitutions = 0, numMatches = 0; + while (a = re.exec(str)) + { + var leftpart = a[1], pPad = a[2], pJustify = a[3], pMinLength = a[4]; + var pPrecision = a[5], pType = a[6], rightPart = a[7]; + + //alert(a + '\n' + [a[0], leftpart, pPad, pJustify, pMinLength, pPrecision); + + numMatches++; + if (pType == '%') + { + subst = '%'; + } + else + { + numSubstitutions++; + if (numSubstitutions >= arguments.length) + { + alert('Error! Not enough function arguments (' + (arguments.length - 1) + ', excluding the string)\nfor the number of substitution parameters in string (' + numSubstitutions + ' so far).'); + } + var param = arguments[numSubstitutions]; + var pad = ''; + if (pPad && pPad.substr(0,1) == "'") pad = leftpart.substr(1,1); + else if (pPad) pad = pPad; + var justifyRight = true; + if (pJustify && pJustify === "-") justifyRight = false; + var minLength = -1; + if (pMinLength) minLength = parseInt(pMinLength); + var precision = -1; + if (pPrecision && pType == 'f') precision = parseInt(pPrecision.substring(1)); + var subst = param; + if (pType == 'b') subst = parseInt(param).toString(2); + else if (pType == 'c') subst = String.fromCharCode(parseInt(param)); + else if (pType == 'd') subst = parseInt(param) ? parseInt(param) : 0; + else if (pType == 'u') subst = Math.abs(param); + else if (pType == 'f') subst = (precision > -1) ? Math.round(parseFloat(param) * Math.pow(10, precision)) / Math.pow(10, precision): parseFloat(param); + else if (pType == 'o') subst = parseInt(param).toString(8); + else if (pType == 's') subst = param; + else if (pType == 'x') subst = ('' + parseInt(param).toString(16)).toLowerCase(); + else if (pType == 'X') subst = ('' + parseInt(param).toString(16)).toUpperCase(); + } + str = leftpart + subst + rightPart; + } + return str; +}
---|