2016-08-11 22:05:23 +08:00
|
|
|
/*
|
|
|
|
* Truncate long strings where is necessary.
|
|
|
|
*/
|
2016-07-22 19:29:01 +08:00
|
|
|
function truncateLongString( el, chars ) {
|
|
|
|
var input = $.trim(el.text());
|
|
|
|
|
|
|
|
if( input.length >= chars){
|
|
|
|
var newText = el.text().slice(0, chars);
|
|
|
|
for( var i = newText.length; i > 0; i--){
|
|
|
|
if(newText[i] === ' '){
|
|
|
|
newText = newText.slice(0, i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
el.text(newText + '...');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-11 22:05:23 +08:00
|
|
|
/*
|
|
|
|
* Usefull for converting locals messages to error format
|
|
|
|
* (i.e. lower cased capital and no dot at the end).
|
|
|
|
*/
|
2016-08-05 23:00:29 +08:00
|
|
|
String.prototype.strToErrorFormat = function() {
|
2016-07-22 19:29:01 +08:00
|
|
|
var length = this.length;
|
|
|
|
if (this[length - 1] === ".") {
|
|
|
|
length -= 1;
|
|
|
|
}
|
|
|
|
return this.charAt(0).toLowerCase() + this.slice(1, length);
|
2016-08-05 23:00:29 +08:00
|
|
|
}
|