aboutsummaryrefslogtreecommitdiff
path: root/www/inc/global.js
blob: ff8ec216c889b603dc8dae2d6f821642db39f8f9 (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
function setActiveStyleSheet(title) {
   var i, a, main;
   for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
     if(a.getAttribute("rel").indexOf("style") != -1
        && a.getAttribute("title")) {
       a.disabled = true;
       if(a.getAttribute("title") == title) a.disabled = false;
     }
   }
   if (title!="") {
      writeCookie(title);
   }
}

function getInactiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && a.disabled) return a.getAttribute("title");
  }
  return null;
}

function readCookie() {
    var theme = document.cookie;
    var theme = unescape(theme);

    return theme;
}

function writeCookie(theme) {
   //FIXME - set expires
   var original_cookie = "theme=" + escape(theme);
   document.cookie = original_cookie;
}

function checkForTheme() {
   var theme = readCookie();
   //alert(theme);
   if (theme=="undefined") {
      var theme = "none";
   }
}

// what a kludge. Luckily I found a clean way
function alignForGorilla() {
var image_preview = document.getElementById('preview');
image_preview.style.marginLeft = "-" + (image_preview.width/2 + 16) + "px";
}

// to hide and show the comment block
// inspired by www.wikipedia.org
function toggle_comment() {
    var comment_form = document.getElementById('comment_form');
    var showlink=document.getElementById('showlink');
    var hidelink=document.getElementById('hidelink');
    if(comment_form.style.display == 'none') {
	comment_was = comment_form.style.display; 
	comment_form.style.display = '';
	hidelink.style.display='';
	showlink.style.display='none';
    } else {
	comment_form.style.display = comment_was;
	hidelink.style.display='none';
	showlink.style.display='';
    }
}

function toggle_exif() {
	var exif_table = document.getElementById('exif_table');
	var exif_line = document.getElementById('exif_line');
    if(exif_table.style.display == 'none') {
			exif_table.style.display = 'block';
			exif_line.style.display = 'none';
		} else {
			exif_table.style.display = 'none';
			exif_line.style.display = 'block';
		}
}