blob: 31741a0fa3c7c31f6fa4ee5d25f77cfc76de2039 [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;
Nils Diewald4e9fbcb2014-07-15 11:45:09 +000026 var c_start = c_value.indexOf(" " + pc + "=");
27 if (c_start == -1)
28 c_start = c_value.indexOf(pc + "=");
29
30 if (c_start == -1) {
31 c_value = '/tutorial?embedded=1';
32 }
33 else {
34 c_start = c_value.indexOf("=", c_start) + 1;
35 var c_end = c_value.indexOf(";", c_start);
36
37 if (c_end == -1)
38 c_end = c_value.length;
39
40 c_value = unescape(c_value.substring(c_start,c_end));
41 };
Nils Diewald4e9fbcb2014-07-15 11:45:09 +000042 return c_value;
43};