سلام خدمت دوستان.
من تخصصم جاوا اسکریپت نیست ولی توی یه پروژه به کد زیر برخورد کردم که اصلا منظورشو نمیفهمم چه کاری رو میخواد انجام میده.
از دوستانی که با این ساختار کد آشنایی دارن خواهش میکنم منو راهنمایی کنن.
البته نیازی به ریز جزئیات و کاری که انجام میده نیست. من فقط میخوام مفهوم ساختاری که داره تعریف میشه رو بفهمم. مثلا اون function اول کاری چی هست؟ متغییر a چیه و کجا قراره استفاده بشه؟ prototype چیه و اون function هایی که تعریف میشه چطوری استفاده میشه؟ اون call آخر کارش چیه؟
((function (){
var a;
a = function ()
{
function a()
{
this.options_index = 0,
this.parsed = []
}
return a.prototype.add_node = function (a)
{
return a.nodeName === "OPTGROUP" ? this.add_group(a) : this.add_option(a)
}
, a.prototype.add_group = function (a)
{
var b, c, d, e, f, g;
b = this.parsed.length,
this.parsed.push(
{
array_index: b,
group: !0,
label: a.label,
children: 0,
disabled: a.disabled
}),
f = a.childNodes,
g = [];
for (d = 0, e = f.length; d < e; d++) c = f[d], g.push(this.add_option(c, b, a.disabled));
return g
}
,a.prototype.add_option = function (a, b, c)
{
if (a.nodeName === "OPTION") return a.text !== "" ? (b != null && (this.parsed[b].children += 1), this.parsed.push({
array_index: this.parsed.length,
options_index: this.options_index,
value: a.value,
text: a.text,
html: a.innerHTML,
selected: a.selected,
disabled: c === !0 ? c : a.disabled,
group_array_index: b,
classes: a.className,
style: a.style.cssText
})) : this.parsed.push({
array_index: this.parsed.length,
options_index: this.options_index,
empty: !0
}), this.options_index += 1
}, a
}()
, a.select_to_array = function (b)
{
var c, d, e, f, g;
d = new a, g = b.childNodes;
for (e = 0, f = g.length; e < f; e++) c = g[e], d.add_node(c);
return d.parsed
},
this.SelectParser = a
})).call(this)