Nils Diewald | 4e9fbcb | 2014-07-15 11:45:09 +0000 | [diff] [blame] | 1 | function 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 | |
| 23 | function getTutorialPage() { |
| 24 | var pc = 'tutorial_page'; |
| 25 | var c_value = document.cookie; |
Nils Diewald | 4e9fbcb | 2014-07-15 11:45:09 +0000 | [diff] [blame] | 26 | 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) { |
Nils Diewald | 3d87184 | 2015-03-10 23:14:34 +0000 | [diff] [blame] | 31 | if (document.location.pathname.indexOf('kalamar') >= 0) { |
| 32 | c_value = '/kalamar/tutorial?embedded=1'; |
| 33 | } |
| 34 | else { |
| 35 | c_value = '/tutorial?embedded=1'; |
| 36 | }; |
Nils Diewald | 4e9fbcb | 2014-07-15 11:45:09 +0000 | [diff] [blame] | 37 | } |
| 38 | else { |
| 39 | c_start = c_value.indexOf("=", c_start) + 1; |
| 40 | var c_end = c_value.indexOf(";", c_start); |
| 41 | |
| 42 | if (c_end == -1) |
| 43 | c_end = c_value.length; |
| 44 | |
| 45 | c_value = unescape(c_value.substring(c_start,c_end)); |
| 46 | }; |
Nils Diewald | 4e9fbcb | 2014-07-15 11:45:09 +0000 | [diff] [blame] | 47 | return c_value; |
| 48 | }; |