1// ========================================
2/* highlight day and cities in table according the event under the mouse */
3function scheduleHighlightEvent (day, locations) {
4    jQuery ('div.cityBubble div.bubble').each (function () {
5	jQuery (this).hide ();
6    });
7    scheduleHighlightPOI (locations);
8    jQuery ('div.schedule table.short div.mapSelect').each (function () {
9	var showDay = jQuery (this);
10	var today = showDay.attr ('day');
11	if (day && today == day)
12	    showDay.show ();
13	else
14	    showDay.hide ();
15    });
16}
17
18// ========================================
19/* highlight all days in table according the city under the mouse */
20function scheduleHighlightDays (targetLocations) {
21    jQuery ('div.cityBubble div.bubble').each (function () {
22	jQuery (this).hide ();
23    });
24    if (!targetLocations || !targetLocations.length) {
25	jQuery ('div.schedule table.short div.mapSelect').hide ();
26	return;
27    }
28    targetLocations.forEach (function (location) {
29	jQuery ('div.cityBubble[location="'+location+'"] div.bubble').each (function () {
30	    jQuery (this).show ();
31	});
32    });
33    jQuery ('div.schedule table.short div.mapSelect').each (function () {
34	var showDay = jQuery (this);
35	var eventLocations = showDay.attr ('locations');
36	if (!eventLocations) {
37	    showDay.hide ();
38	    return;
39	}
40	var doShow = false;
41	targetLocations.forEach (function (location) {
42	    if ((','+eventLocations+',').indexOf (location) >= 0) {
43		doShow = true;
44		return;
45	    }
46	});
47	if (doShow)
48	    showDay.show ();
49	else
50	    showDay.hide ();
51    });
52}
53
54var scheduleMapList;
55
56// ========================================
57/* highlight all cities on the map according the day under the mouse */
58function scheduleHighlightPOI (locations) {
59    if (!locations) {
60	jQuery ('div.schedule table.short div.mapSelect').hide ();
61	jQuery.each (scheduleMapList, function (mapId, scheduleMap) {
62	    scheduleMap.poi.forEachFeature (function (item) {
63		item.set ('selected', false);
64	    });
65	    scheduleMap.poi.changed ();
66	    scheduleMap.map.render ();
67	});
68	return;
69    }
70    jQuery.each (scheduleMapList, function (mapId, scheduleMap) {
71	var changed = false;
72	scheduleMap.poi.forEachFeature (function (item) {
73	    var location = item.get ('location');
74	    item.set ('selected', (location && (','+locations).indexOf (location) >= 0));
75	});
76	scheduleMap.poi.changed ();
77	scheduleMap.map.render ();
78    });
79}
80// ========================================
81function scheduleChangeDate (obj, ns, mapId, date) {
82    var table = jQuery (obj).closest ("table")[0];
83    scheduleSend (table,
84		  DOKU_BASE+"lib/plugins/schedule/ajax.php",
85		  "schd[ns]="+ns+"&schd[mapId]="+mapId+"&schd[action]=changeDate&schd[date]="+date);
86}
87
88// ========================================
89function scheduleSelectDate (date) {
90    jQuery ("#scheduleFrom").val (date);
91}
92
93// ========================================
94