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. 深入理解js——作用域和上下文环境

    如图除全局作用域外,每个函数都会创建自己的作用域.作用域在函数定义时就确定了,而不是在函数调用时确定. 下面按照程序执行的步骤加上上下文环境. 第一步:程序加载时已经确定全局上下文环境,并随着程序的执 ...

  2. jQuery与Ajax的应用——《锋利的jQuery》(第2版)读书笔记3

    第6章 jQuery与Ajax的应用 jQuery对Ajax操作进行了封装,在jQuery中$.ajax()方法属于最底层的方法,第2层是load().$.get()和$.post()方法,第3层是$ ...

  3. Java 枚举7种常见用法

    (转)原创地址:http://blog.lichengwu.cn/java/2011/09/26/the-usage-of-enum-in-java/ JDK1.5引入了新的类型--枚举.在 Java ...

  4. Register DLL Assembly Gacutil.exe(全局程序集缓存工具)

    全局程序集缓存工具使你可以查看和操作全局程序集缓存和下载缓存的内容. 此工具会自动随 Visual Studio 一起安装. 若要运行此工具,请使用开发人员命令提示(或 Windows 7 中的 Vi ...

  5. 运动 js

    <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...

  6. 【转】Linux学习之路--启动VNC服务

    我的Linux是Fedora 13,安装方法如下: 1.打开终端,执行 # yum install -y tigervnc tigervnc-server 2.编辑/etc/sysconfi/vncs ...

  7. C#(asp.net )读取ASHX文件(一般处理程序)

    c#后台获取asxh的返回数据,后台创建一个请求实例,获取请求实例的返回值 public string GetResponseByPost(string apiUrl, string queryStr ...

  8. 一个简单的makefile

    #common makefile header LOCAL_INCLUDE := \ -I/xxx/ACE/ACE/ LOCAL_FLAGS := $(LOCAL_INCLUDE) LIBS := - ...

  9. 【如何快速的开发一个完整的iOS直播app】(播放篇)

    原文转自:袁峥Seemygo    感谢分享.自我学习 前言 在看这篇之前,如果您还不了解直播原理,请查看上篇文章如何快速的开发一个完整的iOS直播app(原理篇) 开发一款直播app,集成ijkpl ...

  10. 在Sublime Text3上面更加方便愉快的写php

    写php代码,elcipse体积太大,开起来太麻烦,记事本又没有什么标识,稍不留神就会出现;没加.大括号没对全的尴尬情况.所以我选择使用Sublime. 推荐几个 sublime插件:sublimeL ...