Namespace.register("U.Control.td"); //浏览列表命名空间 //14通信G5-2丘润成 15互联网-3叶延裕 /*window.onload = function () { U.Control.td.A(); }*/ U.Control.td.c = [{ "name": "张三", "pid": "0", "id": "1" }, { "name": "李四", "pid": "0", "id": "111" },{ "name": "lalala", "pid": "1", "id": "2" }, { "name": "zzm", "pid": "2", "id": "3"}]; U.Control.td.A = function () { if ($(".left_con")[0]) { $(".left_con")[0].parentNode.removeChild($(".left_con")[0]); } var mlk = $$("div", { "className": "left_con" },$("body")[0]); var ssk = $$("div", { "className": "select" }, mlk); var sskin = $$("input", { "placeholder": "请输入关键字..." }, ssk); var i; for (i in U.Control.td.c) { if (U.Control.td.c[i].pid == 0) { var fml = $$("div", { "id": U.Control.td.c[i].id, "style": { "width": "95%", "margin-left": "3%", "float": "left", "cursor": "pointer", "display": "block"} }, mlk); var fmlsxk = $$("div", { "className": "wenjian" }, fml); var fmlzk = $$("div", { "className": "zk" }, fmlsxk); var fmlwz = $$("div", { "className": "gj" }, fmlsxk); var fmlwzm = $$("div", { "className": "content", "innerHTML": U.Control.td.c[i].name }, fmlsxk); fml.setAttribute("pid", 0); U.Control.td.ZJ(fmlsxk); //用于判断子目录是否隐藏的函数 if (U.Control.td.B(U.Control.td.c[i].id) == 0) { $("#" + U.Control.td.c[i].id)[0].children[0].children[0].style.background = "none"; } //用来检查是否有子级目录并生成div的函数 } } return mlk; } U.Control.td.B = function (pid) { var Wture = 0 var i; for (i in U.Control.td.c) { if (U.Control.td.c[i].pid == pid) { var zml = $$("div", { "id": U.Control.td.c[i].id, "style": { "margin-left": "10px", "float": "left", "display": "none"} }, $("#" + pid)[0]); var zmlsxk = $$("div", { "className": "wenjian" }, zml); var zmlzk = $$("div", { "className": "zk" }, zmlsxk); var zmlwz = $$("div", { "className": "gj" }, zmlsxk); var zmlwzm = $$("div", { "className": "content", "innerHTML": U.Control.td.c[i].name }, zmlsxk); zml.setAttribute("pid", pid); U.Control.td.ZJ(zmlsxk); //用于判断子目录是否隐藏的函数 if (U.Control.td.B(U.Control.td.c[i].id) == 0) { $("#" + U.Control.td.c[i].id)[0].children[0].children[0].style.background = "none"; } //用来检查是否有子级目录并生成div的函数//用来检查是否有子级目录并生成div的函数 Wture = 1; } } if (Wture == 0) { return 0; } } U.Control.td.ZJ = function (ml) { ml.onclick = function () { var zml = ml.nextSibling; if (zml && zml.style.display == "block") { zml.style.display = "none"; ml.children[0].style.background = "url(http://d.1473.cn/controls/pc/Tree_directory/img/jmz.png)"; ml.children[0].style.backgroundSize = "100% 100%"; ml.children[1].style.background = "url(http://d.1473.cn/controls/pc/Tree_directory/img/gj.png)" ml.children[1].style.backgroundSize = "100% 100%"; return; } else if (zml && zml.style.display == "none") { zml.style.display = "block"; ml.children[0].style.background = "url(http://d.1473.cn/controls/pc/Tree_directory/img/jzk.png)"; ml.children[0].style.backgroundSize = "100% 100%"; ml.children[1].style.background = "url(http://d.1473.cn/controls/pc/Tree_directory/img/kj.png)" ml.children[1].style.backgroundSize = "100% 100%"; return; } else { return; } } } U.Control.td.Add = function (pid, name) { var id = Guid.newGuid(); var addml = $$("div", { "id": id, "style": { "width": "95%", "margin-left": "3%", "float": "left", "cursor": "pointer", "display": "block"} }, $("#" + pid)[0]); var addsxk = $$("div", { "className": "wenjian" }, addml); var addzk = $$("div", { "className": "zk" }, addsxk); var addwz = $$("div", { "className": "gj" }, addsxk); var addwzm = $$("div", { "className": "content", "innerHTML": name }, addsxk); addml.setAttribute("pid", pid); var addmldx = { "name": name, "pid": pid, "id": id }; U.Control.td.c.push(addmldx); U.Control.td.A(); } U.Control.td.Del = function (pid) { document.getElementById(pid).parentNode.removeChild(document.getElementById(pid)); }