Showing posts with label JavaScript. Show all posts
Showing posts with label JavaScript. Show all posts

Wednesday, August 17, 2016

Replacing parentheses in Haivision CoolSigns data table items

When using an RSS feed to populate a data table in Haivision CoolSigns, apostrophes will be replaced by its HTML encoded entity, "'". When working with the data table in Content Creator, you'll need to use the following javascript to decode the HTML entity back to an apostrophe. Notice that the use of RegEx and the global flag is needed to catch multiple apostrophes.

return GetValueEx("title",rowindex,timeoffset,"").replace(/'/g,"'")

Wednesday, December 10, 2014

Displaying the first day of the week in CoolSigns content

The following javascript can be used to display the first day of the current week in content created for CoolSigns.

var d = new Date();
var day = d.getDay();
var diff = d.getDate() - day + (day == 0 ? -6:1);
var monday = new Date(d.setDate(diff));

var month = monday.getMonth() == 0 ? "January":
monday.getMonth() == 1 ? "February":
monday.getMonth() == 2 ? "March":
monday.getMonth() == 3 ? "April":
monday.getMonth() == 4 ? "May":
monday.getMonth() == 5 ? "June":
monday.getMonth() == 6 ? "July":
monday.getMonth() == 7 ? "August":
monday.getMonth() == 8 ? "September":
monday.getMonth() == 9 ? "October":
monday.getMonth() == 10 ? "November":"December";

return month + " " + monday.getDate() + ", " + monday.getYear();

Monday, March 11, 2013

Hiding SharePoint list columns from NewForm.aspx using JavaScript

There are times I create a column in a SharePoint custom list and I don't want anyone with Contribute rights to alter the default value. In the NewForm.aspx and EditForm.aspx pages I add the following script to a CEWP on the page.

<script type="text/javascript">
  function HideField(title){
   var header_h3 = document.getElementsByTagName("h3");
   for (var i = 0; i < header_h3.length; i++)
   {
       var el = header_h3[i];
       var foundField;
       if (el.className=="ms-standardheader")
       {
           for (var j=0; j<el.childNodes.length; j++)
           {
              if (el.childNodes[j].innerHTML == title || el.childNodes[j].nodeValue == title)
             {
                 var elRow = el.parentNode.parentNode;
                 elRow.style.display = "none"; //and hide the row
                 foundField = true;
                 break;
         }
      }       
    }
     if (foundField)
  break;
 }
}
HideField("Workspace");
HideField("Remote Item ID");
</script>

Tuesday, May 22, 2012

Adding Javascript to a SharePoint Master or Layout page

If you need to add javascript to a SharePoint Master or Layout page, add the script to the Head section or PlaceHolderAdditionalHead content area. Be sure to include the  _spBodyOnLoadFunctionNames.push function so your function is added to the OnLoad method.

<script type="text/javascript">
function UpdateCampusAddress()
{
if (window.location.href.toLowerCase().startsWith("http://<site name>/"))
{
document.getElementById('CampusAddress').innerHTML = "Williams Campus";
}
else if (window.location.href.toLowerCase().startsWith("http://<site name>/"))
{
document.getElementById('CampusAddress').innerHTML = "Sun Lakes Campus";
}
}
_spBodyOnLoadFunctionNames.push("UpdateCampusAddress");
</script>

Tuesday, January 4, 2011

Dynamically changing Frameset dimensions

There may be a need to dynamically change the dimensions of an HTML Frameset in the DigitalSignage system.

If we have a frameset defined:


<frameset id="mainFrame" border="0" rows="25%,70%,*">
<frame border="0" noresize="noresize" src="header.html" />
<frame src="" scrolling="no" frameborder="0" />
<frameset border="0" cols="25%,50%,*">
<frame src="footer1.html" scrolling="no" frameborder="0" />
<frame src="footer2.html" scrolling="no" frameborder="0" />
<frame src="weather.aspx" scrolling="no" frameborder="0" />
</frameset>
</frameset>

Below is an example of javascript that varies the dimensions of the rows:

parent.document.getElementById('mainFrame').rows='0%,95%,*';

With this code we're hiding the top row by setting the height to 0%.

Friday, October 29, 2010

SharePoint's _spBodyOnLoadFunctionNames function

The Body onLoad event for the SharePoint master page runs the _spBodyOnLoadFunctionNames function. If you need to run any other javascript at page load, push function name this function. As an example:

function setSearchBoxFocus() // set focus to search textbox
{
document.getElementById('ctl00_ctl00_SearchBox_S3A1EF0A8_InputKeywords').focus();
}

_spBodyOnLoadFunctionNames.push("setSearchBoxFocus");

Wednesday, October 6, 2010

Adding scripts or styles to SharePoint master pages

There are times you may need to add a script or a style to the <head> tag of a CGCC public or Inside webpage. In each SharePoint Master page (except CGCC-Parent.master) there is a content placeholder named 'PlaceHolderAdditionalPageHead' that looks like this.

<asp:ContentPlaceHolder id="PlaceHolderAdditionalPageHead" runat="server" >
</asp:ContentPlaceHolder>

In your aspx layout page, add the following asp:Content control:

<asp:Content ContentPlaceholderID="PlaceHolderAdditionalPageHead" runat="server" >
</asp:Content>

Place the script or style in between the opening and closing tag. After saving and publishing, go to the website and verify.