I'm developing a plugin for Spiceworks that reformats a block of text. Unfortunately it only works in Firefox, and not in Chrome or IE.
plugin.includeStyles();
function log(msg) {
throw new Error(msg);
}
SPICEWORKS.app.helpdesk.ticket.ready(function(){
console.log('###Start function###');
console.log('###URL###');
var url = jQuery("li.custom")[2].lastElementChild.firstChild.wholeText;
//Check to see if category is project.
for(var i=0;i<jQuery("li.custom").length;i++)
{
if (jQuery("li.custom")[i].lastElementChild.firstChild.wholeText == "Project")
{
for(var u=0;u<jQuery("li.custom").length;u++)
{
if (jQuery("li.custom")[u].lastElementChild.firstChild.wholeText.contains("http"))
{
jQuery("li.custom")[u].innerHTML = '<a href="'+url+'" target="_blank"><span class="projectLink">Project Link</span></a>';
}
}
}
}
});
Chrome is showing that there's an error "Uncaught TypeError: Cannot read property 'lastElementChild' of undefined" on line 9 (var url = ...) Here's a screenshot comparing the display of the different browsers.
What can I do to make the display consistent across the different browsers?