2012-09-06 64 views
3

我试图找出一个jQuery插件,将显示的日期长路的的全月的价值(如下 - 这些数字反映了一个月的天数(平日唯一的)jQuery插件 - 1个月日历

-3 4 5 6 7- -10 11 12 13 14- -17 18 19 20 21- -24 25 26 27 28- 

理论上这种方法使得当月列的一天 - 几个民族日历然后可以下显示为行下面展示了这种:

---------3 4 5 6 7- -10 11 12 13 14- -17 18 19 20 21- -24 25 26 27 28- 
Person A X - - - - - - - X - - - - X X - - - - - 
Person B X X X - - - X - X - - - X X X X X X - - 

我的问题是“我怎样才能实现与jQuery以上。? (我曾质问Google试图找到一个妓女ble插件 - 但我一直无法确定)“。

+0

自己开发这不是一个选项吗? – MalSu

+0

这个数据来自哪里,你需要jQuery的地方? – Ties

+0

我可以自己开发它 - 没有底层的数据结构 - 我不一定非要使用jQuery。这只是我以前用过的框架。 – JHarley1

回答

1

那么,lets get you started

(function($){ 
    var getWeekDaysInCurrentMonth = function(){ 
     // this will operate off of the current month 
     // you can make the month an argument 
     // and then d.setMonth(m) 

     var d = new Date(), 
      daysInMonth = [], 
      currentDay; 

     // go to first day of month 
     d.setDate(1); 
     var firstDay = d.getDate(); 
     // go to last day of month 
     d.setDate(0); 
     var lastDay = d.getDate(); 

     for (var i = firstDay; i <= lastDay; i++){ 
      d.setDate(i); 
      // get the current day of the week in loop 
      currentDay = d.getDay(); 
      // check not sunday or saturday 
      if(currentDay !== 0 && currentDay !== 6) 
       daysInMonth.push(i);     
     } 
     return daysInMonth; 
    }; 

    console.log(getWeekDaysInCurrentMonth()); 
    // OUTPUT: [1, 2, 3, 6, 7, 8, 9, 10, 13, 
    //   14, 15, 16, 17, 20, 21, 22, 23, 24, 27, 28, 29, 30, 31] 

})(jQuery)​;​ 

你的下一步是此功能工作到一个jQuery插件输出一些表格标记。然后,您将向您的插件添加配置,这会改变标记的显示方式,首先显示哪个月份等。如果您仔细阅读我的其他一些jQuery答案,可以找到创建jQuery插件(或Google)的示例。