~maddevelopers/mg5amcnlo/WWW5_caching

« back to all changes in this revision

Viewing changes to madgraph3/public/javascript/test/java.js

  • Committer: John Doe
  • Date: 2013-03-25 20:27:02 UTC
  • Revision ID: john.doe@gmail.com-20130325202702-5sk3t1r8h33ca4p4
first clean version

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
var nombre_process =0;
 
2
var processes=[];
 
3
var model="sm";         //Default Model
 
4
var nro_models=["sm"]; //Edit this line to select models where the "next rulling order" button exists
 
5
var show_nro=true;
 
6
var particles=[];
 
7
var invert=[];          //True or false if option has inverted display
 
8
var global_option_div=document.createElement("div");
 
9
 
 
10
function loading(element){ //Shows "loading..."
 
11
        if (element.childNodes.length<2)        {
 
12
                element.innerHTML+=".";
 
13
                element.innerHTML=element.innerHTML.replace(".....",".");
 
14
                setTimeout(function(){loading(element)},500);
 
15
        }
 
16
}
 
17
 
 
18
 
 
19
 
 
20
function submitForm(element, page, argument) //Get info from page "page". Argument not useful.
 
21
 
22
    var xhr; 
 
23
    try {  xhr = new ActiveXObject('Msxml2.XMLHTTP');   }
 
24
    catch (e) 
 
25
    {
 
26
        try {   xhr = new ActiveXObject('Microsoft.XMLHTTP'); }
 
27
        catch (e2) 
 
28
        {
 
29
           try {  xhr = new XMLHttpRequest();  }
 
30
           catch (e3) {  xhr = false;   }
 
31
         }
 
32
    }
 
33
    element.innerHTML+="Loading";
 
34
    loading(element);
 
35
    xhr.onreadystatechange  = function() 
 
36
    { 
 
37
       if(xhr.readyState  == 4)
 
38
       {
 
39
        if(xhr.status  == 0 || xhr.status == 200) {
 
40
            element.innerHTML = xhr.responseText; 
 
41
        }
 
42
        else
 
43
            element.innerHTML="Internal Error " + xhr.status;
 
44
        }
 
45
    }; 
 
46
 
 
47
   xhr.open("GET", page,  true); 
 
48
   xhr.send(argument); 
 
49
}
 
50
 
 
51
 
 
52
(function () {//Creates "model" div.
 
53
        var option_list=document.getElementById("select_model");
 
54
        submitForm(option_list,"create_option_list",null);
 
55
        option_list.onchange=function(){
 
56
                model=option_list[option_list.selectedIndex].innerHTML;
 
57
                show_nro=false;
 
58
                for (var i=0;i<nro_models.length;i++){
 
59
                        if (model === nro_models[i]) {show_nro=true; break;}
 
60
                }
 
61
                for(var i=0; i<processes.length;i++){//Changes if model changed
 
62
                        var pr=processes[i];
 
63
                        pr.option.selectedIndex=0;
 
64
                        pr.option_div.innerHTML="";
 
65
                        if(!show_nro){pr.nro_div.style.display="none";}
 
66
                        else{pr.nro_div.style.display="inline-block";}
 
67
                        for(var j=0; j<pr.decays.length;j++){
 
68
                                var dc=pr.decays[j];    
 
69
                                dc.option.selectedIndex=0;
 
70
                                dc.option_div.innerHTML="";
 
71
                                for (var k=0;k<dc.sub_decays.length;k++){
 
72
                                        var sd=dc.sub_decays[k];
 
73
                                        sd.option.selectedIndex=0;
 
74
                                        sd.option_div.innerHTML="";
 
75
                                }
 
76
                        }
 
77
                }
 
78
                load_models();
 
79
        };
 
80
})();
 
81
 
 
82
var options=null;
 
83
 
 
84
function load_models(){// Function loading model options and particles
 
85
        var to_fill=document.getElementById("select_options");
 
86
        options=to_fill;
 
87
        var page="load_option?model_name="+model;
 
88
        to_fill.innerHTML="";
 
89
        var page2="get_order?model="+model;
 
90
        global_option_div.innerHTML="";
 
91
        submitForm(global_option_div,page2,null);
 
92
        var returned="";
 
93
        var xhr2; 
 
94
    try {  xhr2 = new ActiveXObject('Msxml2.XMLHTTP');   }
 
95
    catch (e) 
 
96
    {
 
97
        try {   xhr2 = new ActiveXObject('Microsoft.XMLHTTP'); }
 
98
        catch (e2) 
 
99
        {
 
100
           try {  xhr2 = new XMLHttpRequest();  }
 
101
           catch (e3) {  xhr = false;   }
 
102
         }
 
103
    }
 
104
    xhr2.onreadystatechange  = function() 
 
105
    { 
 
106
       if(xhr2.readyState  == 4)
 
107
       {
 
108
        if(xhr2.status  === 0 || xhr2.status === 200) {
 
109
            returned = xhr2.responseText; 
 
110
                returned=returned.split("##");
 
111
                if (returned.length>1){
 
112
                        var invert_txt=returned[0].split(",");
 
113
                        invert=[];
 
114
                        for (var i = 0; i< invert_txt.length; i++){
 
115
                                if (invert_txt[i] !== "")invert.push(invert_txt[i])
 
116
                        }
 
117
                        to_fill.innerHTML=returned[1];
 
118
                }
 
119
                else{
 
120
                        invert="empty"
 
121
                        to_fill.innerHTML=returned[0];
 
122
                }
 
123
        }
 
124
        else{
 
125
                to_fill="internal error "+xhr2.status;
 
126
        }
 
127
       }
 
128
    }; 
 
129
        xhr2.open("GET", page,  true); 
 
130
        xhr2.send(null);
 
131
        
 
132
        var xhr; 
 
133
    try {  xhr = new ActiveXObject('Msxml2.XMLHTTP');   }
 
134
    catch (e) 
 
135
    {
 
136
        try {   xhr = new ActiveXObject('Microsoft.XMLHTTP'); }
 
137
        catch (e2) 
 
138
        {
 
139
           try {  xhr = new XMLHttpRequest();  }
 
140
           catch (e3) {  xhr = false;   }
 
141
         }
 
142
    }
 
143
    xhr.onreadystatechange  = function() 
 
144
    { 
 
145
       if(xhr.readyState  == 4)
 
146
       {
 
147
        if(xhr.status  == 0 || xhr.status == 200) {
 
148
            var txt = xhr.responseText; 
 
149
            txt+=" p j l+ l- vl vl~ $ / $$ | ";
 
150
            particles=[];
 
151
            particles=txt.split(" ");
 
152
        }
 
153
        else{
 
154
            particles=[];
 
155
        }
 
156
        }
 
157
    }; 
 
158
         page="get_particles?model="+model;
 
159
           xhr.open("GET", page,  true); 
 
160
           xhr.send(null);
 
161
}
 
162
 
 
163
load_models();
 
164
 
 
165
function check_particles(element){// returns particles that are not in the model
 
166
        var txt=element.value;
 
167
        var pb=[];
 
168
        var txt_array=txt.split(" ");
 
169
        var correct=true;
 
170
        for (var i =0;i<txt_array.length;i++){
 
171
                var isin=false;
 
172
                for (var j=0; j<particles.length;j++){
 
173
                        if (txt_array[i]===particles[j]) isin=true;
 
174
                }
 
175
                if (isin===false){correct=false; pb.push(txt_array[i]);}
 
176
        }
 
177
        if (!correct){return pb;}
 
178
        else return false;
 
179
}
 
180
 
 
181
function set_title(title,x){// returns a full name per process.
 
182
  if(title.firstChild){  title.removeChild(title.firstChild);}
 
183
    switch(x)
 
184
  {
 
185
    case 0:
 
186
      title_text=document.createTextNode("First process");
 
187
      title.appendChild(title_text);
 
188
      break;
 
189
    case 1:
 
190
      title_text=document.createTextNode("Second process");
 
191
      title.appendChild(title_text);
 
192
      break;
 
193
    case 2:
 
194
      title_text=document.createTextNode("Third process");
 
195
      title.appendChild(title_text);
 
196
      break;
 
197
    case 3:
 
198
      title_text=document.createTextNode("Fourth process");
 
199
      title.appendChild(title_text);
 
200
      break;
 
201
    case 4:
 
202
      title_text=document.createTextNode("Fifth process");
 
203
      title.appendChild(title_text);
 
204
      break;
 
205
    default:
 
206
      var titre_temp=x+1;
 
207
      if(titre_temp%10===1){
 
208
        titre_temp+="st process";
 
209
      }
 
210
      else if(titre_temp%10===2){
 
211
        titre_temp+="nd process";
 
212
      }
 
213
      else if(titre_temp%10===3){
 
214
        titre_temp+="rd process";
 
215
      }
 
216
      else{
 
217
        titre_temp+="th process";
 
218
      }
 
219
      title_text=document.createTextNode(x+1+"th process");
 
220
      title.appendChild(title_text);
 
221
      break;
 
222
  }
 
223
}
 
224
 
 
225
 
 
226
function reload_title(){
 
227
  var nombre_titres_abs=0;
 
228
  for(var i=0;i<nombre_process;i++){
 
229
    if(processes[i].exists){
 
230
      nombre_titres_abs++;
 
231
      set_title(processes[i].title,nombre_titres_abs-1);
 
232
    
 
233
    }
 
234
  }
 
235
}
 
236
 
 
237
 
 
238
function add_decay(param){
 
239
    param.decays.push(new decay(param));
 
240
  }
 
241
 
 
242
function add_subdecay(param){
 
243
    param.sub_decays.push(new sub_decay(param));
 
244
}
 
245
  
 
246
function delete_button(id_a_detruire,endroit,process,thing_to_de_exist){
 
247
  this.element=document.createElement('img');
 
248
  this.element.src="images/test/moins.png";
 
249
  this.element.id=endroit.id+"delete_button";
 
250
  this.element.className="delete_button";
 
251
  if(endroit.className==="formulaire_process_complet"){
 
252
    this.element.className+="_form";
 
253
  }
 
254
  endroit.appendChild(this.element);
 
255
  this.element.onclick=function(){
 
256
    var elem_to_del=document.getElementById(id_a_detruire);
 
257
    if (elem_to_del.className==="formulaire_process_complet"){
 
258
      if(confirm("Are you sure you want to delete this process?")){
 
259
            process.exists=false;
 
260
            elem_to_del.parentNode.removeChild(elem_to_del);
 
261
            reload_title();
 
262
      }
 
263
    }
 
264
    else if (elem_to_del.className==="decay_input"){
 
265
      process.num_decay_left--;
 
266
      if (process.num_decay_left===0){
 
267
        elem_to_del.parentNode.parentNode.removeChild(elem_to_del.parentNode);
 
268
        
 
269
      }
 
270
      else{
 
271
        elem_to_del.parentNode.removeChild(elem_to_del);
 
272
      }
 
273
    }
 
274
    else{
 
275
    elem_to_del.parentNode.removeChild(elem_to_del);
 
276
    
 
277
    }
 
278
    thing_to_de_exist.exists=false;
 
279
  };
 
280
}
 
281
 
 
282
 
 
283
function sub_decay(decay){//Class containing info about a subdecay.
 
284
        this.exists=true;
 
285
        var ceci=this;
 
286
        this.element_subdecaypos=document.createElement("select");
 
287
        
 
288
        
 
289
        this.reload_subdecaypos=function(){
 
290
             var elem=ceci.element_subdecaypos;
 
291
             var selected_txt="";
 
292
             if(ceci.element_subdecaypos.selectedIndex>-1)selected_txt=ceci.element_subdecaypos.childNodes[ceci.element_subdecaypos.selectedIndex].value;
 
293
             if(ceci.element.childNodes.length>0)    { ceci.element.removeChild(ceci.element_subdecaypos);}
 
294
             if(elem.childNodes.length>0) {
 
295
                while(elem.childNodes.length>0){
 
296
                        elem.removeChild(elem.firstChild);
 
297
                } 
 
298
             }
 
299
              elem= document.createElement("select");
 
300
             for (var i=0; i<ceci.parent_decay.subdecay_pos.length; i++){
 
301
               if(ceci.parent_decay.subdecay_pos[i]!==" " && ceci.parent_decay.subdecay_pos[i]!==""){
 
302
                   var temp=document.createElement("option");
 
303
                   var temp2=document.createTextNode(ceci.parent_decay.subdecay_pos[i]);
 
304
                   temp.appendChild(temp2);
 
305
                   if (temp2.data===selected_txt)temp.selected="selected";
 
306
                   ceci.element_subdecaypos.appendChild(temp);
 
307
               }
 
308
             }
 
309
            if(ceci.element.childNodes.length>0) {ceci.element.insertBefore(ceci.element_subdecaypos,ceci.element.firstChild);}
 
310
            else {ceci.element.appendChild(ceci.element_subdecaypos);}
 
311
           };
 
312
 
 
313
                
 
314
        
 
315
  this.num_subdecay=decay.nombre_subdecay+1;
 
316
  this.parent_decay=decay;
 
317
  decay.nombre_subdecay++;
 
318
  
 
319
  this.element=document.createElement('div');
 
320
  this.element.className="sub_decay";
 
321
  this.element.id="subdecay"+this.parent_decay.parent_process.num_process+this.parent_decay.num_decay+this.num_subdecay;
 
322
  var element=this.element;
 
323
  
 
324
  element.appendChild(this.element_subdecaypos);
 
325
  element.id="sp"+this.parent_decay.parent_process.num_process+"_"+this.parent_decay.num_decay+"_"+this.num_subdecay;
 
326
  var temp=document.createElement("text");
 
327
  temp.innerHTML="&#8594;";
 
328
  element.appendChild(temp);
 
329
  var temp=document.createElement("input");
 
330
  this.input=temp;
 
331
  var ceci=this;
 
332
  this.input.onblur=function(){
 
333
                 var error=check_particles(ceci.input);  
 
334
                 if (error){
 
335
                    ceci.input.style.backgroundColor="#FFAFAF";
 
336
                 }
 
337
                 else{
 
338
                         ceci.input.style.backgroundColor="white";
 
339
                 }
 
340
  }
 
341
  temp.size="18";
 
342
  this.option_div=document.createElement("div");
 
343
  this.option_div.style.marginLeft="220px";
 
344
  element.appendChild(temp);
 
345
  var temp=document.createElement("select");
 
346
  this.option=temp;
 
347
  var temp2=document.createElement("option");
 
348
  var temp3=document.createTextNode("Order Automatic");
 
349
  temp2.appendChild(temp3);
 
350
  temp.appendChild(temp2);
 
351
  var temp2=document.createElement("option");
 
352
  var temp3=document.createTextNode("Order Manual");
 
353
  var ceci=this;
 
354
  temp.onchange=function(){
 
355
          if(temp.selectedIndex===0){
 
356
                  ceci.option_div.innerHTML="";
 
357
          }
 
358
          else{
 
359
                  /*var page="get_order?model="+model;
 
360
                  submitForm(ceci.option_div,page);*/
 
361
                  ceci.option_div.innerHTML=global_option_div.innerHTML;
 
362
                  y=function(){
 
363
                          if(ceci.option_div.innerHTML[0]=="L"){
 
364
                                  ceci.option_div.innerHTML=global_option_div.innerHTML;
 
365
                                        setTimeout(y, 10);
 
366
                          }
 
367
                  };
 
368
                  y();    }
 
369
          
 
370
  };
 
371
 
 
372
  temp2.appendChild(temp3);
 
373
  temp.appendChild(temp2);
 
374
  element.appendChild(temp);
 
375
  var ceci=this;
 
376
  delete_button(element.id,element,ceci,ceci);
 
377
  element.appendChild(ceci.option_div);
 
378
  this.parent_decay.decay_input.appendChild(this.element);
 
379
  this.reload_subdecaypos();
 
380
 
 
381
}
 
382
 
 
383
 
 
384
function decay(process){
 
385
        this.exists=true;
 
386
        this.decays_pos=true;
 
387
        this.subdecay_pos=[];
 
388
   this.element_decay_pos=document.createElement("select");
 
389
   var ceci=this;
 
390
   this.reload_decay_pos=function(){
 
391
     var elem=ceci.element_decay_pos;
 
392
         var selected_txt="";
 
393
         if(elem.selectedIndex>-1)selected_txt=elem.childNodes[elem.selectedIndex].value;
 
394
     if(ceci.decay_input.childNodes.length>0)     ceci.decay_input.removeChild(elem);
 
395
      ceci.element_decay_pos=document.createElement("select");
 
396
     
 
397
     for (var i=0; i<ceci.parent_process.decay_pos.length; i++){
 
398
       if(ceci.parent_process.decay_pos[i]!==" " && ceci.parent_process.decay_pos[i]!==""){
 
399
        var temp=document.createElement("option");
 
400
        var temp2=document.createTextNode(ceci.parent_process.decay_pos[i]);
 
401
        temp.appendChild(temp2);
 
402
        if(temp2.data===selected_txt)temp.selected="selected";
 
403
        ceci.element_decay_pos.appendChild(temp);
 
404
       }
 
405
     }
 
406
    if(decay_input.childNodes.length>0){ceci.decay_input.insertBefore(ceci.element_decay_pos,ceci.decay_input.firstChild);}
 
407
    else {ceci.decay_input.appendChild(ceci.element_decay_pos);}
 
408
   };
 
409
   
 
410
   this.num_decay=process.nombre_decay;
 
411
   process.num_decay_left++;
 
412
   this.parent_process=process;
 
413
   this.nombre_subdecay=0;
 
414
   if(this.num_decay===0){
 
415
     var titre_temp=document.createTextNode("Decays:");
 
416
     process.decay_element.appendChild(titre_temp);
 
417
   }
 
418
   else if(process.num_decay_left===1){
 
419
     process.decay_element=document.createElement("div");
 
420
     var titre_temp=document.createTextNode("Decays:");
 
421
     process.element2.insertBefore(process.decay_element,process.element2.lastChild.previousSibling.previousSibling);
 
422
     process.decay_element.appendChild(titre_temp);
 
423
     process.decay_element.className="decays";
 
424
   }
 
425
     
 
426
   this.decay_input=document.createElement("div");
 
427
   var decay_input=this.decay_input;
 
428
    decay_input.id="di_"+this.parent_process.num_process+"_"+this.num_decay;
 
429
   decay_input.className="decay_input";
 
430
   process.nombre_decay++;
 
431
   this.sub_decays=[];
 
432
   var ceci=this;
 
433
   this.add_subdecay=function(){
 
434
    ceci.sub_decays.push(new sub_decay(this_global_2));
 
435
   };
 
436
 
 
437
   this.reload_decay_pos();
 
438
   decay_input.appendChild(this.element_decay_pos);
 
439
   var temp3=document.createElement("text");
 
440
   temp3.innerHTML='&#8594;';
 
441
   decay_input.appendChild(temp3);
 
442
   var temp=document.createElement("input");
 
443
   temp.id=this.parent_process.id+"process"+this.num_decay;
 
444
   temp.size=40;
 
445
   this.input_element=document.createElement("input");
 
446
   var input_element=this.input_element;
 
447
   //input_element.id='process'+nombre_process+'input';
 
448
   input_element.size="40";
 
449
   this.subdecay_string="";
 
450
   var ceci=this;
 
451
   input_element.onblur=function(){
 
452
         var error=check_particles(input_element);  
 
453
         if (error){
 
454
                    ceci.input_element.style.backgroundColor="#FFAFAF";
 
455
         }
 
456
         else{ceci.input_element.style.backgroundColor="white";}
 
457
         ceci.subdecay_pos=ceci.input_element.value.split(" ");
 
458
         for (var i =0; i<ceci.sub_decays.length; i++) {ceci.sub_decays[i].reload_subdecaypos();}
 
459
   };
 
460
   
 
461
   decay_input.appendChild(input_element);
 
462
   
 
463
    var temp=document.createElement("select");
 
464
    var temp2=document.createElement("option");
 
465
    var temp3=document.createTextNode("Order Automatic");
 
466
    this.option=temp;
 
467
    temp2.appendChild(temp3);
 
468
    temp.appendChild(temp2);
 
469
    temp3=document.createTextNode("Order Manual");
 
470
    temp2=document.createElement("option");
 
471
    temp2.appendChild(temp3);
 
472
    this.option_div=document.createElement("div");
 
473
    var ceci=this;
 
474
    temp.onchange=function(){     
 
475
        if(ceci.option.selectedIndex===0){
 
476
                  ceci.option_div.innerHTML="";
 
477
          }
 
478
          else{
 
479
                  //var page="get_order?model="+model;
 
480
                  //submitForm(ceci.option_div,page);
 
481
                  ceci.option_div.innerHTML=global_option_div.innerHTML;
 
482
                  y=function(){
 
483
                          if(ceci.option_div.innerHTML[0]=="L"){
 
484
                                  ceci.option_div.innerHTML=global_option_div.innerHTML;
 
485
                                        setTimeout(y, 10);
 
486
                          }
 
487
                  };
 
488
                  y();    }
 
489
         };
 
490
    this.option_div.style.marginLeft="375px";
 
491
    temp.appendChild(temp2);
 
492
    decay_input.appendChild(temp);
 
493
    delete_button(decay_input.id,decay_input,this.parent_process,this);
 
494
    var temp=document.createTextNode(" ");
 
495
    decay_input.appendChild(temp);
 
496
    
 
497
    var temp=document.createElement("img");
 
498
    temp.src="images/test/plus.png";
 
499
    var self=this;
 
500
    temp.onclick=function(){add_subdecay(self);    };
 
501
    decay_input.appendChild(temp);
 
502
    decay_input.appendChild(this.option_div);
 
503
    //decay_input.appendChild(global_option_div);
 
504
 
 
505
   process.decay_element.appendChild(decay_input);
 
506
}
 
507
 
 
508
 
 
509
function process(endroit){
 
510
  this.card_short="";
 
511
  this.error_message="";
 
512
  processes.push(this);
 
513
  this.nro_div=document.createElement("div");
 
514
  this.nro_string="";
 
515
  this.exists=true;
 
516
  this.num_decay_left=0;
 
517
  this.input_string="";
 
518
  this.num_process=nombre_process;
 
519
  this.nombre_decay=0;
 
520
  this.decays=[];
 
521
  this.id="process"+this.num_process;
 
522
  this.decay_element=document.createElement('div');
 
523
  this.decay_element.className="decays";
 
524
  this.decay_string="";
 
525
  this.decay_pos=[" "];
 
526
  this.decays_exist=true;
 
527
  var structure=document.createElement('div');
 
528
  this.structure=structure;
 
529
  structure.className="formulaire_process_complet";
 
530
  structure.id='struct'+nombre_process;
 
531
  var element=document.createElement('div');
 
532
   this.element=element;
 
533
  element.className='command';
 
534
  var title=document.createElement("h2");
 
535
  this.title=title;
 
536
  var input=document.createElement("div");
 
537
  input.className="input_process";
 
538
  var temp=document.createTextNode("Process:");
 
539
  input.appendChild(temp);
 
540
  var input_element=document.createElement("input");
 
541
  this.input_element=input_element;
 
542
  input_element.id='process'+nombre_process+'input';
 
543
  input_element.size="40";
 
544
  var ceci=this;
 
545
  input_element.onblur=function(){
 
546
        ceci.input_string=input_element.value;
 
547
    ceci.decay_string=input_element.value;
 
548
    var ds=ceci.decay_string;
 
549
    var position_gt=ds.search(">");
 
550
    if(position_gt!==-1){
 
551
      ceci.error_message="";
 
552
      input_element.style.backgroundColor="white";
 
553
      ds=ds.split(">");
 
554
      ds=ds[1].split(" ");
 
555
      ceci.decay_pos=[" "];
 
556
      ceci.decay_pos=ds;
 
557
      for (var i=0; i<ceci.nombre_decay; i++){
 
558
        ceci.decays[i].reload_decay_pos();
 
559
      }
 
560
    }
 
561
    else {
 
562
      input_element.style.backgroundColor="#FFAFAF";
 
563
      ceci.error_message=" > expected <br />"
 
564
    }
 
565
         var error=check_particles(input_element);  
 
566
         var error2=[];
 
567
         var pg=0;
 
568
         for (var i = 0; i< error.length;i++){
 
569
                 if (error[i]===">"){
 
570
                         pg+=1;
 
571
                         if(pg>2)error2.push(">");
 
572
                 }
 
573
                 else{
 
574
                         error2.push(">");
 
575
                 }
 
576
         }
 
577
         if (error2.length>0){
 
578
            input_element.style.backgroundColor="#FFAFAF";
 
579
         }
 
580
  };
 
581
  
 
582
  input.appendChild(input_element);
 
583
  var temp=document.createElement("select");
 
584
  var temp2=document.createElement("option");
 
585
  var temp3=document.createTextNode("Order Automatic");
 
586
  temp2.appendChild(temp3);
 
587
  temp.appendChild(temp2);
 
588
  this.option=temp;
 
589
  temp3=document.createTextNode("Order Manual");
 
590
  temp2=document.createElement("option");
 
591
  temp2.appendChild(temp3);
 
592
  this.option_div=document.createElement("div");
 
593
  var ceci=this;
 
594
  this.option_string="";
 
595
  temp.onchange=function(){
 
596
          if(ceci.option.selectedIndex===0){
 
597
                  ceci.option_div.innerHTML="";
 
598
          }
 
599
          else{
 
600
                  /*var page="get_order?model="+model;
 
601
                  submitForm(ceci.option_div,page);*/
 
602
                  ceci.option_div.innerHTML=global_option_div.innerHTML;
 
603
                  y=function(){
 
604
                          if(ceci.option_div.innerHTML[0]=="L"){
 
605
                                  ceci.option_div.innerHTML=global_option_div.innerHTML;
 
606
                                        setTimeout(y, 10);
 
607
                          }
 
608
                  };
 
609
                  y();
 
610
                  //ceci.option_div.innerHTML=global_option_div
 
611
          }
 
612
  };
 
613
  temp.appendChild(temp2);
 
614
  input.appendChild(temp);
 
615
  
 
616
  var temp=document.createElement("select");
 
617
  var temp2=document.createElement("option");
 
618
  var temp3=document.createTextNode("LO");
 
619
  temp2.appendChild(temp3);
 
620
  temp.appendChild(temp2);
 
621
  var temp2=document.createElement("option");
 
622
  var temp3=document.createTextNode("NLO");
 
623
  temp2.appendChild(temp3);
 
624
  temp.appendChild(temp2);
 
625
  var temp2=document.createElement("option");
 
626
  var temp3=document.createTextNode("Loop Only");
 
627
  temp2.appendChild(temp3);
 
628
  temp.appendChild(temp2);
 
629
  var ceci_pr=this;
 
630
  temp.onchange=function(){
 
631
          var selected=ceci_pr.nro_div.childNodes[0][ceci_pr.nro_div.childNodes[0].selectedIndex].childNodes[0].data
 
632
          if (selected !== "LO"){
 
633
                  ceci.decays_exist=false; 
 
634
                  ceci.nro_string="";
 
635
                  if (selected === "Loop Only") ceci.nro_string="[virt=QCD]";
 
636
                  if (selected === "NLO") ceci.nro_string="[QCD]";
 
637
                  ceci.decay_element.style.display="none";
 
638
                  ceci.add_decay_button.style.display="none";
 
639
 
 
640
          }
 
641
          else{
 
642
                  ceci.nro_string="";
 
643
                  ceci.decays_exist=true;
 
644
                  ceci.add_decay_button.style.display="inline-block";
 
645
                  ceci.decay_element.style.display="block";
 
646
                  
 
647
          }
 
648
         //ceci.generateCard();
 
649
  }
 
650
  this.nro_div.appendChild(temp);
 
651
  if(show_nro) this.nro_div.style.display="inline-block";
 
652
  else this.nro_div.style.display="none";
 
653
  input.appendChild(this.nro_div);
 
654
 
 
655
  var ecart=document.createElement("div");
 
656
  ecart.style.marginLeft="50px";
 
657
  ecart.style.display="inline-block";
 
658
  ecart.innerHTML= "&#160;";
 
659
  input.appendChild(ecart);
 
660
  var temp=document.createElement("input");
 
661
  this.add_decay_button=temp;
 
662
  temp.type="button";
 
663
  var ceci =this;
 
664
  temp.onclick=function(){add_decay(ceci); };
 
665
  temp.value="Add Decay";
 
666
  temp.style.display="inline-block";
 
667
 
 
668
  input.appendChild(temp);
 
669
  this.option_div.style.marginLeft="390px";
 
670
  input.appendChild(this.option_div);
 
671
  var nombre_a_afficher=0;
 
672
  for(var i=0;i<nombre_process;i++){
 
673
    if(processes[i].exists){
 
674
      nombre_a_afficher++;
 
675
    }
 
676
  }
 
677
 
 
678
  set_title(title,nombre_a_afficher);
 
679
  reload_title();
 
680
  element.appendChild(title);
 
681
  var element2=document.createElement("div");
 
682
  this.click_to_show=document.createElement("div");
 
683
  this.click_to_show.innerHTML="Click to show... <br/>"+this.card_short;
 
684
  this.click_to_show.style.display="none";
 
685
  this.element.appendChild(this.click_to_show);
 
686
  this.element2=element2;
 
687
  var ceci=this;
 
688
  this.element.onclick=function(){
 
689
          for (var i=0; i<processes.length;i++){
 
690
                  processes[i].click_to_show.style.display="block";
 
691
                  processes[i].element2.style.display="none";
 
692
          }
 
693
          ceci.click_to_show.style.display="none";
 
694
          ceci.element2.style.display="block";
 
695
  };
 
696
  element.appendChild(element2);
 
697
  element2.appendChild(input);
 
698
  element2.appendChild(this.decay_element);
 
699
  if(this.num_process===0){
 
700
    var temp_div=document.createElement("div");
 
701
    temp_div.className="decays";
 
702
    var temp1=document.createTextNode(" p and j definitions: ");
 
703
    temp_div.appendChild(temp1);
 
704
    var temp1=document.createElement("select");
 
705
    var temp2=document.createElement("option");
 
706
    temp2.innerHTML="  p=j=d u s d~ u~ s~  g";
 
707
    temp1.appendChild(temp2);
 
708
    temp_div.appendChild(temp1);
 
709
    var temp2=document.createElement("option");
 
710
    temp2.innerHTML="p=j=d u s c d~ u~ s~ c~ g";
 
711
    temp1.appendChild(temp2);
 
712
    temp_div.appendChild(temp1);
 
713
    var temp2=document.createElement("option");
 
714
    temp2.innerHTML="p=j=d u s c b d~ u~ s~ c~ b~ g";
 
715
    temp1.appendChild(temp2);
 
716
    temp_div.appendChild(temp1);
 
717
    
 
718
    
 
719
    
 
720
    
 
721
    this.def=temp1;
 
722
    element2.appendChild(temp_div);
 
723
     var temp_div=document.createElement("div");
 
724
    temp_div.className="decays";
 
725
    var temp1=document.createTextNode("Sum over leptons: ");
 
726
    temp_div.appendChild(temp1);
 
727
    var temp1=document.createElement("select");
 
728
    var temp2=document.createElement("option");
 
729
    temp2.innerHTML="l+ = e+, mu+; l- = e-, mu-; vl = ve, vm, vt; vl~ = ve~, vm~, vt~";
 
730
    temp1.appendChild(temp2);
 
731
    temp_div.appendChild(temp1);    
 
732
    var temp2=document.createElement("option");
 
733
    temp2.innerHTML="l+ = e+, mu+ ta+; l- = e-, mu- ta-; vl = ve, vm, vt; vl~ = ve~, vm~, vt~";
 
734
    temp1.appendChild(temp2);
 
735
    temp_div.appendChild(temp1);
 
736
    var temp2=document.createElement("option");
 
737
    temp2.innerHTML="l = e+, mu+, e-, mu-; vl = ve, vm, vt, ve~, vm~, vt~";
 
738
    temp1.appendChild(temp2);
 
739
    temp_div.appendChild(temp1);
 
740
    var temp2=document.createElement("option");
 
741
    temp2.innerHTML="l = e+, mu+, ta+, e-, mu-, ta-; vl = ve, vm, vt, ve~, vm~, vt~";
 
742
    temp1.appendChild(temp2);
 
743
    temp_div.appendChild(temp1);
 
744
    
 
745
    
 
746
    
 
747
    this.sum=temp1;
 
748
    element2.appendChild(temp_div);   
 
749
    
 
750
    
 
751
  }
 
752
   this.aside_element_gauche=document.createElement('aside');
 
753
   this.aside_element_gauche.className="explanation";
 
754
   this.aside_element_gauche.id=element.id+"aside";
 
755
   
 
756
  structure.appendChild(this.aside_element_gauche);
 
757
  structure.appendChild(element);
 
758
  if(this.num_process!==0){new delete_button(structure.id,structure,this,this);}
 
759
  this.structure=structure;
 
760
  endroit.appendChild(this.structure);
 
761
  nombre_process++;
 
762
  var temp=document.createElement("div");
 
763
  this.cardText=document.createElement("div");
 
764
  var temp2=document.createElement("div");
 
765
  var temp3=document.createTextNode("Equivalent Code: ");
 
766
  temp2.appendChild(temp3);
 
767
  temp2.style.display="inline-block";
 
768
  temp2.style.verticalAlign="top";
 
769
  temp.appendChild(temp2);
 
770
  var temp2=document.createElement("div");
 
771
  temp2.className="card"
 
772
  temp2.style.display="inline-block";
 
773
  temp2.style.marginLeft="30px";
 
774
  temp2.appendChild(this.cardText);
 
775
  temp.appendChild(temp2);
 
776
  temp.style.paddingTop="10px";
 
777
  this.element2.appendChild(temp)
 
778
  var ceci=this;
 
779
  var card=this.cardText;
 
780
  this.generateCard=function(){
 
781
          card.innerHTML="";
 
782
          if(ceci.error_message){
 
783
                  card.innerHTML+="<div class=error>"+ceci.error_message+"</div>";
 
784
          }
 
785
          var ertab=check_particles(ceci.input_element);
 
786
          var ertab2=[];
 
787
          var numpg=0;
 
788
          for(var i=0; i<ertab.length;i++){
 
789
                  if (ertab[i]===">" && numpg<2){
 
790
                          numpg++;
 
791
                  }
 
792
                  else{
 
793
                          ertab2.push(ertab[i]);
 
794
                  }
 
795
          }
 
796
          if (ertab2.length>0){
 
797
                    var temp_error_message="ERROR: No particle named "
 
798
                            for (var k=0; k<ertab2.length;k++){temp_error_message+=" "+ertab2[k];}
 
799
                            temp_error_message+=" in model <br />";
 
800
                  card.innerHTML+="<div class=error>"+temp_error_message+"</div>";
 
801
          }
 
802
 
 
803
          if(ceci.decays_exist){
 
804
                  for (var i = 0; i<ceci.decays.length;i++){
 
805
                          if(ceci.decays[i].exists){
 
806
                                  var ertab=check_particles(ceci.decays[i].input_element);
 
807
                                  if (ertab.length>0){
 
808
                                            var temp_error_message="ERROR: No particle named "
 
809
                                                    for (var k=0; k<ertab.length;k++){temp_error_message+=" "+ertab[k];}
 
810
                                                    temp_error_message+=" in model <br />";
 
811
                                          card.innerHTML+="<div class=error>"+temp_error_message+"</div>";
 
812
                                  }
 
813
                                  for (var j=0; j<ceci.decays[i].sub_decays.length;j++){
 
814
                                          var sub=ceci.decays[i].sub_decays[j];
 
815
                                          if(sub.exists){
 
816
                                                  var ertab=check_particles(ceci.decays[i].sub_decays[j].input);
 
817
                                                  if (ertab.length>0){
 
818
                                                            var temp_error_message="ERROR: No particle named "
 
819
                                                                    for (var k=0; k<ertab.length;k++){temp_error_message+=" "+ertab[k];}
 
820
                                                                    temp_error_message+=" in model <br />";
 
821
                                                          card.innerHTML+="<div class=error>"+temp_error_message+"</div>";
 
822
                                                  }
 
823
                                          }
 
824
                                  }
 
825
                          }
 
826
                  }
 
827
          }
 
828
 
 
829
          
 
830
          if (ceci.num_process===0){
 
831
                  card.innerHTML+="define "+ceci.def.childNodes[ceci.def.selectedIndex].innerHTML.replace("j=d"," ").replace("p=","p =")+" <br /> define j = p <br />";
 
832
                  card.innerHTML+="define "+ceci.sum.childNodes[ceci.sum.selectedIndex].innerHTML.replace(/;/g,"<br />define ").replace(/,/g,"");
 
833
                  card.innerHTML+="<br /> <br />"
 
834
          }
 
835
          
 
836
          if (ceci.num_process===0) card.innerHTML+="generate";
 
837
          else card.innerHTML+="add process";
 
838
          card.innerHTML+=" ";
 
839
          card.innerHTML+=ceci.input_string;
 
840
          if(ceci.option.selectedIndex>0){
 
841
                  var childs=ceci.option_div.childNodes;
 
842
                        for(var j=0; j<childs.length;j++) {
 
843
                                if(childs[j].innerHTML !== undefined){
 
844
                                        var inside_text=childs[j][childs[j].selectedIndex].innerHTML;
 
845
                                        inside_text=inside_text.replace(/∞/,"99");
 
846
                                        inside_text=inside_text.replace(/&lt;/,"");
 
847
                                        card.innerHTML=card.innerHTML+" "+inside_text+" ";
 
848
                                }
 
849
                        }
 
850
 
 
851
          }
 
852
          
 
853
          card.innerHTML=card.innerHTML+" "+ceci.nro_string+" ";
 
854
          if(ceci.decays_exist){
 
855
                  for (var i = 0; i<ceci.decays.length;i++){
 
856
                          if(ceci.decays[i].exists){
 
857
                                  card.innerHTML+=", (";
 
858
                                  var si=ceci.decays[i].element_decay_pos.selectedIndex;
 
859
                                  if (si>-1){  card.innerHTML=card.innerHTML+" "+ceci.decays[i].element_decay_pos[si].innerHTML+" > "+ceci.decays[i].input_element.value; }
 
860
                                  var dc=ceci.decays[i];                                  
 
861
                                  if(dc.option.selectedIndex===1){
 
862
                                                var childs=dc.option_div.childNodes;
 
863
                                                for(var j=0; j<childs.length;j++) {
 
864
                                                        if(childs[j].innerHTML !== undefined){
 
865
                                                                var inside_text=childs[j][childs[j].selectedIndex].innerHTML;
 
866
                                                                inside_text=inside_text.replace(/∞/,"99");
 
867
                                                                inside_text=inside_text.replace(/&lt;/,"");
 
868
                                                                card.innerHTML=card.innerHTML+" "+inside_text+" ";
 
869
                                                        }
 
870
                                                }
 
871
                                  }
 
872
                                  
 
873
                                  
 
874
                                  for (var j=0; j<ceci.decays[i].sub_decays.length;j++){
 
875
                                          var sub=ceci.decays[i].sub_decays[j];
 
876
                                          if(sub.exists){
 
877
                                                  card.innerHTML+=", ";
 
878
                                                  var sbi=sub.element_subdecaypos.selectedIndex;
 
879
                                                  if(sbi>-1){card.innerHTML+=sub.element_subdecaypos[sbi].innerHTML+" > "+sub.input.value;}
 
880
                                                  
 
881
                                                  var dc=ceci.decays[i].sub_decays[j];                            
 
882
                                                  if(dc.option.selectedIndex===1){
 
883
                                                                var childs=dc.option_div.childNodes;
 
884
                                                                for(var k=0; k<childs.length;k++) {
 
885
                                                                        if(childs[k].innerHTML !== undefined){
 
886
                                                                                var inside_text=childs[k][childs[k].selectedIndex].innerHTML;
 
887
                                                                                inside_text=inside_text.replace(/∞/,"99");
 
888
                                                                                inside_text=inside_text.replace(/&lt;/,"");
 
889
                                                                                card.innerHTML=card.innerHTML+" "+inside_text+" ";
 
890
                                                                        }
 
891
                                                                }
 
892
                                                  }
 
893
 
 
894
                                          }
 
895
                                  }
 
896
                                  card.innerHTML+=")";
 
897
                          }
 
898
                  }
 
899
          }
 
900
          var position=0;
 
901
          if (ceci.num_process===0){position=card.innerHTML.indexOf("generate");}
 
902
          else{position=card.innerHTML.indexOf("add process");}
 
903
          ceci.card_short=card.innerHTML.substring(position,card.innerHTML.length);
 
904
          ceci.click_to_show.innerHTML="Click to show:<br/><div style=\"font-family: ‘Courier New’, Courier, monospace;\">"+ceci.card_short+"<\div>";
 
905
  }
 
906
  this.generateCard();
 
907
  for (var i=0; i<processes.length;i++){
 
908
          processes[i].click_to_show.style.display="block";
 
909
          processes[i].element2.style.display="none";
 
910
  }
 
911
  ceci.click_to_show.style.display="none";
 
912
  ceci.element2.style.display="block";
 
913
}
 
914
 
 
915
new process(document.getElementById("input"));
 
916
 
 
917
x=function salut(){
 
918
        //alert("tick");
 
919
        for (var i=0; i<processes.length; i++){
 
920
                processes[i].generateCard();
 
921
        }
 
922
        setTimeout(x, 1000);
 
923
};
 
924
 
 
925
x();
 
926
 
 
927
 
 
928
function transform(){
 
929
        for (var j=0; j<processes.length; j++){
 
930
                processes[j].generateCard();
 
931
        }
 
932
        var to_send="_di_ model";
 
933
        to_send+="_nl_ import model "+model+"_nl__nl_";
 
934
        var k=-1;
 
935
        if (invert !=="empty"){
 
936
                to_send+="_di_Options _nl_"
 
937
                to_send+="customize_model_nl_";
 
938
                for (var j = 0; j< options.childNodes.length; j++){
 
939
                        if (options.childNodes[j].innerHTML !== undefined) {
 
940
                                for (var i=0; i<options.childNodes[0].childNodes.length;i++){
 
941
                                        if (options.childNodes[j].childNodes[i]!== undefined && options.childNodes[j].childNodes[i].value!== undefined) {
 
942
                                                k++;
 
943
                                                to_send+="set "+options.childNodes[j].childNodes[i].value.replace(/ /g,"");
 
944
                                                if(options.childNodes[j].childNodes[i].checked){
 
945
                                                        to_send+=" True_nl_";
 
946
                                                }
 
947
                                                else{
 
948
                                                        to_send+=" False_nl_";
 
949
                                                }
 
950
                                        }
 
951
                                }
 
952
                        }
 
953
                }
 
954
                to_send+="_nl__nl_";
 
955
        }
 
956
        to_send+="_di_Definitions_nl_";
 
957
        for (var i =0; i<processes.length;i++){
 
958
                if (processes[i].exists){
 
959
                        if (i>0){to_send+="_nl_ _nl_ _di_ New Process _nl_";}
 
960
                        to_send+=processes[i].cardText.innerHTML.replace("generate","_di_ First Process_nl_generate");}
 
961
        }
 
962
        to_send=to_send.replace(/&gt;/g,"_pg_");
 
963
        to_send=to_send.replace(/>/g,"_pg_");
 
964
        to_send=to_send.replace(/</g,"_pp_");
 
965
        to_send=to_send.replace(/&/g,"_and_");
 
966
        to_send=to_send.replace(/_pp_br_pg_/g,"_nl_");
 
967
        to_send=to_send.replace(/;/g,"_pv_");
 
968
        while(to_send.search(/_nl_ /g)>0){
 
969
                to_send=to_send.replace(/_nl_ /g,"_nl_");
 
970
        }
 
971
        to_send=to_send.replace(/_pp_div class=\"error\"_pg_/g,"_di_");
 
972
        to_send=to_send.replace(/_pp_\/div_pg_/g,"");
 
973
        to_send=to_send.replace(/\"/g,"_gg_");
 
974
        to_send=to_send.replace(/\+/g,"_p_");
 
975
        return to_send;
 
976
}
 
977
 
 
978
 
 
979
function process_data(){
 
980
        for (var j=0; j<processes.length; j++){
 
981
                processes[j].generateCard();
 
982
        }
 
983
        window.location="process?code="+transform();
 
984
}
 
985
 
 
986
function edit_data(){
 
987
        for (var j=0; j<processes.length; j++){
 
988
                processes[j].generateCard();
 
989
        }
 
990
        window.location="edit?code="+transform();
 
991
}