CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Public Attributes
cfg-viewer.generateBrowser Class Reference

Public Member Functions

def __init__
 
def css
 
def doPaths
 
def doPsets
 
def javascript
 
def printStart
 

Public Attributes

 cfg
 
 html
 
 js
 
 pathLi
 
 pathName
 
 thecss
 
 theDir
 

Detailed Description

Definition at line 14 of file cfg-viewer.py.

Constructor & Destructor Documentation

def cfg-viewer.generateBrowser.__init__ (   self,
  htmlFile,
  cfgFile 
)

Definition at line 15 of file cfg-viewer.py.

15 
16  def __init__(self,htmlFile, cfgFile):
17  self.html = htmlFile
18  self.theDir=''
19  self.pathName = "paths.html"
20  self.js = "search.js"
21  self.thecss = "style.css"
22 
23  rest= html.rsplit('/',1)
24  # Find where the html file is to be stored.
25  # store everything else there, move other stuff there.
26  if(len(rest)>1):
27  self.theDir=rest[0]+'/'
28  if(not os.path.isdir(self.theDir)):
29  os.mkdir(self.theDir)
30  self.javascript("%s%s"%(self.theDir,self.js))
31  self.css("%s%s"%(self.theDir,self.thecss))
32  self.pathLi="""
33  <li class="expand %(className)s" data-name="%(nameID)s">%(nameID)s:</li>
34  """
35  self.cfg = imp.load_source("cfg", cfgFile)
36  # do the psets (in other file, provide link to it.)
37  psetTypes = open("%sparamTypes.js"%(self.theDir),'w')
38  psetTypes.close()
39  print "Starting print out of psets."
40  self.doPsets()
41  print "Finished finding psets. Now onto paths..."
42  self.doPaths()
43  print "Paths done"
if(dp >Float(M_PI)) dp-

Member Function Documentation

def cfg-viewer.generateBrowser.css (   self,
  thecss 
)

Definition at line 744 of file cfg-viewer.py.

745  def css(self,thecss):
746  cssFile= open(thecss, 'w')
747  cssFile.write( """
748 
749 em {
750  background-color: rgb(255,255,0);
751  font-style: normal;
752 }
753 .module{
754  color: #0000CC
755 }
756 .param {
757  color: #9999CC;
758  cursor:default;
759 }
760 .paramInner {
761  color: #9999FF;
762  cursor:default;
763 }
764 .value{
765  color:#0000FF;
766 }
767 .type{
768  color: #00CCFF;
769 }
770 
771 ul {
772  list-style-type:none;
773  padding-left:0.6em;
774 }
775  .expand:before{
776  content:'›';
777  float: left;
778  margin-right: 10px;
779 }
780  .expanded:before, .param:before{
781  content:'ˇ';
782  float: left;
783  margin-right: 10px;
784 }
785 .expand, .expanded, .param{
786  cursor:pointer;
787 }
788 
789  """)
790  cssFile.close()
791 
792 """
793  Do Module Objects e.g. producers etc
794 """
def cfg-viewer.generateBrowser.doPaths (   self)

Definition at line 44 of file cfg-viewer.py.

References reco.if(), join(), cfg-viewer.generateBrowser.js, cfg-viewer.generateBrowser.pathLi, cfg-viewer.generateBrowser.pathName, ecaldqm::MEData.pathName, stor::ResourceMonitorCollection::DiskUsageStats.pathName, FWPSetTableManager::PathUpdate.pathName, FWPSetTableManager::PathInfo.pathName, ConfigBuilder.ConfigBuilder.pathName, cfg-viewer.generateBrowser.printStart(), cfg-viewer.generateBrowser.thecss, cfg-viewer.generateBrowser.theDir, Line.theDir, MillePedeAlignmentAlgorithm.theDir, and cmsPerfHarvest.visit().

44 
45  def doPaths(self):
46  modHTMLName= "%sparamTypes.js"%(self.theDir)
47  modToPathName = "%smodToPath.js" %(self.theDir)
48  tempFile ="%stemp.js"%(self.theDir)
49  f={modHTMLName:"params",modToPathName:"modules"}
50  o={modHTMLName:"a",modToPathName:"w"}
51  theS="var %s={"
52  for key in f.keys():
53  curFile = open(key,o[key])
54  curFile.write(theS%(f[key]))
55  curFile.close()
56  first = True
57  liToBeWritten, frmPathHolder="", "";
58  className, theS,frmPathStr ="path","",'%s%s:["%s"]'
59  newModsStr, oldModsStr='%s\n%s:["%s"]', '%s"%s",%s'
60  dataFile= open(modHTMLName,'a')
61  v = visitor(dataFile)
62  paths = self.cfg.process.paths
63  global oldMods
64  global allMods
65  global newModsNames
66  for item in paths.keys():
67  oldMods=[] # module names which have been seen before.
68  # needed so we can add this path name to the dictionary in modToPath.js
69  allMods =[]# set of current path modules names including duplciates.
70  newModsNames=[] # set of current paths module name without duplicates.
71  # could get oldMods from all Mods if we take away all newModsNames
72  liToBeWritten +=format(self.pathLi,nameID=item,className=className)
73  paths[item].visit(v)
74  frmPathHolder +=frmPathStr%(theS,item,"\",\"".join(allMods))
75  fromMod = open(modToPathName, 'r')
76  fromModTemp = open(tempFile, 'w')
77  for line in fromMod:
78  tLine= re.sub('\[.*?\]', "",line)
79  result = re.split(':|,', tLine[tLine.find('{')+1:])
80  namesFound = [x for i, x in enumerate(result)if not i%2]
81  # the new names we have is going to be smaller,
82  # so we'll loop round that
83  for each in oldMods:
84  if(each in namesFound):
85  oldMods.remove(each)
86  index = line.find(each)+len(each)+2 # as will have :[ after it
87  line = oldModsStr %(line[:index],item,line[index:])
88  fromModTemp.write(line)
89  fromMod.close()
90  for each in newModsNames:
91  fromModTemp.write(newModsStr%(theS,each,item))
92  theS=","
93  fromModTemp.close()
94  os.rename(tempFile,modToPathName)
95  if(first):
96  theS=","
97  first=False
98  out = open("%s%s"%(self.theDir,self.pathName), 'w')
99  self.printStart(self.js,self.thecss, """disabled="True" """, out)
100  out.write("<a href='%s'> See Psets</a>&nbsp;\n<ul>%s"\
101  "</ul>\n</body>\n</html>"%(self.html.rsplit('/',1)[-1],liToBeWritten))
102  out.close()
103  dataFile.write("};\nfunction getAllParams(){\n"\
104  "var newD ={};\n var keys = Object.keys(params);\n"\
105  "for(var i=0; i <keys.length; i++){ \n"\
106  " newD[keys[i]]= params[keys[i]][\"parameters\"];\n}"\
107  " return newD;}\n"\
108  " function getParams(modName){\n"\
109  " return params[modName][\"parameters\"];}\n"\
110  "function getInnerParams(parentsNames){\n"\
111  "var curList=params[parentsNames[0]][\"parameters\"];\n"\
112  "for(var i=1; i < parentsNames.length;i++){\n"\
113  " for(var p=0; p < curList.length;p++){\n"\
114  " if(curList[p][0]==parentsNames[i]){\n"\
115  " var found = curList[p][1];\n"\
116  " break;\n }\n}\n curList = found;\n}\n"\
117  " return curList;}\n"\
118  "function getFile(name){\n"\
119  "return params[name][\"file\"];\n}"\
120  "function getType(name){\n"\
121  "return params[name][\"type\"];\n}")
122  fromPath= open("%spathToMod.js" %(self.theDir),'w')
123  fromPath.write("var paths={%s}\n "\
124  "function getModules(thePath){\n"\
125  "return paths[thePath];\n}"\
126  "\n function keys(){\n return Object.keys(paths); "\
127  "\n}" %(frmPathHolder))
128  fromPath.close()
129  fromMod = open(modToPathName, 'a')
130  fromMod.write("}\n function getPaths(theMod){\n"\
131  "return modules[theMod];\n}")
132  fromMod.close()
def visit
Retrieve data from a perf suite output (sub) directory, only examines TimeSize at the moment...
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
if(dp >Float(M_PI)) dp-
def cfg-viewer.generateBrowser.doPsets (   self)

Definition at line 133 of file cfg-viewer.py.

References cfg-viewer.do(), cfg-viewer.generateBrowser.html, reco.if(), cfg-viewer.generateBrowser.js, cfg-viewer.generateBrowser.pathLi, cfg-viewer.generateBrowser.pathName, ecaldqm::MEData.pathName, stor::ResourceMonitorCollection::DiskUsageStats.pathName, FWPSetTableManager::PathUpdate.pathName, FWPSetTableManager::PathInfo.pathName, ConfigBuilder.ConfigBuilder.pathName, cfg-viewer.generateBrowser.printStart(), cfg-viewer.generateBrowser.thecss, cfg-viewer.generateBrowser.theDir, Line.theDir, and MillePedeAlignmentAlgorithm.theDir.

134  def doPsets(self):
135  addC,writeOut,toParamWrite= "","",""
136  first = True
137  outStr=self.pathLi
138  pStr="%s%s:'%s'"
139  classN = "module"
140  process = self.cfg.process
141  psets = process.psets
142  theDict ={}
143  for pset in psets:
144  writeOut+=format(outStr,nameID=pset,className=classN)
145  psetCfg = process.__dict__[pset]
146  res = do(psetCfg.parameters_(),[])
147  theDict[pset] = res
148  if(first):
149  addC=","
150  first=False
151  out = open(self.html, 'w')
152  self.printStart(self.js, self.thecss ,"", out)
153  out.write("<a href=\"%s\"> See Paths</a>\n<ul>"\
154  "%s</ul></html>"%(self.pathName,writeOut))
155  out.close()
156 
157  psetTypes = open("%sparamTypes.js"%(self.theDir),'w')
158  psetTypes.write("psetParams=%s\nfunction getAllpsetParams(){\n"\
159  "return psetParams;}\n"\
160  " function getpsetParams(modName){\n"\
161  " return psetParams[modName];}\n"\
162  "function getInnerpsetParams(parentsNames){\n"\
163  "var currentList = psetParams[parentsNames[0]];\n"\
164  "for(var i=1; i < parentsNames.length;i++){\n"\
165  " for(var p=0; p < currentList.length;p++){\n"\
166  " if(currentList[p][0]==parentsNames[i]){\n"\
167  " var found = currentList[p][1];\n"\
168  " break;\n }\n}\n currentList = found;\n}\n"\
169  " return currentList;}\n"%(theDict))
if(dp >Float(M_PI)) dp-
def cfg-viewer.generateBrowser.javascript (   self,
  thejs 
)

Definition at line 232 of file cfg-viewer.py.

233  def javascript(self,thejs):
234  jsFile = open(thejs, 'w')
235  jsFile.write( """
236 $(document).ready(function(){
237  $(document).on('click', '#search', function(e){
238  numFound = 0;
239  var par = $(this).parent();
240  var id = $(par).find('#searchType').attr('id');
241  var option = $('#'+id+' option:selected').text();
242  var val = $(par).find('#searchWord').val()
243  var reg = new RegExp("("+val+")", "gi");
244  switch(option){
245  case "Path":
246  reset('li.path', e, true);
247  numFound = topLevelMatch(keys(),reg,false); // will stay the same
248 
249  case "Module":
250  if(typeof modKeys != 'function' && false){
251  //if modKeys is not defined means we're using pset html.
252  //maybe change this so instead we define top layer li with class top
253  reset('li.module', e, true);
254  //numFound = topLevelMatch
255  numFound = topLevelMatch( $('li.module'),reg,true);
256  }
257  else{
258  // for now pretend that its in html.
259  //searchReplaceHTML(reg, "module");
260  // if not in the html
261  //Okay can either, get allmatched modules and add them
262  // to all html parents
263  // or go round paths and get all matched modules adding to tghe path
264  var strings = allMods(reg);
265  var Li = $(document.createElement('li')).attr(
266  "class","module expand");
267  console.log("hereiam before");
268  searchReplaceNonHTML(strings,Li, reg)
269  }
270 
271  case "File Name":
272  //get all modules names, get files for all modules
273  // once we have a list of all modules we want
274  // add those modules to
275 
276  case "Parameter":
277  // gives the params which match the reg.
278  numFound = lowerLevels(reg,doInnerParams, e)
279 
280  case "Type":
281  reset('li.path',e,true);
282  // similar to params except we're looking at
283  // the types and not the params names.
284  // so need to get all the params, loop over the keys
285  var matches = matchValue(reg);
286  console.log("matches are "+ matches)
287 
288  case "Value":
289  numFound = lowerLevels(reg,doInnerValue, e)
290  }
291  $('#searchNumber').html(numFound+" found.");
292  $('#searchReset').show();
293  });
294 
295 //do Params, values.
296 function lowerLevels(reg,funcCall, e){
297  reset('li.path', e, true);
298  var numFound=0;
299  if($("span[id='pageType']").attr("data-type")=="pset"){
300  var matches = getAllpsetParams();
301  }
302  else var matches = getAllParams();
303 
304  var keys = Object.keys(matches);
305  for(var i=0; i < keys.length; i++){
306  var theKey = keys[i];
307  var params = matches[theKey];
308  var theMod = moduleLI.clone().attr("data-name",theKey).text(theKey);
309  // need to make the ul
310  tempNumber =0;
311  var theUL = funcCall(params,reg);
312  if(tempNumber ==0)continue;
313  theMod.append(theUL);
314  // for now just do parents
315  var pathsAddTo = getPaths(theKey);
316  var mul =0;
317  for(var k=0; k < pathsAddTo.length;k++){
318  // all paths to be added to.
319  var theP = pathsAddTo[k];
320  // find the parent.
321  $('li.path[name='+theP+']').each(function(){
322  // for each one add the theMod.
323  $(this).children().empty();
324  $(this).append(theMod.clone());
325  mul +=1;
326  });
327  }
328  numFound += (tempNumber*mul)
329  }
330  return numFound;
331 }
332 
333 function doInnerValue(modules,reg){
334  var theUL = UL.clone();
335  // okay we have a list where we want to check the
336  // inner list is an inner list.
337  for(var i=0; i < modules.length; i++){
338  var innerList= modules[i];
339  var theName = innerList[0];
340  var next = innerList[1];
341  // next could be inner or could be what we want.
342  if(typeof(next)=="object"){
343  // we have inner params, recurse!
344  var oldNum = tempNumber
345  var newUL = doInnerValue(next, reg); // will return a ul.
346  if(tempNumber == oldNum){
347  var li= LIExpand.clone().attr("data-name", theName).html(theName);
348  }
349  else {
350  var li= LIExpanded.clone().attr("data-name", theName).html(theName);
351  li.append(newUL);
352  }
353  }
354  else{
355  // else do normal and make the
356  // rename the value
357  var newValue = next.replace(reg, "<em>$1</em>");
358  if(newValue != next){
359  tempNumber +=next.match(reg).length;
360  }
361  var li= paramLI.clone().attr("data-name",theName).html(theName);
362  var theClass="value";
363  li.append(span.clone().attr("class", "value").html(": "+newValue));
364  innerList.slice(2).forEach(function(i){
365  li.append(span.clone().attr("class", "type").text(" ("+i+")"));
366  });
367  }
368  theUL.append(li);
369  }
370  return theUL;
371  }
372 
373 function doInnerParams(params,reg){
374  var theUL = UL.clone();
375  // okay we have a list where we want to check the
376  // inner list is an inner list.
377  for(var i=0; i < params.length; i++){
378  var param = params[i];// it's name.
379  var theName = param[0];
380  var newName = theName.replace(reg, "<em>$1</em>");
381  if(newName != theName){
382  tempNumber +=theName.match(reg).length;
383  }
384  var next = param[1];
385  if(typeof(next)=="object"){
386  // we have inner params, recurse!
387  //var cloLI= LIExpand.clone().attr("name", theName).text(theName);
388  //var ul = UL.clone();
389  var old = tempNumber;
390  var newUL = doInnerParams(next, reg); // will return a ul.
391  if(old == tempNumber){
392  var li= LIExpand.clone().attr("data-name", theName).html(newName);
393  }
394  else {
395  var li= LIExpanded.clone().attr("data-name", theName).html(newName);
396  li.append(newUL);
397  }
398  }
399  else{
400  // else do normal and make the
401  var li= paramLI.clone().attr("data-name",theName).html(newName);
402  var theClass="value";
403  for(var w=1; w < param.length;w++){
404  // do types etc.
405  if(w==1)
406  li.append(span.clone().attr("class", "value").text(": "+param[w]));
407  else
408  li.append(span.clone().attr("class", "type").text(
409  " ("+param[w]+")"));
410  }
411  }
412  theUL.append(li);
413  }
414  return theUL;
415  }
416  var LI= $(document.createElement('li'));
417  var moduleLI= LI.clone().attr("class","module expand");
418  var paramLI= LI.clone().attr("class","param expanded");
419  var UL = $(document.createElement('ul'));
420  var span = $(document.createElement('span'));
421  var LIExpand = LI.clone().attr("class","expand paramInner");
422  var LIExpanded = LI.clone().attr("class","expanded paramInner");
423 // All params send here.
424 //[[normaloparam, value,type]
425 //[inner[innervalues, value,type]][norm, value, type]]
426 // we will get [normaloparam, value,type] etc
427 var numFound =0;
428 var tempNumber =0;
429  /*
430  String format should have where they want the string to go as name.
431  For module just now. //
432  */// stringformat would be what we want it to go in,
433  function searchReplaceNonHTML(strings, theLi, regex){
434  // we have the things we want, the string should just be the
435  // what we want to be shwn i.e. an LI, which we clone.
436  var UL = $(document.createElement('ul'));
437  for(var i=0; i <strings.length; i++){
438  var thisOne = strings[i]; // e.g. generator
439  //here i have the string and now i will
440  //need a format string or something, to know what to put around it?
441  var LI = theLi.clone().attr("data-name", thisOne).html(
442  thisOne.replace(regex, "<em>$1</em>"));
443  var paths = getPaths(thisOne);
444  for (var p=0; p < paths.length; p++){
445  // need to find the path on the page and add the module to it.
446  $('li.path[name='+paths[p]+']').each(function(){
447  // for each add this LI
448  if($(this).children('ul').length ==0){
449  $(this).append(UL.clone().append(LI.clone()));
450  }
451  else{
452  $(this).children('ul').append(LI.clone());
453  // so all paths dont point to the same LI,maybe can change this?
454  }
455  $(this).attr("class","expanded path");
456  });
457  }
458  }
459  }
460  /*
461  Search when what we're looking for is in HTML but not topLevel element.
462  To be global replace, find should be regexp object with g.
463  */
464  function searchReplaceHTML(find,identifier){
465  var found =0;
466  var foundParents=[];
467  var notFoundLI=[];
468  $("li ."+identifier).each(function(){
469  var howMany=0;
470  if(howmany = $(this).attr("data-name").match(find)){
471  // we found you
472  found +=howMany
473  $(this).html() = $(this).html().replace(find,"<em>$1</em>");
474  // now find parents
475  // if parents not already showen show them
476  $(this).parents('ul').each(function(){
477  if(foundParents.indexOf(this) ==-1){
478  $(this).show();
479  foundParents.append(this);
480  }
481  else{
482  // already done these parents
483  return false;// (i.e. break out loop);// the parents loop.
484  }
485  });
486  }
487  else{
488  notFoundLI.append(this);
489  // not a match, can just try and find a ul parent,
490  //if there is one, then we need to know whether to
491  // hide it.TODO or do nothing.
492  }
493  });
494  // now we have list of parents we want to hide all other parents
495  $(notFoundLI).each(function(){
496  $(this).parents('ul').each(function(){
497  if(foundParents.indexOf(this) ==-1){
498  $(this).hide();
499  }
500  else{
501  // already done these parents
502  return false;// (i.e. break out loop);// the parents loop.
503  }
504  });
505  });
506  return found;
507  }
508  /*
509  Resets search ouput.
510  */
511  $(document).on('click', '#searchReset', function(e){
512  $('#searchNumber').html("");
513  if($(this).attr('class') == "pathReset"){
514  reset('li.path',e,true);
515  }
516  else{
517  reset('li.module',e,true);
518  }
519  $(this).hide();
520  });
521  /*
522  Hides children of top level. TODO: Done - works
523  */
524  $(document).on('click', '#hide', function(e){
525  //for hiding we just get top level and remove children.
526  if($(this).css('cursor')!='default'){
527  $('#searchNumber').html("");
528  if($(this).attr('class') == "pathReset"){
529  var selec ='li.path';
530  }
531  else var selec ='li.module';
532  $(selec).each(function(){
533  if(removeChildren(this, e))toggleExpand(this, e);
534  });
535  $(this).css('color','#CCCCCC');
536  $(this).css('cursor','default');
537  }
538  });
539  /*
540  Retrieves and expands path elements. - works
541  */
542  $(document).on('click', '.path.expand',function(event){
543  var UL = addModules(getModules($(this).attr('data-name')));
544  $(this).append(UL);
545  $('#hide').css('color','')
546  $('#hide').css('cursor','')
547  });
548  /*
549  Adds modules to a list and returns list.
550  */
551  function addModules(results){
552  var UL = $(document.createElement("ul"));
553  var LI = $(document.createElement('li')).attr("class","module expand");
554  for(var i=0; i < results.length; i++){
555  var theName = results[i];
556  var val = theName+"("+getType(theName)+")"
557  if(document.getElementById("ShowFiles").checked)
558  val+=" ("+getFile(theName)+")"
559  UL.append(LI.clone().attr("data-name", theName).text(val));
560  }
561  return UL;
562  }
563 
564  /*
565  Retrieve and expands module elements.
566  //changed to deal with new data format,
567  //(data now seperate from html specification) - works
568  */
569  $(document).on('click','.module.expand', function(event){
570  addParams(this);
571  event.stopPropagation();
572  });
573 
574  /*
575  Add params to the object. Object can be of any type
576  (normally module or param).
577  It's name needs to be in the data to find its parameters. - works
578  */
579  function addParams(obj, results){
580  var LIBasic = $(document.createElement('li')).attr("class","param");
581  var LIExpand = LIBasic.clone().attr("class","expand paramInner");
582  var span = $(document.createElement("span"));
583  var UL = $(document.createElement("ul"));
584  // getParams returns list of list.
585  // Format:[[name,value,type,trackedornot]].CHANGED!!
586  // new format
587  // :[[name, value,type,trackedornot],[namePset,[name,value,type]]]
588  // If 2nd element is list then its a pset.
589  var objName = $(obj).attr('data-name');
590  if(!results){
591  if($("span[id='pageType']").attr("data-type")=="pset"){
592  var results = getpsetParams(objName);
593  }
594  else {
595  var results = getParams(objName);
596  var type = getType(objName);
597  if(type == "Sequence"){
598  // inside will be names of modules
599  //- so do the same as if this was a path obj
600  var ul = addModules(results);
601  $(obj).append(ul);
602  return
603  }
604  }
605  }
606  for(var i =0; i < results.length; i++){
607  var all = results[i].slice();
608  var theName = all.shift();
609  if(typeof(all[0]) == "object"){
610  var cloLI= LIExpand.clone().attr("data-name", theName).text(theName);
611  //for(var p=0; p < all[0].length;p++){
612  // add all children.
613  //}
614  }
615  else{
616  // Not a Pset.
617  var cloLI = LIBasic.clone().attr("data-name", theName).text(theName);
618  var value = all.shift()
619  // formating so lots of strings look nicer
620  if(value.indexOf(",")>-1)
621  value = "<ul>"+value.replace(/,/g, "</li><li>")+"</li></ul>"
622  cloLI.append(span.clone().attr("class","value").html(": "+value))
623  for(var p=0; p < all.length; p++){
624  cloLI.append(span.clone().attr("class","type").text(
625  " ("+all[p]+")"))
626  }
627  }
628  UL.append(cloLI);
629  }
630  $(obj).append(UL);
631  $('#hide').css('color','')
632  $('#hide').css('cursor','')
633  }
634  /*
635  Hides/Shows children from class param.
636  //changed to deal with new data format - works
637  */
638 $(document).on('click', '.paramInner.expand, .paramInner.expanded',
639  function(event){
640  if($(this).children('ul').length ==0){
641  // find parents
642  var theClass =""
643  var obj = this;
644  var parents =[$(this).attr("data-name")]
645  while(theClass.indexOf("module")==-1){
646  obj = $(obj).parent();
647  if(obj.prop("tagName")=="UL") continue;
648  var parName = obj.attr("data-name");
649  parents.unshift(parName);
650  theClass = obj.attr("class");
651  }
652  if($("span[id='pageType']").attr("data-type")=="pset"){
653  var result = getInnerpsetParams(parents);
654  }
655  else var result = getInnerParams(parents);
656  addParams(this, result);
657  }
658  else{
659  $(this).children('ul').toggle();
660  }
661  event.stopPropagation();
662  });
663  // Needed to stop the propagation of event when it should not be expanded.
664  $(document).on('click', '.param',function(event){
665  if($(this).find('ul').length >0){
666  $(this).find('ul').toggle();
667  }
668  event.stopPropagation();
669  });
670  /*
671  Removes children from expanded paths or modules.
672  */
673  $(document).on('click', '.path.expanded, .module.expanded',function(event){
674  removeChildren(this,event);
675  });
676 
677  // Toggles class names.
678  $(document).on('click','.expand, .expanded', function(event){
679  toggleExpand(this, event);
680  });
681  /*
682  Does matching for top level list elements.
683  Returns number of matches.
684  */
685  function topLevelMatch(list, reg, haveLIs){
686  var numFound =0;
687  for(var p=0; p < list.length; p++){
688  if(haveLIs){
689  var li = $(list[p]);
690  var item = li.attr('data-name');
691  }
692  else{
693  var item = list[p];
694  var li= $('li[name='+item+']');
695  }
696  if(num=item.match(reg)){
697  numFound +=num.length;
698  li.html(li.html().replace(reg, "<em>$1</em>"));
699  }
700  else{
701  li.hide();
702  }
703  }
704  return numFound;
705  }
706  /*
707  Removes highlights from selector, removes also children
708  if rmChildren == true.
709  */
710  function reset(selector, e, rmChildren){
711  var rm = new RegExp('<em>|</em>', 'g');
712  $(selector).each(function(i){
713  var html = $(this).html();
714  if(html.match(rm)){
715  $(this).html(html.replace(rm, ''));
716  }
717  else{
718  $(this).show();
719  }
720  if(rmChildren)if(removeChildren(this, e))toggleExpand(this, e);});
721  }
722  /*
723  Removes children from parent.
724  */
725  function removeChildren(parent, event){
726  var c = $(parent).children('ul');
727  if(c.length >0){
728  $(c).remove();
729  event.stopPropagation();
730  return true;
731  }
732  return false;
733  }
734  /*
735  Helper function toggles classes.
736  */
737  function toggleExpand(me,event){
738  $(me).toggleClass("expanded expand");
739  event.stopPropagation();
740  }
741 });
742  """)
743  jsFile.close()
def cfg-viewer.generateBrowser.printStart (   self,
  js,
  css,
  dis,
  out 
)

Definition at line 171 of file cfg-viewer.py.

References reco.if().

Referenced by cfg-viewer.generateBrowser.doPaths(), and cfg-viewer.generateBrowser.doPsets().

172  def printStart(self,js, css, dis, out):
173  scripts ="""
174  <script type="text/javascript" src="paramTypes.js"></script>
175  """
176  classType="pset"
177  buttons="""
178  <option id="module" selected="selected">Module</option>
179  """
180  if(len(dis)>0):
181  classType="path"
182  buttons="""
183  <option id="path" selected="selected">Path</option>
184  <option id="module">Module</option>
185  <option value="type">Type</option>
186  <option value="parameter">Parameter</option>
187  <option value="value">Value</option>
188  """
189  scripts= """
190  <script type="text/javascript" src="pathToMod.js"></script>
191  <script type="text/javascript" src="modToPath.js"></script>
192  <script type="text/javascript" src="paramTypes.js"></script>
193  """
194  out.write( """
195  <!DOCTYPE html>
196  <html>
197  <head>
198  <meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
199  <title>cfg-browser</title>
200  <script type="text/javascript"
201  src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">
202  </script>
203  %(scripts)s
204  <script type="text/javascript" src="%(js)s"></script>
205 
206  <link href="%(css)s" rel="stylesheet" type="text/css"/>
207  </head>
208  <body>
209  <!--form name="input" action="html_form_action.asp" method="get"-->
210  <form name="searchInput" onsubmit="return false;">
211  <input type="text" id="searchWord"/>
212  <select id="searchType">
213  %(option)s
214  </select>
215 
216  <input type="submit" value="Search" id="search" disabled/></form>
217  <br/><p id="searchNumber"></p><br/>
218  <a id="hide" style="cursor:default; color:#CCCCCC;"
219  class="%(class)sReset"
220  href="javascript:;" >
221  Hide All</a>
222  <br/><br/>
223  <span id="pageType" data-type=%(class)s></span>
224 
225  <input type="submit" id ="searchReset" style="display:none"
226  value="Reset search results." class="%(class)sReset"/>
227  <br/><input type="checkbox" id="ShowFiles" value="File"/>Show module File.
228  <br/>
229 
230  """%{'js':js,'option':buttons, 'css':css, 'dis':dis,
231  'scripts':scripts, 'class':classType})
if(dp >Float(M_PI)) dp-

Member Data Documentation

cfg-viewer.generateBrowser.cfg

Definition at line 34 of file cfg-viewer.py.

cfg-viewer.generateBrowser.html

Definition at line 16 of file cfg-viewer.py.

Referenced by cfg-viewer.generateBrowser.doPsets().

cfg-viewer.generateBrowser.js

Definition at line 19 of file cfg-viewer.py.

Referenced by cfg-viewer.generateBrowser.doPaths(), and cfg-viewer.generateBrowser.doPsets().

cfg-viewer.generateBrowser.pathLi

Definition at line 31 of file cfg-viewer.py.

Referenced by cfg-viewer.generateBrowser.doPaths(), and cfg-viewer.generateBrowser.doPsets().

cfg-viewer.generateBrowser.pathName

Definition at line 18 of file cfg-viewer.py.

Referenced by cfg-viewer.generateBrowser.doPaths(), and cfg-viewer.generateBrowser.doPsets().

cfg-viewer.generateBrowser.thecss

Definition at line 20 of file cfg-viewer.py.

Referenced by cfg-viewer.generateBrowser.doPaths(), and cfg-viewer.generateBrowser.doPsets().

cfg-viewer.generateBrowser.theDir

Definition at line 17 of file cfg-viewer.py.

Referenced by cfg-viewer.generateBrowser.doPaths(), and cfg-viewer.generateBrowser.doPsets().