Click here to Skip to main content
15,888,527 members
Home / Discussions / JavaScript
   

JavaScript

 
GeneralRe: is it possible? Pin
dusty_dex12-May-13 12:38
dusty_dex12-May-13 12:38 
GeneralRe: is it possible? Pin
Hakan Bulut12-May-13 21:17
Hakan Bulut12-May-13 21:17 
GeneralRe: is it possible? Pin
dusty_dex13-May-13 1:24
dusty_dex13-May-13 1:24 
GeneralRe: is it possible? Pin
Hakan Bulut13-May-13 2:44
Hakan Bulut13-May-13 2:44 
GeneralRe: is it possible? Pin
dusty_dex13-May-13 3:24
dusty_dex13-May-13 3:24 
GeneralRe: is it possible? Pin
Hakan Bulut13-May-13 4:23
Hakan Bulut13-May-13 4:23 
GeneralRe: is it possible? Pin
dusty_dex13-May-13 4:51
dusty_dex13-May-13 4:51 
GeneralRe: is it possible? Pin
dusty_dex13-May-13 13:38
dusty_dex13-May-13 13:38 
I had a look at your web server code and tried to figure out Random bits.

You do understand these are not finished code? Just "Work in progress", but I'm not getting much response as usual. D'Oh! | :doh:

JavaScript
function RandomNumber() {
    var IsToken = [
           [ 9,10,38,40,46,48],
           [11,40,42,45,47,48],
           [ 1,19,26,30,31,48]
        ];

    var MAX_WEEKS  = 3; // array can now be extended, avoids (future) problems ;)
    var MAX_DATA   = 50;
    var items      = 1;
    var items2     = 1;
    var scope;
    var dups       = new Array(MAX_DATA); 
    var nodups     = new Array(MAX_DATA); // ** NEW **
    var lucky      = new Array(MAX_DATA);
    var arr        = [];

    //===================================
    for (var i=0; i < MAX_DATA; i++) {
         dups[i]=0;
    }
    //===================================

    // ArrIns can be dealt with in exactly the same way
    // as before it's just easier to manage changes
    for (var week=0; week < MAX_WEEKS; week++) {
    //document.write("items= "+ items);

      for (var j=0; j < 6; j++) {
          var x = IsToken[week][j];
                    
          if(dups[x] == 0) {
              //document.write("yes: "+ x +" "+ items);
              dups[x]  = x; // replaces boolean with actual value (non-zero == used)
              nodups[items] = x;
              items++;
          } else {
              //document.write("no: "+ x);
          }

      } // loop-j

    } // loop-week

    // *** NEW *** - no duplicates, now sort them
    nodups.sort(function(a,b){return a-b;});
            
    /* copied from IsToken[][] with any duplicates removed */
    document.write("<br>numbers: (without duplicates)<br>");
    for (var i=0; i < items-1; i++) {
         document.write(nodups[i] +" ");
    }

    /* array used for tracking duplicates & used by random.
       int instead of boolean.
    */
    document.writeln("<br>");
    document.write("<br>used numbers: <br>");
         
    for (var i=1; i < 50; i++) {
         if (dups[i] == 0) {
            arr[items2++] = i;
         } else {
            arr[items2++] = 0;
         }
        document.write(dups[i] +" ");
    }

    document.writeln("<br>");
    document.writeln("<br>unused numbers:<br>");

    for (var i=1; i < items2; i++) {
        document.write(arr[i] +" ");
    }

    document.writeln("<br><br>");

    /* watch when arr[q] = 0 (gets value of q which is in IsToken[])
     * 
     * NEW : Random 
     */
    for (var r=6; r > 0; r--) {
        var q = Math.round(48 * Math.random())+1;
        document.writeln("q: "+ q +" arr[q]="+ arr[q] +"<br>");
        if (dups[arr[q]] != 0) {
             lucky[r] = arr[q];
             dups[arr[q]] = 0; // mark as used
        } else {
             lucky[r] = q;
        }
    }

    document.writeln("<br><br>");

    lucky.sort(function(a,b){return a-b;});
    for (var i=0; i < 6; i++) {
        document.writeln(lucky[i]);
    }

}



GeneralRe: is it possible? Pin
dusty_dex15-May-13 6:00
dusty_dex15-May-13 6:00 
GeneralRe: is it possible? Pin
Hakan Bulut15-May-13 7:51
Hakan Bulut15-May-13 7:51 
GeneralRe: is it possible? Pin
dusty_dex15-May-13 8:45
dusty_dex15-May-13 8:45 
GeneralRe: is it possible? Pin
Hakan Bulut15-May-13 21:52
Hakan Bulut15-May-13 21:52 
GeneralRe: is it possible? Pin
dusty_dex15-May-13 23:04
dusty_dex15-May-13 23:04 
GeneralRe: is it possible? Pin
dusty_dex15-May-13 23:28
dusty_dex15-May-13 23:28 
GeneralRe: is it possible? Pin
Hakan Bulut15-May-13 23:52
Hakan Bulut15-May-13 23:52 
GeneralRe: is it possible? Pin
dusty_dex16-May-13 0:12
dusty_dex16-May-13 0:12 
GeneralRe: is it possible? Pin
Richard MacCutchan11-May-13 4:06
mveRichard MacCutchan11-May-13 4:06 
GeneralRe: is it possible? Pin
Hakan Bulut11-May-13 4:28
Hakan Bulut11-May-13 4:28 
GeneralRe: is it possible? Pin
Richard MacCutchan11-May-13 4:30
mveRichard MacCutchan11-May-13 4:30 
QuestionHow do I hide a column using JQuery? Pin
AshwiniRS7-May-13 23:35
AshwiniRS7-May-13 23:35 
AnswerRe: How do I hide a column using JQuery? Pin
walterhevedeich8-May-13 1:03
professionalwalterhevedeich8-May-13 1:03 
GeneralRe: How do I hide a column using JQuery? Pin
AshwiniRS8-May-13 2:07
AshwiniRS8-May-13 2:07 
GeneralRe: How do I hide a column using JQuery? Pin
Manfred Rudolf Bihy8-May-13 2:30
professionalManfred Rudolf Bihy8-May-13 2:30 
GeneralRe: How do I hide a column using JQuery? Pin
AshwiniRS8-May-13 20:34
AshwiniRS8-May-13 20:34 
AnswerRe: How do I hide a column using JQuery? Pin
Dennis E White8-May-13 4:37
professionalDennis E White8-May-13 4:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.