javascript: what does this syntax means?
Posted
by
user1067138
on Stack Overflow
See other posts from Stack Overflow
or by user1067138
Published on 2011-11-26T17:44:44Z
Indexed on
2011/11/26
17:50 UTC
Read the original article
Hit count: 368
JavaScript
|function
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?
© Stack Overflow or respective owner