Index: polymer_1.0.4/bower_components/prism/plugins/file-highlight/prism-file-highlight.js |
diff --git a/polymer_1.0.4/bower_components/prism/plugins/file-highlight/prism-file-highlight.js b/polymer_1.0.4/bower_components/prism/plugins/file-highlight/prism-file-highlight.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c81dd01af1219ec135344532592ae40abfe0d6b6 |
--- /dev/null |
+++ b/polymer_1.0.4/bower_components/prism/plugins/file-highlight/prism-file-highlight.js |
@@ -0,0 +1,61 @@ |
+(function () { |
+ if (!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' |
+ }; |
+ |
+ Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function(pre) { |
+ var src = pre.getAttribute('data-src'); |
+ var extension = (src.match(/\.(\w+)$/) || [,''])[1]; |
+ var 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(); |
+ |
+})(); |