FANDOM


This function trucates a text string using either end or center ellipsis (...) to a specified maximum length. If the string is shorter than the maximum length the string will be returned unaltered.


function truncate(str, len, mode) {
	if (str.length < len) {
		return str;
	} else {
		if (mode == 'center') {
			return str.substr(0, Math.floor(len / 2) - 2)
			+ '...' + str.substr(str.length - Math.ceil(len / 2) + 1);
		} else if (mode == 'end') {
			return str.substr(0, len - 3) + '...';
		} else {
			return str;
		}
	}
}

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.