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) { |
| 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 Diewald | 4e9fbcb | 2014-07-15 11:45:09 +0000 | [diff] [blame] | 42 | return c_value; |
| 43 | }; |