Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/gui/common/functions_utility.js
Show First 20 Lines • Show All 124 Lines • ▼ Show 20 Lines | function removeDupes(array) | ||||
var i = array.length; | var i = array.length; | ||||
while (i--) | while (i--) | ||||
{ | { | ||||
if (array.indexOf(array[i]) != i) | if (array.indexOf(array[i]) != i) | ||||
array.splice(i, 1); | array.splice(i, 1); | ||||
} | } | ||||
} | } | ||||
// Filter out conflicting characters and limit the length of a given name. | |||||
// @param name Name to be filtered. | |||||
// @param stripUnicode Whether or not to remove unicode characters. | |||||
// @param stripSpaces Whether or not to remove whitespace. | |||||
function sanitizePlayerName(name, stripUnicode, stripSpaces) | |||||
{ | |||||
// We delete the '[', ']' characters (GUI tags) and delete the ',' characters (player name separators) by default. | |||||
var sanitizedName = name.replace(/[\[\],]/g, ""); | |||||
// Optionally strip unicode | |||||
if (stripUnicode) | |||||
sanitizedName = sanitizedName.replace(/[^\x20-\x7f]/g, ""); | |||||
// Optionally strip whitespace | |||||
if (stripSpaces) | |||||
sanitizedName = sanitizedName.replace(/\s/g, ""); | |||||
// Limit the length to 20 characters | |||||
return sanitizedName.substr(0,20); | |||||
} | |||||
function singleplayerName() | function singleplayerName() | ||||
{ | { | ||||
return Engine.ConfigDB_GetValue("user", "playername.singleplayer") || Engine.GetSystemUsername(); | return Engine.ConfigDB_GetValue("user", "playername.singleplayer") || Engine.GetSystemUsername(); | ||||
} | } | ||||
function multiplayerName() | function multiplayerName() | ||||
{ | { | ||||
return Engine.ConfigDB_GetValue("user", "playername.multiplayer") || Engine.GetSystemUsername(); | return Engine.ConfigDB_GetValue("user", "playername.multiplayer") || Engine.GetSystemUsername(); | ||||
▲ Show 20 Lines • Show All 102 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator