Tuesday, August 17, 2010

HOW TO Display table with images/rollovers based on a backend SharePoint List data using HTML/jQuery

The code below shows how to display a table (containing images/rollovers). The data that is displayed in the table, is retrieved from a backend SharePoint List. It uses jQuery and HTML to render the table.

 

Embed the entire code in a Content Editor Web Part.

 

 

<link href="http://intranet.na.kraft.com/sites/TC/jQuery/AltToTravel.css" rel="stylesheet"

type="text/css"/>

 

 

<script type="text/javascript"

src="http://intranet.na.kraft.com/sites/TC/jQuery/jquery-1.3.2.min.js"></script>

 

 

 

<script type="text/javascript">

    

    //$(document).ready(function() {

  $(window).load(function() {

 

        var costSoapEnv =

            "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \

                <soapenv:Body> \

                     <GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \

                        <listName>Travel and Collaboration Tools Cost</listName> \

                  <viewFields> \

                            <ViewFields> \

                              <FieldRef Name='Typical_x0020_domestic_x0020_tra' /> \

                              <FieldRef Name='Typical_x0020_international_x002' /> \

                              <FieldRef Name='Most_x0020_Collaboration_x0020_T' /> \

                              <FieldRef Name='B2B_x0020_TelePresence_x0020_too' /> \

                            </ViewFields> \

                        </viewFields> \

                    </GetListItems> \

                </soapenv:Body> \

            </soapenv:Envelope>";

 

 

//alert("Soap = " + costSoapEnv);

        $.ajax({

            url: "http://intranet.na.kraft.com/sites/TC/plantrip/_vti_bin/lists.asmx",

            type: "POST",

            dataType: "xml",

            data: costSoapEnv,

            complete: buildTravelCostsChart,

            contentType: "text/xml; charset=\"utf-8\""

        });

    });

 

function buildTravelCostsChart(xData, status) {

var costsColTag;

var itemCount;

 

//Construct the Column tag classes here

costsColTag = "sizedata chart_td";

 

//Get a handle to the SPAN tag

var spnElement= document.getElementById("spnCostsChart");

 

 

//alert("here");

//alert(xData.responseXML.xml);

 

 

//Check if a SoapServerException has occurred

//This could occur if the List is missing/deleted

//The Response XML will contain the SoapServerException

//If SoapServerException is found, IndexOf returns an integer

//IndexOf returns -1 if SoapServerException is not found.

 

//var strErrorCheck = xData.responseXML.xml;

//alert ("strErrorCheck = " + strErrorCheck);

//var posErrStr = strErrorCheck.indexOf("SoapServerException");

 

//if (posErrStr >= 0)

//{

       //alert ("A Soap Exception has occurred"); 

 

 

      //Display a table with a message indicating that

      //Travel and B2B Costs SharePoint List NOT found in the Site

      //Display an appropriate error message

      //Start constructing No List Table HTML here

  //var noListTableHtml = "";

  //noListTableHtml += "<TABLE WIDTH=100% border=0>";

  //noListTableHtml += "<TBODY>";

  //noListTableHtml += "<TR>";

  //noListTableHtml += "<TD><SPAN class=ms-rteCustom-Kraft_Major_Headline><FONT

size=2>&nbsp;<FONT color=#ff0000>Travel and B2B Costs SharePoint List not found! Please contact

the Site Administrator.</FONT></FONT></SPAN></TD>"

  //noListTableHtml += "</TR></TBODY></TABLE>";

 

   //Assign the noListTableHTML code to the span tag INNER HTML property to display it

     //spnElement.innerHTML = noListTableHtml ; 

 

//}

 

//else //returning -1; No Soap Exception

//{

 

 

 

//Get the Item Count here

$(xData.responseXML).find("[nodeName=rs:data]").each(function() {

  itemCount = $(this).attr("ItemCount");

  //alert("Total Number of Items = " + itemCount); 

});

 

 

 

//If Item Count is 0 display an error message to user

//Travel and B2 Tools cost info not found

//Have user fill it out by providing a link to SharePoint List

if (itemCount == "0")

 

{

 

   //alert ("Travel and B2B Tools cost info not defined in SharePoint List");

  //Display a table with a message indicating that

  //Travel Cost info has NOT been defined in the SharePoint List

  //Provide a link to the SharePoint List here

  //Start constructing table HTML here

  var noCostsTableHtml = "";

  noCostsTableHtml += "<TABLE WIDTH=100% border=0>";

  noCostsTableHtml += "<TBODY>";

  noCostsTableHtml += "<TR>";

  noCostsTableHtml += "<TD><SPAN class=ms-rteCustom-Kraft_Major_Headline><FONT size=2>&nbsp;<FONT

color=#ff0000>Travel and B2B tools cost info not found!</FONT></FONT></SPAN></TD>"

  noCostsTableHtml += "</TR>";

  noCostsTableHtml += "<TR>";

  noCostsTableHtml += "<TD>&nbsp;Please click on the link below to define the Travel and B2B

tools cost info in the SharePoint List.</TD>";

  noCostsTableHtml += "</TR>";

  noCostsTableHtml += "<TR>";

  noCostsTableHtml += "<TD><A

href='http://intranet.na.kraft.com/sites/TC/plantrip/Lists/Alternatives%20to%20Travel/AllItems.as

px'>&nbsp;<STRONG><U><FONT color=#0000ff>Define Travel and B2B tools cost info

tools</FONT></U></STRONG></A></TD>";

   noCostsTableHtml += "</TR></TBODY></TABLE>";

 

   //Assign the tableHTML code to the span tag INNER HTML property to display it

     spnElement.innerHTML = noCostsTableHtml; 

 

}

 

else //Item Count is greater than 0; render the Travel and B2B tools cost info chart

 

{

 

 

//Loop through the result set returned in the SOAP

//envelope courtesy of the SharePoint Lists Web Service

$(xData.responseXML).find("[nodeName=z:row]").each(function() {

   

    //alert("here");

   

    //Get domestic travel cost

    domCost = $(this).attr("ows_Typical_x0020_domestic_x0020_tra");

   

    //Check if domCost is blank

    if (typeof(domCost) == 'undefined') 

    {

      domCost = "Domestic travel cost not defined in SharePoint List.";

 

    }

 

    //alert(domCost);

 

     //Get international travel cost

     intlCost = $(this).attr("ows_Typical_x0020_international_x002");

   

    //Check if intlCost is blank

    if (typeof(intlCost) == 'undefined') 

    {

      intlCost = "International travel cost not defined in SharePoint List.";

 

    }

 

  

    //alert(intlCost);

 

    //Get Most Collab tools cost

    collabCost = $(this).attr("ows_Most_x0020_Collaboration_x0020_T");

   

    //Check if collabCost is blank

    if (typeof(collabCost) == 'undefined') 

    {

      collabCost = "Collaboration tools cost not defined in SharePoint List.";

 

    }

 

    //alert(collabCost);

 

   //Get B2B TelePresence tools cost

    b2bCost = $(this).attr("ows_B2B_x0020_TelePresence_x0020_too");

 

   //Check if b2bCost is blank

    if (typeof(b2bCost) == 'undefined') 

    {

      b2bCost = "B2B tools cost not defined in SharePoint List.";

 

    }

 

    //alert(b2bCost);

 

}); //closing for jQuery for loop

 

    //Start constructing chart table HTML here

    var tableHtml = "";

 

   //Render Page Heading here

    tableHtml += "<P><B><FONT size=4><SPAN class=ms-rteCustom-Kraft_Major_Headline>Alternatives

to Travel</SPAN></B></P>";

 

  //Render Travel and B2B Tool Costs table here

    tableHtml += "<P><TABLE id='costsgrid' cellSpacing='0' cellPadding='0' border='0'>";

 

    tableHtml += "<TBODY><TR><TH width='450px' class=cost_th>Typical US domestic travel

cost</TH><TH width='450px' class=cost_th>Typical international travel (US to int'l)

cost</TH></TR>";

 

    tableHtml += "<TR><TD width='450px' class='";

    tableHtml += costsColTag + "'><P align=center><SPAN class=ms-rteCustom-Kraft_Body><FONT

size=2>1 person - 2 night stay</FONT></SPAN></P></TD>";

 

    tableHtml += "<TD width='450px' class='";

 

    tableHtml += costsColTag + "'><P align=center><SPAN class=ms-rteCustom-Kraft_Body><FONT

size=2>1 person - 2 night stay</FONT></SPAN></P></TD></TR>";

 

 

    tableHtml += "<TR><TD width='450px' class='";

 

    tableHtml += costsColTag + "'><P align=center><B><SPAN class=ms-rteCustom-Kraft_Body><FONT

size=3>" + domCost + "</FONT></SPAN></B></P></TD>";

 

  tableHtml += "<TD width='450px' class='";

 

  //End Cost table rendering here

  tableHtml += costsColTag + "'><P align=center><B><SPAN class=ms-rteCustom-Kraft_Body><FONT

size=3>" + intlCost + "</FONT></SPAN></B></P></TD></TR><TR></TR></TBODY></TABLE></P>";

 

  //Render TelePresence Costs table here

tableHtml += "<P><TABLE id='telepresencecostsgrid' cellSpacing='0' cellPadding='0' border='0'>";

 

    tableHtml += "<TBODY><TR><TH width='450px' class=cost_th>Most Collaboration Tools

cost</TH><TH width='450px' class=cost_th>Cost of using external TelePresence</TH></TR>";

 

    tableHtml += "<TR><TD width='450px' class='";

 

    tableHtml += costsColTag + "'><P align=center><B><SPAN class=ms-rteCustom-Kraft_Body><FONT

size=3>" + collabCost + "</FONT></SPAN></B></P></TD>";

 

  tableHtml += "<TD width='450px' class='";

 

  //End TelePresence Cost table rendering here

  tableHtml += costsColTag + "'><P align=center><B><SPAN class=ms-rteCustom-Kraft_Body><FONT

size=3>" + b2bCost + "</FONT></SPAN></B></P></TD></TR><TR></TR></TBODY></TABLE></P>";

 

 

    //Assign the tableHTML code to the span tag INNER HTML property to display it

     spnElement.innerHTML = tableHtml ;

 

   

} //closing brace for (itemCount == 0) if statement   

 

//} //closing brace for SoapException if statement

 

} //closing brace for function

 

 

</script>

 

<span id="spnCostsChart"></span>

 

 

 

 

 

<script type="text/javascript"

src="http://intranet.na.kraft.com/sites/TC/jQuery/jquery-1.3.2.min.js"></script>

 

<script type="text/javascript"

src="http://intranet.na.kraft.com/sites/TC/jQuery/wz_tooltip.js"></script>

 

<style type="text/css">

 

th.chart_th {

                font-family: Arial, Helvetica, sans-serif;

                font-size: 12px;

                font-weight: bold;

                color: #FFF;

                background-color: #039;

                border-top-width: 1px;

                border-right-width: 1px;

                border-bottom-width: 1px;

                border-left-width: 1px;

                border-top-style: none;

                border-right-style: solid;

                border-bottom-style: none;

                border-left-style: none;

                border-top-color: #FFF;

                border-right-color: #FFF;

                border-bottom-color: #FFF;

                border-left-color: #FFF;

                padding-top: 4px;

                padding-bottom: 4px;

}

 

th.cost_th {

                font-family: Arial, Helvetica, sans-serif;

                font-size: 12px;

                font-weight: bold;

                color: #FFF;

                background-color: #339966;

                border-top-width: 1px;

                border-right-width: 1px;

                border-bottom-width: 1px;

                border-left-width: 1px;

                border-top-style: none;

                border-right-style: solid;

                border-bottom-style: none;

                border-left-style: none;

                border-top-color: #FFF;

                border-right-color: #FFF;

                border-bottom-color: #FFF;

                border-left-color: #FFF;

                padding-top: 4px;

                padding-bottom: 4px;

}

 

 

td.names {

                font-family: Arial, Helvetica, sans-serif;

                font-size: 12px;

                font-weight: bold;

                color: #036;

                border-right-width: 2px;

                border-right-style: solid;

                border-right-color: #FFF;

                margin: 0px;

                padding-top: 0px;

                padding-right: 2px;

                padding-bottom: 0px;

                padding-left: 8px;

                width: 150px;

 

}

td.sizedata, td.locationdata, td.techdata {

                font-family: Arial, Helvetica, sans-serif;

                font-size: 12px;

                color: #000;

                border-right-width: 2px;

                border-left-width: 2px;

                border-right-style: solid;

                border-left-style: none;

                border-right-color: #FFF;

                border-left-color: #FFF;

                text-align: center;

}

td.featuresdata {

                font-family: Arial, Helvetica, sans-serif;

                font-size: 12px;

                color: #000;

                border-right-width: 2px;

                border-left-width: 2px;

                border-right-style: solid;

                border-left-style: none;

                border-right-color: #FFF;

                border-left-color: #FFF;

                text-align: left;

}

 

.features {

                margin: 0px;

                padding-top: 0px;

                padding-right: 0px;

                padding-bottom: 0px;

                padding-left: 14px;

                font-size: 12px;

}

td.chart_td {

                padding-top: 4px;

                padding-right: 2px;

                padding-bottom: 4px;

                padding-left: 2px;

                border-bottom-width: 4px;

                border-bottom-style: solid;

                border-bottom-color: #FFF;

                border-top-width: 2px;

                border-top-style: solid;

                border-top-color: #CCC;

}

#alternativesgrid a {

                color: #036;

                text-decoration: none;

                font-weight: bold;

}

#alternativesgrid {

}

.costs {

                font-family: Arial, Helvetica, sans-serif;

                font-size: 14px;

                width: 100%;

                padding: 4px;

                margin-bottom: 8px;

}

.costs h2 {

                font-size: 18px;

                line-height: 18px;

                margin: 0px;

                padding: 0px;

}

.names a img {

}

.key {

                font-size: 11px;

                margin-bottom: 0px;

                padding-bottom: 0px;

}

.key p {

                margin-bottom: 4px;

                line-height: 12px;

                padding: 4px;

                margin-top: 0px;

}

chart_span {

                background-color: #FFF;

}

#Span1 {

}

#alternativesgrid {

                background-color: #D9E6FF;

}

 

#costsgrid {

                background-color: #D7E4BC;

}

 

#telepresencecostsgrid {

                background-color: #D7E4BC;

}

</style>

 

 

 

 

 

<script type="text/javascript">

    //$(document).ready(function() {

    $(window).load(function() {

        var soapEnv =

            "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \

                <soapenv:Body> \

                     <GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \

                        <listName>Alternatives to Travel</listName> \

                        <viewFields> \

                            <ViewFields> \

                              <FieldRef Name='Title' /> \

                              <FieldRef Name='In_x0020_all_x0020_Kraft_x0020_L' /> \

                              <FieldRef Name='Audience_x0020_Size' /> \

                              <FieldRef Name='Best_x0020_for' /> \

                              <FieldRef Name='Features_x0020_and_x0020_Benefit' /> \

                              <FieldRef Name='Main_x0020_Image' /> \

                              <FieldRef Name='Rollover_x0020_Image' /> \

                              <FieldRef Name='Rollover_x0020_Text' /> \

                              <FieldRef Name='Target_x0020_Page' /> \

 <FieldRef Name='Rollover_x0020_text_x0020_for_x0' /> \

<FieldRef Name='Rollover_x0020_text_x0020_for_x00' /> \

<FieldRef Name='Target_x0020_Page_x0020_for_x002' /> \

<FieldRef Name='Target_x0020_Page_x0020_for_x0020' /> \

</ViewFields> \

                        </viewFields> \

                    </GetListItems> \

                </soapenv:Body> \

            </soapenv:Envelope>";

 

 

//alert("Soap = " + soapEnv);

        $.ajax({

            url: "http://intranet.na.kraft.com/sites/TC/plantrip/_vti_bin/lists.asmx",

            type: "POST",

            dataType: "xml",

            data: soapEnv,

            complete: buildAltToTravelChart,

            contentType: "text/xml; charset=\"utf-8\""

        });

    });

 

function buildAltToTravelChart(xData, status) {

var altTravelTitle, allKraftLoc;

var targetPageValue, targetPage;

var mainImageURLValue, mainImageURL;

var rolloverText, rolloverImageURLValue, rolloverImageURL;

var toolsColTag;

var audSizeColTag, krftLocColTag, bestForColTag, ftrBnftColTag;

var spnID;

var audSizeRolloverText, locRolloverText;

var audSizeTargetPageValue, audSizeTargetPage;

var locTargetPageValue, locTargetPage;

var itemCount;

 

 

//Construct the Column tag classes here

toolsColTag = "names chart_td";

audSizeColTag = "sizedata chart_td";

krftLocColTag = "locationdata chart_td";

bestForColTag = "techdata chart_td";

ftrBnftColTag = "featuresdata chart_td";

 

     //Get a handle to the SPAN tag

      var spnElement= document.getElementById("spnChart");

 

 

//alert("here");

//alert(xData.responseXML.xml);

 

//Check if a SoapServerException has occurred

//This could occur if the List is missing/deleted

//The Response XML will contain the SoapServerException

//If SoapServerException is found, IndexOf returns an integer

//IndexOf returns -1 if SoapServerException is not found.

 

//var strErrorCheck = xData.responseXML.xml;

//alert ("strErrorCheck = " + strErrorCheck);

//var posErrStr = strErrorCheck.indexOf("SoapServerException");

 

//if (posErrStr >= 0)

//{

       //alert ("A Soap Exception has occurred"); 

 

 

      //Display a table with a message indicating that

      //Alternatives to Travel SharePoint List NOT found in the Site

      //Display an appropriate error message

      //Start constructing No List Table HTML here

  //var noListTableHtml = "";

  //noListTableHtml += "<TABLE WIDTH=100% border=0>";

  //noListTableHtml += "<TBODY>";

  //noListTableHtml += "<TR>";

  //noListTableHtml += "<TD><SPAN class=ms-rteCustom-Kraft_Major_Headline><FONT

size=2>&nbsp;<FONT color=#ff0000>Alternatives to Travel SharePoint List not found! Please contact

the Site Administrator.</FONT></FONT></SPAN></TD>"

  //noListTableHtml += "</TR></TBODY></TABLE>";

 

   //Assign the noListTableHTML code to the span tag INNER HTML property to display it

     //spnElement.innerHTML = noListTableHtml ; 

 

//}

 

//else //returning -1; No Soap Exception

//{

  //alert("No Soap Exception");

  

  //Get the Item Count here

  $(xData.responseXML).find("[nodeName=rs:data]").each(function() {

     itemCount = $(this).attr("ItemCount");

     //alert("Total Number of Items = " + itemCount); 

   });

 

    

   

    //If Item Count is 0 display an error message to user

    //Alt To Travels not found

    //Have user fill it out by providing a link to SharePoint List

     if (itemCount == "0")

 

     {

 

      //alert ("No Tools defined in SharePoint List");

      //Display a table with a message indicating that

      //Alt To Travel tools have NOT been defined in the SharePoint List

  //Provide a link to the SharePoint List here

  //Start constructing table HTML here

  var noToolsTableHtml = "";

  noToolsTableHtml += "<TABLE WIDTH=100% border=0>";

  noToolsTableHtml += "<TBODY>";

  noToolsTableHtml += "<TR>";

  noToolsTableHtml += "<TD><SPAN class=ms-rteCustom-Kraft_Major_Headline><FONT size=2>&nbsp;<FONT

color=#ff0000>Alternatives to Travel tools not found!</FONT></FONT></SPAN></TD>"

  noToolsTableHtml += "</TR>";

  noToolsTableHtml += "<TR>";

  noToolsTableHtml += "<TD>&nbsp;Please click on the link below to define the Alternatives to

Travel tools in the SharePoint List.</TD>";

  noToolsTableHtml += "</TR>";

  noToolsTableHtml += "<TR>";

  noToolsTableHtml += "<TD><A

href='http://intranet.na.kraft.com/sites/TC/plantrip/Lists/Alternatives%20to%20Travel/AllItems.as

px'>&nbsp;<STRONG><U><FONT color=#0000ff>Define Alternatives to Travel

tools</FONT></U></STRONG></A></TD>";

   noToolsTableHtml += "</TR></TBODY></TABLE>";

 

   //Assign the tableHTML code to the span tag INNER HTML property to display it

     spnElement.innerHTML = noToolsTableHtml; 

 

} //ending brace for (if itemCount == 0)

 

else //Item Count is greater than 0; render the Alt To Travel chart

 

{

 

     //Start constructing the rollover text HTML here

     //This HTML will contain the text that will be used for mouseover events  

      //Get a handle to the SPAN tag

      var spnRollover= document.getElementById("spnRollover");

     //alert("Current Rollover text = " + spnRollover.innerHTML);

     var spnHtml = spnRollover.innerHTML;

 

    //Append style to not display the rollover text at bottom of page

    spnHtml += "<DIV style=display:none>";

   

 

   //Start constructing chart table HTML here

    var tableHtml = "";

 

   //Render Alternatives to Travel table here

    tableHtml += "<TABLE id='alternativesgrid' border='1' cellspacing='0' cellpadding='1'>";

      

   

    //Construct Top column header here

    tableHtml += "<TBODY><TR><TH class=chart_th>Collaboration Tools </TH><TH

class=chart_th><P>Audience Size</P></TH><TH class=chart_th>Locations</TH><TH class=chart_th

width='20%'>Best for...</TH><TH class=chart_th width='40%'>Features and

Benefits</TH></TR><TBODY><TR>";

 

 

//Loop through the result set returned in the SOAP

//envelope courtesy of the SharePoint Lists Web Service

$(xData.responseXML).find("[nodeName=z:row]").each(function() {

   

    //alert("here");

   

    //Get the title of the Collab Tool

    altTravelTitle = $(this).attr("ows_Title"); 

 

     //Get Audience Size supported by this Tool

     audSize = $(this).attr("ows_Audience_x0020_Size");

 

     //Check if Audience Size column is blank in SharePoint List

     //If true, display a message in the column

     if (typeof audSize == 'undefined')

     {

        audSize = "Audience Size for this tool must be defined in the SharePoint List.";  

      }

   

    //Get Is Tool available in all Kraft locations

    allKraftLoc = $(this).attr("ows_In_x0020_all_x0020_Kraft_x0020_L"); 

 

      //Check if Tool availability column is blank in SharePoint List

     //If true, display a message in the column

     if (typeof allKraftLoc == 'undefined')

     {

        allKraftLoc = "Availability info for this tool must be defined in the SharePoint List."; 

 

      }

 

   //Get Best for...

   bestFor = $(this).attr("ows_Best_x0020_for");  

 

   //Check if Best For... column is blank in SharePoint List

   //If true, display a message in the column

   if (typeof(bestFor) == 'undefined')

   {

       bestFor = "Best For... text for this tool must be defined in the SharePoint List.";  

   }

          

  //Get Features and Benefits

  ftrBnft = $(this).attr("ows_Features_x0020_and_x0020_Benefit");

 

   //Check if Features and Benefits column is blank in SharePoint List

   //If true, display a message in the column

 

   if (typeof ftrBnft == 'undefined')

   {

       ftrBnft = "<ul>";

       ftrBnft += "<li>Features and Benefits text for this tool must be defined in the SharePoint

List.</li>";

       ftrBnft += "</ul>";

  

   }

 

   //Get Main Image URL Value. This is a comma separated value

   mainImageURLValue = $(this).attr("ows_Main_x0020_Image"); 

 

   //Check if Main Image URL is missing

   //If true, display a generic Image Not Found image

    if (typeof(mainImageURLValue) == 'undefined')

 

    {

        //alert("No Main Image");

        mainImageURLValue =

"http://intranet.na.kraft.com/sites/TC/Travel%20Central%20Images/noimage.jpg,http://intranet.na.k

raft.com/sites/TC/Travel%20Central%20Images/noimage.jpg";

    }

 

   //Split the Main Image URL Value at the comma separator

   mainImageURL= mainImageURLValue.split(",");

 

    //Get Rollover Image URL Value. This is a comma separated value

   rolloverImageURLValue = $(this).attr("ows_Rollover_x0020_Image"); 

 

 

      //Check if Rollover Image URL is missing

   //If true, display a generic Image Not Found image

    if (typeof(rolloverImageURLValue) == 'undefined')

 

    {

        //alert("No Rollover Image");

        rolloverImageURLValue =

"http://intranet.na.kraft.com/sites/TC/Travel%20Central%20Images/noimage.jpg,http://intranet.na.k

raft.com/sites/TC/Travel%20Central%20Images/noimage.jpg";

    }

 

 

   //Split the Rollover Image URL Value at the comma separator

   rolloverImageURL = rolloverImageURLValue.split(",");

 

 

    //Get the Rollover text for the Tool

    rolloverText = $(this).attr("ows_Rollover_x0020_Text"); 

 

   //Check if Rollover text column is blank in SharePoint List

   //If true, display a message in the rollover

 

   if (typeof rolloverText == 'undefined')

   {

       rolloverText = "<B>Rollover Text not found</B><BR>";

       rolloverText += "Rollover text for this tool must be defined in the SharePoint List.";  

   }

 

    //Get the Target page to link to when user clicks on the Tool

    targetPageValue = $(this).attr("ows_Target_x0020_Page");

 

    //Check if Target page value is blank

    //If true, then set the Target page to the current page

     if (typeof(targetPageValue) == 'undefined')

 

    {

         targetPageValue = "#,#"; 

    }  

 

   //Split the Target Page URL Value at the comma separator

   targetPage = targetPageValue.split(",");

 

 

    //Get the Target page to link to when user clicks on the Audience Size link

    audSizeTargetPageValue = $(this).attr("ows_Target_x0020_Page_x0020_for_x0020"); 

 

 

    //Check if Audience Size Target page value is blank

    //If true, then set the Target page to the current page

     if (typeof(audSizeTargetPageValue) == 'undefined')

    {

         audSizeTargetPageValue = "#,#"; 

    }  

 

   //Split the Target Page URL Value at the comma separator

   audSizeTargetPage = audSizeTargetPageValue.split(",");

 

    //Get the Rollover text for the Audience Size column

    audSizeRolloverText = $(this).attr("ows_Rollover_x0020_text_x0020_for_x00"); 

 

 

   //Check if Rollover text column for Audience Size

   //is blank in SharePoint List

   //If true, display a message in the rollover

 

   //if (typeof audSizeRolloverText == 'undefined')

   //{

     //  audSizeRolloverText = "<B>Rollover Text not found</B><BR>";

     //  audSizeRolloverText += "Rollover text for Audience size for this tool must be defined in

the SharePoint List.";  

   //}

 

 

   //Get the Target page to link to when user clicks on the Locations link

    locTargetPageValue= $(this).attr("ows_Target_x0020_Page_x0020_for_x002"); 

 

    //Check if Kraft Locations Target page value is blank

    //If true, then set the Target page to the current page

     if (typeof(locTargetPageValue) == 'undefined')

 

    {

         locTargetPageValue = "#,#"; 

    }  

 

   //Split the Target Page URL Value at the comma separator

   locTargetPage= locTargetPageValue.split(",");

 

   if (allKraftLoc == "All")

   {

     locTargetPage[0] = "#";

   }

 

 

    //Get the Rollover text for the Locations column

    locRolloverText = $(this).attr("ows_Rollover_x0020_text_x0020_for_x0"); 

 

 

   //Check if Rollover text column for Locations

   //is blank in SharePoint List

   //If true, display a message in the rollover

 

   if (typeof locRolloverText == 'undefined')

   {

       locRolloverText = "<B>Rollover Text not found</B><BR>";

       locRolloverText += "Rollover text for Kraft locations availability for this tool must be

defined in the SharePoint List.";  

   }

 

        

     //alert("Title = " + altTravelTitle);

     //alert("In All Kraft locations = " + allKraftLoc);

     //alert("Main Image URL = " + mainImageURL[0]);

     //alert("Rollover text = " + rolloverText);

     //alert("Target Page = " + targetPage);

    

    //Render Begin Row tag

     tableHtml += "<TR>";

 

         

     //Create SPAN id tag based on Tool title

     //Remove spaces if any in the title

     //This is the ID of the SPAN tag for the rollover text/image

     spnID = altTravelTitle.split(' ').join('');

 

     //alert("Span ID = " + spnID);

    

     //Render Collab Tools column

     //If Target Page is blank in the List, then display an alert

     //when user clicks on the link

     if(targetPage[0] == "#")

 

     {

     tableHtml += "<TD class='" + toolsColTag + "'>";

     tableHtml += "<A onmouseover=TagToTip('" ;

     tableHtml += spnID + "') onmouseout='UnTip()' onclick='NoTargetPage()' ";

     tableHtml += "href='" + targetPage[0] + "'>";

     tableHtml += "<IMG align=middle width=116 height=65 border=0 src='";

 

     }

 

     else

 

     {

 

 

     tableHtml += "<TD class='" + toolsColTag + "'>";

     tableHtml += "<A onmouseover=TagToTip('" ;

     tableHtml += spnID + "') onmouseout='UnTip()'";

     tableHtml += "href='" + targetPage[0] + "' target=_blank>";

     tableHtml += "<IMG align=middle width=116 height=65 border=0 src='";

 

      }

 

     //Render Tool main image here

     tableHtml += mainImageURL[0] + "'><BR>";

//     tableHtml += altTravelTitle + "</A></TD>";

tableHtml += "<U><FONT color=#0000ff>" + altTravelTitle + "</FONT></U></A></TD>";

 

 

 

   //Check if Rollover text column for Audience Size

   //is blank in SharePoint List

   //If true, don't display rollover, just display the Audience Size value

 

  //alert("Aud Size Rollover text = " + audSizeRolloverText);

   if ((typeof audSizeRolloverText == 'undefined') || (audSizeRolloverText == '<p>&nbsp;</p>') ||

(audSizeRolloverText == '<div>&nbsp;</div>'))

   {

 

    //tableHtml += "<TD>" + audSize + "</TD>";

    tableHtml += "<TD class='" + audSizeColTag + "'>";

    tableHtml += "<STRONG>" + audSize + "</STRONG></TD>";

 

   }

 

   else  //Render Audience Size column with rollover text

 

  {

    tableHtml += "<TD class='" + audSizeColTag + "'>";

    tableHtml += "<A onmouseover=TagToTip('" ;

    tableHtml += spnID + "Size" + "') onmouseout='UnTip()'";

    tableHtml += "href='#'>"

    //tableHtml += audSize + "</TD>";

    tableHtml += "<FONT color=#0000ff>" + audSize + "</FONT></TD>";

 

  }

 

 

//Render Location column

//If Location is All, then don't render hyperlink

    

   if (allKraftLoc == "All")

 

   {

     tableHtml += "<TD class='" + krftLocColTag + "'>";

     tableHtml += "<A onmouseover=TagToTip('" ;

     tableHtml += spnID + "Loc" + "') onmouseout='UnTip()'";

     tableHtml += "href='#'>"

     tableHtml += allKraftLoc + "</TD>";

   }

 

else

 

   {

 

     if(locTargetPage[0] == "#")

 

 

    {

 

      //If Target Page is blank in the List, then display an alert

      //when user clicks on the link

     tableHtml += "<TD class='" + krftLocColTag + "'>";

     tableHtml += "<A onmouseover=TagToTip('" ;

     tableHtml += spnID + "Loc" + "') onmouseout='UnTip()' onclick='NoTargetPage()' ";

     tableHtml += "href='" + locTargetPage[0] + "'>";

     tableHtml += "<U><FONT color=#0000ff>" + allKraftLoc + "</FONT></U></TD>";

   }

 

   else //locTargetPage[0] is NOT #

 

   {

      tableHtml += "<TD class='" + krftLocColTag + "'>";

     tableHtml += "<A onmouseover=TagToTip('" ;

     tableHtml += spnID + "Loc" + "') onmouseout='UnTip()'";

     tableHtml += "href='" + locTargetPage[0] + "' target=_blank>";

     tableHtml += "<U><FONT color=#0000ff>" + allKraftLoc + "</FONT></U></TD>";

 

 

 

   }

 

}

     //Render Best for... column

     tableHtml += "<TD class='" + bestForColTag + "'>";

     tableHtml += bestFor + "</TD>";

 

     //Render Features and Benefits column

     tableHtml += "<TD class='" + ftrBnftColTag + "'>";

     tableHtml += ftrBnft + "</TD>";

 

     //Render Closing Row tag

     tableHtml += "</TR>";

 

    //Populate Tool column rollover text and image in SPAN tag and

    //append to existing SPAN tag

    spnHtml += "<SPAN id=" + spnID + ">";

    spnHtml += "<IMG height=128 width=225 hspace=8 vspace=4 align=right src='";

    spnHtml += rolloverImageURL[0] + "'>";

    spnHtml += "<P><STRONG>" + altTravelTitle + "</STRONG></P>";

    spnHtml += "<P>" + rolloverText + "</P>";

    spnHtml += "<P>Click your mouse for more " + altTravelTitle + " information. </P></SPAN>";

    //alert("Span HTML = " + spnHtml);

 

 

 

    //Populate Audience Size column rollover text in SPAN tag

    //append to existing SPAN tag

    //Create SPAN tag only if Audience Size rollover text is not blank

 

   if ((typeof audSizeRolloverText != 'undefined') || (audSizeRolloverText != '<p>&nbsp;</p>') ||

(audSizeRolloverText != '<div>&nbsp;</div>'))

 

  {

 

    spnHtml += "<SPAN id=" + spnID + "Size" + ">";

    spnHtml += "<P>" + audSizeRolloverText + "</P>";

    spnHtml += "</SPAN>";

  }   

 

    //Populate Locations column rollover text in SPAN tag

    //append to existing SPAN tag

    //If Location is All, don't show "click your mouse" text in rollover

   if (allKraftLoc == "All")

   {

     spnHtml += "<SPAN id=" + spnID + "Loc" + ">";

     spnHtml += "<P>" + locRolloverText + "</P>";

     spnHtml += "</SPAN>";    

   }

  else //Show "click your mouse" text in rollover

   {

    spnHtml += "<SPAN id=" + spnID + "Loc" + ">";

    spnHtml += "<P>" + locRolloverText + "</P>";

    spnHtml += "<P>Click your mouse for more information. </P></SPAN>";

   }   

 

 

}); //closing for jQuery for loop

 

     //Render closing Table Body and Table tags

     tableHtml += "</TBODY></TABLE>";

 

    //Close the <DIV> tag

    //Append the SPAN HTML to the existing span tag

    //This will contain the rollover text/images

    spnHtml += "</DIV>";

 

 

    //Assign the tableHTML code to the span tag INNER HTML property to display it

     spnElement.innerHTML = tableHtml ;

 

    //Construct the static HTML related to Audience size

    spnHtml += "<DIV class=key><P><STRONG>Location Availability:</STRONG><STRONG><i>

Limited</i></STRONG> - few to several locations; <STRONG><i>Moderate</i></STRONG> - many

locations; <STRONG><i>All </i></STRONG> - available to everyone at Kraft locations</P></DIV>";

 

    //Assign the Rollover text/image to the span tag

    spnRollover.innerHTML = spnHtml;

 

} //closing brace for (itemCount == 0) if statement   

 

//} //closing brace for SoapException if statement

 

} //closing brace for function

 

function NoTargetPage()

 

{

   alert("Target Page not defined. Please define a target Page in the Alternatives to Travel

SharePoint List.");

}

 

 

</script>

 

<span id="spnChart"></span>

<span id="spnRollover"></span>

No comments: