Namespace.register("U.NS");
U.NS.UW = window.external;

window.onload = function () { U.M.stopRefresh(); U.M.OLM(); }

//存储ID
SetID = function (UDID) {
    //  try { alert(UDID); U.DW.local().set("UserDirectoryID", UDID); } catch (e) { }
}

//获取ID
GetID = function () {
    return "";
    //  try { return U.DW.local().get("UserDirectoryID") || ""; } catch (e) { return ""; }
}

//消息交互
Init = function (UJE) {
    try {
        var i, a, e = eval("(" + UJE + ")"), s = $$("frag"), b = $("#UNS_XO"), _l = b.Child().length; var c = [[]]; $("#UNS_XOS").remove();
        for (var i = 0; i < e.length; i++) { //只显示 最后一个消息
            switch (e[i].UsType) {
                case "UD_DiskCon": //文件添加消息
                    var g = e[i].UsSYScontent; e[i].UsParamet = [g[g.length - 1].UserFilesID, g[g.length - 1].UserDirectoryID, g[g.length - 1].UserId];
                    e[i].UsSYSUN = "发现新文件"; e[i].UsSYScontent = "<span>" + e[i].UsName + " </span>向你提交了" + g.length + "个文件"; c[0].push(e[i]);
                    break;
                case "TZ": //通知消息
                    e[i].UsSYSUN = "系统通知";
                    c[0].push(e[i]);
                    break;
                case "UPBR": //评论消息
                    if (!e[i].UsParamet) { c = e[i].UsSYScontent; e[i].UsParamet = [c.NewsType == 2, c.ArticleID]; e[i].UsSYScontent = e[i].ReplyContent; }
                    e[i].UsSYSUN = "评论提醒"; e[i].UsSYScontent = "<span>" + e[i].UsName + " </span>给您发了一条评论<div class='UNS_XOAZX UTDF'>" + ($$("div", { "innerHTML": e[i].UsSYScontent }).innerText) + "</div>"; c[0].push(e[i]);
                    break;
                default: //即时获取消息
                    e[i] = e[i][0];
                    e[i].UsSYSUN = "系统通知";
                    e[i].UsSYScontent = e[i].ArticleContentBrief;
                    e[i].UsImag = U.M.GetImgU(e[i].UserThumbnailImageHead);
                    e[i].UsName = e[i].UserNickName; e[i].UsType = "TZ";
                    e[i].UsParamet = [true, e[i].ArticleID];
                    SetID(e[i].ArticleID); U.NS.UW.SetId(e[i].ArticleID); //保存ID
                    c[0].push(e[i]);
                    break;
            }
            U.NS.Create(e[i], s);
        }
        if (_l + e.length > 50) { for (i = 0; i < _l + e.length - 50; i++) { $(a[_l + i]).remove(); } } b.append(s, 0, b[0].firstChild); return true;
    } catch (e) { return false; }
}

//创建和打印消息
U.NS.Create = function (UDE, UDOD) {
    var _UDTD, _UDSD, _UDKD, _UDND;
    _UDTD = $$("div", { "className": "UNS_XOA", "title": "点击查看", "onclick": [[U.NS.Click, ([UDE, "this"])]] }, UDOD);
    _UDSD = $$("div", { "className": "UNS_XOAL" }, _UDTD);
    _UDKD = $$("div", { "className": "UNS_XOALS UTDF" }, _UDSD);
    _UDND = $$("div", { "className": "UNS_XOALSL" }, _UDKD);
    $$("img", { "onerror": U.M.ImgError, "src": U.M.GetImgU(UDE["UsImag"]) }, _UDND);
    $$("div", { "className": "UNS_XOALSR UTDF", "innerHTML": UDE["UsName"] }, _UDKD);
    _UDSD = $$("div", { "className": "UNS_XOAZ UTDF" }, _UDTD);
    $$("div", { "className": "UNS_XOAZS UTDF", "innerHTML": UDE["UsSYScontent"] }, _UDSD);
    $$("div", { "className": "UNS_XOAR UNS_I", "title": "忽略", "onclick": [[U.M.StopBubble], [U.NS.Remove, ([_UDTD])]] }, _UDTD);
}

//创建
U.NS.Null = function () {
    $$("div", { "id": "UNS_XOS" }, $("#UNS_XO")[0]);
}

//移除
U.NS.Remove = function (UDOD) {
    var _UL = $(UDOD).parentg().Child().length; $(UDOD).remove();
    if (!(_UL - 1)) { U.NS.Close(); U.NS.Null(); }
}

//查看历史记录
U.NS.LSJL = function () {

}

//点击查看1473
U.NS.Click = function (UDE, UDOD) {
    U.NS.Remove(UDOD);
    U.NS.UW.Look(UDE.UsType, U.MS.SerializeJsonToStr(UDE.UsParamet || ""));
}

//关闭
U.NS.Close = function () {
    U.NS.UW.remove();
}

//拖动函数
U.NS.Drag = function () {
    U.NS.UW.Drag();
}