
function _formatString( strFormat )
{
this.format( strFormat );
};

_formatString.prototype.format = function ( strPattern )
{
this._pattern = strPattern;
this._p = 0;
this._res = "";
};

_formatString.prototype._moveToNext = function ()
{
for ( ; this._p < this._pattern.length; ++this._p )
{
var ch = this._pattern.charAt( this._p );
if ( ch == "%" )
{
++this._p;
if ( this._p < this._pattern.length && this._pattern.charAt( this._p ) == "%" )
{
this._res += "%";
} else
{
break;
}
}
else
this._res += ch;
}
return this;
};

_formatString.prototype.str = function ()
{
this._res += this._pattern.substr( this._p );
return this._res;
};

function fmt( strPattern )
{
return new _formatString( strPattern );
};

_formatString.prototype.a = function ()
{
this._moveToNext();
for (var i = 0; i < arguments.length; i++)
{
this._res += arguments[i];
}
return this;
}

_formatString.prototype.s = function ()
{
return this.str();
}| 只有注冊用戶登錄后才能發表評論。 | ||
|
||
|
相關文章:
|
||
網站導航:
博客園
IT新聞
BlogJava
博問
Chat2DB
管理
|
||
|
|