RSI helpers  0.1
RSI helpers
dump.js
Go to the documentation of this file.
1 var dump = {
2 
3  element: function(id){
4  return document.getElementById('dump-' + id);
5  },
6 
7  setSub: function(index,sub,show,hide,event){
8  if(event) event.stopPropagation();
9  this.element('sub-' + index).style.display = sub;
10  this.element('show-' + index).style.display = show;
11  this.element('hide-' + index).style.display = hide;
12  },
13 
14  showSub: function(index,event){
15  this.setSub(index,'table-row','none','inline-block',event);
16  },
17 
18  hideSub: function(index,event){
19  this.setSub(index,'none','inline-block','none',event);
20  },
21 
22  showSubs: function(from,to,event){
23  if(event) event.stopPropagation();
24  for(var i = from; i <= to; i++) this.showSub(i);
25  },
26 
27  showTab: function(index,select,keys){
28  var self = this;
29  this.showSub(index);
30  keys.forEach(function(key){
31  var tab = self.element('tab-' + index + '-' + key),nav = self.element('nav-' + index + '-' + key),active = key == select;
32  if(tab) tab.style.display = active ? 'block' : 'none';
33  if(nav){
34  nav.className = nav.className.replace(/(^| )dump-active/,'');
35  if(active) nav.className += ' dump-active';
36  }
37  });
38  },
39 
40  copy: function(input){
41  input.select();
42  document.execCommand('copy');
43  input.selectionStart = input.selectionEnd;
44  },
45 
46  sort: function(index,keys){
47  var self = this,body = this.element('sort-' + index);
48  keys.forEach(function(key){ body.appendChild(self.element('sort-' + index + '-' + key)) });
49  }
50 
51 };