Skip to content

Commit

Permalink
Story 1959: Improve javascript and isolate to single file.
Browse files Browse the repository at this point in the history
  • Loading branch information
at88mph committed Oct 19, 2016
1 parent 3efd4f7 commit d71dc96
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions cadc-js/src/www/cadcJS/javascript/org.opencadc.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,19 @@
*
* My name is George and I am 39 years old
*
* @param _str The string to check.
* Indexes begin at 1, NOT 0.
*
* @param _str The string to check.
* @param _values {Array} The values to replace.
* @returns {string}
*/
function format(_str)
function format(_str, _values)
{
// Create new string to not modify the original.
var s = _str;
var args = arguments;

return s.replace(/{(\d+)}/g, function (match, number)
return _str.replace(/{(\d+)}/g, function (match, number)
{
return args[number] ? args[number] : match;
var index = (number - 1);
return _values[index] ? _values[index] : match;
});
}

Expand Down

0 comments on commit d71dc96

Please sign in to comment.