debugging-night part 1

This commit is contained in:
Steffen Vogel 2010-10-01 23:06:40 +02:00
parent 95fb4f0b71
commit fd4d4cfcc0
2 changed files with 34 additions and 6 deletions

View file

@ -82,6 +82,34 @@ function showChart() {
});
}
/*
* Cookie & UUID related functions
*/
function getUUIDs() {
if ($.getCookie('uuids')) {
return JSON.parse($.getCookie('uuids'));
}
else {
return new Array;
}
}
function addUUID(uuid) {
if (!uuids.contains(uuid)) {
uuids.push(uuid);
$.setCookie('uuids', JSON.stringify(uuids));
}
}
function removeUUID(uuid) {
if (uuids.contains(uuid)) {
uuids.filter(function(value) {
return value != uuid;
});
$.setCookie('uuids', JSON.stringify(uuids));
}
}
/*
* Entity list related functions
*/
@ -128,7 +156,7 @@ function showEntities() {
.attr('type', 'image')
.attr('src', 'images/delete.png')
.attr('alt', 'delete')
.bind('click', entity, function(event) { alert('delete: ' + event.data.uuid); })
.bind('click', entity, function(event) { removeUUID(event.data.uuid); })
)
)
.append($('<td>')

View file

@ -91,14 +91,14 @@ var myWindowStart = myWindowEnd - 24*60*60*1000;
// executed on document loaded complete
// this is where it all starts...
$(document).ready(function() {
// parse uuids from cookie and url
// parse uuids from cookie
uuids = getUUIDs();
var uuid;
if($.getUrlVar('uuid') && !uuids.contains($.getUrlVar('uuid'))) {
uuids.push($.getUrlVar('uuid'));
$.setCookie('uuids', JSON.stringify(uuids));
// add optional uuid from url
if($.getUrlVar('uuid')) {
addUUID($.getUrlVar('uuid'));
}
console.log('cookie uuids', uuids);
// start auto refresh timer
window.setInterval(refreshWindow, 5000);