PageSourceSearch

https://www.lseg.com/etc.clientlibs/forge/components/data-layer/page/v1/page/clientlibs.min.js

js lseg.com collected 2026-10-09 21:48:21 UTC 12,375 bytes, 374 lines download raw bytes

1/*
2 Copyright (c) 2010,2011,2012,2013,2014 Morgan Roderick http://roderick.dk
3 License: MIT - http://mrgnrdrck.mit-license.org
4
5 https://github.com/mroderick/PubSubJS
6 */
7
8(function (root, factory){
9    'use strict';
10
11    var PubSub = {};
12    root.PubSub = PubSub;
13
14    var define = root.define;
15
16    factory(PubSub);
17
18    // AMD support
19    if (typeof define === 'function' && define.amd){
20        define(function() { return PubSub; });
21
22        // CommonJS and Node.js module support
23    } else if (typeof exports === 'object'){
24        if (module !== undefined && module.exports) {
25            exports = module.exports = PubSub; // Node.js specific `module.exports`
26        }
27        exports.PubSub = PubSub; // CommonJS module 1.1.1 spec
28        module.exports = exports = PubSub; // CommonJS
29    }
30
31}(( typeof window === 'object' && window ) || this, function (PubSub){
32    'use strict';
33
34    var messages = {},
35        lastUid = -1,
36        formSuccessEventName = 'analytics.formSuccess';
37
38    function hasKeys(obj){
39        var key;
40
41        for (key in obj){
42            if ( obj.hasOwnProperty(key) ){
43                return true;
44            }
45        }
46        return false;
47    }
48
49    /**
50     *	Returns a function that throws the passed exception, for use as argument for setTimeout
51     *	@param { Object } ex An Error object
52     */
53    function throwException( ex ){
54        return function reThrowException(){
55            throw ex;
56        };
57    }
58
59    function callSubscriberWithDelayedExceptions( subscriber, message, data ){
60        try {
61            subscriber( message, data );
62        } catch( ex ){
63            setTimeout( throwException( ex ), 0);
64        }
65    }
66
67    function callSubscriberWithImmediateExceptions( subscriber, message, data ){
68        subscriber( message, data );
69    }
70
71    function deliverMessage( originalMessage, matchedMessage, data, immediateExceptions ){
72        var subscribers = messages[matchedMessage],
73            callSubscriber = immediateExceptions ? callSubscriberWithImmediateExceptions : callSubscriberWithDelayedExceptions,
74            s;
75
76        if ( !messages.hasOwnProperty( matchedMessage ) ) {
77            return;
78        }
79
80        for (s in subscribers){
81            if ( subscribers.hasOwnProperty(s)){
82                callSubscriber( subscribers[s], originalMessage, data );
83            }
84        }
85    }
86
87    function createDeliveryFunction( message, data, immediateExceptions ){
88        return function deliverNamespaced(){
89            var topic = String( message ),
90                position = topic.lastIndexOf( '.' );
91
92            // deliver the message as it is now
93            deliverMessage(message, message, data, immediateExceptions);
94
95            // trim the hierarchy and deliver message to each level
96            while( position !== -1 ){
97                topic = topic.substr( 0, position );
98                position = topic.lastIndexOf('.');
99                deliverMessage( message, topic, data, immediateExceptions );
100            }
101        };
102    }
103
104    function messageHasSubscribers( message ){
105        var topic = String( message ),
106            found = Boolean(messages.hasOwnProperty( topic ) && hasKeys(messages[topic])),
107            position = topic.lastIndexOf( '.' );
108
109        while ( !found && position !== -1 ){
110            topic = topic.substr( 0, position );
111            position = topic.lastIndexOf( '.' );
112            found = Boolean(messages.hasOwnProperty( topic ) && hasKeys(messages[topic]));
113        }
114
115        return found;
116    }
117
118    function publish( message, data, sync, immediateExceptions ){
119        var deliver = createDeliveryFunction( message, data, immediateExceptions ),
120            hasSubscribers = messageHasSubscribers( message );
121
122        if ( !hasSubscribers ){
123            return false;
124        }
125
126        if ( sync === true ){
127            deliver();
128        } else {
129            setTimeout( deliver, 0 );
130        }
131        return true;
132    }
133
134    /**
135     *	PubSub.publish( message[, data] ) -> Boolean
136     *	- message (String): The message to publish
137     *	- data: The data to pass to subscribers
138     *	Publishes the the message, passing the data to it's subscribers
139     **/
140    //Changes done As part of MYA-19551 Analytics
141     PubSub.publish = function( message, data ){
142        var isDebug = localStorage.getItem("pubSubConsoleDebug");
143        if(data !=null && isDebug === "enable"){
144            console.warn("Event: " +message +"\n digitalData: " +JSON.stringify(window.digitalData));
145        }
146        if(message == formSuccessEventName) {
147            sessionStorage.setItem('userEmailSh256', window?.digitalData?.user?.profileInfo?.userEmailSh256);
148        }
149        return publish( message, data, false, PubSub.immediateExceptions );
150    };
151     //End of MYA-19551
152
153    /**
154     *	PubSub.publishSync( message[, data] ) -> Boolean
155     *	- message (String): The message to publish
156     *	- data: The data to pass to subscribers
157     *	Publishes the the message synchronously, passing the data to it's subscribers
158     **/
159    PubSub.publishSync = function( message, data ){
160        return publish( message, data, true, PubSub.immediateExceptions );
161    };
162
163    /**
164     *	PubSub.subscribe( message, func ) -> String
165     *	- message (String): The message to subscribe to
166     *	- func (Function): The function to call when a new message is published
167     *	Subscribes the passed function to the passed message. Every returned token is unique and should be stored if
168     *	you need to unsubscribe
169     **/
170    PubSub.subscribe = function( message, func ){
171        if ( typeof func !== 'function'){
172            return false;
173        }
174
175        // message is not registered yet
176        if ( !messages.hasOwnProperty( message ) ){
177            messages[message] = {};
178        }
179
180        // forcing token as String, to allow for future expansions without breaking usage
181        // and allow for easy use as key names for the 'messages' object
182        var token = 'uid_' + String(++lastUid);
183        messages[message][token] = func;
184
185        // return token for unsubscribing
186        return token;
187    };
188
189    /**
190     *	PubSub.subscribeOnce( message, func ) -> PubSub
191     *	- message (String): The message to subscribe to
192     *	- func (Function): The function to call when a new message is published
193     *	Subscribes the passed function to the passed message once
194     **/
195    PubSub.subscribeOnce = function( message, func ){
196        var token = PubSub.subscribe( message, function(){
197            // before func apply, unsubscribe message
198            PubSub.unsubscribe( token );
199            func.apply( this, arguments );
200        });
201        return PubSub;
202    };
203
204    /* Public: Clears all subscriptions
205     */
206    PubSub.clearAllSubscriptions = function clearAllSubscriptions(){
207        messages = {};
208    };
209
210    /*Public: Clear subscriptions by the topic
211     */
212    PubSub.clearSubscriptions = function clearSubscriptions(topic){
213        var m;
214        for (m in messages){
215            if (messages.hasOwnProperty(m) && m.indexOf(topic) === 0){
216                delete messages[m];
217            }
218        }
219    };
220
221    /* Public: removes subscriptions.
222     * When passed a token, removes a specific subscription.
223     * When passed a function, removes all subscriptions for that function
224     * When passed a topic, removes all subscriptions for that topic (hierarchy)
225     *
226     * value - A token, function or topic to unsubscribe.
227     *
228     * Examples
229     *
230     *		// Example 1 - unsubscribing with a token
231     *		var token = PubSub.subscribe('mytopic', myFunc);
232     *		PubSub.unsubscribe(token);
233     *
234     *		// Example 2 - unsubscribing with a function
235     *		PubSub.unsubscribe(myFunc);
236     *
237     *		// Example 3 - unsubscribing a topic
238     *		PubSub.unsubscribe('mytopic');
239     */
240    PubSub.unsubscribe = function(value){
241        var descendantTopicExists = function(topic) {
242                var m;
243                for ( m in messages ){
244                    if ( messages.hasOwnProperty(m) && m.indexOf(topic) === 0 ){
245                        // a descendant of the topic exists:
246                        return true;
247                    }
248                }
249
250                return false;
251            },
252            isTopic    = typeof value === 'string' && ( messages.hasOwnProperty(value) || descendantTopicExists(value) ),
253            isToken    = !isTopic && typeof value === 'string',
254            isFunction = typeof value === 'function',
255            result = false,
256            m, message, t;
257
258        if (isTopic){
259            PubSub.clearSubscriptions(value);
260            return;
261        }
262
263        for ( m in messages ){
264            if ( messages.hasOwnProperty( m ) ){
265                message = messages[m];
266
267                if ( isToken && message[value] ){
268                    delete message[value];
269                    result = value;
270                    // tokens are unique, so we can just stop here
271                    break;
272                }
273
274                if (isFunction) {
275                    for ( t in message ){
276                        if (message.hasOwnProperty(t) && message[t] === value){
277                            delete message[t];
278                            result = true;
279                        }
280                    }
281                }
282            }
283        }
284
285        return result;
286    };
287
288
289}));
290
291    window.onload=function() {
292        const userEmailSh256 = sessionStorage.getItem('userEmailSh256');
293        if (!userEmailSh256) return; 
294
295        // Ensure digitalData structure exists
296        window.digitalData = window.digitalData || {};
297        window.digitalData.user = window.digitalData.user || {};
298        window.digitalData.user.profileInfo = window.digitalData.user.profileInfo || {};
299        
300        // Assign value and remove from sessionStorage
301        window.digitalData.user.profileInfo.userEmailSh256 = userEmailSh256;
302        sessionStorage.removeItem('userEmailSh256');
303    };
304
305document.addEventListener("DOMContentLoaded", function () {
306    // Track custom clicks
307    document.body.addEventListener("click", function (e) {
308        const target = e.target.closest(".track-custom-clicks");
309
310        if (target) {
311            const href = target.getAttribute("href") || "";
312            const linkDetails = {
313                linkType: target.getAttribute("data-link-type"),
314                assetTitle: target.getAttribute("data-asset-title"),
315                eventType: target.getAttribute("data-event-type"),
316                fileName: target.getAttribute("data-href-analytics"),
317                exitLink: target.getAttribute("data-href-analytics"),
318                linkText: target.getAttribute("data-title"),
319            };
320
321            const dataIndex = target.getAttribute("data-index");
322            const parsedIndex = parseInt(dataIndex, 10);
323            if (!isNaN(parsedIndex)) {
324                linkDetails.linkPosition = parsedIndex + 1;
325            }
326
327            const pageInfo = {
328                findMethod: target.getAttribute("data-find-method")
329            };
330
331            if (linkDetails.eventType === 'file download') {
332				linkDetails.exitLink = "";
333                linkDetails.eventType = "";
334				linkDetails.linkText = "file download";
335            } else if (linkDetails.eventType === 'exit link') {
336                linkDetails.fileName = "";
337            } else {
338                linkDetails.fileName = "";
339                linkDetails.exitLink = "";
340            }
341
342            if (isExternalLink(href)) {
343				linkDetails.exitLink = href;
344                linkDetails.eventType = "exit link";
345			}
346
347            if(href.startsWith("/content/dam")){
348				linkDetails.fileName = href;
349                linkDetails.linkText = "file download";
350			}
351
352            if (digitalData.page) {
353                digitalData.page.linkDetails = linkDetails;
354                digitalData.page.pageInfo = pageInfo;
355            }
356
357            if (digitalData) {
358                PubSub.publish('analytics.linkClick', digitalData);
359            }
360        }
361    }, true);
362
363});
364
365function isExternalLink(url) {
366    try {
367        if (url.startsWith("/content")) return false;
368        const linkHost = new URL(url).hostname;
369        const currentHost = window.location.hostname;
370        return linkHost !== currentHost;
371    } catch (e) {
372        return false;
373    }
374}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.