🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.javascript
Article #50709

[jquery] generator hasła

#50709
From: ŁR
Date: Tue, 12 Apr 2011 10:04
35 lines
1986 bytes
Witam,
próbuję ogarnąć jquery i jeden z pluginów do generowania haseł. I niby 
wszystko ok ale nie potrafię wywołać funkcji.

Jest sobie taki kod:
$.extend({
   password: function (length, special) {
     var iteration = 0;
     var password = "";
     var randomNumber;
     if(special == undefined){
         var special = false;
     }
     while(iteration < length){
         randomNumber = (Math.floor((Math.random() * 100)) % 94) + 33;
         if(!special){
             if ((randomNumber >=33) && (randomNumber <=47)) { continue; }
             if ((randomNumber >=58) && (randomNumber <=64)) { continue; }
             if ((randomNumber >=91) && (randomNumber <=96)) { continue; }
             if ((randomNumber >=123) && (randomNumber <=126)) { continue; }
         }
         iteration++;
         password += String.fromCharCode(randomNumber);
     }
     return password;
   }
});

// How to use
$.password(8);

Niby napisane jest jak to wywołać, ale nie mam pojęcia w jaki sposób. 
Chciałbym aby wygenerowane hasło pojawiało się w polu input. Bardzo 
proszę o jakieś sugestie, bo siedzę i wertuję dokumentacje od jquery, 
ale jeszcze widać pewne rzeczy do mnie nie docierają.
Technical Details
Message-ID: <4da4239e$1@news.home.net.pl>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.rmf.pl!nf1.ipartners.pl!ipartners.pl!news.home.net.pl!not-for-mail

Show Full Headers
Complete Article Headers
Date: Tue, 12 Apr 2011 12:04:11 +0200
From: ŁR <lukaszTylkO@WyTNIJrostalski.pl>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9
MIME-Version: 1.0
Newsgroups: pl.comp.lang.javascript
Subject: [jquery] generator hasła
NNTP-Posting-Host: 94.40.65.238
Message-ID: <4da4239e$1@news.home.net.pl>
X-Trace: news.home.net.pl 1302602654 94.40.65.238 (12 Apr 2011 12:04:14 +0100)
Organization: home.pl news server
Lines: 35
X-Authenticated-User: lukasz.rostalski@im.pl
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.rmf.pl!nf1.ipartners.pl!ipartners.pl!news.home.net.pl!not-for-mail
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit