PageSourceSearch

https://www.ctt.pt/application/themes/js/ctt-general.js?t=100021042026

js ctt.pt collected 2026-10-01 08:31:28 UTC 7,506 bytes, 204 lines download raw bytes

1$(document).ready(function(){
2
3    // Code needed to play <video> from slider, since no autoplay doesn't happens if the video is not muted
4    //setTimeout(function(){ $("#video-player")[0].play(); }, 1000);
5    // FAQ Toggle feedback 
6    var $feedbacks = $('.feedback');
7    $feedbacks.each(function(){
8    var $feedback = $(this);
9      //negative answer
10      $feedback.find('[data-feedback="negative"]').on('click', function() {
11        $feedback.find('[data-feedback="negative-form"]').slideDown();
12      });
13    })
14      
15    logInOut('ISNE_COOKIE');  
16            
17    var currentLocation = $(location).attr("href");
18    currentLocation = currentLocation.replace("&", "%26");
19            
20    $("#s-user-nav > a").attr("href", $("#s-user-nav > a").attr("href") + currentLocation);
21  
22    $("#nav-user-register").attr("href", $("#nav-user-register").attr("href") + window.location.protocol+"//"+window.location.host + window.location.pathname);
23    $("#nav-user-editUser").attr("href", $("#nav-user-editUser").attr("href") + currentLocation);
24    $("#nav-user-forgotPassword").attr("href", $("#nav-user-forgotPassword").attr("href") + currentLocation);
25  
26  
27    $("#s-nav-user-login").click(function(){    
28      var languageId = $("#hidden_lang").val();
29      var languageCode = languageId == 1 ? "en" : "pt";
30      window.location.href= baseApplicationUrl + '/femgu/login.jspx?request_locale='+languageCode+'&redirect=' + currentLocation;    
31    });
32    
33    $("#s-nav-user-logout").click(function(){    
34      var languageId = $("#hidden_lang").val();
35      var languageCode = languageId == 1 ? "en" : "pt";
36      window.location.href= baseApplicationUrl + '/femgu/logout.jspx?request_locale='+languageCode+'&redirect=' + currentLocation;    
37    });
38    
39    $("[data-button-app=ctt-logistica] a").click(function(){
40           window.location = $(this).attr('href').replace("#nonce", guid());
41    });
42    /*
43    if ($.cookie('hide-cookie-warning-ctt') != 'yes') {
44		$('[data-widget-cookie-warning]').show();
45		
46		$('[data-widget-cookie-warning] a.close-ctt').click(function(e){
47			e.preventDefault();
48			$('[data-widget-cookie-warning]').hide();
49			$.cookie('hide-cookie-warning-ctt', 'yes', { path : '/' });
50		});
51	}
52	*/
53    $("#header-search-input").keydown(function(event){
54        if (event.which == 13) $("#header-search-form").submit();
55    });
56  });
57    /*
58    * Code needed to generate a guid everytime cttlogistica url is called
59    */
60    function guid() {
61        function s4() {
62            return Math.floor((1 + Math.random()) * 0x10000)
63            .toString(16)
64            .substring(1);
65      }
66      return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
67        s4() + '-' + s4() + s4() + s4();
68    }
69    
70    
71  // ADDED by mailtec
72  function getIsneCookie(cookie_name){
73    var cookieData = new Array(5);
74    cookieData[0] = '';
75    cookieData[1] = '';
76    cookieData[2] = '';
77    cookieData[3] = '';
78    cookieData[4] = '';
79  
80    var results = document.cookie.match(cookie_name + '=(.*?)(;|$)');
81    var repl = /\$|,|~|`|\^|\(|\)|\=|\[|\_|\]|\[|\}|\{|\;|\'|\"|\<|\>|\||\\|\./g;  
82    if (results) {
83      if(results[1] != null){
84        results[1] = $.base64Decode(results[1]);
85      }
86      if ((results[1] != null) && (results[1].split("|")[0] != null )) {
87        cookieData[0] = unescape(results[1].split("|")[0].replace(repl,""));
88      }
89      if ((results[1] != null) && (results[1].split("|")[1] != null )) {
90        cookieData[1] = unescape(results[1].split("|")[1].replace(repl,""));  
91      }
92      if ((results[1] != null) && (results[1].split("|")[2] != null )) {
93        cookieData[2] = unescape(results[1].split("|")[2].replace(repl,""));  
94      }
95      if ((results[1] != null) && (results[1].split("|")[3] != null )) {
96        cookieData[3] = unescape(results[1].split("|")[3].replace(repl,""));  
97      }
98      if ((results[1] != null) && (results[1].split("|")[4] != null )) {
99        cookieData[4] = unescape(results[1].split("|")[4].replace(repl,""));  
100      }
101    }
102        
103    return cookieData;
104  }
105  
106  function logInOut(cookie_name, landingPage)
107  {
108    var cookie = readCookie(cookie_name);
109  
110    if (cookie){//cookie available
111	  var username = getIsneCookie(cookie_name)[1];
112	
113      $("#s-nav-loginArea").hide();
114      $("#s-nav-userName").html(username);
115      
116	  var usernameParts = username.split(" ");
117	  var userNameInitial = usernameParts[0].substring(0, 1);
118	  if (usernameParts.length > 1) {
119		  userNameInitial = userNameInitial + usernameParts[usernameParts.length-1].substring(0, 1);
120	  }	  
121	  
122      $("#s-nav-userNameInitials").html(userNameInitial);
123      $("#s-nav-user-icon-anonymous").hide();	    	   	   	  
124	  $("#s-nav-user-icon-user").show();	  
125    }else{//no cookie
126    }
127  }
128  
129  function readCookie(name) {
130    try{
131      var nameEQ = name + "=";
132      var ca = document.cookie.split(';');
133      for(var i=0;i < ca.length;i++) {
134        var c = ca[i];
135        while (c.charAt(0)==' ') c = c.substring(1,c.length);
136          if (c.indexOf(nameEQ) == 0){
137            return c.substring(nameEQ.length,c.length);
138          }
139      }
140    }
141    catch(erro){}
142    return null;
143  }
144  
145    //  This methods is a copy of the method getSiteUserId that exist on file salesforce-init.vtl 
146    //  file location: application/themes/velocity/salesforce/salesforce-init.vtl
147    //
148    //  This method is necessary because the salesforce-init is not available for site applications (feecom, feapl...) 
149	function getSiteUserIdForApps(cookieName) {
150		// Find the cookie string
151		const cookieString = document.cookie.split('; ').find(row => row.startsWith(cookieName + '='));
152		if (!cookieString) return null; // Cookie not found
153
154		// Extract everything after "cookieName="
155		let encodedValue = cookieString.substring(cookieName.length + 1);
156
157		// Remove non-printing characters and surrounding quotes if present
158		let cleanEncodedValue = encodedValue.replace(/[\u200B\u00A0]/g, '').trim();
159
160		// Remove surrounding quotes if they exist (handling both single and double quotes)
161		if (cleanEncodedValue.startsWith('"') && cleanEncodedValue.endsWith('"')) {
162			cleanEncodedValue = cleanEncodedValue.slice(1, -1);
163		}
164		if (cleanEncodedValue.startsWith("'") && cleanEncodedValue.endsWith("'")) {
165			cleanEncodedValue = cleanEncodedValue.slice(1, -1);
166		}
167
168		try {
169			// Decode from Base64
170			const decodedValue = atob(cleanEncodedValue);
171
172			// Split the decoded string by "|"
173			const parts = decodedValue.split('|');
174
175			// Check if the first value is numeric
176			if (!isNaN(parts[0]) && parts[0].trim() !== '') {
177				return parts[0];
178			}
179		} catch (e) {
180			console.error("Error decoding Base64:", e);
181		}
182
183		return null; // Return null if conditions are not met
184	}
185	
186	
187  //retorna lista de tabelas 
188let tabelas = document.getElementsByTagName('table');
189// for (tabela of tabelas)
190//é preciso um loop para criar a div em cada tabela
191for (let i= 0; i < tabelas.length; i++ ) {
192  //tabelas é como se fosse uma lista e tabela está a aceder a cada elemento dessa lista através do i
193  let tabela = tabelas[i]
194  //vai buscar o elemento pai da tabela
195 let parentTabela = tabela.parentNode;
196 //cria um novo elemento para embrulhar a tabela
197 let wrapper = document.createElement('div');
198 // dá-lhe uma class name
199 wrapper.className = 'full-width-table-scroller';
200 //troca a tabela pelo elemento q a vai embrulhar
201 parentTabela.replaceChild(wrapper, tabela);
202 //adiciona a tabela como filha desse element
203 wrapper.appendChild(tabela);
204}

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.