1
2
3
4
5
6
7 package nl.mineleni.cbsviewer.util;
8
9
10
11
12
13
14
15 public enum CookieNamesConstants {
16
17
18
19 COOKIE_baselyr("baselyr"),
20
21 COOKIE_mapid("mapid"),
22
23 COOKIE_X("x"),
24
25 COOKIE_Y("y"),
26
27 COOKIE_S("s");
28
29
30 public final String value;
31
32
33
34
35
36
37
38
39 CookieNamesConstants(final String value) {
40 this.value = value;
41 }
42
43
44
45
46
47
48
49
50 @Override
51 public String toString() {
52 return this.value;
53 }
54
55
56
57
58
59
60
61 public static String asJavaScript() {
62 final StringBuilder sb = new StringBuilder(
63 "/* <![CDATA[ */ var COOKIE = {};");
64 for (final CookieNamesConstants cconst : CookieNamesConstants.values()) {
65 sb.append(cconst.name().replace('_', '.'));
66 sb.append("='");
67 sb.append(cconst.value);
68 sb.append("',");
69 }
70 sb.deleteCharAt(sb.length() - 1);
71 sb.append("; /* ]]> */");
72 return sb.toString();
73 }
74 }