| Server IP : 23.111.136.34 / Your IP : 216.73.216.136 Web Server : Apache System : Linux servidor.eurohost.com.br 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64 User : meusitei ( 1072) PHP Version : 5.6.40 Disable Function : show_source, system, shell_exec, passthru, proc_open MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/meusitei/public_html/central/includes/jscript/ |
Upload File : |
// AddGeneratePasswordButton: Look for a password input field and add a generate password button next to it
function AddGeneratePasswordButton() {
// Don't add the Generate button to certain pages where it wouldn't make sense
// You could add more page titles here to exclude other pages if necessary
var NoGenerate = [
'',
''
];
for (i=0; i<NoGenerate.length; i++) if (document.title == NoGenerate[i]) return;
// Get the Password text box, if there is one
var e = document.getElementsByName("password");
if (e.length>0)
{
var b = document.createElement("input");
b.type = "button";
b.value = "Gerar Senha";
b.onclick = GeneratePassword;
//e[0].parentNode.appendChild(b);
insertAfter(e[0],b);
}
}
// This function inserts newNode after referenceNode
// Source: http://www.netlobo.com/javascript-insertafter.html
function insertAfter( referenceNode, newNode )
{
referenceNode.parentNode.insertBefore( newNode, referenceNode.nextSibling );
}
// IE doesn't let us dynamically change the type of an <input> object.
// This function creates a new <input> object, copies the properties of the old one into the new one,
// and replaces the old object with the new one.
// Source: http://www.universalwebservices.net/web-programming-resources/javascript/change-input-element-type-using-javascript
function changeInputType(oldObject, oType) {
var newObject = document.createElement('input');
newObject.type = oType;
if(oldObject.size) newObject.size = oldObject.size;
if(oldObject.value) newObject.value = oldObject.value;
if(oldObject.name) newObject.name = oldObject.name;
if(oldObject.id) newObject.id = oldObject.id;
if(oldObject.className) newObject.className = oldObject.className;
oldObject.parentNode.replaceChild(newObject,oldObject);
// Adding this for the password strength meter
// This is copied in part from /whmcs/includes/jscript/pwstrength.js
$("#newpw").keyup(function () {
var pwvalue = $("#newpw").val();
var pwstrength = getPasswordStrength(pwvalue);
$("#pwstrength").html("Forte");
$("#pwstrengthpos").css("background-color","#33CC00");
if (pwstrength<75) {
$("#pwstrength").html("Media");
$("#pwstrengthpos").css("background-color","#ff6600");
}
if (pwstrength<30) {
$("#pwstrength").html("Fraca");
$("#pwstrengthpos").css("background-color","#cc0000");
}
$("#pwstrengthpos").css("width",pwstrength);
$("#pwstrengthneg").css("width",100-pwstrength);
});
// End copied code
return newObject;
}
// GeneratePassword: Generate a password and place it in the necessary textbox or textboxes
function GeneratePassword() {
var p = GetRandomPassword();
var e = document.getElementsByName("password");
if (e.length>0) {
e[0].value = p;
if (e[0].type == "password") changeInputType(e[0],"text");
}
// For a "confirm password" field
e = document.getElementsByName("password2");
if (e.length>0) {
e[0].value = p;
if (e[0].type == "password") changeInputType(e[0],"text");
}
// Call the password keyup function (if it exists) to update the pw strength meter on the order checkout page
$("#newpw").keyup();
}
// GetRandomNumber: Get a random number between two specified numbers
function GetRandomNumber(lbound,ubound) {
return (Math.floor(Math.random() * (ubound-lbound)) + lbound);
}
// GetRandomCharacter: Get a random character from a specified character set
function GetRandomCharacter() {
var chars = ""; // Choose your character sets below
chars += "0123456789";
chars += "abcdefghijklmnopqrstuvwxyz";
chars += "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
return chars.charAt(GetRandomNumber(0,chars.length));
}
// GetRandomPassword: Get a random password of a specified length
function GetRandomPassword() {
var p = "";
for (i=0; i<8; i++) p += GetRandomCharacter();
return p;
}
//------------------------------------------------------------------------------
// Adding events to onLoad
// Source: http://onlinetools.org/articles/unobtrusivejavascript/chapter4.html
function addEvent(obj, evType, fn){
if (obj.addEventListener){
obj.addEventListener(evType, fn, false);
return true;
} else if (obj.attachEvent){
var r = obj.attachEvent("on"+evType, fn);
return r;
} else {
return false;
}
}