Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/common/functions_utility.js
Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | function sortNameIgnoreCase(x, y) | ||||
else if (lowerX > lowerY) | else if (lowerX > lowerY) | ||||
return 1; | return 1; | ||||
else | else | ||||
return 0; | return 0; | ||||
} | } | ||||
/** | /** | ||||
* Escape tag start and escape characters, so users cannot use special formatting. | * Escape tag start and escape characters, so users cannot use special formatting. | ||||
* Also limit string length to 256 characters (not counting escape characters). | |||||
*/ | */ | ||||
function escapeText(text, limitLength = true) | function escapeText(text) | ||||
{ | { | ||||
if (!text) | |||||
return text; | |||||
if (limitLength) | |||||
text = text.substr(0, 255); | |||||
return text.replace(/\\/g, "\\\\").replace(/\[/g, "\\["); | return text.replace(/\\/g, "\\\\").replace(/\[/g, "\\["); | ||||
} | } | ||||
function unescapeText(text) | function unescapeText(text) | ||||
{ | { | ||||
if (!text) | |||||
return text; | |||||
return text.replace(/\\\\/g, "\\").replace(/\\\[/g, "\["); | return text.replace(/\\\\/g, "\\").replace(/\\\[/g, "\["); | ||||
} | } | ||||
/** | /** | ||||
* Merge players by team to remove duplicate Team entries, thus reducing the packet size of the lobby report. | * Merge players by team to remove duplicate Team entries, thus reducing the packet size of the lobby report. | ||||
*/ | */ | ||||
function playerDataToStringifiedTeamList(playerData) | function playerDataToStringifiedTeamList(playerData) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 166 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator