zoukankan      html  css  js  c++  java
  • JS命名空间实例


    var types = new MeetingList.EventList(msg);

    $(".divclass").html(types.Build(new Date($("#_start").val()), new Date($("#_end").val())));

    /**
    *
    *
    *
    */
    var MeetingList;
    (function (MeetingList) {
    var TimeItem = (function () {
    function TimeItem() {
    }
    return TimeItem;
    })();
    MeetingList.TimeItem = TimeItem;
    var Type = (function () {
    function Type() {
    }
    return Type;
    })();
    MeetingList.Type = Type;
    var TypeEvent = (function () {
    function TypeEvent() {
    }
    return TypeEvent;
    })();
    MeetingList.TypeEvent = TypeEvent;
    var EventList = (function () {
    function EventList(myJson) {
    this.TypeEvent = myJson.TypeEvent;
    this.Type = myJson.Type;
    }
    EventList.prototype.Build = function (date1, date2) {
    //打印列表标题
    var ListTitle = "<div class="tie_more clearfix color_f font12"><ul><li class="www1">日期</li><li class="www2 tc">会议标题</li><li class="www3 tc">会议时间</li><li class="www4 tc">会议室</li><li class="www5 tc">主持人</li><li class="www6 tc">召集部门</li></ul></div>";
    //列表正文
    var ListBody = "<div class="tab_con font12"><table width="100%" border="0"><tbody>";

    //获取2个日期间所有天数
    var dateArr = this.GetAllDays(date1, date2);

    for (var i = 0; i < dateArr.length; i++) {
    var curList = "<tr class="bor_b">";
    ////获取当前日期的数据
    var curDatas = this.GetCurDateDatas(dateArr[i]);
    //第一列
    var weekDay = this.GetWeekDay(dateArr[i]);

    if (curDatas.length == 0) {
    curList += "<td class="color_6 tc wbg1 pb10 pt10" width="79">{0}<br>{1}</td>";
    }
    else {
    curList += "<td class="color_6 tc wbg1 pb10" width="79">{0}<br>{1}</td>";

    }
    curList = curList.replace("{0}", weekDay);

    curList = curList.replace("{1}", this.FormatDate1(dateArr[i]));

    //第二列
    curList += "<td class="pb10">";
    for (var ii = 0; ii < curDatas.length; ii++) {
    var curItemData = curDatas[ii];
    var curBeginTime = new Date(curItemData.BeginTime.toString().replace(/-/g, "/"));
    var curEndTime = new Date(curItemData.EndTime.toString().replace(/-/g, "/"));
    curList += "<div class="f_w clearfix tc"><div class="fl www2 mart1">{0}</div><div class="fl www3 color_6">{1}</div><div class="fl www4 color_6">{2}</div><div class="fl www5">{3}</div><div class="fl www61 color_6">{4}</div></div><div class="clearfix mart15"><h3 class="fl color_lh www4 tc">{5}</h3><div class="fl color_6 www111">{6}</div></div>"

    curList = curList.replace("{0}", curItemData.Name);

    curList = curList.replace("{1}", this.FormatDate2(curBeginTime) + "-" + this.FormatDate2(curEndTime));
    curList = curList.replace("{2}", this.GetMeetingRoomByTypeID(curItemData.TypeID));
    curList = curList.replace("{3}", curItemData.Host);
    curList = curList.replace("{4}", curItemData.CallDepartment);
    curList = curList.replace("{5}", "出席部门");
    curList = curList.replace("{6}", curItemData.AttendingDepartment);

    }
    curList += "</td>";
    curList += "</tr>";
    ListBody += curList;
    }
    ListBody += "</div></tbody></table>";

    return ListTitle + ListBody;

    };
    //获取2个日期间所有的天数
    EventList.prototype.GetAllDays = function (date1, date2) {
    var dateArr = new Array();

    var curDate = new Date(date1.toString());


    while (curDate <= date2) {

    dateArr.push(new Date(curDate.toString()));
    var curDate = this.AddDate(curDate, 1);

    }

    return dateArr;
    };
    //日期加减
    EventList.prototype.AddDate = function (date, days) {

    var d = new Date(date.toString());

    d.setDate(d.getDate() + days);
    var m = d.getMonth();
    return new Date(d.getFullYear(), m, d.getDate());
    };
    //日期转星期
    EventList.prototype.GetWeekDay = function (date) {
    var weekDay = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];

    return weekDay[date.getDay()];
    };
    //获取当前日期对应的会议室信息
    EventList.prototype.GetCurDateDatas = function (date) {
    var curDatas = new Array();

    for (var i = 0; i < this.TypeEvent.length; i++) {

    var item = this.TypeEvent[i];

    var curBeginTime = new Date(item.BeginTime.toString().replace(/-/g, "/"));

    if (this.FormatDate1(curBeginTime) == this.FormatDate1(date)) {
    curDatas.push(item);
    }
    }
    return curDatas;

    };
    //获取当前会议室ID对应的会议室name
    EventList.prototype.GetMeetingRoomByTypeID = function (typeID) {
    for (var i = 0; i < this.Type.length; i++) {
    var item = this.Type[i];
    if (item.ID == typeID) {
    return item.Name;
    }
    }
    }
    //返回2015-11-11格式
    EventList.prototype.FormatDate1 = function (date) {

    return date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
    };
    //返回H:mm格式
    EventList.prototype.FormatDate2 = function (date) {
    return date.getHours() + ':' + date.getMinutes();
    };

    return EventList;
    })();
    MeetingList.EventList = EventList;

    })(MeetingList || (MeetingList = {}));

  • 相关阅读:
    [CF1295E] Permutation Separation
    [APIO2010] 特别行动队
    [CF1296F] Berland Beauty
    [CEOI2004] 锯木厂选址
    [CF1334E] Divisor Paths
    Review 2020.11.14
    [CQOI2016] 手机号码
    [LEETCODE600] 不含连续1的非负整数
    [CF55D] Beautiful numbers
    内存取证工具volatility
  • 原文地址:https://www.cnblogs.com/King-JJ/p/5006609.html
Copyright © 2011-2022 走看看