Browse Source

Add notice about the content may be wrong.

Toni Fadjukoff 11 years ago
parent
commit
f7f5b31bb2
2 changed files with 40 additions and 3 deletions
  1. 8 3
      food.pl
  2. 32 0
      ruoka.js

+ 8 - 3
food.pl View File

@@ -1,8 +1,8 @@
1 1
 #!/usr/bin/env perl
2 2
 
3
-# Ruokalistaparseri v1.5.3
3
+# Ruokalistaparseri v1.5.4
4 4
 # Copyright (c) 2007-2010 Timo Sirainen
5
-#               2011-2012 Toni Fadjukoff
5
+#               2011-2013 Toni Fadjukoff
6 6
 # This is Public Domain
7 7
 
8 8
 use strict;
@@ -80,8 +80,12 @@ my $file_header = '<?xml version="1.0" encoding="iso-8859-1"?>
80 80
   <title>Ruokalistat</title>
81 81
   <link rel="stylesheet" type="text/css" href="'.$global_prefix.'/ruoka.css" />
82 82
 </head>
83
-<body onload="set_allergies()">
83
+<body>
84 84
 
85
+<div id="notice" style="border: 1px solid black; border-radius: 5px; padding: 5px;">
86
+PNA.fi on kolmannen osapuolen tarjoama palvelu. En voi taata ruokalistojen oikeellisuutta.
87
+Jos huomaat ruokalistassa virheen, nopeiten asia korjaantuu kun lähetät minulle siitä sähköpostia: <a href="mailto:lamperi+pna@gmail.com">lamperi+pna@gmail.com</a>
88
+</div>
85 89
 
86 90
 <form method="get" action="/cgi-bin/food.cgi">
87 91
 ';
@@ -337,6 +341,7 @@ sub write_day {
337 341
   my @allergy_strings = map('"'.$_.'"', @allergies);
338 342
   print $fout "var allergies = [".join(",", @allergy_strings)."];\n";
339 343
   print $fout "var food_count = $foodnum\n";
344
+  print $fout "window.onload = function() { set_allergies(); show_warning(); };\n";
340 345
   print $fout "</script>\n";
341 346
 
342 347
   print $fout "</div></div>$file_footer";

+ 32 - 0
ruoka.js View File

@@ -93,3 +93,35 @@ function set_allergies()
93 93
   }
94 94
   highlight();
95 95
 }
96
+
97
+var NO_WARNING_SETTING = "pna-no-warning";
98
+function shouldShowWarning() {
99
+  if (window.localStorage) {
100
+    return !localStorage[NO_WARNING_SETTING];
101
+  } else {
102
+    return document.cookie.indexOf(NO_WARNING_SETTING) == -1;
103
+  }
104
+}
105
+function noMoreWarning() {
106
+  if (window.localStorage) {
107
+    localStorage[NO_WARNING_SETTING] = "true";
108
+  } else { 
109
+    document.cookie += NO_WARNING_SETTING + "=true; expires=Tue, 19 Jan 2038 03:14:07 GMT";
110
+  } 
111
+}
112
+function show_warning() {
113
+  var notice = document.getElementById("notice");
114
+  if (shouldShowWarning()) {
115
+    var input = document.createElement("input");
116
+    input.type="submit";
117
+    input.value="Älä näytä tätä enää";
118
+    input.onclick = function() {
119
+      notice.parentNode.removeChild(notice); 
120
+      noMoreWarning();
121
+      return false;
122
+    }
123
+    notice.appendChild(input)
124
+  } else {
125
+    notice.parentNode.removeChild(notice);
126
+  }
127
+}