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 = {}));

JS命名空间实例的更多相关文章

  1. js命名空间笔记

    在量比较大或者多人编写的情况下,命名冲突就很有可能发生,同一个页面引用了两个命名相同功能不同的文件,调用的时候就会出问题.因此使用JS命名空间很重要. 1.采用字面量方法创建命名空间: var a={ ...

  2. Node.js入门实例程序

    在使用Node.js创建实际“Hello, World!”应用程序之前,让我们看看Node.js的应用程序的部分.Node.js应用程序由以下三个重要组成部分: 导入需要模块: 我们使用require ...

  3. js命名空间的使用

    js命名空间的使用: test.html 代码如下: <!DOCTYPE HTML><html lang="en-US"><head>    & ...

  4. jQuery图片懒加载插件jquery.lazyload.js使用实例注意事项说明

    jQuery图片懒加载插件jquery.lazyload.js使用实例注意事项说明 jquery.lazyload.js是一个用JavaScript编写的jQuery插件.它可以延迟加载长页面中的图片 ...

  5. jQuery懒加载插件jquery.lazyload.js使用说明实例

    jQuery懒加载插件jquery.lazyload.js使用说明实例很多网站都会用到‘图片懒加载’这种方式对网站进行优化,即延迟加载图片或符合某些条件才开始加载图片.懒加载原理:浏览器会自动对页面中 ...

  6. js分页实例

    js分页实例 案例1 1.js_pageusers.html <!DOCTYPE html> <html> <head> <title>js_pageu ...

  7. JS hashMap实例详解

    链接:http://www.jb51.net/article/85111.htm JS hashMap实例详解 作者:囧侠 字体:[增加 减小] 类型:转载 时间:2016-05-26我要评论 这篇文 ...

  8. Python爬虫教程-16-破解js加密实例(有道在线翻译)

    python爬虫教程-16-破解js加密实例(有道在线翻译) 在爬虫爬取网站的时候,经常遇到一些反爬虫技术,比如: 加cookie,身份验证UserAgent 图形验证,还有很难破解的滑动验证 js签 ...

  9. Python3.2官方文档翻译--作用域和命名空间实例

    6.2.1 作用域和命名空间实例 以下的实例主要用来示范怎样引用不同的作用域和命名空间,keywordglobal和nonlocalru怎样影响变量绑定. 实例执行结果是: After local a ...

随机推荐

  1. 在 .NET 4.0 中使用 .NET 4.5 中新增的特性(CallerMemberNameAttribute/CallerFilePathAttribute/CallerLineNumberAttribute)

    介绍 标题中所说的三个特性 CallerMemberNameAttribute / CallerFilePathAttribute / CallerLineNumberAttribute 我们统称为调 ...

  2. ROW_NUMBER() OVER的用法

    语法:ROW_NUMBER() OVER(PARTITION BY COLUMN ORDER BY COLUMN)        //PARTITION 分割 一.ROW_NUMBER() OVER ...

  3. WPF自适应窗体实现小结

    WPF自适应窗体实现小结 这几天,因工作需要,要对一个小软件进行UI调整.主要内容就是让其能够实现自适应窗体(包括文字和图标),做成像WIN7下的Media Center一样的UI.自适应窗体,顾名思 ...

  4. Linux(Centos) 安装windows字体

    有时候在Linux中需要用到windows字体,比如微软雅黑字体,这个时候,可能就需要我们手动去安装字体了(当然,如果服务器上没装过),简单几步如下: 1.在$WINDOWS/Fonts目录中找到对应 ...

  5. HDU 1251统计难题

    统计难题 Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131070/65535 K (Java/Others)Total Submi ...

  6. Mediator(中介者)-对象行为型模式

    1.意图 用一个中介对象来封装一系列的对象交互.中介者使各个对象不需要显示地相互引用,从而使其耦合松散,而且可以独立地改变它们之间的交互. 2.动机 通过将集体行为封装在一个单独的中介者对象中,中介者 ...

  7. TCP、UDP协议间的区别(转)

    一.TCP/IP协议是一个协议簇.里面包括很多协议的.UDP只是其中的一个.之所以命名为TCP/IP协议,因为TCP,IP协议是两个很重要的协议,就用他两命名了. TCP/IP协议集包括应用层,传输层 ...

  8. 启动WCF多个服务方法

    引用就不说明,直接贴上: using System;using System.Collections.Generic;using System.Linq;using System.Text;using ...

  9. C++读写文件ofstream,ifstream,fstream)[转]

    在看C++编程思想中,每个练习基本都是使用ofstream,ifstream,fstream,以前粗略知道其用法和含义,在看了几位大牛的博文后,进行整理和总结: 这里主要是讨论fstream的内容:[ ...

  10. 使用spring配置quartz定时器

    quartz是石英钟的意思,所以用这个名字来做定时器的框架名称再适合不过.一年前做项目的时候有用过这个框架,当时没有整理,今天刚好新的商城系统也需要定时器.想要达到的效果是:每天的固定时间,比如凌晨3 ...