//json array format /* 0 uid (text) 1 num (itteration of this uid) 2 start (ics format datetime) 3 end (ics format datetime) 4 allday (true/false) 5 summary (text) 6 category (int) 7 tags (array) 8 attachments (array) [[1,"httpwwwgooglecom","http:\/\/www.google.com"],[2,"2","Adam"],[0,"15","34441"]] 12 description (moved) 13 location (moved) */ // GLOBAL SCOPE VARIABLES //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! months = new Array( "", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ); days = new Array( "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ); pageon = 0; pagemax = 0; filtersrendered = false; formerpage = 0; pagejumpto = 0; nexteventset = false; viewinglist = false; userselectedlist = false; formermonth = 0; monthshowing = 0; monthlimits = new Array(0, 0); monthpickerdiv = ""; calmonths = new Array(); todaydateobj = new Date(); todayuid = "d" + todaydateobj.getDate() + "d" + (todaydateobj.getMonth() + 1) + "d" + todaydateobj.getFullYear(); mondayon = new Date(); monthon = 0; firstevent = true; events = new Array(); eimonths = new Array(); predisplayday = 0; divheightsset = false; mtrackfortitle = todaydateobj.getMonth(); // HOUSEKEEPING / HELPER FUNCTIONS //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //function to remove any orphaned categories or tags on load from event json array function cleanJson() { for (pj = 0; pj < json.length; pj++) { //check categorys catokay = false; for (pc = 0; pc < cats.length; pc++) { if (cats[pc][0] == json[pj]["CATEGORY"]) { catokay = true; } } if (catokay == false) { json[pj]["CATEGORY"] = 0; } //check tags if (json[pj]["TAGS"]) { for (tj = 0; tj < json[pj]["TAGS"].length; tj++) { tagokay = false; for (pc = 0; pc < tags.length; pc++) { if (tags[pc][0] == json[pj]["TAGS"][tj]) { tagokay = true; } } if (tagokay == false) { json[pj]["TAGS"].splice(tj, 1); tj--; } } } } } function convtodt(jsondt) { //take dt from json and convert it to javascript datetime object ydt = parseInt(jsondt.substr(0, 4)); mdt = parseInt(jsondt.substr(4, 2)) - 1; ddt = parseInt(jsondt.substr(6, 2)); returndt = new Date(ydt, mdt, ddt); return returndt; } function numberdays(es, ee) { first = es.getTime(); second = ee.getTime(); return Math.round((second - first) / (1000 * 60 * 60 * 24)); } function getdivid(ms, d) { rettime = new Date(ms.getTime() + 86400000 * d); return ( "d" + rettime.getDate() + "d" + (rettime.getMonth() + 1) + "d" + rettime.getFullYear() ); } function getcatcolor(catid) { for (c = 0; c < cats.length; c++) { if (cats[c][0] == catid) { return cats[c][2]; } } return defaultcolor; } function startdateislater(sdatetime) { today = new Date(); eventdate = new Date( sdatetime.substr(0, 4), parseInt(sdatetime.substr(4, 2)) - 1, parseInt(sdatetime.substr(6, 2)), 23, 59, 59 ); if (eventdate >= today) { return true; } else { return false; } } function nth(dnth) { if (dnth > 3 && dnth < 21) return "th"; switch (dnth % 10) { case 1: return "st"; case 2: return "nd"; case 3: return "rd"; default: return "th"; } } //returns dateobject for monday of the week in which d dateobject exists function getMonday(d) { d = new Date(d); var day = d.getDay(), diff = d.getDate() - day + (day == 0 ? -6 : 1); // adjust when day is sunday return new Date(d.setDate(diff)); } function getmonthtitle(m) { today = new Date(); var n = today.getMonth(); var y = today.getFullYear(); returnstring = ""; adjyear = 0; if (m < 0) { adjyear = -1; } if (m > 11) { adjyear = 1; } if (longmonth == true) { returnstring += months[((m + 24) % 12) + 1]; } else { returnstring += months[((m + 24) % 12) + 1].substr(0, 3); } if (longyear == true) { returnstring += " " + (y + adjyear).toString(); } else { returnstring += " " + (y + adjyear).toString().substr(2, 2); } return returnstring; } function getDaysInMonth(month, year) { return new Date(year, month + 1, 0).getDate(); } function getStartOfMonth(month, year) { return new Date(year, month, 0).getDay(); } //returns if this is first event in week for pagination by week formatting function firstinweek(sdate) { thisdateobj = new Date( parseInt(sdate.substr(0, 4)), parseInt(sdate.substr(4, 2)), parseInt(sdate.substr(6, 2)) ); thismonday = getMonday(thisdateobj); if ( thismonday.getYear() != mondayon.getYear() || thismonday.getMonth() != mondayon.getMonth() || thismonday.getDate() != mondayon.getDate() ) { mondayon = thismonday; if (firstevent == true) { firstevent = false; return false; } else { return true; } } else { return false; } } //returns if this is first event in month for pagination by month formatting function firstinmonth(sdate) { thismonth = sdate.substr(0, 6); if (thismonth != monthon) { monthon = thismonth; if (firstevent == true) { firstevent = false; return false; } else { return true; } } else { return false; } } function escapeHtml(unsafe) { return unsafe .replace(/&/g, "&") .replace(//g, ">") .replace(/"/g, """) .replace(/'/g, "'"); } //set tagsshow array (filter settings) according to tags selected function settags(tagobj) { tagsshow.length = 0; $("#" + tagobj).toggleClass("selected"); $(".tagfilter").each(function () { if ($(this).hasClass("selected")) { splitup = $(this).attr("id").split("t"); tagsshow[tagsshow.length] = splitup[1]; } }); pageon = 0; formerpage = 0; renderCalendar(); } //set catsshow array (filter settings) according to categories selected function setcats(catobj) { catsshow.length = 0; $("#" + catobj).toggleClass("selected"); $(".catfilter").each(function () { if ($(this).hasClass("selected")) { splitup = $(this).attr("id").split("c"); catsshow[catsshow.length] = splitup[1]; } }); pageon = 0; formerpage = 0; renderCalendar(); } // FORMATING FUNCTIONS //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //return formatted date / time string according to format mask and date/time object function formatdate(formatstring, dtstringobj) { for (objref = 2; objref < 4; objref++) { var thisdate = new Date( parseInt(dtstringobj[objref].substr(0, 4)), parseInt(dtstringobj[objref].substr(4, 2)), parseInt(dtstringobj[objref].substr(6, 2)) ); var YYYY = dtstringobj[objref].substr(0, 4); var YY = dtstringobj[objref].substr(2, 2); var MMMM = months[parseInt(dtstringobj[objref].substr(4, 2))]; var MMM = months[parseInt(dtstringobj[objref].substr(4, 2))].substr( 0, 3 ); var MM = dtstringobj[objref].substr(4, 2); var M = parseInt(dtstringobj[objref].substr(4, 2)); var DDDD = days[thisdate.getDay()]; var DDD = days[thisdate.getDay()].substr(0, 3); var DD = dtstringobj[objref].substr(6, 2); var D = parseInt(dtstringobj[objref].substr(6, 2)); var O = nth(D); var HHHH = dtstringobj[objref].substr(9, 2); var HHH = parseInt(dtstringobj[objref].substr(9, 2)); if (parseInt(HHHH) >= 12) { if (parseInt(HHHH) > 12) { var HH = parseInt(HHHH) - 12; } else { HH = 12; } if (HH < 10) { HH = "0" + HH; } var A = "pm"; } else { var HH = HHHH; var A = "am"; } var H = parseInt(HH); var NN = dtstringobj[objref].substr(11, 2); if (dtstringobj[objref].length <= 9) { HHHH = "00"; HHH = "0"; HH = "00"; H = "0"; A = "am"; NN = "00"; } if (objref == 2) { formatstring = formatstring.replace(/\[YYYYs\]/g, YYYY); formatstring = formatstring.replace(/\[YYs\]/g, YY); formatstring = formatstring.replace(/\[MMMMs\]/g, MMMM); formatstring = formatstring.replace(/\[MMMs\]/g, MMM); formatstring = formatstring.replace(/\[MMs\]/g, MM); formatstring = formatstring.replace(/\[Ms\]/g, M); formatstring = formatstring.replace(/\[DDDDs\]/g, DDDD); formatstring = formatstring.replace(/\[DDDs\]/g, DDD); formatstring = formatstring.replace(/\[DDs\]/g, DD); formatstring = formatstring.replace(/\[Ds\]/g, D); formatstring = formatstring.replace(/\[Os\]/g, O); formatstring = formatstring.replace(/\[HHHHs\]/g, HHHH); formatstring = formatstring.replace(/\[HHHs\]/g, HHH); formatstring = formatstring.replace(/\[HHs\]/g, HH); formatstring = formatstring.replace(/\[Hs\]/g, H); formatstring = formatstring.replace(/\[APs\]/g, A); formatstring = formatstring.replace(/\[NNs\]/g, NN); } else { formatstring = formatstring.replace(/\[YYYYe\]/g, YYYY); formatstring = formatstring.replace(/\[YYe\]/g, YY); formatstring = formatstring.replace(/\[MMMMe\]/g, MMMM); formatstring = formatstring.replace(/\[MMMe\]/g, MMM); formatstring = formatstring.replace(/\[MMe\]/g, MM); formatstring = formatstring.replace(/\[Me\]/g, M); formatstring = formatstring.replace(/\[DDDDe\]/g, DDDD); formatstring = formatstring.replace(/\[DDDe\]/g, DDD); formatstring = formatstring.replace(/\[DDe\]/g, DD); formatstring = formatstring.replace(/\[De\]/g, D); formatstring = formatstring.replace(/\[Oe\]/g, O); formatstring = formatstring.replace(/\[HHHHe\]/g, HHHH); formatstring = formatstring.replace(/\[HHHe\]/g, HHH); formatstring = formatstring.replace(/\[HHe\]/g, HH); formatstring = formatstring.replace(/\[He\]/g, H); formatstring = formatstring.replace(/\[APe\]/g, A); formatstring = formatstring.replace(/\[NNe\]/g, NN); } } return formatstring; } //takes event and formats according to event format mask and date time format masks function formatmask(eventobj, eventobjid, hpslider) { //insert summary thismask = eventmask; splitup = thismask.split("[SUMMARY]"); thismask = splitup.join(escapeHtml(eventobj[5])); //insert location splitup = thismask.split("[LOCATION]"); if (hpslider == true) { if (typeof eventobj[11] === "undefined") { thismask = splitup.join(""); } else { thismask = splitup.join(eventobj[11]); } } else { if (typeof eventobj[13] === "undefined") { thismask = splitup.join(""); } else { thismask = splitup.join(eventobj[13]); } } //insert calendarurl splitup = thismask.split("[CALURL]"); thismask = splitup.join(callinkurl); //insert can book status splitup = thismask.split("[CANBOOK]"); canbook = "false"; thiseventdate = convtodt(eventobj[2]); todaysdate = new Date(); todaysdate.setHours(0, 0, 0, 0); for (le = 0; le < linkedevents.length; le++) { if (eventobj[0] == linkedevents[le]) { if (todaysdate <= thiseventdate) { canbook = "true"; } else { canbook = "past"; } } } thismask = splitup.join(canbook); //true = bookable event //false = not bookable event //past = was bookable but in past //insert booking link splitup = thismask.split("[BOOKINGLINK]"); if (canbook == "true") { thismask = splitup.join( '' ); } else { thismask = splitup.join(""); } //insert primary link splitup = thismask.split("[LINK]"); primarylinkurl = ""; for (a = 0; a < eventobj[9].length; a++) { if (eventobj[9][a].length > 3 && eventobj[9][a][3] == "true") { if (eventobj[9][a][0] == 0) { for (ac = 0; ac < assetarray.length; ac++) { if (assetarray[ac][0] == eventobj[9][a][1]) { primarylinkurl = ''; } } } else if (eventobj[9][a][0] == 1) { primarylinkurl = ''; } else { for (ac = 0; ac < pagesarray.length; ac++) { if (pagesarray[ac][0] == eventobj[9][a][1]) { primarylinkurl = ''; } } } } } thismask = splitup.join(primarylinkurl); //insert icsurl splitup = thismask.split("[ICSURL]"); thismask = splitup.join("javascript:downloadeventics(" + eventobjid + ");"); //prepare date depending on start-end date/month/year span if (eventobj[2].substr(0, 8) == eventobj[3].substr(0, 8)) { prepdate = formatdate(dtmasks[0], eventobj); } else { if (eventobj[2].substr(0, 6) == eventobj[3].substr(0, 6)) { prepdate = formatdate(dtmasks[1], eventobj); } else { prepdate = formatdate(dtmasks[2], eventobj); } } //insert date splitup = thismask.split("[DATE]"); thismask = splitup.join(prepdate); //prepare time depending on start - end time span if ( eventobj[2].length < 13 || eventobj[3].length < 13 || parseInt(eventobj[2].substr(9, 4)) < 2 ) { preptime = formatdate(dtmasks[5], eventobj); } else { if ( parseInt(eventobj[2].substr(9, 4)) != parseInt(eventobj[3].substr(9, 4)) ) { preptime = formatdate(dtmasks[4], eventobj); } else { preptime = formatdate(dtmasks[3], eventobj); } } //insert time splitup = thismask.split("[TIME]"); thismask = splitup.join(preptime); //prepare category name and color if (eventobj[6] == 0) { prepcolor = defaultcolor; prepcategory = ""; } else { catisset = false; for (col = 0; col < cats.length; col++) { if (cats[col][0] == eventobj[6]) { prepcolor = cats[col][2]; prepcategory = escapeHtml(cats[col][1]); catisset = true; } } if (catisset == false) { prepcolor = defaultcolor; prepcategory = ""; } } //insert date splitup = thismask.split("[DATE]"); thismask = splitup.join(prepdate); //prepare time depending on start - end time span if ( eventobj[2].length < 13 || eventobj[3].length < 13 || parseInt(eventobj[2].substr(9, 4)) < 2 ) { preptime = formatdate(dtmasks[5], eventobj); } else { if ( parseInt(eventobj[2].substr(9, 4)) != parseInt(eventobj[3].substr(9, 4)) ) { preptime = formatdate(dtmasks[4], eventobj); } else { preptime = formatdate(dtmasks[3], eventobj); } } //insert category name and color splitup = thismask.split("[CATEGORY]"); thismask = splitup.join(prepcategory); splitup = thismask.split("[COLOR]"); thismask = splitup.join(prepcolor); return thismask; } // NAVIGATION FUNCTIONS //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //change between calendar & list views when both available function toggleview() { $(".monthsWrapper").remove(); $(".dialogWrapper").remove(); if (userselectedlist == false) { userselectedlist = true; } else { userselectedlist = false; } renderCalendar(); } //hide and show filters function togglefiltersfnc() { $(".monthsWrapper").remove(); $(".dialogWrapper").remove(); $(".filtersWrapper").toggle(); } //calendar view displays month picker function monthpick() { //show month picker $(".dialogWrapper").remove(); if ($(".monthsWrapper").is(":visible")) { $(".monthsWrapper").remove(); } else { if ($(".monthsWrapper").length == 0) { $(".monthcontainer").append(monthpickerdiv); } wheight = $(".monthcontainer").css("height"); $(".monthsWrapper").css({ height: wheight, position: "absolute", top: "0px", left: "0px", width: "100%", }); $(".monthsWrapper").show(); $(".monthpicker").removeClass("selected"); $("#mp" + monthshowing).addClass("selected"); } setcalmonthcontainerheight(); } //calendar view jumps to month via picker function monthjump(tomonth) { //change month $(".monthsWrapper").remove(); $(".dialogWrapper").remove(); if (tomonth != monthshowing) { formermonth = monthshowing; setheight = $("#month" + formermonth).height(); monthshowing = tomonth; $(".monthheader").html(getmonthtitle(tomonth)); $(".month").hide(); $(".monthcontainer").css("height", setheight + "px"); $("#month" + monthshowing).show(); addeventsmonthid = tomonth - monthlimits[0]; addmonthevents(addeventsmonthid); $("#month" + monthshowing).css({ position: "absolute", top: "0px", left: "0px", width: "100%", height: setheight + "px", }); setcalendarevents(); } mtrackfortitle = tomonth; } //calendar view moves +- month function monthpage(updown) { mtrackfortitle += updown; $(".dialogWrapper").remove(); $(".monthsWrapper").hide(); newmonth = monthshowing + updown; if (newmonth >= monthlimits[0] && newmonth <= monthlimits[1]) { ffmonth = formermonth; formermonth = monthshowing; monthshowing = newmonth; $(".monthheader").html(getmonthtitle(newmonth)); $("#month" + ffmonth).hide(); $(".month").stop(); $(".monthcontainer").stop(); addeventsmonthid = newmonth - monthlimits[0]; addmonthevents(addeventsmonthid); movemonth(); setcalendarevents(); } } //calendar view animates month change function movemonth() { lcwidth = $(".monthcontainer").width(); fpheight = $("#month" + formermonth).height(); poheight = $("#month" + monthshowing).height(); $(".monthcontainer").css({ height: fpheight + "px", width: "100%" }); switch (pageanimation[1]) { case "leftright": if (monthshowing > formermonth) { $("#month" + formermonth).css({ position: "absolute", top: "0px", left: "0px;", width: "100%", }); $("#month" + monthshowing).show(); $("#month" + monthshowing).css({ position: "absolute", top: "0px", left: lcwidth, width: "100%", }); $("#month" + monthshowing).animate( { left: 0 }, pageanimation[0] ); $("#month" + formermonth).animate( { left: 0 - lcwidth }, pageanimation[0], function () { $("#month" + formermonth).hide(); } ); } else { $("#month" + formermonth).css({ position: "absolute", top: "0px", left: "0px;", width: "100%", }); $("#month" + monthshowing).show(); $("#month" + monthshowing).css({ position: "absolute", top: "0px", left: 0 - lcwidth, width: "100%", }); $("#month" + monthshowing).animate( { left: 0 }, pageanimation[0] ); $("#month" + formermonth).animate( { left: lcwidth }, pageanimation[0], function () { $("#month" + formermonth).hide(); } ); } break; case "updown": if (monthshowing > formermonth) { $("#month" + formermonth).css({ position: "absolute", top: "0px", left: "0px;", width: "100%", }); $("#month" + monthshowing).show(); $("#month" + monthshowing).css({ position: "absolute", top: fpheight, left: "0px;", width: "100%", }); $("#month" + monthshowing).animate( { top: 0 }, pageanimation[0] ); $("#month" + formermonth).animate( { top: 0 - fpheight }, pageanimation[0], function () { $("#month" + formermonth).hide(); } ); } else { $("#month" + formermonth).css({ position: "absolute", top: "0px", left: "0px;", width: "100%", }); $("#month" + monthshowing).show(); $("#month" + monthshowing).css({ position: "absolute", top: 0 - poheight, left: "0px;", width: "100%", }); $("#month" + monthshowing).animate( { top: 0 }, pageanimation[0] ); $("#month" + formermonth).animate( { top: poheight }, pageanimation[0], function () { $("#month" + formermonth).hide(); } ); } break; case "fade": $("#month" + formermonth).fadeOut(pageanimation[0], function () { $("#month" + monthshowing).fadeIn(pageanimation[0]); }); break; default: $("#month" + formermonth).hide(); $("#month" + monthshowing).show(); } } //changes list view +- page function calendarpage(updown) { $(".dialogWrapper").remove(); ffpage = formerpage; formerpage = pageon; pageon += updown; if (pageon < 0) { pageon = 0; } if (pageon > pagemax) { pageon = pagemax; } if (formerpage != pageon) { $("#page_" + ffpage).hide(); $(".events_page").stop(); $(".list_events_container").stop(); movepage(); } else { formerpage = ffpage; } if (pagemax > 9) { redrawpagination(); } } //changes list view page via pagination function pagejump(jumpto, animate) { $(".dialogWrapper").remove(); if (jumpto != pageon) { ffpage = formerpage; formerpage = pageon; pageon = jumpto; if (animate == false) { $("#page_" + formerpage).hide(); $("#page_" + pageon).show(); $(".calendarpagetab").removeClass("selected"); $("#pagetab_" + pageon).addClass("selected"); } else { $("#page_" + ffpage).hide(); $(".events_page").stop(); $(".list_events_container").stop(); movepage(); } if (pagemax > 9) { redrawpagination(); } } } //animates list view page change function movepage() { lcwidth = $(".list_events_container").width(); fpheight = $("#page_" + formerpage).height(); poheight = $("#page_" + pageon).height(); $(".list_events_container").animate({ height: poheight }, pageanimation[0]); switch (pageanimation[1]) { case "leftright": if (pageon > formerpage) { $("#page_" + formerpage).css({ position: "absolute", top: "0px", left: "0px;", }); $("#page_" + pageon).show(); $("#page_" + pageon).css({ position: "absolute", top: "0px", left: lcwidth, }); $("#page_" + pageon).animate({ left: 0 }, pageanimation[0]); $("#page_" + formerpage).animate( { left: 0 - lcwidth }, pageanimation[0], function () { $("#page_" + formerpage).hide(); } ); } else { $("#page_" + formerpage).css({ position: "absolute", top: "0px", left: "0px;", }); $("#page_" + pageon).show(); $("#page_" + pageon).css({ position: "absolute", top: "0px", left: 0 - lcwidth, }); $("#page_" + pageon).animate({ left: 0 }, pageanimation[0]); $("#page_" + formerpage).animate( { left: lcwidth }, pageanimation[0], function () { $("#page_" + formerpage).hide(); } ); } break; case "updown": if (pageon > formerpage) { $("#page_" + formerpage).css({ position: "absolute", top: "0px", left: "0px;", }); $("#page_" + pageon).show(); $("#page_" + pageon).css({ position: "absolute", top: fpheight, left: "0px;", }); $("#page_" + pageon).animate({ top: 0 }, pageanimation[0]); $("#page_" + formerpage).animate( { top: 0 - fpheight }, pageanimation[0], function () { $("#page_" + formerpage).hide(); } ); } else { $("#page_" + formerpage).css({ position: "absolute", top: "0px", left: "0px;", }); $("#page_" + pageon).show(); $("#page_" + pageon).css({ position: "absolute", top: 0 - poheight, left: "0px;", }); $("#page_" + pageon).animate({ top: 0 }, pageanimation[0]); $("#page_" + formerpage).animate( { top: poheight }, pageanimation[0], function () { $("#page_" + formerpage).hide(); } ); } break; case "fade": $("#page_" + formerpage).fadeOut(pageanimation[0], function () { $("#page_" + pageon).fadeIn(pageanimation[0]); }); break; default: $("#page_" + formerpage).hide(); $("#page_" + pageon).show(); } $(".calendarpagetab").removeClass("selected"); $("#pagetab_" + pageon).addClass("selected"); } //close dialog - event of day list of more events in calendar view function closedialog() { $(".dialogWrapper").remove(); } // RENDERING FUNCTIONS //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //if calendar is bloq and more than one calendar instance exists function deleteallbutfirstcalendar() { $(".caldeletable").each(function (index) { if (index > 0) { $(this).remove(); } }); } //list view redraw pagination according to filters, page on, results & pagination settings function redrawpagination() { paginationhtml = ""; pageshtml = ""; pagecenter = pageon; if (pageon < 5) { pagecenter = 5; } if (pageon > pagemax - 5) { pagecenter = pagemax - 5; } for (p = pagecenter - 5; p < pagecenter + 4; p++) { pageshtml += '' + (p + 2) + ""; } pageshtml += '' + (pagemax + 1) + ""; paginationhtml = ''; $(".paginationWrapper").html(paginationhtml); } //render both calendar and list views according to filtered json array callinkurl = ""; function renderCalendar() { if (typeof eventstoside !== "undefined" && eventstoside == false) { $(".eventsWrapper").remove(); } callinkurl = $("#calendarlinkpagelocation").html(); if ($(".calendarWrapper").length > 1) { deleteallbutfirstcalendar(); } if (filtersrendered == false) { cleanJson(); } $(".dialogWrapper").remove(); pagemasksplit = pagemask.split("[EVENTS]"); calhtml = ""; listhtml = ""; mondayon = new Date(); calmonths.length = 0; monthon = 0; pagemax = 0; firstevent = true; nexteventset = false; catsfiltered = false; tagsfiltered = false; //set filter values in json array for tags and categories if (prefilter != 0) { catsshow[catsshow.length] = prefilter; } if (catsshow.length > 0) { catsfiltered = true; } if (tagsshow.length > 0) { tagsfiltered = true; } for (i = 0; i < json.length; i++) { if (json[i].length < 14) { tempdesc = json[i][10]; templocation = json[i][11]; json[i][10] = false; json[i][11] = false; json[i][12] = tempdesc; json[i][13] = templocation; } if (catsfiltered == false) { json[i][10] = true; } else { showthis = false; for (o = 0; o < catsshow.length; o++) { if (catsshow[o] == json[i][6]) { showthis = true; } } json[i][10] = showthis; } if (tagsfiltered == false) { json[i][11] = true; } else { showthis = false; for (t = 0; t < json[i][7].length; t++) { for (o = 0; o < tagsshow.length; o++) { if (tagsshow[o] == json[i][7][t]) { showthis = true; } } } json[i][11] = showthis; } } //create list view html according to events and pagination settings listhtml += '
' + pagemasksplit[0]; eventnumon = 0; for (i = 0; i < json.length; i++) { if (json[i][10] == true && json[i][11] == true) { //this is event is unfiltered so display if (pagination == "week" && firstinweek(json[i][2]) == true) { listhtml += pagemasksplit[1] + "
"; pagemax++; listhtml += '"; pagemax++; listhtml += '"; pagemax++; eventnumon = 0; listhtml += '"; //create pagination paginationhtml = ""; if (pagemax > 0) { pageshtml = ""; if (pagemax > 9) { for (p = 0; p < 9; p++) { pageshtml += '' + (p + 2) + ""; } pageshtml += '' + (pagemax + 1) + ""; } else { for (p = 0; p < pagemax; p++) { pageshtml += '' + (p + 2) + ""; } } paginationhtml = ''; } //create calendar view & monthpicker html calendarhtml = '
'; monthpickerhtml = ""; monthhtml = '"; //show correct view (list or calendar) according to div width or override (if set by user) canjumptotoday = false; if ( viewwidths[1] >= $(".calendarWrapper").width() || userselectedlist == true ) { $(".calendarWrapper").html(listhtml); $(".paginationWrapper").html(paginationhtml); canjumptotoday = true; viewinglist = true; } else { $(".calendarWrapper").html(calendarhtml); $(".paginationWrapper").html(monthhtml); monthpickerdiv = '
' + monthpickerhtml + "
"; addmonthevents(curmonthid); viewinglist = false; } togglefiltershtml = ""; if (filters == 1) { togglefiltershtml = ''; } if (allowtoggle == true && viewwidths[1] < $(".calendarWrapper").width()) { $(".optionsWrapper").html( '' + togglefiltershtml ); } else { $(".optionsWrapper").html(togglefiltershtml); } //if first render then setup containing div width checker for switching between list and calendar views on resize if (filtersrendered == false) { $(window).resize(function () { widthstyle = new Array(); $("#calendarOuter").removeClass("cal_mobile cal_tablet"); for (sw = 0; sw < stylewidths.length; sw++) { if ($(".calendarWrapper").width() <= stylewidths[sw][0]) { $("#calendarOuter").addClass(stylewidths[sw][1]); } } setcalmonthcontainerheight(); if ( viewwidths[1] < $(".calendarWrapper").width() && viewinglist == true ) { renderCalendar(); } if ( viewwidths[1] >= $(".calendarWrapper").width() && viewinglist == false ) { renderCalendar(); } if ( viewwidths[1] >= $(".calendarWrapper").width() && viewinglist == true ) { $(".optionsWrapper").html(togglefiltershtml); } if (allowtoggle == true) { if (viewwidths[1] < $(".calendarWrapper").width()) { $(".optionsWrapper").html( '' + togglefiltershtml ); } } setcalendarevents(); }); //set up classes in #calendarOuter widthstyle = new Array(); $("#calendarOuter").removeClass("cal_mobile cal_tablet"); for (sw = 0; sw < stylewidths.length; sw++) { if ($(".calendarWrapper").width() <= stylewidths[sw][0]) { $("#calendarOuter").addClass(stylewidths[sw][1]); } } setcalmonthcontainerheight(); } setcalendarevents(); //if first render then display filters if required if (filtersrendered == false) { if (filters > 0) { filtershtml = '
'; for (f = 0; f < cats.length; f++) { filtershtml += "' + escapeHtml(cats[f][1]) + ""; } filtershtml += '
'; for (f = 0; f < tags.length; f++) { filtershtml += "' + tags[f][1] + ""; } filtershtml += "
"; $(".filtersWrapper").html(filtershtml); if (filters == 1) { $(".filtersWrapper").hide(); } } filtersrendered = true; if (eventstoside == true) { showday(predisplayday, true); } if ($('div[data-anim*="loadhomepagecalendar"]').length > 0) { objhideanimate = $('div[data-anim*="loadhomepagecalendar"]'); if ( objhideanimate.offset().top - $(window).height() > $(window).scrollTop() ) { objhideanimate.css({ opacity: "0" }); } } } //render ics download button(s) if (prefilter != 0) { if (downloadable == true) { downloadhtml = ""; if (catsshow.length > 0 || tagsshow.length > 0) { downloadhtml += ''; } downloadhtml += ''; $(".downloadsWrapper").html(downloadhtml); } } else { if (downloadable == true) { downloadhtml = ''; if (catsshow.length > 0 || tagsshow.length > 0) { downloadhtml += ''; } downloadhtml += ''; $(".downloadsWrapper").html(downloadhtml); } } //set page navigation / animation variables pageon = 0; formerpage = 0; //jumps page to today if list view and unlimited results and is first render if (limitedto == 0 && canjumptotoday == true) { pagejump(pagejumpto, false); } if (accessibilitymode.length > 0) { $(".eventcolor").css({ "background-color": "transparent" }); } } //show full page dialog with single event details (from list view event click, calendar view event click or calendar view day list event click) function eventpopup(jsonref) { if (suppressEventPopup !== true) { attachments = ""; if (json[jsonref][9].length > 0) { attachments += '
'; for (a = 0; a < json[jsonref][9].length; a++) { if ( json[jsonref][9][a].length < 4 || json[jsonref][9][a][3] != "true" ) { if (json[jsonref][9][a][0] == 0) { for (ac = 0; ac < assetarray.length; ac++) { if (assetarray[ac][0] == json[jsonref][9][a][1]) { attachments += '"; } } } else if (json[jsonref][9][a][0] == 1) { attachments += '"; } else { for (ac = 0; ac < pagesarray.length; ac++) { if (pagesarray[ac][0] == json[jsonref][9][a][1]) { attachments += '"; } } } } } attachments += "
"; } eventdescription = ""; if (json[jsonref][12].length > 0) { eventdescription = '
' + nl2br(json[jsonref][12]) + "
"; } popuphtml = '
' + formatmask(json[jsonref], jsonref, false) + eventdescription + attachments + '
'; if (eventstoside == true) { $(".dialogWrapper").remove(); event.stopPropagation(); window.event.cancelBubble = true; if (viewinglist == false) { $(".eventsWrapper").append(popuphtml); $(".dialogWrapper").show(); $(".dialogWrapper").css({ position: "relative", top: "0px", left: "0px", width: "100%", height: "100%", }); } } else { event.stopPropagation(); window.event.cancelBubble = true; $(".dialogWrapper").remove(); $(".calendarWrapper").append(popuphtml); $(".dialogWrapper").show(); $(".dialogWrapper").css({ position: "absolute", top: "0px", left: "0px", width: "100%", height: "100%", }); } } } function nl2br(str) { var breakTag = "
"; return (str + "").replace( /([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, "$1" + breakTag + "$2" ); } function setcalmonthcontainerheight() { oldheight = $("#month" + monthshowing).css("height"); monthheadergetheight = parseInt( $("#month" + monthshowing + " .dayheader:nth-child(1)").css("height"), 10 ); monthdaygetheight = parseInt( $("#month" + monthshowing + " .dop0").css("height"), 10 ); newheight = monthheadergetheight + monthdaygetheight * 6 + "px"; if (newheight != oldheight || divheightsset == false) { $("#month" + monthshowing).css("height", newheight); $(".monthcontainer").css("height", newheight); $(".monthsWrapper").css("height", newheight); $(".monthpicker").css("height", "20%"); divheightsset = true; } } //render single month events in calendar view function addmonthevents(monthid) { $(".clickableevents").removeClass("clickableevents"); $(".clickable").removeClass("clickable"); $(".cl_indicator").remove(); events.length = 0; eimonths.length = 0; monthspan = new Array( new Date( parseInt(calmonths[monthid][2]), parseInt(calmonths[monthid][1]) - 1, parseInt(calmonths[monthid][0]) ), new Date( parseInt(calmonths[monthid][5]), parseInt(calmonths[monthid][4]) - 1, parseInt(calmonths[monthid][3]) + 1 ) ); //create array of events to be included in this month for (j = 0; j < json.length; j++) { if (json[j][10] == true && json[j][11] == true) { hasatts = false; if (json[j][9].length > 0) { published = false; for (a = 0; a < json[j][9].length; a++) { if (json[j][9][a][0] == 0) { for (ac = 0; ac < assetarray.length; ac++) { if (assetarray[ac][0] == json[j][9][a][1]) { hasatts = true; } } } if (json[j][9][a][0] == 1) { hasatts = true; } if (json[j][9][a][0] == 2) { for (ac = 0; ac < pagesarray.length; ac++) { if (pagesarray[ac][0] == json[j][9][a][1]) { hasatts = true; } } } } } estart = convtodt(json[j][2]); if (json[j][3].length == 8 && json[j][2].length == 8) { newendday = parseInt(json[j][3]) - 1; eend = convtodt(newendday + ""); } else { eend = convtodt(json[j][3]); } if (estart < monthspan[1] && eend >= monthspan[0]) { numdays = numberdays(estart, eend) + 1; events[events.length] = new Array( estart, eend, json[j][5], json[j][6], j, numdays, hasatts ); } } } for (d = 0; d < 43; d++) { eimonths[d] = new Array("", "", "", new Array()); } for (d = 0; d < 42; d++) { thisday = monthspan[0].getTime() + d * 86400000; for (v = 0; v < events.length; v++) { if ( events[v][0].getTime() == thisday || events[v][0].getTime() == thisday + 3600000 || events[v][0].getTime() == thisday - 3600000 ) { track = -1; numdays = numberdays(events[v][0], events[v][1]); for (k = 0; k < 3; k++) { if (eimonths[d][k] === "" && track == -1) { track = k; } } if (track == -1) { track = 3; } enterval = v; for (n = 0; n <= numdays; n++) { if (d + n < 42) { if (track == 3) { eimonths[d + n][3][eimonths[d + n][3].length] = enterval; } else { eimonths[d + n][track] = enterval; } } } } } } conth = $(".dop0.monthid" + monthid) .css("height") .replace("px", ""); eventdivheight = Math.floor(conth / 4); for (i = 0; i < 42; i++) { dayhasevents = false; for (t = 0; t < 3; t++) { if (eimonths[i][t] !== "") { dayhasevents = true; ev = eimonths[i][t]; eventdivid = "e" + events[ev][4] + "m" + monthid + "i0"; if ($("#" + eventdivid).length < 1) { //event div does not exist edivs = new Array(new Array(i, 0, 0)); won = 0; evcheck = ev; icheck = i; isfirstonmonday = i % 7; while (evcheck === ev && icheck < eimonths.length - 1) { //if(((icheck)%7 == 0)&&(icheck != 0)&&(isfirstonmonday != 0)){ if (icheck % 7 == 0 && icheck != 0) { edivs[won][2] += 2; won++; edivs[edivs.length] = new Array(icheck, 1, 1); } else { edivs[won][1]++; } icheck++; evcheck = eimonths[icheck][t]; } //alert(edivs); for (k = 0; k < edivs.length; k++) { hasattachments = ""; if (events[ev][6] == true) { hasattachments = ''; } //evhtml = '
' + escapeHtml(events[ev][2]) + ''; evhtml = '
' + escapeHtml(events[ev][2]) + ""; if (edivs[k][2] == 1 || edivs[k][2] == 3) { evhtml += ''; } if (edivs[k][2] == 2 || edivs[k][2] == 3) { evhtml += ''; } evhtml += hasattachments + "
"; $(".dop" + edivs[k][0] + ".monthid" + monthid).append( evhtml ); } } } } if (eimonths[i][3].length > 0) { //ADD MORE TAG if ($(".morelink" + i + "l" + monthid).length == 0) { $(".dop" + i + ".monthid" + monthid).append( '
' + eimonths[i][3].length + " more
" ); } } if (dayhasevents == true) { $(".dop" + i).addClass("clickableevents"); $(".dop" + i).append('
'); } } } //show all events on a single day function showday(dayid, onloadoverridenext = false) { dayevents = new Array(); dayeventshtml = ""; for (i = 0; i < 3; i++) { if (eimonths[dayid][i] !== "") { hasattachments = ""; if (json[events[eimonths[dayid][i]][4]][9].length > 0) { published = false; for ( a = 0; a < json[events[eimonths[dayid][i]][4]][9].length; a++ ) { if (json[events[eimonths[dayid][i]][4]][9][a][0] == 0) { for (ac = 0; ac < assetarray.length; ac++) { if ( assetarray[ac][0] == json[events[eimonths[dayid][i]][4]][9][a][1] ) { published = true; } } } if (json[events[eimonths[dayid][i]][4]][9][a][0] == 1) { published = true; } if (json[events[eimonths[dayid][i]][4]][9][a][0] == 2) { for (ac = 0; ac < pagesarray.length; ac++) { if ( pagesarray[ac][0] == json[events[eimonths[dayid][i]][4]][9][a][1] ) { published = true; } } } } if (published == true) { hasattachments = ''; } } dayevents[dayevents.length] = json[events[eimonths[dayid][i]][4]]; dayeventshtml += '
' + formatmask( json[events[eimonths[dayid][i]][4]], events[eimonths[dayid][i]][4], false ) + hasattachments + "
"; } } for (i = 0; i < eimonths[dayid][3].length; i++) { hasattachments = ""; if (json[events[eimonths[dayid][3][i]][4]][9].length > 0) { published = false; for ( a = 0; a < json[events[eimonths[dayid][3][i]][4]][9].length; a++ ) { if (json[events[eimonths[dayid][3][i]][4]][9][a][0] == 0) { for (ac = 0; ac < assetarray.length; ac++) { if ( assetarray[ac][0] == json[events[eimonths[dayid][3][i]][4]][9][a][1] ) { published = true; } } } if (json[events[eimonths[dayid][3][i]][4]][9][a][0] == 1) { published = true; } if (json[events[eimonths[dayid][3][i]][4]][9][a][0] == 2) { for (ac = 0; ac < pagesarray.length; ac++) { if ( pagesarray[ac][0] == json[events[eimonths[dayid][3][i]][4]][9][a][1] ) { published = true; } } } } if (published == true) { hasattachments = ''; } } dayevents[dayevents.length] = json[events[eimonths[dayid][3][i]][4]]; dayeventshtml += '
' + formatmask( json[events[eimonths[dayid][3][i]][4]], events[eimonths[dayid][3][i]][4], false ) + hasattachments + "
"; } popuphtml = '
' + dayeventshtml + '
'; if (eventstoside == true) { if (dayeventshtml == "") { if (onloadoverridenext == true) { shownextdaywithevents(dayid); } else { $(".dialogWrapper").remove(); $(".eventsWrapper").append( '
There are no events on selected day
' ); $(".dialogWrapper").show(); $(".dialogWrapper").css({ position: "relative", top: "0px", left: "0px", width: "100%", height: "100%", }); $(".dialogWrapper").off("click"); } } else { $(".dialogWrapper").remove(); $(".eventsWrapper").append(popuphtml); $(".dialogWrapper").show(); $(".dialogWrapper").css({ position: "relative", top: "0px", left: "0px", width: "100%", height: "100%", }); $(".dialogWrapper").off("click"); } } else { if (dayeventshtml != "") { $(".calendarWrapper").append(popuphtml); $(".dialogWrapper").show(); $(".dialogWrapper").css({ position: "absolute", top: "0px", left: "0px", width: "100%", height: "100%", }); $(".dialogWrapper").off("click"); } } } function shownextdaywithevents(dayid) { newshowdayid = -1; for (o = dayid; o < eimonths.length; o++) { if (eimonths[o][0] !== "" && newshowdayid == -1) { newshowdayid = o; } } if (newshowdayid != -1) { showday(newshowdayid); } else { $(".dialogWrapper").remove(); $(".eventsWrapper").append( '
There are no events today
' ); $(".dialogWrapper").show(); $(".dialogWrapper").css({ position: "relative", top: "0px", left: "0px", width: "100%", height: "100%", }); $(".dialogWrapper").off("click"); } } function ordinal_suffix_of(i) { var j = i % 10, k = i % 100; if (j == 1 && k != 11) { return i + "st"; } if (j == 2 && k != 12) { return i + "nd"; } if (j == 3 && k != 13) { return i + "rd"; } return i + "th"; } // OUTPUT FUNCTIONS //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //produce ics on the fly and send to download as blob function downloadics(filtered) { dt = new Date(); dtmonth = dt.getMonth() + 1; if (dtmonth < 10) { dtmonth = "0" + dtmonth; } dtdate = dt.getDate(); if (dtdate < 10) { dtdate = "0" + dtdate; } dtyear = dt.getFullYear(); dtstamp = dtyear + dtmonth + dtdate + "T000000"; cal = "BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:-//School Website//NONSGML Product//EN\n"; for (i = 0; i < json.length; i++) { //change DTSTART, DTEND, SUMMARY & UID to number references in json array if (filtered == false || (json[i][10] == true && json[i][11] == true)) { cal += "BEGIN:VEVENT\nDTSTAMP:" + dtstamp + "\nUID:" + json[i][0] + "-" + i + "\nDTSTART:" + json[i][2] + "\nDTEND:" + json[i][3] + "\nSUMMARY:" + json[i][5] + "\nEND:VEVENT\n"; } } cal += "END:VCALENDAR"; var file = new Blob([cal], { type: "text/plain" }); if (window.navigator.msSaveOrOpenBlob) // IE10+ window.navigator.msSaveOrOpenBlob(file, "Calendar.ics"); else { // Others var a = document.createElement("a"), url = URL.createObjectURL(file); a.href = url; a.download = "Calendar.ics"; document.body.appendChild(a); a.click(); setTimeout(function () { document.body.removeChild(a); window.URL.revokeObjectURL(url); }, 0); } } //produce ics on the fly and send to download as blob function downloadeventics(eventid) { filtered = false; dt = new Date(); dtmonth = dt.getMonth() + 1; if (dtmonth < 10) { dtmonth = "0" + dtmonth; } dtdate = dt.getDate(); if (dtdate < 10) { dtdate = "0" + dtdate; } dtyear = dt.getFullYear(); dtstamp = dtyear + dtmonth + dtdate + "T000000"; cal = "BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:-//School Website//NONSGML Product//EN\n"; cal += "BEGIN:VEVENT\nDTSTAMP:" + dtstamp + "\nUID:" + json[eventid][0] + "-" + i + "\nDTSTART:" + json[eventid][2] + "\nDTEND:" + json[eventid][3] + "\nSUMMARY:" + json[eventid][5] + "\nEND:VEVENT\n"; cal += "END:VCALENDAR"; var file = new Blob([cal], { type: "text/plain" }); if (window.navigator.msSaveOrOpenBlob) // IE10+ window.navigator.msSaveOrOpenBlob(file, "Calendar.ics"); else { // Others var a = document.createElement("a"), url = URL.createObjectURL(file); a.href = url; a.download = "Calendar.ics"; document.body.appendChild(a); a.click(); setTimeout(function () { document.body.removeChild(a); window.URL.revokeObjectURL(url); }, 0); } } //produced html in new window of events yet to finish that are unfiltered and opens print dialog for that window function print() { monthon = ""; var win = window.open(""); //open new window and write to it var html = "Calendar"; var nmonth = true; for (p = 0; p < json.length; p++) { if ( json[p][10] == true && json[p][11] == true && convtodt(json[p][3]).getTime() >= todaydateobj.getTime() ) { nmonth = false; thismonth = months[convtodt(json[p][2]).getMonth() + 1]; if (monthon != thismonth) { nmonth = true; monthon = thismonth; html += '
' + thismonth + " " + convtodt(json[p][3]).getFullYear() + "

"; } sdate = convtodt(json[p][2]); edate = convtodt(json[p][3]); if (json[p][2].substr(0, 8) == json[p][3].substr(0, 8)) { prepdate = sdate.getDate() + nth(sdate.getDate()) + " " + months[sdate.getMonth() + 1]; } else { if (json[p][2].substr(0, 6) == json[p][3].substr(0, 6)) { prepdate = sdate.getDate() + nth(sdate.getDate()) + " - " + edate.getDate() + nth(edate.getDate()) + " " + months[sdate.getMonth() + 1]; } else { prepdate = sdate.getDate() + nth(sdate.getDate()) + " " + months[sdate.getMonth() + 1] + " - " + edate.getDate() + nth(edate.getDate()) + " " + months[edate.getMonth() + 1]; } } //check for all day event if ( json[p][2].length < 13 || json[p][3].length < 13 || parseInt(json[p][2].substr(9, 4)) < 2 ) { preptime = "All Day"; } else { if ( parseInt(json[p][2].substr(9, 4)) != parseInt(json[p][3].substr(9, 4)) ) { preptime = json[p][2].substr(9, 2) + ":" + json[p][2].substr(11, 2) + " - " + json[p][3].substr(9, 2) + ":" + json[p][3].substr(11, 2); } else { preptime = json[p][2].substr(9, 2) + ":" + json[p][2].substr(11, 2); } } if (nmonth == false) { html += '

'; } else { html += '
'; } html += prepdate + " " + preptime + '
' + json[p][5] + "

"; } } html += ""; win.document.write(html); win.window.print(); win.document.close(); } function setcalendarevents() { if (viewwidths[0] < $(".calendarWrapper").width()) { $(".calevent").css({ display: "inline-block" }); $(".more").css({ display: "inline-block" }); $(".clickableevents").removeClass("clickable"); $(".cl_indicator").removeClass("indicator"); } else { $(".calevent").css({ display: "none" }); $(".more").css({ display: "none" }); $(".clickableevents").addClass("clickable"); $(".cl_indicator").addClass("indicator"); } curyear = new Date().getFullYear(); var d = new Date(curyear, monthshowing, 1, 1, 1, 1, 1); dayofweek = d.getDay(); if (dayofweek == 0) { dayofweek = 7; } dayofweek -= 1; if ($(".HomePage").length) { shownextdaywithevents(dayofweek); } } callinkurl = ""; function renderCalendarEvents(sliderrows, totitems) { if ($(".calendarWrapper").length > 1) { deleteallbutfirstcalendar(); } callinkurl = $("#calendarlinkpagelocation").html(); if (filtersrendered == false) { cleanJson(); } $(".dialogWrapper").remove(); pagemasksplit = pagemask.split("[EVENTS]"); calhtml = ""; listhtml = ""; listhtml2 = ""; mondayon = new Date(); calmonths.length = 0; monthon = 0; firstevent = true; nexteventset = false; catsfiltered = false; tagsfiltered = false; eventnumon = 0; for (i = 0; i < json.length; i++) { eventnumon++; if ( startdateislater(json[i][2]) == true && nexteventset == false && limitedto == 0 ) { nexteventset = true; pagejumpto = pagemax; } hasattachments = ""; if (json[i][9].length > 0) { published = false; for (a = 0; a < json[i][9].length; a++) { if (json[i][9][a][0] == 0) { for (ac = 0; ac < assetarray.length; ac++) { if (assetarray[ac][0] == json[i][9][a][1]) { published = true; } } } if (json[i][9][a][0] == 1) { published = true; } if (json[i][9][a][0] == 2) { for (ac = 0; ac < pagesarray.length; ac++) { if (pagesarray[ac][0] == json[i][9][a][1]) { published = true; } } } } if (published == true) { hasattachments = ''; } } itemstart = '
'; itemend = "
"; itemstart2 = '
'; itemend2 = "
"; totgroups = Math.ceil(json.length / sliderrows); if (i % sliderrows == 0) { group = Math.floor(i / sliderrows); fnum = group + 1; bnum = group - 1; checked = ""; if (group + 1 == totgroups) { checked = " checked"; } else if (i == json.length - 1) { checked = " checked"; } if (bnum < 1) { bnum += totgroups; } fnum = "E-" + fnum + "-"; bnum = "E-" + bnum + "-"; itemstart = '"; itemstart += ''; itemstart += ''; itemstart += ''; itemstart += ''; itemstart += ''; itemstart += ''; itemstart += ''; itemstart += '
'; itemstart += '
'; if (i == 0) { itemstart2 = ''; itemstart2 += ''; itemstart2 += ''; itemstart2 += ''; itemstart2 += ''; itemstart2 += ''; itemstart2 += ''; itemstart2 += ''; itemstart2 += '
'; itemstart2 += '
'; } else { itemstart2 = '
'; itemstart2 += '
'; } } if (i % sliderrows == sliderrows - 1 || i == json.length - 1) { itemend = "
"; itemend2 = "
"; } listhtml += itemstart + '
' + formatmask(json[i], i, true) + hasattachments + "
" + itemend; listhtml2 += itemstart2 + '
' + formatmask(json[i], i, true) + hasattachments + "
" + itemend2; } if (nexteventset == false && limitedto == 0) { nexteventset = true; pagejumpto = 0; } $("#prependeventstothis").html(listhtml + listhtml2); viewinglist = true; togglefiltershtml = ""; //if first render then display filters if required filtersrendered = true; }