JavaScript utility functions for Sitemagic CMS
This pages covers a couple of useful utility (helper) functions available for Sitemagic CMS.
Creating unique IDs
Using the
SMRandom class it is possible to create an 32 bit ID with the format of a GUID.
// Returns something like: b77b9c943c9b31486feb474ee6830953
var guid = SMRandom.CreateGuid();
String replace all
Replacing all occurences of a word within a string requires use of a regular expression or repeating the operation. Sitemagic CMS exposes a ReplaceAll function through the
SMStringUtilities class.
// Test string
var str = "Sitemagic CMS is a great platform for building great web applications";
// Replace all occurences of the word "great" with the word "phenomenal"
var newStr = SMStringUtilities.ReplaceAll(str, "great", "phenomenal");