This repository was archived by the owner on Mar 4, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 30
fix current date and add specific set date #22
Open
luciluci
wants to merge
1
commit into
nizarmah:master
Choose a base branch
from
luciluci:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
<html> | ||
|
||
<head> | ||
<title>Dynamic Organizer Example</title> | ||
<link href="../calendarorganizer.min.css" rel="stylesheet"> | ||
</head> | ||
|
||
<body> | ||
<div id="calendarContainer"></div> | ||
<div id="organizerContainer"></div> | ||
<script src="../calendarorganizer.js"></script> | ||
<script> | ||
"use strict"; | ||
|
||
// function that creates dummy data for demonstration | ||
function createDummyData() { | ||
var date = new Date(); | ||
var data = {}; | ||
|
||
for (var i = 0; i < 10; i++) { | ||
data[date.getFullYear() + i] = {}; | ||
|
||
for (var j = 0; j < 12; j++) { | ||
data[date.getFullYear() + i][j + 1] = {}; | ||
|
||
for (var k = 0; k < Math.ceil(Math.random() * 10); k++) { | ||
var l = Math.ceil(Math.random() * 28); | ||
|
||
try { | ||
data[date.getFullYear() + i][j + 1][l].push({ | ||
startTime: "10:00", | ||
endTime: "12:00", | ||
text: "Some Event Here" | ||
}); | ||
} catch (e) { | ||
data[date.getFullYear() + i][j + 1][l] = []; | ||
data[date.getFullYear() + i][j + 1][l].push({ | ||
startTime: "10:00", | ||
endTime: "12:00", | ||
text: "Some Event Here" | ||
}); | ||
} | ||
} | ||
} | ||
} | ||
|
||
return data; | ||
} | ||
|
||
// INSTEAD OF GRABBING THE DATA FROM AN AJAX REQUEST | ||
// I WILL BE DEMONSTRATING THE SAME EFFECT THROUGH MEMORY | ||
// THIS DEFEATS THE PURPOSE BUT IS SIMPLER TO UNDERSTAND | ||
var serverData = createDummyData(); | ||
var test_day = new Date(Date.parse("2020/11/21")); | ||
|
||
// stating variables in order for them to be global | ||
var calendar, organizer; | ||
|
||
// initializing a new calendar object, that will use an html container to create itself | ||
calendar = new Calendar("calendarContainer", // id of html container for calendar | ||
"small", // size of calendar, can be small | medium | large | ||
[ | ||
"Wednesday", // left most day of calendar labels | ||
3 // maximum length of the calendar labels | ||
], | ||
[ | ||
"#ffc107", // primary color | ||
"#ffa000", // primary dark color | ||
"#ffffff", // text color | ||
"#ffecb3" // text dark color | ||
], | ||
{ | ||
indicator: true, | ||
indicator_type: 0, // indicator type, can be 0 (not numeric) | 1 (numeric) | ||
indicator_pos: "top", // indicator position, can be top | bottom | ||
custom_date: test_day | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you please change the |
||
} | ||
); | ||
|
||
// This is gonna be similar to an ajax function that would grab | ||
// data from the server; then when the data for a this current month | ||
// is grabbed, you just add it to the data object of the form | ||
// { year num: { month num: { day num: [ array of events ] } } } | ||
function dataWithAjax(date, callback) { | ||
var data = {}; | ||
|
||
try { | ||
data[date.getFullYear()] = {}; | ||
data[date.getFullYear()][date.getMonth() + 1] = serverData[date.getFullYear()][date.getMonth() + 1]; | ||
} catch (e) {} | ||
|
||
callback(data); | ||
}; | ||
|
||
window.onload = function() { | ||
dataWithAjax(new Date(), function(data) { | ||
// initializing a new organizer object, that will use an html container to create itself | ||
organizer = new Organizer("organizerContainer", // id of html container for calendar | ||
calendar, // defining the calendar that the organizer is related | ||
data // small part of the data of type object | ||
); | ||
|
||
// after initializing the organizer, we need to initialize the onMonthChange | ||
// there needs to be a callback parameter, this is what updates the organizer | ||
organizer.onMonthChange = function(callback) { | ||
dataWithAjax(organizer.calendar.date, function(data) { | ||
organizer.data = data; | ||
callback(); | ||
}); | ||
}; | ||
}); | ||
}; | ||
</script> | ||
</body> | ||
|
||
</html> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you please tweak this line so it looks like the following example?