blob: 0ae1b1dbd73615c0d822faacbb705ad38ef3851f [file] [log] [blame]
Nils Diewald4e9fbcb2014-07-15 11:45:09 +00001function setTutorialPage(obj) {
2 var page = obj;
3 if (typeof page != 'string') {
4 page = window.location.pathname + window.location.search;
5 for (i = 1; i < 5; i++) {
6 if (obj.nodeName === 'SECTION') {
7 if (obj.hasAttribute('id'))
8 page += '#' + obj.getAttribute('id');
9 break;
10 }
11 else if (obj.nodeName === 'PRE' && obj.hasAttribute('id')) {
12 page += '#' + obj.getAttribute('id');
13 break;
14 }
15 else {
16 obj = obj.parentNode;
17 };
18 };
19 };
20 document.cookie = 'tutorial_page=' + page + '; path=/';
21};
22
23function getTutorialPage() {
24 var pc = 'tutorial_page';
25 var c_value = document.cookie;
26 console.log("Found cookie " + c_value);
27
28 var c_start = c_value.indexOf(" " + pc + "=");
29 if (c_start == -1)
30 c_start = c_value.indexOf(pc + "=");
31
32 if (c_start == -1) {
33 c_value = '/tutorial?embedded=1';
34 }
35 else {
36 c_start = c_value.indexOf("=", c_start) + 1;
37 var c_end = c_value.indexOf(";", c_start);
38
39 if (c_end == -1)
40 c_end = c_value.length;
41
42 c_value = unescape(c_value.substring(c_start,c_end));
43 };
44console.log("got tutpage " + c_value);
45 return c_value;
46};