All Projects → niinpatel → Calendarhtml Javascript

niinpatel / Calendarhtml Javascript

Licence: mit
Simple Calendar built with Pure JavaScript (No Libraries) http://iamnitinpatel.com/projects/calendar/

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Calendarhtml Javascript

Scalajs Bootstrap
Scala.js bootstrap components
Stars: ✭ 55 (-51.33%)
Mutual labels:  bootstrap, dom
Angular Bootstrap Calendar
A port of the bootstrap calendar widget to AngularJS (no jQuery required!)
Stars: ✭ 803 (+610.62%)
Mutual labels:  calendar, bootstrap
Devextreme Reactive
Business React components for Bootstrap and Material-UI
Stars: ✭ 1,800 (+1492.92%)
Mutual labels:  calendar, bootstrap
Jquery Calendar
A responsive jquery calendar scheduler built with bootstrap and moment.js
Stars: ✭ 67 (-40.71%)
Mutual labels:  calendar, bootstrap
Staradmin Free Angular Admin Template
Star Admin Angular Admin is a free admin template based on Bootstrap 4 and Angular
Stars: ✭ 112 (-0.88%)
Mutual labels:  bootstrap
Vue Schedule Calendar
日程调度日历。
Stars: ✭ 110 (-2.65%)
Mutual labels:  calendar
Pg Calendar
📆 beautiful and eidetic date picker
Stars: ✭ 109 (-3.54%)
Mutual labels:  calendar
Lightning Admin Angular
A mobile first design of a responsive admin template built with angular and bootstrap
Stars: ✭ 107 (-5.31%)
Mutual labels:  bootstrap
Knowledge
文档着重构建一个完整的「前端技术架构图谱」,方便 F2E(Front End Engineering又称FEE、F2E) 学习与进阶。
Stars: ✭ 1,620 (+1333.63%)
Mutual labels:  dom
React Bs Notifier
A react component to show growl-like notifications using bootstrap alerts
Stars: ✭ 112 (-0.88%)
Mutual labels:  bootstrap
Tsmoothie
A python library for time-series smoothing and outlier detection in a vectorized way.
Stars: ✭ 109 (-3.54%)
Mutual labels:  bootstrap
Calendarx
📅 Your go-to, prescribed, Calendar component for React
Stars: ✭ 110 (-2.65%)
Mutual labels:  calendar
Interview Problem Summary
🎤 Prepare for the interviews and sum up the most popular interview problems for front-end(HTML/CSS/Javascript), Web development, full-stack. Also did some typical coding practice questions, such as UI caculator
Stars: ✭ 112 (-0.88%)
Mutual labels:  dom
Light Blue Dashboard
🔥 Free and open-source admin dashboard template built with Bootstrap
Stars: ✭ 110 (-2.65%)
Mutual labels:  bootstrap
Calendar
📅 PHP Date & Time library that solves common problems in object oriented, immutable way.
Stars: ✭ 113 (+0%)
Mutual labels:  calendar
Isl Python
Solutions to labs and excercises from An Introduction to Statistical Learning, as Jupyter Notebooks.
Stars: ✭ 108 (-4.42%)
Mutual labels:  bootstrap
Framework
[NOT MAINTAINED] A full-featured PHP framework powering the server side of Webiny Platform. Can also be used as standalone library.
Stars: ✭ 110 (-2.65%)
Mutual labels:  bootstrap
Scrivener html
HTML view helpers for Scrivener
Stars: ✭ 112 (-0.88%)
Mutual labels:  bootstrap
Flippy.js
FLIP animation helper; animate DOM changes with ease
Stars: ✭ 110 (-2.65%)
Mutual labels:  dom
Laravel Alert
A Bootstrap alert helper for Laravel
Stars: ✭ 110 (-2.65%)
Mutual labels:  bootstrap

Calendar with Pure JavaScript and HTML

The program uses Date() function to build a simple calendar with Pure JavaScript and HTML. Here's the final implementation of it - http://iamnitinpatel.com/projects/calendar

alt html javascript calendar

Explanation- When the program is started, the function showCalendar() is with arguments currentMonth and currentYear. This function populates the table with dates at the correct places.

The buttons "previous", "next" and dropdown "jump" control the functions, previous(), next() and jump(). These function update the currentMonth and currentYear variable.

How showCalendar Works-

showCalendar(month, year) function which takes in two parameters, month and year. Once, the function is called, it dynamically generates a calendar in HTML and appends it into our table. Here’s my approach.

Get the starting day of the month, we’ll use -

let firstDay = (new Date(year, month)).getDay();
  1. Next, get the number of days in that month. We can achieve this too using date function.

    let daysInMonth = 32 - new Date(year, month, 32).getDate();

Explanation, the function new Date(year, month, 32) returns the 32nd day after the month started. If we subtract that date from 32, we get the final day of that month. Example, If we pass feb 2018 as an argument, its ‘32nd’ day will be 4th of march, subtract 32 from 4 and we get 28, final day of the month of feb 2018.

Once we have the two things ready, we populate the table with numbers 1 to [last day of month] on appropriate places. For example, if the starting of that month is Thursday and Ending date is 28, we’ll put the number 1 below thursday, 2 below, friday, 3 below saturday and so on. When we reach 28, we break out of the loop.

Here, we use a nested for loop because we have upto 6 rows and 7 columns.

In the outer loop, we create a new “tr” element, ie, table row, up to 6 times. (maximum number of rows we need to create the calendar), then run the inner loop to create elements in each rows, then append those rows into our table.

In the inner loop, we populate each row with “td” elements in it. We keep track of the date using variable “date” in it.There are three if conditions at each iteration:

If we’re at first row and we have not yet reached first yet, create td element and leave it blank.

If “date” is higher than max days in that month, we break out of the loop because we have finished creating the table.

Else, we create the “td” element and print the “date” in it.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].