mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
update components
This commit is contained in:
parent
2a4b879c21
commit
63664e6c1c
1155 changed files with 62261 additions and 84 deletions
76
dashboard-ui/bower_components/prism/plugins/file-highlight/prism-file-highlight.js
vendored
Normal file
76
dashboard-ui/bower_components/prism/plugins/file-highlight/prism-file-highlight.js
vendored
Normal file
|
@ -0,0 +1,76 @@
|
|||
(function () {
|
||||
if (typeof self === 'undefined' || !self.Prism || !self.document || !document.querySelector) {
|
||||
return;
|
||||
}
|
||||
|
||||
self.Prism.fileHighlight = function() {
|
||||
|
||||
var Extensions = {
|
||||
'js': 'javascript',
|
||||
'html': 'markup',
|
||||
'svg': 'markup',
|
||||
'xml': 'markup',
|
||||
'py': 'python',
|
||||
'rb': 'ruby',
|
||||
'ps1': 'powershell',
|
||||
'psm1': 'powershell'
|
||||
};
|
||||
|
||||
if(Array.prototype.forEach) { // Check to prevent error in IE8
|
||||
Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {
|
||||
var src = pre.getAttribute('data-src');
|
||||
|
||||
var language, parent = pre;
|
||||
var lang = /\blang(?:uage)?-(?!\*)(\w+)\b/i;
|
||||
while (parent && !lang.test(parent.className)) {
|
||||
parent = parent.parentNode;
|
||||
}
|
||||
|
||||
if (parent) {
|
||||
language = (pre.className.match(lang) || [, ''])[1];
|
||||
}
|
||||
|
||||
if (!language) {
|
||||
var extension = (src.match(/\.(\w+)$/) || [, ''])[1];
|
||||
language = Extensions[extension] || extension;
|
||||
}
|
||||
|
||||
var code = document.createElement('code');
|
||||
code.className = 'language-' + language;
|
||||
|
||||
pre.textContent = '';
|
||||
|
||||
code.textContent = 'Loading…';
|
||||
|
||||
pre.appendChild(code);
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
|
||||
xhr.open('GET', src, true);
|
||||
|
||||
xhr.onreadystatechange = function () {
|
||||
if (xhr.readyState == 4) {
|
||||
|
||||
if (xhr.status < 400 && xhr.responseText) {
|
||||
code.textContent = xhr.responseText;
|
||||
|
||||
Prism.highlightElement(code);
|
||||
}
|
||||
else if (xhr.status >= 400) {
|
||||
code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;
|
||||
}
|
||||
else {
|
||||
code.textContent = '✖ Error: File does not exist or is empty';
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
xhr.send(null);
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
self.Prism.fileHighlight();
|
||||
|
||||
})();
|
Loading…
Add table
Add a link
Reference in a new issue