From f097dfb6ee1e5d02b9e11e5ff752c4d25c7922ce Mon Sep 17 00:00:00 2001 From: khawkins98 <khawkins98@gmail.com> Date: Tue, 6 Feb 2018 10:51:12 +0000 Subject: [PATCH] Namespace .last for #121 --- js/foundationExtendEBI.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/js/foundationExtendEBI.js b/js/foundationExtendEBI.js index 2be79383..7c7a6111 100644 --- a/js/foundationExtendEBI.js +++ b/js/foundationExtendEBI.js @@ -37,10 +37,10 @@ ebiGaIndicateLoaded(0,2); /** * Utility method to get the last in an array * @returns {var} the last item in the array - * @example linkName = jQuery(actedOnItem).attr('src').split('/').last(); + * @example linkName = jQuery(actedOnItem).attr('src').split('/').ebiLast(); */ -if (!Array.prototype.last){ - Array.prototype.last = function(){ +if (!Array.prototype.ebiLast){ + Array.prototype.ebiLast = function(){ return this[this.length - 1]; }; }; @@ -76,7 +76,7 @@ function analyticsTrackInteraction(actedOnItem, parentContainer, customEventName } else { // then derive a value var linkName = jQuery(actedOnItem).text().toString(); // if there's no text, it's probably and image - if (linkName.length == 0 && jQuery(actedOnItem).attr('src')) linkName = jQuery(actedOnItem).attr('src').split('/').last(); + if (linkName.length == 0 && jQuery(actedOnItem).attr('src')) linkName = jQuery(actedOnItem).attr('src').split('/').ebiLast(); if (linkName.length == 0 && jQuery(actedOnItem).val()) linkName = jQuery(actedOnItem).val(); // special things for gloabl search box -- GitLab