|
|
@ -37,7 +37,7 @@ $(document).ready(function() {
|
|
|
|
|
|
|
|
|
|
|
|
var newHistory = '<div class="event-wrapper">';
|
|
|
|
var newHistory = '<div class="event-wrapper">';
|
|
|
|
for (var i = 0; i < eventHistory.length; i++) {
|
|
|
|
for (var i = 0; i < eventHistory.length; i++) {
|
|
|
|
var dateString = (new Date(eventHistory[i].time*1000)).toLocaleString();
|
|
|
|
var dateString = (new Date(eventHistory[i].time*1000)).toLocaleString('sv-SE');
|
|
|
|
var newElement = '<div class="event" card-id="' + eventHistory[i].cardID + '">\
|
|
|
|
var newElement = '<div class="event" card-id="' + eventHistory[i].cardID + '">\
|
|
|
|
<div class="time">' + dateString + '</div>\
|
|
|
|
<div class="time">' + dateString + '</div>\
|
|
|
|
<div class="name">';
|
|
|
|
<div class="name">';
|
|
|
@ -77,25 +77,42 @@ $(document).ready(function() {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$('.search-bar').on('keyup', function() {
|
|
|
|
$('.search-bar').on('keyup', function() {
|
|
|
|
var newHistory = '<div class="event-wrapper">';
|
|
|
|
var newHistory = '<div class="event-wrapper">';
|
|
|
|
|
|
|
|
var args = $('.search-bar').val().split(' ');
|
|
|
|
|
|
|
|
var toMatch = [-1,-1,-1];
|
|
|
|
|
|
|
|
var nameToMatch = '';
|
|
|
|
|
|
|
|
for (var j = 0; j < args.length; j++) {
|
|
|
|
|
|
|
|
if(args[j].charAt(0) == '-') {
|
|
|
|
|
|
|
|
switch(args[j].charAt(1)) {
|
|
|
|
|
|
|
|
case 'y':
|
|
|
|
|
|
|
|
toMatch[0] = parseInt(args[j].substring(2));
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'm':
|
|
|
|
|
|
|
|
toMatch[1] = parseInt(args[j].substring(2));
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'd':
|
|
|
|
|
|
|
|
toMatch[2] = parseInt(args[j].substring(2));
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
nameToMatch += args[j] + ' ';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
nameToMatch = nameToMatch.substring(0, nameToMatch.length - 1);
|
|
|
|
for (var i = 0; i < eventHistory.length; i++) {
|
|
|
|
for (var i = 0; i < eventHistory.length; i++) {
|
|
|
|
|
|
|
|
var dateMatch = true;
|
|
|
|
var eventDate = new Date(eventHistory[i].time*1000);
|
|
|
|
var eventDate = new Date(eventHistory[i].time*1000);
|
|
|
|
var mdy = $('.search-bar').val().split('/');
|
|
|
|
if (toMatch[0] > 0)
|
|
|
|
var dateMatch = false;
|
|
|
|
dateMatch = dateMatch && (toMatch[0] == eventDate.getFullYear());
|
|
|
|
switch(mdy.length) {
|
|
|
|
if (toMatch[1] > 0)
|
|
|
|
case 1:
|
|
|
|
dateMatch = dateMatch && (toMatch[1] == (eventDate.getMonth() + 1));
|
|
|
|
dateMatch = parseInt(mdy[0])==(eventDate.getMonth()+1);
|
|
|
|
if (toMatch[2] > 0)
|
|
|
|
break;
|
|
|
|
dateMatch = dateMatch && (toMatch[2] == eventDate.getDate());
|
|
|
|
case 2:
|
|
|
|
/*if (toMatch[0]<0 && toMatch[1]<0 && toMatch[2]<0)
|
|
|
|
dateMatch = (parseInt(mdy[0])==(eventDate.getMonth()+1)) && (parseInt(mdy[1])==eventDate.getDate());
|
|
|
|
dateMatch = false;*/
|
|
|
|
break;
|
|
|
|
if ((eventHistory[i].name.match(nameToMatch) != null) && dateMatch) {
|
|
|
|
case 3:
|
|
|
|
var dateString = eventDate.toLocaleString('sv-SE');
|
|
|
|
dateMatch = (parseInt(mdy[0])==(eventDate.getMonth()+1)) && (parseInt(mdy[1])==eventDate.getDate()) && (parseInt(mdy[2])==eventDate.getFullYear());
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (eventHistory[i].name.match($('.search-bar').val()) || dateMatch) {
|
|
|
|
|
|
|
|
var dateString = eventDate.toLocaleString();
|
|
|
|
|
|
|
|
var newElement = '<div class="event" card-id="' + eventHistory[i].cardID + '">\
|
|
|
|
var newElement = '<div class="event" card-id="' + eventHistory[i].cardID + '">\
|
|
|
|
<div class="time">' + dateString + '</div>\
|
|
|
|
<div class="time">' + dateString + '</div>\
|
|
|
|
<div class="name">';
|
|
|
|
<div class="name">';
|
|
|
|