|
4 | 4 | var CMD_RX = /^\$ (\S[^\\\n]*(\\\n(?!\$ )[^\\\n]*)*)(?=\n|$)/gm |
5 | 5 | var LINE_CONTINUATION_RX = /( ) *\\\n *|\\\n( ?) */g |
6 | 6 | var TRAILING_SPACE_RX = / +$/gm |
| 7 | + |
7 | 8 | var config = (document.getElementById('site-script') || { dataset: {} }).dataset |
| 9 | + var supportsCopy = window.navigator.clipboard |
| 10 | + var svgAs = config.svgAs |
| 11 | + var uiRootPath = (config.uiRootPath == null ? window.uiRootPath : config.uiRootPath) || '.' |
8 | 12 |
|
9 | 13 | ;[].slice.call(document.querySelectorAll('.doc pre.highlight, .doc .literalblock pre')).forEach(function (pre) { |
10 | 14 | var code, language, lang, copy, toast, toolbox |
|
28 | 32 | } |
29 | 33 | ;(toolbox = document.createElement('div')).className = 'source-toolbox' |
30 | 34 | if (lang) toolbox.appendChild(lang) |
31 | | - if (window.navigator.clipboard) { |
| 35 | + if (supportsCopy) { |
32 | 36 | ;(copy = document.createElement('button')).className = 'copy-button' |
33 | 37 | copy.setAttribute('title', 'Copy to clipboard') |
34 | | - if (config.svgAs === 'svg') { |
| 38 | + if (svgAs === 'svg') { |
35 | 39 | var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg') |
36 | 40 | svg.setAttribute('class', 'copy-icon') |
37 | 41 | var use = document.createElementNS('http://www.w3.org/2000/svg', 'use') |
38 | | - use.setAttribute('href', window.uiRootPath + '/img/octicons-16.svg#icon-clippy') |
| 42 | + use.setAttribute('href', uiRootPath + '/img/octicons-16.svg#icon-clippy') |
39 | 43 | svg.appendChild(use) |
40 | 44 | copy.appendChild(svg) |
41 | 45 | } else { |
42 | 46 | var img = document.createElement('img') |
43 | | - img.src = window.uiRootPath + '/img/octicons-16.svg#view-clippy' |
| 47 | + img.src = uiRootPath + '/img/octicons-16.svg#view-clippy' |
44 | 48 | img.alt = 'copy icon' |
45 | 49 | img.className = 'copy-icon' |
46 | 50 | copy.appendChild(img) |
|
0 commit comments