summaryrefslogtreecommitdiff
path: root/data/js/misc.js
blob: 9c151eaebae34a7d6fc5d7504abc80f26ff86024 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// expand/collapse release listing (/p+)
(function(){
  var lnk = byId('expandprodrel');
  if(!lnk)
    return;
  function setexpand() {
    var exp = !(getCookie('prodrelexpand') == 1);
    setText(lnk, exp ? 'collapse' : 'expand');
    setClass(byId('prodrel'), 'collapse', !exp);
  };
  lnk.onclick = function () {
    setCookie('prodrelexpand', getCookie('prodrelexpand') == 1 ? 0 : 1);
    setexpand();
    return false;
  };
  setexpand();
})();


// search tabs
(function(){
  function click() {
    var str = byId('q').value;
    if(str.length > 1) {
      this.href = this.href.split('?')[0];
      if(this.href.indexOf('/g') >= 0 || this.href.indexOf('/i') >= 0)
        this.href += '/list';
      this.href += '?q=' + encodeURIComponent(str);
    }
    return true;
  };
  if(byId('searchtabs')) {
    var l = byName(byId('searchtabs'), 'a');
    for(var i=0; i<l.length; i++)
      l[i].onclick = click;
  }
})();


// spam protection on all forms
setTimeout(function() {
  for(var i=1; i<document.forms.length; i++)
    document.forms[i].action = document.forms[i].action.replace(/\/nospam\?/,'');
}, 500);