<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>blog式日曆控件</title> </head> <body> <mce:script type="text/javascript"><!-- var $ = function (id) { return "string" == typeof id ? document.getElementById(id) : id; }; var Class = { create: function() { return function() { this.initialize.apply(this, arguments); } } } Object.extend = function(destination, source) { for (var property in source) { destination[property] = source[property]; } return destination; } var Calendar = Class.create(); Calendar.prototype = { initialize: function(container, options) { this.Container = $(container);//容器(table結構) this.Days = [];//日期對象列表 this.SetOptions(options); this.Year = this.options.Year; this.Month = this.options.Month; this.SelectDay = this.options.SelectDay ? new Date(this.options.SelectDay) : null; this.onSelectDay = this.options.onSelectDay; this.onToday = this.options.onToday; this.onFinish = this.options.onFinish; this.Draw(); }, //設置默認屬性 SetOptions: function(options) { this.options = {//默認值 Year: new Date().getFullYear(),//顯示年 Month: new Date().getMonth() + 1,//顯示月 SelectDay: null,//選擇日期 onSelectDay: function(){},//在選擇日期觸發 onToday: function(){},//在當天日期觸發 onFinish: function(){}//日曆畫完後觸發 }; Object.extend(this.options, options || {}); }, //上一個月 PreMonth: function() { //先取得上一個月的日期對象 var d = new Date(this.Year, this.Month - 2, 1); //再設置屬性 this.Year = d.getFullYear(); this.Month = d.getMonth() + 1; //重新畫日曆 this.Draw(); }, //下一個月 NextMonth: function() { var d = new Date(this.Year, this.Month, 1); this.Year = d.getFullYear(); this.Month = d.getMonth() + 1; this.Draw(); }, //畫日曆 Draw: function() { //用來保存日期列表 var arr = []; //用當月第一天在一週中的日期值作爲當月離第一天的天數 for(var i = 1, firstDay = new Date(this.Year, this.Month - 1, 1).getDay(); i <= firstDay; i++){ arr.push(" "); } //用當月最後一天在一個月中的日期值作爲當月的天數 for(var i = 1, monthDay = new Date(this.Year, this.Month, 0).getDate(); i <= monthDay; i++){ arr.push(i); } var frag = document.createDocumentFragment(); this.Days = []; while(arr.length > 0){ //每個星期插入一個tr var row = document.createElement("tr"); //每個星期有7天 for(var i = 1; i <= 7; i++){ var cell = document.createElement("td"); cell.innerHTML = " "; if(arr.length > 0){ var d = arr.shift(); cell.innerHTML = d; if(d > 0){ this.Days[d] = cell; //判斷是否今日 if(this.IsSame(new Date(this.Year, this.Month - 1, d), new Date())){ this.onToday(cell); } //判斷是否選擇日期 if(this.SelectDay && this.IsSame(new Date(this.Year, this.Month - 1, d), this.SelectDay)){ this.onSelectDay(cell); } } } row.appendChild(cell); } frag.appendChild(row); } //先清空內容再插入(ie的table不能用innerHTML) while(this.Container.hasChildNodes()){ this.Container.removeChild(this.Container.firstChild); } this.Container.appendChild(frag); this.onFinish(); }, //判斷是否同一日 IsSame: function(d1, d2) { return (d1.getFullYear() == d2.getFullYear() && d1.getMonth() == d2.getMonth() && d1.getDate() == d2.getDate()); } }; // --></mce:script> <mce:style type="text/css"><!-- .Calendar { font-family:Verdana; font-size:12px; background-color:#e0ecf9; text-align:center; width:200px; height:160px; padding:10px; line-height:1.5em; } .Calendar a{ color:#1e5494; } .Calendar table{ width:100%; border:0; } .Calendar table thead{color:#acacac;} .Calendar table td { font-size: 11px; padding:1px; } #idCalendarPre{ cursor:pointer; float:left; padding-right:5px; } #idCalendarNext{ cursor:pointer; float:right; padding-right:5px; } #idCalendar td.onToday { font-weight:bold; color:#C60; } #idCalendar td.onSelect { font-weight:bold; } --></mce:style><style type="text/css" mce_bogus="1">.Calendar { font-family:Verdana; font-size:12px; background-color:#e0ecf9; text-align:center; width:200px; height:160px; padding:10px; line-height:1.5em; } .Calendar a{ color:#1e5494; } .Calendar table{ width:100%; border:0; } .Calendar table thead{color:#acacac;} .Calendar table td { font-size: 11px; padding:1px; } #idCalendarPre{ cursor:pointer; float:left; padding-right:5px; } #idCalendarNext{ cursor:pointer; float:right; padding-right:5px; } #idCalendar td.onToday { font-weight:bold; color:#C60; } #idCalendar td.onSelect { font-weight:bold; }</style> <div class="Calendar"> <div id="idCalendarPre"><<</div> <div id="idCalendarNext">>></div> <span id="idCalendarYear">2008</span>年 <span id="idCalendarMonth">8</span>月 <table cellspacing="0"> <thead> <tr> <td>日</td> <td>一</td> <td>二</td> <td>三</td> <td>四</td> <td>五</td> <td>六</td> </tr> </thead> <tbody id="idCalendar"> </tbody> </table> </div> <mce:script language="JavaScript"><!-- var cale = new Calendar("idCalendar", { SelectDay: new Date().setDate(10), onSelectDay: function(o){ o.className = "onSelect"; }, onToday: function(o){ o.className = "onToday"; }, onFinish: function(){ $("idCalendarYear").innerHTML = this.Year; $("idCalendarMonth").innerHTML = this.Month; var flag = [10,15,20]; for(var i = 0, len = flag.length; i < len; i++){ this.Days[flag[i]].innerHTML = "<a href="javascript:void(0);" mce_href="javascript:void(0);" οnclick=/"alert('日期是:"+this.Year+"/"+this.Month+"/"+flag[i]+"');return false;/">" + flag[i] + "</a>"; } } }); $("idCalendarPre").onclick = function(){ cale.PreMonth(); } $("idCalendarNext").onclick = function(){ cale.NextMonth(); } // --></mce:script> </body> </html>
前端面試題 - 說一下原型和原型鏈? JavaScript 中,萬物皆對象,對象分爲普通對象和函數對象。 所有的函數都是函數對象(typeof f === 'function'),其他都是普通對象(typeof o === 'object'
1. 測試背景 starrocks 2.0.1版本使用低基數全局字典優化後,性能有很大提升,這是準備重點測試部分,測試後對於聚合sql有明顯的性能提升。當然企業中統計分析中多維數據分析的場景也比較多,有助於整體的性能提升,大家可以規劃合適
轉載自天地風雷水火山澤 目的 因爲我們的數倉數據源是Kafka,離線數倉需要用Flume採集Kafka中的數據到HDFS中。 在實際項目中,我們不可能一直在Xshell中啓動Flume任務,一是因爲項目的Flume任務很多,二是一旦Xsh
在現代的多線程編程中,Semaphore和CountDownLatch是兩個非常常見和重要的工具類,它們都可以用來實現多線程間的同步和互斥,提高程序的併發性能和效率。本文將詳細介紹Java中的Semaphore和CountDownLatch
聊聊Swift中的宏 宏,Macros是一種常見的編程技術,傳統的C語言中,即包含了宏功能。宏這種功能,簡單來說是在代碼的預編譯階段進行靜態替換,是一種非運行時的特性。但是往復雜了說,宏實際上也提供了一種”元編程“方式,即對程序本身進行編程
唯一索引(Unique Index):保證索引列的值是唯一的,即重複值不允許。 非唯一索引(Non-Unique Index):允許重複值存在。 組合索引(Composite Index):在表的多個列上創建索引。 反向鍵索引(Rever
要查看一個Git分支是基於哪個分支創建的,您可以採取以下幾種方法: 使用git show-branch命令:在Git命令行中,輸入git show-branch --current可以顯示當前分支的提交歷史,並在其中標記出當前所在的分支。
vxe-table 是一款優秀的前段插件,可以採用雙向綁定快速的顯示錶格內容,頁面元素使用即時插入的方式,讓頁面更順滑 ,今天來討論一下vxe-table的合併行以及同一行的合併列 合併需要使用的屬性是 : span-met
DHTMLX Suite UI 組件庫允許您更快地構建跨平臺、跨瀏覽器 Web 和移動應用程序。它包括一組豐富的即用式 HTML5 組件,這些組件可以輕鬆組合到單個應用程序界面中。 DHTMLX Gantt是用於跨瀏覽器和跨平臺應用程序的功
LightningChartJS是Web上性能特高的圖表庫,具有出色的執行性能 - 使用高數據速率同時監控數十個數據源。 GPU加速和WebGL渲染確保您的設備的圖形處理器得到有效利用,從而實現高刷新率和流暢的動畫,常用於貿易,工程,航空航
前端面試題 - 爲什麼在JS中0.1+0.2!=0.3?以及IEE 754標準 JavaScript使用Number類型表示數字(整數和浮點數),遵循 IEEE 754 標準 通過64位來表示一個數字。 首先,計算機無法直接對十進制的數字進
前端面試題 - NodeJS能用ES6模塊嗎?CommonJS 和 ES6模塊的區別是什麼? JS能寫前端web,也能寫NodeJS。 Node.js 後端應用由模塊組成,其模塊系統採用 CommonJS 規範,它並不是 JavaScri
如何更好地與 AI 爲伴,做時代的先進開發者?4 月 17 日,阿里雲推出的 AI 編程助手通義靈碼與雲工開物“高校訓練營”走進西安多所高校開啓實操培訓,結合 AI 輔助編程的發展背景、通義靈碼的具體能力和應用實操,幫助在校大學生了解人工智
本教程將引導您通過啓用Spring DSL和使用Service Spring DSL抽象來引導Spring和Spring代碼生成項目,本教程中學習的技能也可以很容易地應用於其他抽象。在本教程中,您將學習如何: 爲Spring DSL初始化
JetBrains PyCharm是一種Python IDE,其帶有一整套可以幫助用戶在使用Python語言開發時提高其效率的工具。此外,該IDE提供了一些高級功能,以用於Django框架下的專業Web開發。 立即獲取PyCharm v20