Team:UNITN-Trento/JS/Notebook

From 2013.igem.org

(Difference between revisions)
Line 1: Line 1:
/**
/**
-
  *
+
  * Hides/Shows labposts based on active filter
 +
* @return none
  */
  */
 +
function useFilters() {
function useFilters() {
if ($("#tn-active-filters-F").val() == "" && $("#tn-active-filters-T").val() == "" && $("#tn-active-filters-D").val() == "") {
if ($("#tn-active-filters-F").val() == "" && $("#tn-active-filters-T").val() == "" && $("#tn-active-filters-D").val() == "") {
Line 7: Line 9:
//Scroll through the  posts
//Scroll through the  posts
$(".tn-post").each(function() {
$(".tn-post").each(function() {
-
$(this).css("display","block");
+
$(this).css("display", "block");
});
});
Line 26: Line 28:
tags = $(this).attr("data-tag").split("-");
tags = $(this).attr("data-tag").split("-");
date = $(this).attr("data-date");
date = $(this).attr("data-date");
-
+
 
keepThis1 = true;
keepThis1 = true;
-
if($("#tn-active-filters-F").val() != "") {
+
if ($("#tn-active-filters-F").val() != "") {
//If one of the active filters is not present, hide the post
//If one of the active filters is not present, hide the post
for (var i = 0; i < Ffilters.length; i++) {
for (var i = 0; i < Ffilters.length; i++) {
-
if(facesLow.indexOf(Ffilters[i].toLowerCase()) == -1) {
+
if (facesLow.indexOf(Ffilters[i].toLowerCase()) == -1) {
keepThis1 = false;
keepThis1 = false;
}
}
}
}
}
}
-
+
 
keepThis2 = true;
keepThis2 = true;
if (Tfilter != "") {
if (Tfilter != "") {
Line 55: Line 57:
}
}
}
}
-
+
 
keepThis = false;
keepThis = false;
//Combine tags and faces filters
//Combine tags and faces filters
-
if (keepThis1 && keepThis2 && keepThis3) { keepThis = true; }
+
if (keepThis1 && keepThis2 && keepThis3) {
 +
keepThis = true;
 +
}
//Act
//Act
-
if ( !keepThis ) {
+
if (!keepThis) {
-
$(this).css("display","none");
+
$(this).css("display", "none");
} else {
} else {
-
$(this).css("display","block");
+
$(this).css("display", "block");
}
}
});
});
Line 71: Line 75:
/**
/**
-
  *
+
  * Changes border color of every image with the same source of the clicked one
 +
* @param Object parent the <a> tag containing the image
 +
* @param String color
  */
  */
-
function setBorder(parent,color) {
+
 
 +
function setBorder(parent, color) {
img = parent.children();
img = parent.children();
$("img").each(function() {
$("img").each(function() {
if ($(this).attr("src") == img.attr("src")) {
if ($(this).attr("src") == img.attr("src")) {
-
$(this).css("border","1px solid "+color);
+
$(this).css("border", "1px solid " + color);
}
}
});
});
Line 84: Line 91:
/**
/**
-
  *
+
  * Rebuilds the calendar changing the month
 +
* @param Integer yyyy
 +
* @param Integer month
 +
* @param Integer days
  */
  */
-
function setMonth(yyyy,month,days) {
+
 
 +
function setMonth(yyyy, month, days) {
//reset
//reset
$("#tn-calendar-table td").text("");
$("#tn-calendar-table td").text("");
-
$("#tn-calendar-table td").attr("data-date","");
+
$("#tn-calendar-table td").attr("data-date", "");
//Start
//Start
var days = 0;
var days = 0;
//Set  
//Set  
-
switch(month) {
+
switch (month) {
-
case 1: { $("#tn-month").text("January 2013"); days = 31; break; }
+
case 1:
-
case 2: { $("#tn-month").text("February 2013"); days = 30; break; }
+
{
-
case 3: { $("#tn-month").text("March 2013"); days = 31; break; }
+
$("#tn-month").text("January 2013");
-
case 4: { $("#tn-month").text("April 2013"); days = 30; break; }
+
days = 31;
-
case 5: { $("#tn-month").text("May 2013"); days = 31; break; }
+
break;
-
case 6: { $("#tn-month").text("June 2013"); days = 30; break; }
+
}
-
case 7: { $("#tn-month").text("July 2013"); days = 31; break; }
+
case 2:
-
case 8: { $("#tn-month").text("August 2013"); days = 31; break; }
+
{
-
case 9: { $("#tn-month").text("September 2013"); days = 30; break; }
+
$("#tn-month").text("February 2013");
-
case 10: { $("#tn-month").text("October 2013"); days = 31; break; }
+
days = 30;
-
case 11: { $("#tn-month").text("November 2013"); days = 30; break; }
+
break;
-
case 12: { $("#tn-month").text("December 2013"); days = 31; break; }
+
}
 +
case 3:
 +
{
 +
$("#tn-month").text("March 2013");
 +
days = 31;
 +
break;
 +
}
 +
case 4:
 +
{
 +
$("#tn-month").text("April 2013");
 +
days = 30;
 +
break;
 +
}
 +
case 5:
 +
{
 +
$("#tn-month").text("May 2013");
 +
days = 31;
 +
break;
 +
}
 +
case 6:
 +
{
 +
$("#tn-month").text("June 2013");
 +
days = 30;
 +
break;
 +
}
 +
case 7:
 +
{
 +
$("#tn-month").text("July 2013");
 +
days = 31;
 +
break;
 +
}
 +
case 8:
 +
{
 +
$("#tn-month").text("August 2013");
 +
days = 31;
 +
break;
 +
}
 +
case 9:
 +
{
 +
$("#tn-month").text("September 2013");
 +
days = 30;
 +
break;
 +
}
 +
case 10:
 +
{
 +
$("#tn-month").text("October 2013");
 +
days = 31;
 +
break;
 +
}
 +
case 11:
 +
{
 +
$("#tn-month").text("November 2013");
 +
days = 30;
 +
break;
 +
}
 +
case 12:
 +
{
 +
$("#tn-month").text("December 2013");
 +
days = 31;
 +
break;
 +
}
}
}
var week = 1;
var week = 1;
//$("#week-"+week+" td").get(0).text("Prova");
//$("#week-"+week+" td").get(0).text("Prova");
for (var i = 1; i <= days; i++) {
for (var i = 1; i <= days; i++) {
-
pos = new Date(yyyy, month-1, i, 0, 0, 0, 0).getDay();
+
pos = new Date(yyyy, month - 1, i, 0, 0, 0, 0).getDay();
-
$("#week-"+week+" td").eq(pos).text(i);
+
$("#week-" + week + " td").eq(pos).text(i);
-
smonth = ""+month;
+
smonth = "" + month;
-
si = ""+i;
+
si = "" + i;
-
if(smonth.length == 1) { smonth = "0" + smonth; }
+
if (smonth.length == 1) {
-
if(si.length == 1) { si = "0" + si; }
+
smonth = "0" + smonth;
-
$("#week-"+week+" td").eq(pos).attr("data-date",yyyy+"-"+smonth+"-"+si);
+
}
-
if (pos == 6) { week++; }
+
if (si.length == 1) {
 +
si = "0" + si;
 +
}
 +
$("#week-" + week + " td").eq(pos).attr("data-date", yyyy + "-" + smonth + "-" + si);
 +
if (pos == 6) {
 +
week++;
 +
}
}
}
-
$("#tn-calendar-table").attr("data-month",month);
+
$("#tn-calendar-table").attr("data-month", month);
}
}
Line 138: Line 215:
date = $(this).attr("data-date").split("-");
date = $(this).attr("data-date").split("-");
-
if (calenMap["a"+date[0]] == undefined ) {
+
if (calenMap["a" + date[0]] == undefined) {
-
calenMap["a"+date[0]] = {};
+
calenMap["a" + date[0]] = {};
-
calenMap["a"+date[0]]["m"+date[1]] = {};
+
calenMap["a" + date[0]]["m" + date[1]] = {};
-
calenMap["a"+date[0]]["m"+date[1]]["g"+date[2]] = {};
+
calenMap["a" + date[0]]["m" + date[1]]["g" + date[2]] = {};
-
calenMap["a"+date[0]]["m"+date[1]]["g"+date[2]]["s"+c] = $(this);
+
calenMap["a" + date[0]]["m" + date[1]]["g" + date[2]]["s" + c] = $(this);
} else {
} else {
-
if (calenMap["a"+date[0]]["m"+date[1]] == undefined) {
+
if (calenMap["a" + date[0]]["m" + date[1]] == undefined) {
-
calenMap["a"+date[0]]["m"+date[1]] = {};
+
calenMap["a" + date[0]]["m" + date[1]] = {};
-
calenMap["a"+date[0]]["m"+date[1]]["g"+date[2]] = {};
+
calenMap["a" + date[0]]["m" + date[1]]["g" + date[2]] = {};
-
calenMap["a"+date[0]]["m"+date[1]]["g"+date[2]]["s"+c] = $(this);
+
calenMap["a" + date[0]]["m" + date[1]]["g" + date[2]]["s" + c] = $(this);
} else {
} else {
-
if (calenMap["a"+date[0]]["m"+date[1]]["g"+date[2]] == undefined) {
+
if (calenMap["a" + date[0]]["m" + date[1]]["g" + date[2]] == undefined) {
-
calenMap["a"+date[0]]["m"+date[1]]["g"+date[2]] = {};
+
calenMap["a" + date[0]]["m" + date[1]]["g" + date[2]] = {};
-
calenMap["a"+date[0]]["m"+date[1]]["g"+date[2]]["s"+c] = $(this);
+
calenMap["a" + date[0]]["m" + date[1]]["g" + date[2]]["s" + c] = $(this);
} else {
} else {
-
calenMap["a"+date[0]]["m"+date[1]]["g"+date[2]]["s"+c] = $(this);
+
calenMap["a" + date[0]]["m" + date[1]]["g" + date[2]]["s" + c] = $(this);
}
}
}
}
Line 159: Line 236:
c++;
c++;
});
});
-
+
 
//Add posts to the page in an ordered way
//Add posts to the page in an ordered way
for (var ykey in calenMap) {
for (var ykey in calenMap) {
Line 169: Line 246:
for (var skey in day) {
for (var skey in day) {
var post = day[skey];
var post = day[skey];
-
var section = skey.replace(/\D/g,'');
+
var section = skey.replace(/\D/g, '');
$(post).parent().prependTo($("#tn-content"));
$(post).parent().prependTo($("#tn-content"));
-
$(post).append("<a href='?title=Team:UNITN-Trento/Notebook&action=edit&section="+section+"' class='tn-editpost'>Edit</a>");
+
$(post).append("<a href='?title=Team:UNITN-Trento/Notebook&action=edit&section=" + section + "' class='tn-editpost'><img src='https://static.igem.org/mediawiki/2013/0/04/Tn-20130709-edit_button.png' title='Edit' alt='Edit' /></a>");
}
}
}
}
Line 181: Line 258:
$("h2 .editsection a").each(function() {
$("h2 .editsection a").each(function() {
tempId = parseInt($(this).attr("title").split(":")[1].trim());
tempId = parseInt($(this).attr("title").split(":")[1].trim());
-
if(tempId > maxSectionId) { maxSectionId = tempId; }
+
if (tempId > maxSectionId) {
 +
maxSectionId = tempId;
 +
}
});
});
-
$("#tn-content").prepend("<a href='?title=Team:UNITN-Trento/Notebook&action=edit&section=new&preloadtitle="+(maxSectionId+1)+"'>Add new labPost</a>");
+
$("#tn-content").prepend("<a href='?title=Team:UNITN-Trento/Notebook&action=edit&section=new&preloadtitle=" + (maxSectionId + 1) + "'>Add new labPost</a>");
/***********/
/***********/
Line 194: Line 273:
if (added.indexOf($(this).text().toLowerCase().trim()) == -1) {
if (added.indexOf($(this).text().toLowerCase().trim()) == -1) {
added.push($(this).text().toLowerCase().trim());
added.push($(this).text().toLowerCase().trim());
-
$("#tn-filters-tags").append("<option value='"+$(this).text().toLowerCase().trim()+"'>"+$(this).text().toLowerCase().trim()+"</option>");
+
$("#tn-filters-tags").append("<option value='" + $(this).text().toLowerCase().trim() + "'>" + $(this).text().toLowerCase().trim() + "</option>");
}
}
});
});
Line 215: Line 294:
hidBox = $("#tn-active-filters-F");
hidBox = $("#tn-active-filters-F");
name = faceBox.attr("href");
name = faceBox.attr("href");
-
+
 
//If there is no filter active
//If there is no filter active
-
if ( hidBox.val() == "") {
+
if (hidBox.val() == "") {
//Add the current to the active filters
//Add the current to the active filters
hidBox.val(name);
hidBox.val(name);
-
setBorder(faceBox,"red");
+
setBorder(faceBox, "red");
} else {
} else {
//If there are active filters, get them
//If there are active filters, get them
Line 226: Line 305:
//If the current is not active, activate it
//If the current is not active, activate it
-
if ( arnames.indexOf(name) == -1) {
+
if (arnames.indexOf(name) == -1) {
-
hidBox.val(hidBox.val()+"-"+name);
+
hidBox.val(hidBox.val() + "-" + name);
-
setBorder(faceBox,"red");
+
setBorder(faceBox, "red");
} else {
} else {
//If the current is active, deactivate it
//If the current is active, deactivate it
-
arnames.splice(arnames.indexOf(name),1);
+
arnames.splice(arnames.indexOf(name), 1);
hidBox.val(arnames.join("-"));
hidBox.val(arnames.join("-"));
-
setBorder(faceBox,"black");
+
setBorder(faceBox, "black");
}
}
}
}
Line 248: Line 327:
//Creates the calendar
//Creates the calendar
var today = new Date();
var today = new Date();
-
var dd = today.getDate(), wd = today.getDay();
+
var dd = today.getDate(),
-
var mm = today.getMonth()+1;
+
wd = today.getDay();
 +
var mm = today.getMonth() + 1;
var yyyy = today.getFullYear();
var yyyy = today.getFullYear();
-
setMonth(yyyy,mm);
+
setMonth(yyyy, mm);
//Click
//Click
$("#tn-month-fw a").click(function(e) {
$("#tn-month-fw a").click(function(e) {
e.preventDefault();
e.preventDefault();
-
$("#tn-calendar-table td").css("border","1px solid black");
+
$("#tn-calendar-table td").css("border", "1px solid black");
-
setMonth(yyyy,parseInt($("#tn-calendar-table").attr("data-month"))+1);
+
setMonth(yyyy, parseInt($("#tn-calendar-table").attr("data-month")) + 1);
});
});
$("#tn-month-bw a").click(function(e) {
$("#tn-month-bw a").click(function(e) {
e.preventDefault();
e.preventDefault();
-
$("#tn-calendar-table td").css("border","1px solid black");
+
$("#tn-calendar-table td").css("border", "1px solid black");
-
setMonth(yyyy,parseInt($("#tn-calendar-table").attr("data-month"))-1);
+
setMonth(yyyy, parseInt($("#tn-calendar-table").attr("data-month")) - 1);
});
});
//Set link on calendar
//Set link on calendar
Line 268: Line 348:
$(this).click(function(e) {
$(this).click(function(e) {
e.preventDefault();
e.preventDefault();
-
$("#tn-calendar-table td").css("border","1px solid black");
+
$("#tn-calendar-table td").css("border", "1px solid black");
if ($("#tn-active-filters-D").val() == $(this).attr("data-date")) {
if ($("#tn-active-filters-D").val() == $(this).attr("data-date")) {
$("#tn-active-filters-D").val("");
$("#tn-active-filters-D").val("");
} else {
} else {
-
$(this).css("border","1px solid red");
+
$(this).css("border", "1px solid red");
$("#tn-active-filters-D").val($(this).attr("data-date"));
$("#tn-active-filters-D").val($(this).attr("data-date"));
}
}
Line 282: Line 362:
/**SCROLL TO POST BASED ON HASH**/
/**SCROLL TO POST BASED ON HASH**/
-
$("html,body").scrollTo(document.location.hash.replace("#",""),document.location.hash.replace("#",""));
+
$("html,body").scrollTo(document.location.hash.replace("#", ""), document.location.hash.replace("#", ""));
});
});
//When hash changes, scroll to correct div
//When hash changes, scroll to correct div
oHch(function() {
oHch(function() {
-
$("html,body").scrollTo(document.location.hash.replace("#",""),document.location.hash.replace("#",""));
+
$("html,body").scrollTo(document.location.hash.replace("#", ""), document.location.hash.replace("#", ""));
});
});

Revision as of 09:31, 9 July 2013

/**

* Hides/Shows labposts based on active filter
* @return none
*/

function useFilters() { if ($("#tn-active-filters-F").val() == "" && $("#tn-active-filters-T").val() == "" && $("#tn-active-filters-D").val() == "") {

//Scroll through the posts $(".tn-post").each(function() { $(this).css("display", "block"); });

} else {

//Get active filters Ffilters = $("#tn-active-filters-F").val().split("-"); Tfilter = $("#tn-active-filters-T").val(); Dfilter = $("#tn-active-filters-D").val();

//Scroll through the posts $(".tn-post").each(function() { faces = $(this).attr("data-user").split("-"); facesLow = []; for (var i = 0; i < faces.length; i++) { facesLow.push(faces[i].toLowerCase()); } tags = $(this).attr("data-tag").split("-"); date = $(this).attr("data-date");

keepThis1 = true; if ($("#tn-active-filters-F").val() != "") { //If one of the active filters is not present, hide the post for (var i = 0; i < Ffilters.length; i++) { if (facesLow.indexOf(Ffilters[i].toLowerCase()) == -1) { keepThis1 = false; } } }

keepThis2 = true; if (Tfilter != "") { keepThis2 = false; //If the active tag filter is not present, hide the post for (var k = 0; k < tags.length; k++) { if (tags[k].toLowerCase().trim() === Tfilter && !keepThis2) { keepThis2 = true; } } }

keepThis3 = true; if (Dfilter != "") { keepThis3 = false; if (date == Dfilter) { keepThis3 = true; } }

keepThis = false; //Combine tags and faces filters if (keepThis1 && keepThis2 && keepThis3) { keepThis = true; }

//Act if (!keepThis) { $(this).css("display", "none"); } else { $(this).css("display", "block"); } }); } }

/**

* Changes border color of every image with the same source of the clicked one
* @param Object parent the <a> tag containing the image
* @param String color
*/

function setBorder(parent, color) { img = parent.children();

$("img").each(function() { if ($(this).attr("src") == img.attr("src")) { $(this).css("border", "1px solid " + color); } }); }

/**

* Rebuilds the calendar changing the month
* @param Integer yyyy
* @param Integer month
* @param Integer days
*/

function setMonth(yyyy, month, days) { //reset $("#tn-calendar-table td").text(""); $("#tn-calendar-table td").attr("data-date", "");

//Start var days = 0; //Set switch (month) { case 1: { $("#tn-month").text("January 2013"); days = 31; break; } case 2: { $("#tn-month").text("February 2013"); days = 30; break; } case 3: { $("#tn-month").text("March 2013"); days = 31; break; } case 4: { $("#tn-month").text("April 2013"); days = 30; break; } case 5: { $("#tn-month").text("May 2013"); days = 31; break; } case 6: { $("#tn-month").text("June 2013"); days = 30; break; } case 7: { $("#tn-month").text("July 2013"); days = 31; break; } case 8: { $("#tn-month").text("August 2013"); days = 31; break; } case 9: { $("#tn-month").text("September 2013"); days = 30; break; } case 10: { $("#tn-month").text("October 2013"); days = 31; break; } case 11: { $("#tn-month").text("November 2013"); days = 30; break; } case 12: { $("#tn-month").text("December 2013"); days = 31; break; } } var week = 1; //$("#week-"+week+" td").get(0).text("Prova"); for (var i = 1; i <= days; i++) { pos = new Date(yyyy, month - 1, i, 0, 0, 0, 0).getDay(); $("#week-" + week + " td").eq(pos).text(i); smonth = "" + month; si = "" + i; if (smonth.length == 1) { smonth = "0" + smonth; } if (si.length == 1) { si = "0" + si; } $("#week-" + week + " td").eq(pos).attr("data-date", yyyy + "-" + smonth + "-" + si); if (pos == 6) { week++; } } $("#tn-calendar-table").attr("data-month", month); }

//Acts when the document is loaded $(document).ready(function() {

/**************************************/ /**GET THE POSTs BACK IN THE TEMPLATE**/ /**************************************/

var c = 1; var calenMap = {};

//Iterate through all posts and order them $(".tn-post").each(function() { //Get post date date = $(this).attr("data-date").split("-");

if (calenMap["a" + date[0]] == undefined) { calenMap["a" + date[0]] = {}; calenMap["a" + date[0]]["m" + date[1]] = {}; calenMap["a" + date[0]]["m" + date[1]]["g" + date[2]] = {}; calenMap["a" + date[0]]["m" + date[1]]["g" + date[2]]["s" + c] = $(this); } else { if (calenMap["a" + date[0]]["m" + date[1]] == undefined) { calenMap["a" + date[0]]["m" + date[1]] = {}; calenMap["a" + date[0]]["m" + date[1]]["g" + date[2]] = {}; calenMap["a" + date[0]]["m" + date[1]]["g" + date[2]]["s" + c] = $(this); } else { if (calenMap["a" + date[0]]["m" + date[1]]["g" + date[2]] == undefined) { calenMap["a" + date[0]]["m" + date[1]]["g" + date[2]] = {}; calenMap["a" + date[0]]["m" + date[1]]["g" + date[2]]["s" + c] = $(this); } else { calenMap["a" + date[0]]["m" + date[1]]["g" + date[2]]["s" + c] = $(this); } } } c++; });

//Add posts to the page in an ordered way for (var ykey in calenMap) { var year = calenMap[ykey]; for (var mkey in year) { var month = year[mkey]; for (var dkey in month) { var day = month[dkey]; for (var skey in day) { var post = day[skey]; var section = skey.replace(/\D/g, ); $(post).parent().prependTo($("#tn-content")); $(post).append("<a href='?title=Team:UNITN-Trento/Notebook&action=edit&section=" + section + "' class='tn-editpost'><img src='https://static.igem.org/mediawiki/2013/0/04/Tn-20130709-edit_button.png' title='Edit' alt='Edit' /></a>"); } } } }

//"Add Post" Link var maxSectionId = 0; $("h2 .editsection a").each(function() { tempId = parseInt($(this).attr("title").split(":")[1].trim()); if (tempId > maxSectionId) { maxSectionId = tempId; } }); $("#tn-content").prepend("<a href='?title=Team:UNITN-Trento/Notebook&action=edit&section=new&preloadtitle=" + (maxSectionId + 1) + "'>Add new labPost</a>");

/***********/ /**FILTERS**/ /***********/

//Add tags to the select filter option var added = []; $(".tag").each(function() { if (added.indexOf($(this).text().toLowerCase().trim()) == -1) { added.push($(this).text().toLowerCase().trim()); $("#tn-filters-tags").append("<option value='" + $(this).text().toLowerCase().trim() + "'>" + $(this).text().toLowerCase().trim() + "</option>"); } }); //Set TAGS filters $("#tn-filters-tags").change(function(e) { e.preventDefault(); $("#tn-active-filters-T").val($("#tn-filters-tags").val()); //Apply active filters useFilters(); });

//Select all the FACES filters $(".faces").each(function() { //Set the click event $(this).click(function(e) { //Rewrite default e.preventDefault();

faceBox = $(this); hidBox = $("#tn-active-filters-F"); name = faceBox.attr("href");

//If there is no filter active if (hidBox.val() == "") { //Add the current to the active filters hidBox.val(name); setBorder(faceBox, "red"); } else { //If there are active filters, get them arnames = hidBox.val().split("-");

//If the current is not active, activate it if (arnames.indexOf(name) == -1) { hidBox.val(hidBox.val() + "-" + name); setBorder(faceBox, "red"); } else { //If the current is active, deactivate it arnames.splice(arnames.indexOf(name), 1); hidBox.val(arnames.join("-")); setBorder(faceBox, "black"); } }

//Apply active filters useFilters(); }); });

/**********/ /*CALENDAR*/ /**********/

//Creates the calendar var today = new Date(); var dd = today.getDate(), wd = today.getDay(); var mm = today.getMonth() + 1; var yyyy = today.getFullYear(); setMonth(yyyy, mm);

//Click $("#tn-month-fw a").click(function(e) { e.preventDefault(); $("#tn-calendar-table td").css("border", "1px solid black"); setMonth(yyyy, parseInt($("#tn-calendar-table").attr("data-month")) + 1); }); $("#tn-month-bw a").click(function(e) { e.preventDefault(); $("#tn-calendar-table td").css("border", "1px solid black"); setMonth(yyyy, parseInt($("#tn-calendar-table").attr("data-month")) - 1); }); //Set link on calendar $("#tn-calendar-table td").each(function() { $(this).click(function(e) { e.preventDefault(); $("#tn-calendar-table td").css("border", "1px solid black"); if ($("#tn-active-filters-D").val() == $(this).attr("data-date")) { $("#tn-active-filters-D").val(""); } else { $(this).css("border", "1px solid red"); $("#tn-active-filters-D").val($(this).attr("data-date")); }

//Apply active filters useFilters(); }); });

/**SCROLL TO POST BASED ON HASH**/ $("html,body").scrollTo(document.location.hash.replace("#", ""), document.location.hash.replace("#", "")); });

//When hash changes, scroll to correct div oHch(function() { $("html,body").scrollTo(document.location.hash.replace("#", ""), document.location.hash.replace("#", "")); });