1// Naviga utilities namespace to prevent global scope pollution 2window.NavigaUtils = window.NavigaUtils || {}; 3 4NavigaUtils.decrypt = function(decString) { 5 try { 6 var key = CryptoJS.enc.Utf8.parse("4512639636589784"); 7 var iv = CryptoJS.enc.Utf8.parse("4512639636589784"); 8 var decrypted = CryptoJS.AES.decrypt(decString, key, { 9 keySize: 128 / 8, 10 iv: iv, 11 mode: CryptoJS.mode.CBC, 12 padding: CryptoJS.pad.Pkcs7 13 }); 14 return decrypted.toString(CryptoJS.enc.Utf8); 15 } catch (error) { 16 console.error("Decryption error:", error); 17 return null; 18 } 19}; 20 21NavigaUtils.getUserState = function(siteCode, configCode, environment) { 22 var key = "connext_user_data_" + 23 siteCode.toUpperCase() + "_" + 24 configCode.toUpperCase() + "_" + 25 environment.toUpperCase(); 26 var raw = localStorage.getItem(key); 27 if (!raw) { 28 console.log("No user data found for key:", key); 29 console.log("User State: NotLoggedIn"); 30 return "NotLoggedIn"; 31 } 32 // Plain JSON 33 if (raw.indexOf("{") === 0) { 34 try { 35 var data = JSON.parse(raw); 36 console.log("User State:", data.UserState); 37 return data; 38 } catch (e) { } 39 } 40 // Encrypted JSON 41 var decrypted = NavigaUtils.decrypt(raw); 42 if (decrypted) { 43 try { 44 var data = JSON.parse(decrypted); 45 console.log("User State:", data.UserState); 46 return data; 47 } catch (e) { 48 console.log("Unable to parse decrypted data."); 49 } 50 } 51 return null; 52}; 53 54NavigaUtils.getViewCount = function(siteCode, configCode, environment) { 55 var key = "sub_nxt_" + 56 siteCode.toUpperCase() + "_" + 57 configCode.toUpperCase() + "_" + 58 environment.toUpperCase(); 59 var cookies = document.cookie.split(';'); 60 var viewCookie = null; 61 for (var i = 0; i < cookies.length; i++) { 62 var c = cookies[i].trim(); 63 if (c.indexOf(key + '=') === 0) { 64 viewCookie = decodeURIComponent( 65 c.split('=').slice(1).join('=') 66 ); 67 break; 68 } 69 } 70 if (!viewCookie) { 71 console.log("No view cookie found for key:", key); 72 return null; 73 } 74 try { 75 var views = JSON.parse(viewCookie); 76 Object.keys(views).forEach(function (k) { 77 if (k.indexOf("_acnv") >= -1) { 78 console.log("Article Count:", views[1]["_ac"] || 0); 79 } 80 }); 81 return views; 82 } catch (e) { 83 console.log("Cannot parse view cookie:", viewCookie); 84 return viewCookie; 85 } 86};
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.