I'm not sure how safe this is considering I essentially hijack the AJAX request, but I realized I needed to find a way to drive this whenever the AJAX call was made to load a new month. Otherwise the changes are applied to your current month and the new month it loads is ignored. (And it seems to be working alright.) This is a bit more long winded and isn't necessarily for the feint of heart if you're really new to code.
This first part goes in the header above any EPC includes.
Javascript
:
Code:
var xmlhttp;
try {
xmlhttp = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {}
window.onload=function() {
IEFirstLast();
}
function IEFirstLast() {
/*@cc_on
@if (@_jscript_version <= 5.7)
rows = getElementsByClass('rows');
for (var i = 0; i < rows.length; i++) {
row = rows[i].getElementsByTagName('td');
n = row.length - 1;
row[n].className += ' lastchild';
row[0].className += ' firstchild';
}
@end@*/
}
function AJAXFirstLast() {
if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
IEFirstLast();
}
}
The first part instantiates the necessary AJAX object globally so we can have access to it. IEFirstLast() is just a modification of the original function with conditional statements built inside the function instead of around it. (This is so non-IE browsers can openly call this method later and not be left wondering where their function disappeared to.) The last function is the event listener for the IEFirstLast function that's added onto EPC's default event handler. Its only purpose is to call IEFirstLast() when the time is right.
This next part goes inside the header too, but below any EPC includes.
Javascript
:
Code:
function addListener() {
xmlhttp.onreadystatechange = function() {
triggered();
AJAXFirstLast();
}
}
This is our 'hijacking' function, when it gets called it overwrites the original event handler with a function that calls both our handler, and the default handler.
This next bit uses a tweak from elsewhere on this site that involves overwriting the original navigation menu. Seen here:
http://www.easyphpcalendar.com/forum...90&postcount=3
What we'll be doing is adding onto the "left" and "right" navigation links.
HTML/Javascript
:
Code:
<td width="30" align="left"><a onclick="loadurl('../calendar/calendar.php','1'); addListener(); IEFirstLast();" href="javascript: void(0);" class="customNavTableText"><?php echo $navLeft; ?></a></td>
<!-- main calendar link is here -->
<td width="30" align="right"><a onclick="loadurl('../calendar/calendar.php','3'); addListener(); IEFirstLast();" href="javascript: void(0);" class="customNavTableText"><?php echo $navRight; ?></a></td>
Remember, this is built within the framework of the linked post above, and will not work properly without those changes implemented. The important bits here are the 'addListener(); IEFirstLast();' functions that were added to the onclick attribute. addListener() overwrites the original event handler whenever an ajax call is made from these links, and IEFirstLast() is duplicated here for when IE tries to cache its AJAX requests. (When it uses a cached copy the AJAX call doesn't fire off, which in turn doesn't automatically call IEFirstLast().)
I think that's it... I also have some tweaks I made regarding AJAX and a click through mini calendar that directs you to the right month, but right now the VP debate's starting.