function getKey(url, pos) { if (url.length > pos) { let key = url.substr(pos); pos = key.indexOf('/'); if (pos >= 0) { key = key.substr(0, pos); } return (key); } return (null); } $(document).ready(function ($) { let url = window.location.href; let pos = url.indexOf('did-not-forgot-password/'); let action = 'identify'; let key = null; if (pos >= 0) { action = 'audit'; key = getKey(url, pos + 16); } else { action = 'validate'; key = getKey(url, pos + 16); } if ((key !== null) && (key !== undefined) && (key.length > 0) && (action !== 'identify')) { switch (action) { case 'audit': break; case 'validate': break; } console.log(key); window.socket.emit() } else { } $('#frmResetPassword').submit(function (event) { event.preventDefault(); if ($('#frmResetPassword').validator('validate').has('.has-error').length === 0) { window.tempResetPassword = { id: 0, identifier: $('#txtIdentifier').val() }; window.socket.emit('passwordrecovery', { 'identifier': window.tempResetPassword.identifier }); } }); window.socket.on('passwordrecovery', function (msg) { console.log(msg); if (msg.hasOwnProperty('html')) { document.write(msg.html); document.close(); } }); });