<div id=”divCalendarItem”
style=”cursor:default; position: absolute; z-index: auto; top: 360px; left: 230px;
visibility:hidden; width:350px;” onmousemove=”ContinueToShowCalItemDetails()” onmouseout=”HideCalItemDetails()”>
<table style=”background-color:transparent; width:100%; table-layout:fixed;”>
<tr>
<td width=”100%” align=”right”>
<p style=”cursor:pointer; color:Red; font-weight: bolder; font-size: 16px;” onclick=”HideDiv()”>X </p>
</td>
</tr>
<tr>
<td id=”tdCalendarItemDetails” width=”100%” valign=”top” style=”text-align:left”>
</td>
</tr>
</table>
</div>
<script>
function getObjInnerText (obj)
{
try
{
return (obj.innerText) ? obj.innerText : (obj.textContent) ? obj.textContent : “”;
}
catch(err)
{
return “”;
}
}
// Removes leading whitespaces
function LTrim( value ) {
var re = /\s*((\S+\s*)*)/;
return value.replace(re, “$1”);
}
// Removes ending whitespaces
function RTrim( value ) {
var re = /((\s*\S+)*)\s*/;
return value.replace(re, “$1”);
}
// Removes leading and ending whitespaces
function trim( value ) {
return LTrim(RTrim(value));
}
//Main code Starts…
var cal_TD_ID1 = “ms-cal-defaultbgcolor”;
var cal_TD_ID2 = “ms-cal-monthitem”;
var nodes, category, onmouseoverEvent;
var calItemDiv = “divCalendarItem”;
var calItemTD= “tdCalendarItemDetails”;
var divWidth = 300, divHeight = 150, descriptionLength = 150, timeInterval = 1000;
var xPos, yPos;
var timerObj;
// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false;
// If NS — that is, !IE — then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)
// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;
nodes = document.getElementsByTagName(“td”);
for(var i = 0; i < nodes.length; i++)
{
if(nodes[i].className == cal_TD_ID1 || nodes[i].className == cal_TD_ID2)
{
AddNodeEvent(nodes[i]);
}
}
//Main code Ends.
function getMouseXY(e)
{
if (IE)
{
// grab the x-y pos.s if browser is IE
xPos = event.clientX + document.body.scrollLeft
yPos = event.clientY + document.body.scrollTop
}
else
{
// grab the x-y pos.s if browser is NS
xPos = e.pageX
yPos = e.pageY
}
return true
}
function AddNodeEvent(node)
{
try
{
if(navigator.appName == “Microsoft Internet Explorer”)
{
node.attachEvent(“onmouseover”,ShowCalItemDetails);
node.attachEvent(“onmouseout”,HideCalItemDetails);
}
else
{
node.addEventListener(“mouseover”,ShowCalItemDetails,false);
node.addEventListener(“mouseout”,HideCalItemDetails,false);
}
}
catch(err)
{}
}
function GetItemID(srcNode)
{
var itemURL = “0”;
var pattern = /ID=/i;
try
{
for(var i = 0; i < srcNode.childNodes.length; i++)
{
try
{
if(srcNode.childNodes[i].href.match(pattern))
{
itemURL = srcNode.childNodes[i].href;
return itemURL;
}
}
catch(err)
{ itemURL = “0”; }
}
}
catch(err)
{}
if(itemURL == “0”)
{
try
{
if(srcNode.href.match(pattern))
itemURL = srcNode.href;
}
catch(err)
{ itemURL = “0”; }
}
if(itemURL == “0”)
{
try
{
if(srcNode.parentNode.href.match(pattern))
itemURL = srcNode.parentNode.href;
}
catch(err)
{ itemURL = “0”; }
}
if(itemURL == “0”)
{
try
{
if(srcNode.parentNode.parentNode.href.match(pattern))
itemURL = srcNode.parentNode.parentNode.href;
}
catch(err)
{ itemURL = “0”; }
}
return itemURL;
}
function ShowCalItemDetails(evtSource)
{
var itemURL = “0”;
try
{
if(navigator.appName == “Microsoft Internet Explorer”)
itemURL = GetItemID(evtSource.srcElement);
else
itemURL = GetItemID(evtSource.target);
}
catch(err)
{}
if(itemURL == “0”)
{
HideCalItemDetails()
return false;
}
var webURL, listName, itemID, soapEnvelope;
var arr1, arr2, arr3;
arr1 = itemURL.split(“/Lists/”);
webURL = arr1[0];
arr2 = arr1[1].split(“/”);
listName = arr2[0];
arr3 = arr2[arr2.length – 1].split(“?ID=”);
itemID = arr3[arr3.length -1];
soapEnvelope = GetFullSOAPEnvelope(GetSOAPRequest(listName, itemID));
var httpRequest = null;
if (!httpRequest) httpRequest=GetHTTPObject();
httpRequest.onreadystatechange=function()
{
if (httpRequest.readyState==4)
DisplayCalendarItemDetail(httpRequest.responseText, itemURL);
else if (httpRequest.readyState == 4 && httpRequest.status != 200)
HideDiv();
}
httpRequest.open(“POST”, webURL + “/_vti_bin/Lists.asmx?op=GetListItems”,true);
httpRequest.setRequestHeader(“Content-Type”,”text/xml; charset=utf-8″);
httpRequest.setRequestHeader(“SOAPAction”,”http://schemas.microsoft.com/sharepoint/soap/GetListItems“);
httpRequest.setRequestHeader(“Content-Length”, soapEnvelope.length);
httpRequest.send(soapEnvelope);
clearTimeout(timerObj);
}
function DisplayCalendarItemDetail(responseXML, itemURL)
{
var xmlDoc;
if (window.DOMParser)
{
parser=new DOMParser();
xmlDoc=parser.parseFromString(responseXML,”text/xml”);
}
else // Internet Explorer
{
xmlDoc=new ActiveXObject(“Microsoft.XMLDOM”);
xmlDoc.async=”false”;
xmlDoc.loadXML(responseXML);
}
var title = null, location = null, eventDate = null, endDate = null, description = null, allDayEvent = null;
try{ title = xmlDoc.getElementsByTagName(“z:row”)[0].attributes.getNamedItem(“ows_Title”).value; }
catch(err){ title = null; }
try{ location = xmlDoc.getElementsByTagName(“z:row”)[0].attributes.getNamedItem(“ows_Location”).value; }
catch(err){ location = null; }
try{ eventDate = xmlDoc.getElementsByTagName(“z:row”)[0].attributes.getNamedItem(“ows_EventDate”).value; }
catch(err){ eventDate = null; }
try{ endDate = xmlDoc.getElementsByTagName(“z:row”)[0].attributes.getNamedItem(“ows_EndDate”).value; }
catch(err){ endDate = null; }
try{ description = xmlDoc.getElementsByTagName(“z:row”)[0].attributes.getNamedItem(“ows_Description”).value; }
catch(err){ description = null; }
try{ allDayEvent = xmlDoc.getElementsByTagName(“z:row”)[0].attributes.getNamedItem(“ows_fAllDayEvent”).value; }
catch(err){ allDayEvent = null; }
var resultHTML = ‘<table style=”background-color:transparent; width:100%; word-wrap:break-word”>’;
if(title != null)
resultHTML = AddTableRow(resultHTML, ‘Title:’, ‘<a style=”font-weight:bold” href=”‘ + itemURL + ‘”>’ + title + ‘</a>’);
if(location != null)
resultHTML = AddTableRow(resultHTML, ‘Location:’, location);
resultHTML = AddTableRow(resultHTML, ‘Date:’, GetDate(eventDate) + ‘ – ‘ + GetDate(endDate));
if(allDayEvent == “0”)
{
resultHTML = AddTableRow(resultHTML, ‘Time:’, GetTime(eventDate) + ‘ – ‘ + GetTime(endDate));
}
else
resultHTML = AddTableRow(resultHTML, ‘All Day Event:’, ‘Yes’);
if(description != null)
{
//Removing the top level div tag
description = description.substring(5, description.length);
description = description.substring(0, description.length-6);
description = trim(description);
if(description.length > 0)
if(description.length > descriptionLength)
resultHTML = AddTableRow(resultHTML, ‘Description:’, description.substring(0, descriptionLength) + ‘…’);
else
resultHTML = AddTableRow(resultHTML, ‘Description:’, description);
}
resultHTML += ‘<tr><td><br/></td><td><br/></td></tr></table>’;
document.getElementById(calItemTD).innerHTML = resultHTML;
var itemDiv = document.getElementById(calItemDiv);
var clientWidth = document.body.clientWidth;
var clientHeight = document.body.clientHeight;
xPos = xPos + 10; yPos = yPos + 10;
try
{
if((xPos + divWidth) > clientWidth)
xPos = xPos – ((xPos + divWidth) – clientWidth);
if((yPos + divHeight) > clientHeight)
yPos = yPos – (divHeight + 30);
}
catch(err){}
itemDiv.style.left = xPos + “px”;
itemDiv.style.top = yPos + “px”;
itemDiv.style.width = divWidth + “px”;
//itemDiv.style.height = divHeight + “px”;
itemDiv.style.visibility = “visible”;
}
function GetDate(datetime)
{
var dateArr, arr;
arr = datetime.split(” “);
dateArr = arr[0].split(“-“);
return dateArr[1] + ‘/’ + dateArr[2] + ‘/’ + dateArr[0];
}
function GetTime(datetime)
{
var timeArr, arr, hours, minutes, amORpm;
arr = datetime.split(” “);
dateArr = arr[1].split(“:”);
hours = dateArr[0];
minutes = dateArr[1];
if (minutes < 10){
minutes = “0” + minutes
}
if(hours > 11)
amORpm = “PM”;
else
amORpm = “AM”;
if(hours > 12)
hours -= 12;
return hours + “:” + minutes + ” ” + amORpm;
}
function AddTableRow(resultHTML, field, value)
{
resultHTML += ‘<tr>’
+ ‘<td style=”white-space:nowrap;” valign=”top”>’ + field + ‘</td>’
+ ‘<td style=”word-wrap:break-word; width:75%; font-weight:normal” valign=”top”>’ + value + ‘</td>’
+ ‘</tr>’;
return resultHTML;
}
function ContinueToShowCalItemDetails()
{
ShowDiv();
clearTimeout(timerObj);
}
function HideCalItemDetails()
{
timerObj = setTimeout(HideDiv, timeInterval);
}
function ShowDiv()
{
document.getElementById(calItemDiv).style.visibility = “visible”;
}
function HideDiv()
{
document.getElementById(calItemTD).innerHTML = “”;
document.getElementById(calItemDiv).style.visibility = “hidden”;
clearTimeout(timerObj);
}
function GetSOAPRequest(listName, itemID)
{
var soapRequest = ‘<soap:GetListItems>’
+ ‘<soap:listName>’ + listName + ‘</soap:listName>’
+ ‘<soap:viewName />’
+ ‘<soap:query>’
+ ‘<Query>’
+ ‘<Where>’
+ ‘<Eq>’
+ ‘<FieldRef Name=”ID” />’
+ ‘<Value Type=”Number”>’ + itemID + ‘</Value>’
+ ‘</Eq>’
+ ‘</Where>’
+ ‘</Query>’
+ ‘</soap:query>’
+ ‘<soap:viewFields>’
+ ‘<ViewFields>’
+ ‘<FieldRef Name=”ID” />’
+ ‘<FieldRef Name=”Title” />’
+ ‘<FieldRef Name=”Location” />’
+ ‘<FieldRef Name=”EventDate” />’
+ ‘<FieldRef Name=”EndDate” />’
+ ‘<FieldRef Name=”Description” />’
+ ‘</ViewFields>’
+ ‘</soap:viewFields>’
+ ‘<soap:rowLimit>1</soap:rowLimit>’
+ ‘<soap:queryOptions>’
+ ‘<QueryOptions>’
+ ‘<IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns>’
+ ‘<DateInUtc>FALSE</DateInUtc>’
+ ‘</QueryOptions>’
+ ‘</soap:queryOptions>’
+ ‘<soap:webID />’
+ ‘</soap:GetListItems>’;
return soapRequest;
}
function GetFullSOAPEnvelope(soapRequest)
{
var soapPrefix = ‘<soapenv:Envelope xmlns:soapenv=”http://schemas.xmlsoap.org/soap/envelope/” xmlns:soap=”http://schemas.microsoft.com/sharepoint/soap/”>’
+ ‘<soapenv:Header/>’
+ ‘<soapenv:Body>’;
var soapPostfix = ‘</soapenv:Body>’
+ ‘</soapenv:Envelope>’;
return soapPrefix + soapRequest + soapPostfix;
}
function GetHTTPObject()
{
var httpobj;
if(window.XMLHttpRequest)
{
try { httpobj= new XMLHttpRequest(); }
catch(e) { httpobj= null; }
}
else if(window.ActiveXObject)
{
try { httpobj= new ActiveXObject(“Msxml2.XMLHTTP”); }
catch(e)
{
try { httpobj= new ActiveXObject(“Microsoft.XMLHTTP”); }
catch(e) { httpobj= null; }
}
}
return httpobj;
}
</script>
Filed under: Uncategorized | 1 Comment »