Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //js ko
- $(document).ready(function() {
- let storyTemplate;
- var storyCategory = {};
- function getDataByYear(theYear){
- $.ajax({
- url : '/api/calendar/'+theYear+'/',
- dataType : 'json',
- type : 'GET',
- success: function(data)
- {
- // console.log(data)
- storyTemplate = _.template($('#paper-holder').html());
- let valuetoPass = storyTemplate({stories:data});
- $('.paper-box').html(valuetoPass);
- }
- });
- }
- $.ajax({
- url : '/api/category/',
- dataType : 'json',
- type : 'GET',
- success: function(data){
- // console.log(data);
- storyCategory = data;
- }
- });
- console.log(storyCategory);
- _.template.showcatecolor = function (theCateId) {
- for (var i = 0; i < storyCategory.length; i++) {
- if (storyCategory[i].id == theCateId) {
- return storyCategory[i].color;
- }
- }
- return storyCategory.id[theCateId]
- };
- _.template.showmonth = function (themonth) {
- let monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
- let d = new Date(themonth); // or d = new Date(date)
- return monthNames[d.getMonth()];
- };
- //display all years with events
- for (var i = 0; i < allYearsArr.length; i++) {
- $('.slidee').append(
- "<li class='yearitem'>"+allYearsArr[i]+"</li>"
- );
- }
- getDataByYear(latestYear);
- });
Advertisement
Add Comment
Please, Sign In to add comment