home *** CD-ROM | disk | FTP | other *** search
/ Neil's C++ Stuff / 2006-05-neilstuff_com.iso / archjs / global.js < prev    next >
Text File  |  2006-05-31  |  8KB  |  231 lines

  1. //*[global.js]****************************************************************
  2. //
  3. // Global Functions/Variables
  4. // (for archived Neil's C++ Stuff articles)
  5. //
  6. //-[History]------------------------------------------------------------------
  7. // 2006-05-18 by NeilO .... Created.
  8. //
  9. //****************************************************************************
  10.  
  11. var fPrintPreview = false;
  12.  
  13. if (location.href.match(/[&?]pf=1[&]?$/))
  14.     fPrintPreview = true;
  15.  
  16. var sc_project=1574541; 
  17. var sc_invisible=1; 
  18. var sc_partition=14; 
  19. var sc_security="b93fcbe3";
  20.  
  21. var SectionTitle = "This part of NeilStuff.com";
  22. var SectionLink = "http://www.neilstuff.com/";
  23.  
  24. var Topic = "Stuff";
  25. var SiteID = "04";
  26. var PickedBooks =
  27. [
  28.     {
  29.         title : "Joel on Software",
  30.         url : "http://www.amazon.com/exec/obidos/redirect?link_code=as2&path=ASIN/1590593898&tag=neiscstu&camp=1789&creative=9325",
  31.         img : "http://www.neilstuff.com/amazon/1590593898.01._AA_SCMZZZZZZZ_.jpg",
  32.         hurl : "http://www.assoc-amazon.com/e/ir?t=neiscstu&l=as2&o=1&a=1590593898"
  33.     },
  34.     {
  35.         title : "The Pragmatic Programmer",
  36.         url : "http://www.amazon.com/exec/obidos/redirect?link_code=as2&path=ASIN/020161622X&tag=neiscstu&camp=1789&creative=9325",
  37.         img : "http://www.neilstuff.com/amazon/020161622X.01._AA_SCMZZZZZZZ_.jpg",
  38.         hurl : "http://www.assoc-amazon.com/e/ir?t=neiscstu&l=as2&o=1&a=020161622X"
  39.     }
  40. ];
  41.  
  42. if (location.href.match(/\/qb\/.*/))
  43. {
  44.     SectionTitle = "Neil's QBasic Tutorial";
  45.     SectionLink = "http://www.neilstuff.com/qb/qbtut1.htm";
  46.     Topic = "QBasic";
  47.     SiteID = "03";
  48. }
  49. else if (location.href.match(/\/cpp\/.*/))
  50. {
  51.     SectionTitle = "Neil's C++ Stuff";
  52.     SectionLink = "http://www.neilstuff.com/cpp/";
  53.     Topic = "C++";
  54.     SiteID = "01";
  55. }
  56. else if (location.href.match(/\/guide_to_c\+\+\/.*/))
  57. {
  58.     SectionTitle = "Neil's Guide to C++";
  59.     SectionLink = "http://www.neilstuff.com/guide_to_c++/";
  60.     Topic = "C++";
  61.     SiteID = "05";
  62.  
  63.     sc_project=1574537;
  64.     sc_invisible=1; 
  65.     sc_partition=14; 
  66.     sc_security="5044d449";
  67. }
  68. else if (location.href.match(/\/vss\/.*/))
  69. {
  70.     SectionTitle = "Neil's VSS Help";
  71.     SectionLink = "http://www.neilstuff.com/vss/";
  72.     Topic = "VSS";
  73.     SiteID = "02";
  74. }
  75.  
  76. if ("VSS" == Topic)
  77. {
  78.     PickedBooks.push
  79.     ({
  80.         title : "Essential SourceSafe",
  81.         url : "http://www.amazon.com/exec/obidos/redirect?link_code=as2&path=ASIN/1930919050&tag=neiscstu&camp=1789&creative=9325",
  82.         img : "http://www.neilstuff.com/amazon/1930919050.01._AA_SCMZZZZZZZ_.jpg",
  83.         hurl : "http://www.assoc-amazon.com/e/ir?t=neiscstu&l=as2&o=1&a=1930919050"
  84.     });
  85. }
  86.  
  87. if ("C++" == Topic)
  88. {
  89.     PickedBooks.push
  90.     ({
  91.         title : "C++ in Plain English",
  92.         url : "http://www.amazon.com/exec/obidos/redirect?link_code=as2&path=ASIN/0764535455&tag=neiscstu&camp=1789&creative=9325",
  93.         img : "http://www.neilstuff.com/amazon/0764535455.01._AA_SCMZZZZZZZ_.jpg",
  94.         hurl : "http://www.assoc-amazon.com/e/ir?t=neiscstu&l=as2&o=1&a=0764535455"
  95.     });
  96.     PickedBooks.push({
  97.         title : "C How To Program",
  98.         url : "http://www.amazon.com/exec/obidos/redirect?link_code=as2&path=ASIN/0131426443&tag=neiscstu&camp=1789&creative=9325",
  99.         img : "http://www.neilstuff.com/amazon/0131426443.01._AA_SCMZZZZZZZ_.jpg",
  100.         hurl : "http://www.assoc-amazon.com/e/ir?t=neiscstu&l=as2&o=1&a=0131426443"
  101.     });
  102.     PickedBooks.push({
  103.         title : "C For Dummies",
  104.         url : "http://www.amazon.com/exec/obidos/redirect?link_code=as2&path=ASIN/0764570684&tag=neiscstu&camp=1789&creative=9325",
  105.         img : "http://www.neilstuff.com/amazon/0764570684.01._AA_SCMZZZZZZZ_.jpg",
  106.         hurl : "http://www.assoc-amazon.com/e/ir?t=neiscstu&l=as2&o=1&a=0764570684"
  107.     });
  108. }
  109.  
  110. //
  111. // trim PickedBooks to only two
  112. //
  113. PickedBooks.sort(function(x,y){return Math.random() - Math.random();});
  114. PickedBooks = PickedBooks.slice(0,2);
  115.  
  116. var ArchivedMessage =
  117. [
  118.     "<B><A HREF=\"" + SectionLink + "\">" + SectionTitle + "</A></B> and this page are being preserved, but not actively maintained.  I hope you find this to be useful and I encourage you to link it.  Visit <A HREF=\"http://www.neilstuff.com/\">NeilStuff.com</A> to see what else I'm up to or drop me a line at <A HREF=\"mailto:webmaster@neilstuff.com\">webmaster@neilstuff.com</A> for comments/corrections."
  119. ].join("<BR/><BR/>");
  120.  
  121. var HotSpots =
  122. [
  123.     "Otechski JS", "Industrial strength JavaScript for scheduled tasks, quick scripts, ASP, and maybe more!", "http://www.otechski/js/",
  124.     "del.icio.us " + Topic, Topic + " links from del.icio.us users", "http://del.icio.us/tag/" + Topic.toLowerCase()
  125. ];
  126.  
  127. //****************************************************************************
  128. //****************************************************************************
  129. // Client JS for "Test Your Knowledge" Form
  130. //****************************************************************************
  131. //****************************************************************************
  132.  
  133.   var js_iseed  = 0, js_iseed1 = 0, js_iseed2 = 0, formnum = 0;
  134.   var answ = new Array(6);
  135.   var scratch = "", j = 0, k = 0;
  136.   var goodmsg = "Right on!";
  137.   var badmsg = "Try again!";
  138.   var childbub=0; // child bubble
  139.   var bTime;    // bubble timer ID
  140.   var bubblei=0;// desired bubble
  141.   var bubblecfg = false;
  142.   var bmsg=0;   // index of current bubble:
  143.   var mdata;
  144.  
  145.     function config_bubble() { }
  146.  
  147.   function tyk(question, ans1, ans2, ans3, ans4, cans, explanation)
  148.   {
  149.     formnum++;
  150.     answ[0]=ans1; answ[1]=ans2; answ[2]=ans3; answ[3]=ans4; answ[4]=cans;
  151.     for (var i = 0; i < 10; i++)
  152.     {
  153.       j = random(5);
  154.       if (j > 4) alert("ack!");
  155.       scratch = answ[j];
  156.       answ[j] = "";
  157.       k = j;
  158.       while (answ[k] == "")
  159.         k = random(5);
  160.       answ[j] = answ[k];
  161.       answ[k] = scratch;
  162.     }
  163.     for (var i = 0; i < 5; i++)
  164.       if (answ[i] == cans) k = i;
  165.     document.write
  166.     (
  167.       "<CENTER><TABLE BORDER=0 CELLBORDER=0 CELLSPACING=0 CELLPADDING=0>"+
  168.       "<TD ALIGN=CENTER>"+
  169.       "<TABLE WIDTH=570 BORDER=0 CELLBORDER=0 CELLSPACING=0 CELLPADDING=0>"+
  170.       "<TR><TD COLSPAN=3 WIDTH=570 HEIGHT=54>"+
  171.       "<IMG SRC=tyk_gfx/top_title.GIF WIDTH=570 HEIGHT=54></TD></TR>"+
  172.       "<TR><TD WIDTH=32 HEIGHT=135>"+
  173.       "<IMG SRC=tyk_gfx/left_q.GIF WIDTH=32 HEIGHT=135></TD>"+
  174.       "<TD WIDTH=505 HEIGHT=135 BGCOLOR=FFFFFF>"+
  175.       "<IMG SRC=tyk_gfx/blank.GIF WIDTH=505 HEIGHT=1><BR>"+
  176.       "<FORM NAME=ex" + formnum + ">" + question + "</TD>" +
  177.       "<TD WIDTH=33 HEIGHT=135>"+
  178.       "<IMG SRC=tyk_gfx/right_q.GIF WIDTH=32 HEIGHT=135></TD></TR>"+
  179.       "<TR><TD COLSPAN=3 WIDTH=570 HEIGHT=12>"+
  180.       "<IMG SRC=tyk_gfx/middle_div.GIF WIDTH=570 HEIGHT=12></TR></TABLE>"+
  181.       "<TABLE WIDTH=570 BORDER=0 CELLBORDER=0 CELLSPACING=0 CELLPADDING=0>"+
  182.       "<TR><TD ROWSPAN=2 WIDTH=42 HEIGHT=200>"+
  183.       "<IMG SRC=tyk_gfx/left_bot.GIF WIDTH=42 HEIGHT=200></TD>"+
  184.       "<TD WIDTH=496 HEIGHT=182 BGCOLOR=FFFFFF>"
  185.     );
  186.  
  187.     for (var i = 0; i < 5; i++)
  188.       document.write("<INPUT TYPE=RADIO NAME=exchc>" + answ[i] + "<BR>");
  189.  
  190.     document.write
  191.     (
  192.       "<CENTER><INPUT TYPE=BUTTON VALUE='Am I Right?' ONCLICK=\"(document.ex" + formnum + ".exchc[" + k + "].checked)?alert('" + goodmsg
  193.     );
  194.  
  195.     if (explanation != "") { document.write("\\n\\n" + explanation); }
  196.  
  197.     document.write
  198.     (
  199.       "'):alert(badmsg);\"></CENTER></FORM></TD>" +
  200.       "<TD ROWSPAN=2 WIDTH=32 HEIGHT=200>"+
  201.       "<IMG SRC=tyk_gfx/right_bot.GIF WIDTH=32 HEIGHT=200></TD></TR>"+
  202.       "<TR><TD WIDTH=496 VALIGN=BOTTOM BGCOLOR=FFFFFF>"+
  203.       "<IMG SRC=tyk_gfx/middle_bot.GIF WIDTH=496 HEIGHT=9></TD></TR>"+
  204.       "<TR><TD COLSPAN=3 WIDTH=570 HEIGHT=9>"+
  205.       "<IMG SRC=tyk_gfx/bottom.GIF WIDTH=570 HEIGHT=9></TD></TR></TABLE>" +
  206.       "</TD></TABLE></CENTER>"
  207.     );
  208.   }
  209.  
  210.   // ripped this function from a script on www.javascripts.com, can't remember
  211.   // the original script or author, sorry
  212.   function random(n)
  213.   {
  214.     var js_mult1=3141
  215.     var js_mult2=5821
  216.     var js_m1=100000000
  217.     var js_m2=10000
  218.  
  219.     if (js_iseed == 0)
  220.     {
  221.        now = new Date()
  222.        js_iseed = now.getHours() + now.getMinutes() * 60 + now.getSeconds() * 3600
  223.     }
  224.  
  225.     js_iseed1 = js_iseed / js_m2
  226.     js_iseed2 = js_iseed % js_m2
  227.     var tmp = (((js_iseed2 * js_mult1 + js_iseed1 * js_mult2) % js_m2) * js_m2 + (js_iseed2 * js_mult2)) % js_m1
  228.     js_iseed = (tmp + 1) % js_m1
  229.     return (Math.floor((js_iseed/js_m1) * n))
  230.    }
  231.