/** ** script.js ** General stuff used in JForum ** @author: Jack Wootton **/ /* Are we dealing with a valid email address? */ function StrIsEmail(value) { var ret = false; var emailRe=/\w+(.\w+)*@\w+(.\w+)*\.\w{2,3}/; var emailResult = emailRe.exec(value); if (emailResult) { if (emailResult[0].length == emailResult.input.length) ret = true; } return ret; } /* Only use for registration as this is the only door for bad email address values */ function Check() { msg = "" if (! StrIsEmail( document.login.email.value )) msg += "\nPlease enter a valid email address"; if ( msg != "" ) { alert( msg ); return false; } return true; } /* Triggers menu items , do this so don't have to use the querystring */ function setMenu() { document.mainMenu.txtAction.value=arguments[0]; document.mainMenu.submit(); } /* Ensures we don't get a double posting of data when we refresh */ function refreshPage() { document.location.href=arguments[0]; } /* Give user a chance, they might have hit 'remove' by accident */ function removeThread() { answer = confirm("Do you really want to remove this thread?"); if(answer) document.location.href=("MainController?ID=" + arguments[0] + "&txtAction=" + arguments[1]); else return false; } /* Should really write a generic confirmation function, but can't be bothered */ function removeMessage() { answer = confirm("Do you really want to remove this message?"); if(answer) document.location.href=("MainController?ID=" + arguments[0] + "&txtAction=" + arguments[1] + "&threadID=" + arguments[2]); else return false; } /* IE only: swaps stylesheet temporarily */ function swapStyle() { if(document.all) document.all.mainStyle.href = 'include/css/' + arguments[0]; } /* Save the user from writing UBB code if they wish to use it */ function insertUBB(ubb, txtArea) { txtArea.value = txtArea.value += ubb; } function skip2Topic() { if(arguments[0] != "") { document.threadForm.action=arguments[0]; document.threadForm.submit(); } return false; }