Friday, August 29, 2014

adding script to specific page by using Location="ScriptLink" in solution

Ended up with the following (works well, thanks again):



<CustomAction Id="ProjectCenterPage.AdditionalScript"
Location="ScriptLink"
ScriptSrc="~SiteCollection/SiteCollectionDocuments/PDPScheduleExtensionLoader.js"/>

PDPScheduleExtensionLoader.js



String.prototype.endsWith = function (suffix) {
return this.indexOf(suffix, this.length - suffix.length) !== -1;
};

var siteUrl = "";
if (window.location.pathname.toLowerCase().endsWith('schedule.aspx')) {
siteUrl = window.location.href.toLowerCase().substring(0, window.location.href.indexOf("/project%20detail%20pages/schedule.aspx"));
document.write('<link rel="stylesheet" href="' + siteUrl + '/SiteCollectionDocuments/jquery-ui.css">');
document.write('<script type="text/javascript" src="' + siteUrl + '/SiteCollectionDocuments/datajs-1.1.1.min.js"></script>');
document.write('<script type="text/javascript" src="' + siteUrl + '/SiteCollectionDocuments/jquery-1.10.2.min.js"></script>');
document.write('<script type="text/javascript" src="' + siteUrl + '/SiteCollectionDocuments/jquery-ui.js"></script>');
document.write('<script type="text/javascript" src="' + siteUrl + '/SiteCollectionDocuments/Local.js"></script>');
document.write('<script type="text/javascript" src="' + siteUrl + '/SiteCollectionDocuments/Utils.js"></script>');
document.write('<script type="text/javascript" src="' + siteUrl + '/SiteCollectionDocuments/PDPScheduleExtension.js"></script>');
}





Sergey Vdovin


No comments:

Post a Comment