home *** CD-ROM | disk | FTP | other *** search
/ Chip 2009 November / Chip_2009.11_CD.iso / Chip_WPI / WPIScripts / program.js < prev    next >
Encoding:
JavaScript  |  2007-06-25  |  6.0 KB  |  288 lines

  1. //
  2. // Date Last Modified: June 26th, 2007
  3. //
  4. // Modified By: Kelsenellenelvian
  5. //
  6.  
  7.  
  8. function program(idx)
  9. {
  10.     position="program.js";
  11.     whatfunc="program()";
  12.     
  13.     var i = '' + ((ordr[idx]==null) ? (idx+900000) : ordr[idx][0]);
  14.  
  15.     while (i.length<6)  
  16.         i = "0" + i;
  17.  
  18.     this.prog = prog[idx];         
  19.     this.ordr = [i];
  20.     this.desc = desc[idx];
  21.     this.uid  = uid[idx];
  22.     this.dflt = (dflt[idx]==null) ? ['no'] : [dflt[idx][0]] ;
  23.     this.cat = cat[idx];
  24.     this.forc = forc[idx];
  25.     this.configs=(configs[idx]==null) ? [''] : [configs[idx][0]];
  26.     this.deps = deps[idx];
  27.     this.excl = excl[idx];
  28.     this.cond = cond[idx];
  29.     this.gcond = gcond[idx];
  30.     this.regb = regb[idx];
  31.     this.cmd1 = cmd1[idx];
  32.     this.cmd2 = cmd2[idx];
  33.     this.cmd3 = cmd3[idx];
  34.     this.cmd4 = cmd4[idx];
  35.     this.cmd5 = cmd5[idx];
  36.     this.cmd6 = cmd6[idx];
  37.     this.cmd7 = cmd7[idx];
  38.     this.cmd8 = cmd8[idx];
  39.     this.cmd9 = cmd9[idx];
  40.     this.cmd10 = cmd10[idx];
  41.     this.rega = rega[idx];
  42.     this.picf = picf[idx];
  43.     this.picw = picw[idx];
  44.     this.pich = pich[idx];
  45.     this.textl= textl[idx];
  46.  
  47.     this.success = success[idx];
  48.     this.fail = fail[idx];
  49. }
  50.  
  51.  
  52. function WriteBackPrograms(programs)
  53. {
  54.     position="program.js";
  55.     whatfunc="WriteBackPrograms()";
  56.  
  57.     for (var i=0; i<programs.length; i++)
  58.     {
  59.         if (IndentText) 
  60.             textindent ='    ';
  61.         else
  62.             textindent ='';
  63.  
  64.         if (programs[i].picf != null) 
  65.         {
  66.             if (programs[i].textl != "Top") 
  67.             {
  68.                   if (programs[i].textl != "Bottom") 
  69.                 {
  70.                     pwidth=programs[i].picw;
  71.                     pheight=programs[i].pich;
  72.                     textloc=programs[i].textl;
  73.                     desc[i+1]=imagelocationlr + programs[i].picf + imagepart2lr + pwidth  + imagepart3lr + pheight + imagepart4lr + textloc + imagepart5lr + textindent + programs[i].desc;
  74.                 }
  75.             }
  76.  
  77.             if (programs[i].textl != "Left") 
  78.             {
  79.                   if (programs[i].textl != "Right") 
  80.                 {
  81.                        if (programs[i].textl != "Bottom") 
  82.                     {
  83.                         pwidth=programs[i].picw;
  84.                         pheight=programs[i].pich;
  85.                         textloc=programs[i].textl;
  86.                         desc[i+1]=textindent + programs[i].desc + imagepart1t + imagelocationtb + programs[i].picf + imagepart2tb + pwidth  + imagepart3tb + pheight + imagepart4tb;
  87.                     }
  88.                     else
  89.                     {
  90.                         pwidth=programs[i].picw;
  91.                         pheight=programs[i].pich;
  92.                         textloc=programs[i].textl;
  93.                         desc[i+1]=imagelocationtb + programs[i].picf + imagepart2tb + pwidth  + imagepart3tb + pheight + imagepart4tb  + imagepart1b + imageparteb + textindent + programs[i].desc;
  94.                     }
  95.                 }
  96.             }
  97.      
  98.         }
  99.         else 
  100.            desc[i+1]=textindent + programs[i].desc;
  101.  
  102.         prog[i+1]=programs[i].prog;
  103.         ordr[i+1]=programs[i].ordr;
  104.         uid[i+1]=programs[i].uid;
  105.         dflt[i+1]=programs[i].dflt;
  106.         cat[i+1]=programs[i].cat;
  107.         forc[i+1]=programs[i].forc;
  108.         configs[i+1]=programs[i].configs;
  109.         deps[i+1]=programs[i].deps;
  110.         excl[i+1]=programs[i].excl;
  111.         cond[i+1]=programs[i].cond;
  112.         gcond[i+1]=programs[i].gcond;
  113.         regb[i+1]=programs[i].regb;
  114.         cmd1[i+1]=programs[i].cmd1;
  115.         cmd2[i+1]=programs[i].cmd2;
  116.         cmd3[i+1]=programs[i].cmd3;
  117.         cmd4[i+1]=programs[i].cmd4;
  118.         cmd5[i+1]=programs[i].cmd5;
  119.         cmd6[i+1]=programs[i].cmd6;
  120.         cmd7[i+1]=programs[i].cmd7;
  121.         cmd8[i+1]=programs[i].cmd8;
  122.         cmd9[i+1]=programs[i].cmd9;
  123.         cmd10[i+1]=programs[i].cmd10;
  124.         rega[i+1]=programs[i].rega;
  125.         picf[i+1]=programs[i].picf;
  126.         picw[i+1]=programs[i].picw;
  127.         pich[i+1]=programs[i].pich;    
  128.         textl[i+1]=programs[i].text1;
  129.     }
  130.  
  131.     prog[programs.length+1]=null;
  132. }    
  133.  
  134.  
  135. function SortByCat(a, b)
  136. {
  137.     position="program.js";
  138.     whatfunc="SortByCat()";
  139.  
  140.     var x = a.cat;
  141.     var y = b.cat;
  142.  
  143.     return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  144. }
  145.  
  146.  
  147. function SortByOrdr(a, b)
  148. {
  149.     position="program.js";
  150.     whatfunc="SortByOrder()";
  151.  
  152.     var x = a.ordr;
  153.     var y = b.ordr;
  154.  
  155.     return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  156. }
  157.  
  158.  
  159. function SortByProg(a, b)
  160. {
  161.     position="program.js";
  162.     whatfunc="SortByProg()";
  163.  
  164.     var x = a.prog[0].toLowerCase();
  165.     var y = b.prog[0].toLowerCase();
  166.  
  167.     return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  168. }
  169.  
  170.  
  171. function GetCats()
  172. {
  173.     position="program.js";
  174.     whatfunc="GetCats()";
  175.  
  176.     var cats = new Array();
  177.      var oldcat, DefaultCat, i, j;
  178.  
  179.     if (SortOrder)
  180.         cats=SortOrder;
  181.  
  182.      DefaultCat='Applications';
  183.      oldcat='';
  184.  
  185.     for (i=1; prog[i] != null; i++)
  186.     {
  187.         if (cat[i]==null) 
  188.             cat[i]=[DefaultCat];
  189.         if (cat[i][0]=='') 
  190.             cat[i][0] = DefaultCat;            
  191.         if (cat[i][0] != oldcat)
  192.         {
  193.             for (j=0; j<cats.length; j++)
  194.             {
  195.                 if (cats[j]==cat[i][0]) 
  196.                     break;
  197.             }    
  198.             if (j==cats.length) 
  199.                 cats[cats.length++]=cat[i][0];
  200.         }
  201.         oldcat=cat[i][0];
  202.     }    
  203.     
  204.     return cats;
  205. }
  206.  
  207.  
  208. function SortPrograms()
  209. {
  210.     position="program.js";
  211.     whatfunc="SortPrograms()";
  212.  
  213.     var programs = new Array();
  214.      var cats = new Array; 
  215.      var i, j, progspercat;
  216.  
  217.     cats = GetCats();
  218.  
  219.     // sort inside categories
  220.     if (cats.length==0) //this is used to sort programs, if not even one category is given
  221.           cats[cats.length++]='';     
  222.  
  223.     for (j=0; j<cats.length; j++)
  224.     {
  225.         // get a category's apps into temporary array and sort it
  226.         progspercat = new Array();
  227.         for (i=1; prog[i] != null; i++)
  228.         {
  229.             if (cat[i][0] == cats[j])
  230.                 progspercat[progspercat.length++] = new program(i);
  231.         }
  232.         if (SortWithinCats)
  233.             progspercat.sort(SortByProg);
  234.       
  235.         //append array to programs array
  236.         for (i=0; i<progspercat.length; i++) 
  237.               programs[programs.length++]=progspercat[i];
  238.     }
  239.  
  240.     //write back 'cause the rendering uses config.js's values
  241.     WriteBackPrograms(programs);
  242.     programs = null;
  243.     cats = null;
  244. }
  245.  
  246.  
  247. function ProgsInCat(whichCat)
  248. {
  249.     position="program.js";
  250.     whatfunc="ProgsInCat()";
  251.  
  252.     var i, res;
  253.     
  254.     res = 0;
  255.     for (i=1; prog[i]; i++)
  256.     {
  257.         if (cat[i] && cat[i]==whichCat) 
  258.             res++;
  259.     }
  260.  
  261.     return res;
  262. }
  263.  
  264.  
  265. function CatsDefined()
  266. {
  267.     position="program.js";
  268.     whatfunc="CatsDefined()";
  269.  
  270.     for (var i=1; prog[i]; i++)
  271.     {
  272.         if (cat[i]) 
  273.             return true;
  274.     }
  275.  
  276.     return false;
  277. }
  278.  
  279.  
  280. function CheckCatIfAllChecked()
  281. {
  282.     position="program.js";
  283.     whatfunc="CheckCatIfAllSelected()";
  284.  
  285.     for (var i=1; i<prog.length; i++)
  286.         checkCategory(i);
  287. }
  288.