JavaScript small calendar

xiaoxiao2021-03-06  60

Date Selection - by Ziyue </ Title> <script language = "javascript" type = "text / javascript"> // Date Selection // by ziyue (http://www.web-v.com/) var months = new array ("one "" February "," March "," April "," May "," June "," July "," August "," September "," October "," Ten " January "," December "); var daysinmonth = new Array (31, 28, 31, 30, 31, 30, 31); var days = new array (" Japan "," 1 "," two "," three "," four "," five "," six "); var today</p> <p>document.writeln ( "<div id = 'Calendar' style = 'position: absolute; z-index: 1; visibility: hidden; filter: /" progid: DXImageTransform.Microsoft.Shadow (direction = 135, color = # 999999, Stregth = 3) / "'> </ div>");</p> <p>This code below is determined whether the current is the current IF (1 == Month) Return ((0 == Year% 4) && (0! = (Year% 100)) ) || (0 == Year% 400)? 29: 28; else return daysinmonth [Month];</p> <p>Function gettoday () {// get today, month, day this.now = new date (); this.year = this.now.getFullyear (); this.month = this.Now.getMonth (); this. Day = this.now.getdate ();</p> <p>Function getStringDay (STR) {// gets the year, month, day var str = str.split ("-") this.now = new date (parsefloat (str [0]), PARSEFLOAT (STR [1]) -1, Parsefloat (Str [2])); this.year = this.now.Getfullyear (); this.month = this.now.getMonth (); this.day = this.now.getdate ();}</p> <p>Function newcalendar () {var parseyear = parseint (Document.all.Year.Sewations [Document.all.Year.Selected "; var newcal = new date (parseeyear, document.all.month.selectedIndex, 1); var Day = -1; var startday = newcal.getday (); var daily = 0; if ((Today.Year == Newcal.GetFullyear ()) && (Today.Month == Newcal.getMonth ())) DAY = Today .day; var Tablecal = document.all.calendar; var intdaysinmonth = getDays (newcal.getmonth (), newcal.getfullyear (); for (var intwek = 1; intWeek <Tablecal.Rows.Length; INTWEEK ) for (VAR INTDAY = 0; INTDAY <Tablecal.Rows [INTWEEK] .Cells.Length; INTDAY ) {var cell = Tablecal.Rows [INTWEEK] .Cells [INTDAY]; if ((INTDAY == StartDay) && (0 == daily) DAILY = 1; if (day == daily) // Today, call today Class {Cell.Style.Background = '# 6699cc'; ​​cell.style.color = '# fffff'; ///cell.st YLE.FONTWEIGHT = 'bold';} else if (intDay == 6) // Saturday cell.style.color = 'Green'; else if (intDay == 0) // Sunday cell.style.color = ' Red '; if ((Daily> 0) && (Daily <= INTDAYSINMONTH)) {Cell.innertext = Daily; Daily ;} else cell.innerText = ""}}</p> <p>Function getdate (inputbox) {var sdate; // This code handles the case of the mouse click if (event.srcelement.tagname == "td") if (event.srcelement.innerText! = ") {sdate = document.all . Year.Value "-" Document.all.month.Value "-" Event.Srcelement.innertext; Eval ("Document.all." InputBox) .value = sdate; hiddencalendar ();} HiddenCalendar () {// Close Selection window Document.all.calendar.style.visibility = 'hidden';}</p> <p>Function Showcalendar (InputBox) {VAR X, Y, INTLOOP, INTWEEKS, INTDAYS; VAR DIVCONTENT; VAR YEAR, MONTH, DAY; VAR O = EVAL ("Document.all." InputBox; var thisyear; // Real this year Yeyear = new gettoday (); thisyear = thisyear.year; today = o.value; if (isdate) Today = new getStringDay (); else = new gettoDay (); // Display location x = O.offsetleft; y = o.offSettop; while (o = o.offsetParent) {x = o.offsetleft; y = o.Offsettop;} Document.all.calendar.style.left = x 2; Document.all. Calendar.style.top = Y 20; Document.all.Calendar.Style.visibility = "Visible"; // Start Output Calendar Table (Border-Color: # 9dbaf7) DivContent = "<Table Border = '0' Cellspacing = '0' style = 'border: 1px solid # 0066ff; Background-color: # edf2fc'> "; DivContent =" <tr> "; divcontent =" <td style = 'border-bottom: 1px solid # 0066ff; Background -color: # C7D8FA '> "; // year DivContent =" <select name =' year 'id =' year 'onchange =' newcalendar () 'Style =' font-family : Verdana; Font-Size: 12px '> "; for (Intloop = thisyear - 105; Intloop <(thisyear 106); intloop ) DivContent =" <option value = " inTloop " " (Today.Year == INTLOOP? "SELECTED": "" " "> INTLOOP "</ option>"; DivContent = "</ select>"; // month DivContent = "<select name = 'Month'</p> <p>ID = 'month' onchange = 'newcalendar ()' style = 'font-family: verdana; font-size: 12px'>; for (intloop = 0; intloop <months.length; intloop ) DivContent = "<option value = " (INTLOOP 1) " (Today.Month == Intloop? "SELECTED": "") "> months [inTloop] </ option>"; DivContent = "</ select > "; DivContent =" </ td> "; DivContent =" <TD Style = 'border-bottom: 1px solid # 0066ff; Background-Color: # c7d8fa; font-weight: bold; font-family: Wingdings 2, WINGDINGS , WEBDINGS; font-size: 16px; padding-top: 2px; color: # 4477ff; cursor: hand 'align =' center 'title =' Close 'onclick =' javascript: hiddencalendar () '> s </ td> " DivContent = "</ TR>"; DivContent = "<tr> <TD align = 'center' colspan = '2'>; divcontent =" <Table ID = 'calendar' border = '0' width = '100 % '> "; // Week DivContent =" <tr> "; for (INTLOOP = 0; INTLOOP <days.Length; INTLOOP ) DivContent =" <TD align =' center 'style =' font-size: 12px '> " days [intloop] " </ td> "; divcontent =" </ tr> "; // day for INTWEEKS = 0; INTWEEKS <6; INTWEEKS ) {DivContent = "<tr>"; for (intDays = 0; INTDAYS <days.length; intDays )</p> <p>) DivContent = "<td onclick = 'getdate (/" INPUTBOX "/")' style = 'cursor: hand; border-right: 1px solid #bbbbbb; border-bottom: 1px solid #bbbbb; color: # 215DC6; Font-Family: Verdana; Font-size: 12px 'align =' center '> </ td> "; DivContent =" </ TR> ";} DivContent =" </ TABLE> </ td> </ tr > </ table> "; Document.all.calendar.innerHTML = DivContent; newcalendar ();</p> <p>Function isdate (date) {var datepat = / ^ (/ d {4}) (/ D {1, 2}) (/ -) (/ d {1, 2}) $ /; var matcharray = DateStr.match (datepat); if (matcharray == null) Return false; var month = matchay [3]; var day = matcharray [5]; var year = matcharray [1]; if (Month <1 || Month> 12) RETURN FALSE; IF (Day <1 || Day> 31) Return False; if ((Month == 4 || Month == 6 || Month == 9 || Month == 11) && day == 31 ) Return False; if (Month == 2) {var isleap = (Year% 4 == 0 && (Year% 100! = 0 || Year% 400 == 0)); if (DAY> 29 || (Day " == 29 &&! Isleap) Return False;} Return true;} </ script> <style type = "text / css"> <! - td, input {font-family: verdana, arial, helvetica, sans- Serif; font-size: 12px;} -> </ stop> </ head></p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-84527.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="84527" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.039</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'P0coKNiLKTgLGBzyQYmQynfFOiOP_2FvpNiIcnG2Ulo7gLbTHjSKhZj3g9wBYAzkx27wj5BmzzLvdu0C3mJWvs0Q_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>