/xoops/installer/2.0.18/install/include/install.js

http://xoopsfrance.codeplex.com · JavaScript · 98 lines · 62 code · 24 blank · 12 comment · 19 complexity · ef996a3c44f8e55f4f0c3e529d4207fa MD5 · raw file

  1. if ( typeof window.$ != 'function' ) {
  2. function $() {
  3. var elements = new Array();
  4. for (var i = 0; i < arguments.length; i++) {
  5. var element = arguments[i];
  6. if (typeof element == 'string')
  7. element = document.getElementById(element);
  8. if (arguments.length == 1)
  9. return element;
  10. elements.push(element);
  11. }
  12. return elements;
  13. }
  14. }
  15. function xoopsGetElementById(id){
  16. return $(id);
  17. }
  18. function showThemeSelected(imgId, selectId, imgDir, extra, xoopsUrl) {
  19. if (xoopsUrl == null) {
  20. xoopsUrl = "./";
  21. }
  22. imgDom = xoopsGetElementById(imgId);
  23. selectDom = xoopsGetElementById(selectId);
  24. imgDom.src = xoopsUrl + "/"+ imgDir + "/" + selectDom.options[selectDom.selectedIndex].value + "/screenshot.png" + extra;
  25. }
  26. function selectModule( id , button) {
  27. element = xoopsGetElementById(id);
  28. if ( button.value == 1) {
  29. element.style.background = '#E6EFC2';
  30. } else {
  31. element.style.background = 'transparent';
  32. }
  33. }
  34. function passwordStrength(password) {
  35. var score = 0;
  36. //if password bigger than 6 give 1 point
  37. if (password.length > 6) score++;
  38. //if password has both lower and uppercase characters give 1 point
  39. if ( ( password.match(/[a-z]/) ) && ( password.match(/[A-Z]/) ) ) score++;
  40. //if password has at least one number give 1 point
  41. if (password.match(/\d+/)) score++;
  42. //if password has at least one special caracther give 1 point
  43. if ( password.match(/.[!,@,#,$,%,^,&,*,?,_,~,-,(,)]/) ) score++;
  44. //if password bigger than 12 give another 1 point
  45. if (password.length > 12) score++;
  46. document.getElementById("passwordDescription").innerHTML = desc[score];
  47. document.getElementById("passwordStrength").className = "strength" + score;
  48. }
  49. function suggestPassword( passwordlength ) {
  50. var pwchars = "abcdefhjmnpqrstuvwxyz23456789ABCDEFGHJKLMNPQRSTUVWYXZ.,:";
  51. var pwchars = "abcdefhjmnpqrstuvwxyz1234567890,?;.:!$=+@_-&|#ABCDEFGHJKLMNPQRSTUVWYXZ";
  52. var passwd = document.getElementById('generated_pw');
  53. passwd.value = '';
  54. for ( i = 0; i < passwordlength; i++ ) {
  55. passwd.value += pwchars.charAt( Math.floor( Math.random() * pwchars.length ) )
  56. }
  57. return passwd.value;
  58. }
  59. /**
  60. * Copy the generated password (or anything in the field) to the form
  61. *
  62. * @param string the form name
  63. *
  64. * @return boolean always true
  65. */
  66. function suggestPasswordCopy(id) {
  67. generated_pw = xoopsGetElementById('generated_pw');
  68. adminpass = xoopsGetElementById('adminpass')
  69. adminpass.value = generated_pw.value;
  70. adminpass2 = xoopsGetElementById('adminpass2')
  71. adminpass2.value = generated_pw.value;
  72. passwordStrength(adminpass.value)
  73. return true;
  74. }