1wiley.includeHTML(); 2 3$(window).scroll(function () { $(this).scrollTop() > 5 ? $(".navbar-me").addClass("fixed-me") : $(".navbar-me").removeClass("fixed-me") }); 4$(window).scroll(function () { $(this).scrollTop() > 5 ? $(".navbar-new").addClass("fixed-top") : $(".navbar-new").removeClass("fixed-top") }); 5$(".carousel").carousel({ interval: 5e3 }) 6 7window._satellite && _satellite.pageBottom(); 8 9window.addEventListener('load', function () { 10 setTimeout(function () { 11 var iFrame = document.createElement("iframe"); 12 iFrame.src = "https://en.wileyeditingservices.com/prefetch"; 13 iFrame.style = "display:none" 14 document.body.appendChild(iFrame); 15 16 $('.first-button').on('click', function () { 17 18 $('.animated-icon1').toggleClass('open'); 19 }); 20 21 // test server script 22 var currentUrl = window.location.href; 23 if (currentUrl.indexOf('127.0.0.1:5500') > 0 || currentUrl.indexOf('development') > 0 || currentUrl.indexOf('https://development.wileyeditingservicescom.cactusopsdev.com/') > 0 || currentUrl.indexOf('staging') > 0) { 24 setTestServer(); 25 } 26 27 }, 3000); 28 29 // test server script 30 function setTestServer() { 31 var testServer = ''; 32 if (!testServer) { 33 return; 34 } 35 $('a').each(function(){ 36 var oldUrl = $(this).attr("href"); 37 if (!oldUrl || oldUrl.indexOf('en.wileyeditingservices.com') == -1) { 38 return; 39 } 40 oldUrl = oldUrl.split('//'); 41 if (oldUrl[1].indexOf('test') == -1) { 42 var newUrl = oldUrl[0] + '//' + testServer + '.' + oldUrl[1]; // Include ":" after "https" 43 $(this).attr("href", newUrl); 44 } 45 }); 46 } 47 48}); 49 50 51 52 53var hs = document.createElement('div'); 54hs.id = 'eu_cookie_dialog'; 55document.body.prepend(hs); 56 57 58// $(document).ready(function () { 59// $(".navbar-toggle").on("click", function () { 60// $(this).toggleClass("active"); 61// }); 62// }); 63 64// $(".nav-link").hover(function(){ 65// $(this).click(); 66// }); 67 68// ===== INIT FLAG TO PREVENT DUPLICATE TRACKING ===== 69window._chinaModalTracked = false; 70 71// ===== ON PAGE READY, GEOLOCATION CHECK ===== 72$(document).ready(function () { 73 $.ajax({
74 url: 'https://geoip.cactusglobal.io/json/', 75 type: 'GET', 76 success: function (response) { 77 const userCountry = response.country_code; 78 79 // Show/hide banners 80 const showBanners = isCountryAllowed(userCountry); 81 $('#header-banner, #section-banner, #navigation-link, #navigation-link-mob').toggle(showBanners); 82 83 // Show China modal only for target country AND if not seen today 84 if (userCountry === 'CN' && !hasSeenChinaModalToday()) { 85 showChinaModal(); 86 storeChinaModalViewDate(); 87 } 88 }, 89 error: function (error) { 90 console.error('Error fetching geolocation:', error.statusText); 91 $('#header-banner, #section-banner, #navigation-link, #navigation-link-mob, #china-nudge-modal, #china-modal-overlay').hide(); 92 } 93 }); 94}); 95 96// ===== CHECK COUNTRY ALLOW LIST ===== 97function isCountryAllowed(country) { 98 const allowedCountries = ['TR', 'IN', 'ETH', 'IQ', 'ZA', 'MY', 'EG', 'CO', 'PK', 'PT']; 99 return allowedCountries.includes(country); 100} 101 102// ===== Global to China site redirection logic starts from here ===== 103 104// ===== SHOW MODAL + TRACK ===== 105function showChinaModal() { 106 $('#china-nudge-modal, #china-modal-overlay').fadeIn(() => { 107 if (!window._chinaModalTracked) { 108 fireSectionViewed(); 109 window._chinaModalTracked = true; 110 } 111 }); 112} 113 114// ===== HIDE MODAL ===== 115function closeModal() { 116 $('#china-nudge-modal, #china-modal-overlay').fadeOut(); 117} 118 119// ===== MODAL CLOSE EVENTS ===== 120$(document).on('click', '#close-china-modal-btn, #stay-global-btn', closeModal); 121 122// ===== DATE CHECK FUNCTIONS ===== 123function hasSeenChinaModalToday() { 124 const lastSeen = localStorage.getItem('chinaModalShown'); 125 if (!lastSeen) return false; 126 127 const lastSeenDate = new Date(lastSeen); 128 const today = new Date(); 129 130 return ( 131 lastSeenDate.getFullYear() === today.getFullYear() && 132 lastSeenDate.getMonth() === today.getMonth() && 133 lastSeenDate.getDate() === today.getDate() 134 ); 135} 136 137function storeChinaModalViewDate() { 138 localStorage.setItem('chinaModalShown', new Date().toISOString()); 139} 140 141// ===== TRACKING FUNCTIONS ===== 142window.dataLayer = window.dataLayer || []; 143 144function fireSectionViewed() { 145 const trackingData = { 146 event: "section_viewed", 147 section_name: "IP nudge for China website", 148 section_type: "Nudge", 149 section_id: "CHN-IP-ND-00", 150 section_location: "smart nudge" 151 }; 152 153 dataLayer.push(trackingData); 154 console.log("Section Viewed Tracked:", trackingData); 155} 156 157// ===== CTA BUTTON TRACKING WITH DELAYED NAVIGATION ===== 158function waitForModalButtons(callback, attempts = 0) { 159 const visitBtn = document.getElementById('visit-china-btn'); 160 const stayBtn = document.getElementById('stay-global-btn'); 161 const closeBtn = document.getElementById('close-china-modal-btn'); 162 163 if (visitBtn && stayBtn && closeBtn) { 164 callback({ visitBtn, stayBtn, closeBtn }); 165 } else if (attempts < 20) { 166 setTimeout(() => waitForModalButtons(callback, attempts + 1), 250); 167 } else { 168 console.warn('China Nudge buttons not found after multiple attempts.'); 169 } 170} 171 172// --- China/EN site switching logic --- 173window.normalizePath = function(path) { 174 let cleanPath = path.split('?')[0]; 175 if (cleanPath.endsWith('/index.html')) { 176 cleanPath = cleanPath.slice(0, -'/index.html'.length); 177 if (cleanPath === '') cleanPath = '/'; 178 } 179 if (cleanPath.length > 1 && cleanPath.endsWith('/')) { 180 cleanPath = cleanPath.slice(0, -1); 181 } 182 return cleanPath; 183}; 184 185// ===== CONFIG: Set your local CN server URL here if needed ===== 186const LOCAL_CN_URL = 'http://localhost:3000'; // Change this if your local CN runs elsewhere 187 188// ===== Detect environment and set CN domain prefix ===== 189function getCnDomainPrefix() { 190 const host = window.location.host; 191 // Localhost or 127.0.0.1 192 if (host.startsWith('localhost') || host.startsWith('127.0.0.1')) { 193 return LOCAL_CN_URL; 194 } 195 // Test/staging server (adjust as per your test domain pattern) 196 if ( 197 host.includes('test') || 198 host.includes('staging') || 199 host === 'development.wileyeditingservicescom.cactusopsdev.com' 200 ) { 201 return 'https://test.editingservices.wiley.cn'; 202 } 203 // Default: live 204 return 'https://editingservices.wiley.cn'; 205} 206 207document.addEventListener('DOMContentLoaded', () => { 208 waitForModalButtons(({ visitBtn, stayBtn, closeBtn }) => { 209 // --- Visit China button logic --- 210 visitBtn.addEventListener('click', function (e) { 211 e.preventDefault(); 212 var nudgeValue = 'china'; 213 handleCtaClick({ 214 name: 'Visit China website', 215 type: 'link', 216 id: 'CHN-IP-ND-02', 217 location: 'Nudge for China website', 218 nudgeValue: nudgeValue 219 }); 220 var currentPath = window.normalizePath(window.location.pathname); 221 var map = window.urlPatternMap || {}; 222 var cnPath = map[currentPath]; 223 if (!cnPath && currentPath !== '/') { 224 cnPath = map[currentPath + '/']; 225 } 226 var cnDomain = getCnDomainPrefix(); 227 // Build the redirect URL with proper path handling 228 const buildRedirectUrlWithoutNudge = () => { 229 // Get CN site path that corresponds to current path, or use home page 230 if (cnPath) { 231 // Only add trailing slash if needed (not for file paths) 232 if (!cnPath.endsWith('/') && !cnPath.match(/\.[a-zA-Z0-9]+$/)) { 233 cnPath += '/'; 234 } 235 // Remove leading slash if exists to avoid double slashes 236 return `${cnDomain}/${cnPath.replace(/^\//, '')}`; 237 } 238 239 // Default to CN site homepage 240 return `${cnDomain}/`; 241 }; 242 243 // Create the final URL with nudge parameter 244 const finalUrl = new URL(buildRedirectUrlWithoutNudge()); 245 finalUrl.searchParams.set('nudge', nudgeValue); 246 247 // Redirect after short delay to ensure tracking completes 248 setTimeout(() => { 249 window.location.href = finalUrl.toString(); 250 }, 500); 251 }); 252 253 // --- Stay Global button logic --- 254 stayBtn.addEventListener('click', function (e) { 255 e.preventDefault(); 256 257 var stayGlobalRedirectUrl = window.location.href; 258 259 // Create the final URL with nudge parameter 260 const globalUrl = new URL(stayGlobalRedirectUrl); 261 globalUrl.searchParams.set('nudge', 'global'); 262 263 handleCtaClick({ 264 name: 'Stay on Global', 265 type: 'link', 266 id: 'GLB-IP-ND-02', 267 location: 'Nudge for China website', 268 nudgeValue: 'global' 269 }); 270 setTimeout(() => { 271 window.location.href = globalUrl.toString(); 272 }, 500); 273 }); 274 275 closeBtn.addEventListener('click', () => { 276 handleCtaClick({ 277 name: 'Close the popup', 278 type: 'button', 279 id: 'CLOSE-IP-ND-02', 280 location: 'Nudge for China website', 281 nudgeValue: 'closed' 282 }); 283 closeModal(); 284 }); 285 }); 286}); 287 288// Nudge Parameter Handling 289function updateLinksWithNudge(nudge) { 290 if (!nudge) return; 291 $('a[href]').each(function () { 292 const $link = $(this); 293 let href = $link.attr('href'); 294 295 //Skip invalid or special links 296 if ( 297 !href || href.startsWith('#') || 298 href.startsWith('mailto:') || 299 href.startsWith('tel:') || 300 href.startsWith('javascript:') 301 ) { 302 return; 303 } 304 305 try { 306 //Construct URL relative to current origin (works for relative & absolute URLs) 307 const url = new URL(href, window.location.origin); 308 309 //Ensure trailing slash if missing (for servers requiring it) 310 if (!url.pathname.endsWith('/')) { 311 url.pathname += '/'; 312 } 313 314 //Only set nudge if not already present 315 if (!url.searchParams.has('nudge')) { 316 url.searchParams.set('nudge', nudge); 317 } 318 319 //Preserve any hash fragment (e.g. #section) 320 const updatedHref = url.toString(); 321 322 //Avoid unnecessary DOM updates 323 if ($link.attr('href') !== updatedHref) { 324 $link.attr('href', updatedHref); 325 } 326 327 } catch (err) { 328 console.warn('Invalid href skipped:', href, err); 329 } 330 }); 331} 332 333$(document).ready(function () { 334 const params = new URLSearchParams(window.location.search); 335 const nudge = params.get("nudge"); 336 337 if (!nudge) return; 338 339 updateLinksWithNudge(nudge); 340 setTimeout(() => updateLinksWithNudge(nudge), 500); 341 342 const observer = new MutationObserver(() => { 343 updateLinksWithNudge(nudge); 344 }); 345 346 observer.observe(document.body, { childList: true, subtree: true }); 347}); 348 349// ===== URL REDIRECTION FUNCTIONALITY ===== 350(function() { 351 'use strict'; 352 353 // Global configuration 354 const APP_PREFIX = 'test17'; 355 const APP_DOMAIN = 'https://app.en.wileyeditingservices.com'; 356 357 // Set global variables 358 window.app_prefix = APP_PREFIX; 359 window.app_domain = APP_DOMAIN; 360 361 // Set in localStorage 362 localStorage.setItem('app_prefix', APP_PREFIX); 363 localStorage.setItem('app_domain', APP_DOMAIN); 364 365 // URL pattern mapping for redirection 366 window.urlPatternMap = { 367 // Main pages 368 '/en/': '/', 369 '/en/index.html': '/', 370 '/en/404.html': '', 371 '/en/customer-testimonial.html': 'customer-testimonial.html', 372 '/en/knowledge-hub-orders.html': 'knowledge-hub-orders.html', 373 '/en/thankyou.html': 'thankyou.html', 374 '/en/thankyou-testimonial.html': 'thankyou-testimonial.html', 375 '/en/thankyou-tracking.html': 'thankyou-tracking.html', 376 '/en/unsubscribe.html': 'unsubscribe.html', 377 '/en/about-wiley/': 'about-wiley/index.html', 378 '/en/about-wiley/index.html': 'about-wiley/index.html', 379 '/en/contact-us/': 'contact-us/index.html', 380 '/en/contact-us/index.html': 'contact-us/index.html', 381 '/en/quality/': 'quality/index.html', 382 '/en/quality/index.html': 'quality/index.html', 383 '/en/testimonials/': '/', 384 '/en/testimonials/index.html': '/', 385 '/en/privacy-policy/': 'privacy-policy/index.html', 386 '/en/privacy-policy/index.html': 'privacy-policy/index.html', 387 '/en/terms-and-conditions/': 'terms-and-conditions/index.html', 388 '/en/terms-and-conditions/index.html': 'terms-and-conditions/index.html', 389 '/en/faq/': 'faq/index.html', 390 '/en/faq/index.html': 'faq/index.html', 391 '/en/faq/index1.html': 'faq/index1.html', 392 '/en/sitemap/': 'sitemap/index.html', 393 '/en/sitemap/index.html': 'sitemap/index.html', 394 '/en/services/': 'services/index.html', 395 '/en/services/index.html': 'services/index.html', 396 '/en/pricing/': 'pricing/index.html', 397 '/en/pricing/index.html ': 'pricing/index.html', 398 '/en/article-preparation/': 'article-preparation/index.html', 399 '/en/article-preparation/index.html': 'article-preparation/index.html', 400 '/en/article-preparation/academic-illustration/': 'article-preparation/academic-illustration/index.html', 401 '/en/article-preparation/academic-illustration/index.html': 'article-preparation/academic-illustration/index.html', 402 '/en/article-preparation/academic-translation/': 'article-preparation/academic-translation/index.html', 403 '/en/article-preparation/academic-translation/index.html': 'article-preparation/academic-translation/index.html', 404 '/en/article-preparation/english-language-editing/': 'article-preparation/english-language-editing/index.html', 405 '/en/article-preparation/english-language-editing/index.html': 'article-preparation/english-language-editing/index.html', 406 '/en/article-preparation/figure-formatting/': 'article-preparation/figure-formatting/index.html', 407 '/en/article-preparation/figure-formatting/index.html': 'article-preparation/figure-formatting/index.html', 408 '/en/article-preparation/graphical-abstract-design/': 'article-preparation/graphical-abstract-design/index.html', 409 '/en/article-preparation/graphical-abstract-design/index.html': 'article-preparation/graphical-abstract-design/index.html', 410 '/en/article-preparation/journal-recommendation/': 'article-preparation/journal-recommendation/index.html', 411 '/en/article-preparation/journal-recommendation/index.html': 'article-preparation/journal-recommendation/index.html', 412 '/en/article-preparation/manuscript-formatting/': 'article-preparation/manuscript-formatting/index.html', 413 '/en/article-preparation/manuscript-formatting/index.html': 'article-preparation/manuscript-formatting/index.html', 414 '/en/article-preparation/scientific-editing/': 'article-preparation/scientific-editing/index.html', 415 '/en/article-preparation/scientific-editing/index.html': 'article-preparation/scientific-editing/index.html', 416 '/en/article-promotion/': 'article-promotion/index.html', 417 '/en/article-promotion/index.html': 'article-promotion/index.html', 418 '/en/article-promotion/conference-poster-creation/': 'article-promotion/conference-poster-creation/index.html', 419 '/en/article-promotion/conference-poster-creation/index.html': 'article-promotion/conference-poster-creation/index.html', 420 '/en/article-promotion/cover-image-design/': 'article-promotion/cover-image-design/index.html', 421 '/en/article-promotion/cover-image-design/index.html': 'article-promotion/cover-image-design/index.html', 422 '/en/article-promotion/infographic-creation/': 'article-promotion/infographic-creation/index.html', 423 '/en/article-promotion/infographic-creation/index.html': 'article-promotion/infographic-creation/index.html', 424 '/en/article-promotion/lay-summaries/': 'article-promotion/lay-summaries/index.html', 425 '/en/article-promotion/lay-summaries/index.html': 'article-promotion/lay-summaries/index.html', 426 '/en/article-promotion/research-news-story/': 'article-promotion/research-news-story/index.html', 427 '/en/article-promotion/research-news-story/index.html': 'article-promotion/research-news-story/index.html', 428 '/en/article-promotion/video-creation/': 'article-promotion/video-creation/index.html', 429 '/en/article-promotion/video-creation/index.html': 'article-promotion/video-creation/index.html', 430 '/en/payment/': 'payment/index.html', 431 '/en/payment/index.html': 'payment/index.html', 432 '/en/mobile/place-order.html': 'mobile/place-order.html', 433 '/en/mobile/thank-you.html': 'mobile/thank-you.html', 434 }; 435 436 function buildRedirectUrl(redirectPath) { 437 // Parse the app_domain to extract the actual domain part 438 const domainUrl = new URL(APP_DOMAIN); 439 const protocol = domainUrl.protocol; 440 const hostname = domainUrl.hostname; 441 442 // Build the final URL: https://{app_prefix}.{hostname}{redirectPath} 443 return `${protocol}//${APP_PREFIX}.${hostname}${redirectPath}`; 444 } 445 446 function getCurrentPath() { 447 return window.location.pathname; 448 } 449 450 function performRedirection() { 451 const currentPath = getCurrentPath(); 452 453 // Check if current path matches any pattern in the map 454 if (urlPatternMap.hasOwnProperty(currentPath)) { 455 const redirectPath = urlPatternMap[currentPath]; 456 const redirectUrl = buildRedirectUrl(redirectPath); 457 458 console.log('Redirecting from:', currentPath); 459 console.log('Redirecting to:', redirectUrl); 460 461 // Perform the redirection 462 window.location.href = redirectUrl; 463 return true; 464 } 465 466 return false;
467 } 468 469 // Initialize redirection on document load 470 function initializeRedirection() { 471 console.log('URL Redirection System Initialized'); 472 console.log('App Prefix:', APP_PREFIX); 473 console.log('App Domain:', APP_DOMAIN); 474 console.log('Current Path:', getCurrentPath()); 475 476 // Uncomment the next line to enable automatic redirection 477 // performRedirection(); 478 } 479 480 // Run on document ready 481 $(document).ready(function() { 482 initializeRedirection(); 483 }); 484 485 // Also run on window load as a fallback 486 window.addEventListener('load', function() { 487 initializeRedirection(); 488 }); 489 490 // Expose functions globally for manual testing 491 window.wileyRedirection = { 492 performRedirection: performRedirection, 493 buildRedirectUrl: buildRedirectUrl, 494 getCurrentPath: getCurrentPath, 495 urlPatternMap: urlPatternMap 496 }; 497 498})(); 499 500
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.