flymis/WebRoot/dojojs/src/string/extras.js
(开头部分) 7KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
/*
Copyright (c) 2004-2006, The Dojo Foundation
All Rights Reserved.
Licensed under the Academic Free License version 2.1 or above OR the
modified BSD license. For more information on Dojo licensing, see:
http://dojotoolkit.org/community/licensing.shtml
*/
dojo.provide("dojo.string.extras");
dojo.require("dojo.string.common");
dojo.require("dojo.lang.common");
dojo.require("dojo.lang.array");
//TODO: should we use ${} substitution syntax instead, like widgets do?
dojo.string.substituteParams = function(/*string*/template, /* object - optional or ... */hash){
// summary:
// Performs parameterized substitutions on a string. Throws an exception if any parameter is unmatched.
//
// description:
// For example,
// dojo.string.substituteParams("File '%{0}' is not found in directory '%{1}'.","foo.html","/temp");
// returns
// "File 'foo.html' is not found in directory '/temp'."
//
// template: the original string template with %{values} to be replaced
// hash: name/value pairs (type object) to provide substitutions. Alternatively, substitutions may be
// included as arguments 1..n to this function, corresponding to template parameters 0..n-1
var map = (typeof hash == 'object') ? hash : dojo.lang.toArray(arguments, 1);
return template.replace(/\%\{(\w+)\}/g, function(match, key){
if(typeof(map[key]) != "undefined" && map[key] != null){
return map[key];
}
dojo.raise("Substitution not found: " + key);
}); // string
};
dojo.string.capitalize = function(/*string*/str){
// summary:
// Uppercases the first letter of each word
if(!dojo.lang.isString(str)){ return ""; }
if(arguments.length == 0){ str = this; }
var words = str.split(' ');
for(var i=0; i<words.length; i++){
words[i] = words[i].charAt(0).toUpperCase() + words[i].substring(1);
}
return words.join(" "); // string
}
dojo.string.isBlank = function(/*string*/str){
// summary:
// Return true if the entire string is whitespace characters
if(!dojo.lang.isString(str)){ return true; }
后面还有 201 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。