javascript: what does this syntax means?
- by user1067138
it is like this:
(function () {
//codes here
})();
here is an example:
(function () {
var D = TED.EditorCore,
E = TED.extend,
A = TED.EditorInstanceManager,
B = TED.augmentObject;
window.TED["SimpleEditor"] = C;
function C(F) {
C.superclass.call(this, F)
}
C.defaultConfig = {
height: "100px",
width: "400px",
//blablabla...
flashNumLimit: 10,
didaDelay: 300,
imageWidthLimit: 570
};
E(C, D, {
getContentLength: function () {
return Math.ceil(this.filteHTML(this.editArea.innerHTML, ["img", "br"]).replace(/<img[^>]*>/gi, "mm").replace(/<br[^>]*>/gi, "m").replace(/ /gi, "m").replace(/[^\x00-\xff]/g, "mm").length / 2)
},
filteEditHTML: function () {
return html = this.editArea.innerHTML.replace(/_moz_dirty=""/gi, "").replace(/\[/g, "[[-").replace(/\]/g, "-]]").replace(new RegExp("<\\/?(?:br[^>]*)>", "gi"), "[$1]").replace(new RegExp('<span([^>]*class="?at"?[^>]*)>', "gi"), "[span$1]").replace(new RegExp('<img([^>]*class="?(?:' + this.config.emptyClassName + "|" + this.config.smileyClassName + ')"?[^>]*)>', "gi"), "[img$1]").replace(/<[^>]*>/g, "").replace(/\[\[\-/g, "[").replace(/\-\]\]/g, "]").replace(new RegExp("\\[(/?(?:br|img|span)[^\\]]*)\\]", "gi"), "<$1>")
},
filteSubmitHTML: function () {
this.reLayout();
var G = this.editArea.innerHTML.replace(/_moz_dirty=""/gi, "").replace(/\[/g, "[[-").replace(/\]/g, "-]]").replace(new RegExp("<(/?(?:" + this.submitValidHTML.join("|") + ")[^>]*)>", "gi"), "[$1]").replace(new RegExp('<img([^>]*class="?(?:' + this.config.imageClassName + "|" + this.config.smileyClassName + "|" + this.config.flashClassName + "|" + this.config.musicClassName + ')"?[^>]*)>', "gi"), "[img$1]").replace(/<[^>]*>/g, "").replace(/\[\[\-/g, "[").replace(/\-\]\]/g, "]").replace(new RegExp("\\[(/?(?:" + this.submitValidHTML.join("|") + "|img)[^\\]]*)\\]", "gi"), "<$1>");
var F = document.createElement("div");
F.innerHTML = G;
this.parseURL(F);
return F.innerHTML
}
});
B(C, A)
})();
what exactly does (funtion (){})(); do?