Look ma, no CDNs.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3699 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2021-12-22 14:27:52 +00:00
parent ba87f9acaa
commit f760d48368
18 changed files with 59 additions and 22 deletions

View File

@ -77,22 +77,22 @@ function edit() {
}
ensureLoaded([
{tagName: "script", attributes: {src: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.57.0/codemirror.min.js"}},
{tagName: "link", attributes: {rel: "stylesheet", href: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.57.0/theme/base16-dark.min.css"}},
{tagName: "link", attributes: {rel: "stylesheet", href: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.57.0/addon/search/matchesonscrollbar.min.css"}},
{tagName: "link", attributes: {rel: "stylesheet", href: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.57.0/addon/dialog/dialog.min.css"}},
{tagName: "link", attributes: {rel: "stylesheet", href: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.57.0/codemirror.min.css"}},
{tagName: "script", attributes: {src: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.57.0/addon/edit/trailingspace.min.js"}},
{tagName: "script", attributes: {src: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.57.0/addon/dialog/dialog.min.js"}},
{tagName: "script", attributes: {src: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.57.0/addon/search/search.min.js"}},
{tagName: "script", attributes: {src: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.57.0/addon/search/searchcursor.min.js"}},
{tagName: "script", attributes: {src: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.57.0/addon/search/jump-to-line.min.js"}},
{tagName: "script", attributes: {src: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.57.0/addon/search/matchesonscrollbar.min.js"}},
{tagName: "script", attributes: {src: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.57.0/addon/scroll/annotatescrollbar.min.js"}},
{tagName: "script", attributes: {src: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.57.0/mode/javascript/javascript.min.js"}},
{tagName: "script", attributes: {src: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.57.0/mode/css/css.min.js"}},
{tagName: "script", attributes: {src: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.57.0/mode/xml/xml.min.js"}},
{tagName: "script", attributes: {src: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.57.0/mode/htmlmixed/htmlmixed.min.js"}},
{tagName: "script", attributes: {src: "/static/codemirror/codemirror.min.js"}},
{tagName: "link", attributes: {rel: "stylesheet", href: "/static/codemirror/base16-dark.min.css"}},
{tagName: "link", attributes: {rel: "stylesheet", href: "/static/codemirror/matchesonscrollbar.min.css"}},
{tagName: "link", attributes: {rel: "stylesheet", href: "/static/codemirror/dialog.min.css"}},
{tagName: "link", attributes: {rel: "stylesheet", href: "/static/codemirror/codemirror.min.css"}},
{tagName: "script", attributes: {src: "/static/codemirror/trailingspace.min.js"}},
{tagName: "script", attributes: {src: "/static/codemirror/dialog.min.js"}},
{tagName: "script", attributes: {src: "/static/codemirror/search.min.js"}},
{tagName: "script", attributes: {src: "/static/codemirror/searchcursor.min.js"}},
{tagName: "script", attributes: {src: "/static/codemirror/jump-to-line.min.js"}},
{tagName: "script", attributes: {src: "/static/codemirror/matchesonscrollbar.min.js"}},
{tagName: "script", attributes: {src: "/static/codemirror/annotatescrollbar.min.js"}},
{tagName: "script", attributes: {src: "/static/codemirror/javascript.min.js"}},
{tagName: "script", attributes: {src: "/static/codemirror/css.min.js"}},
{tagName: "script", attributes: {src: "/static/codemirror/xml.min.js"}},
{tagName: "script", attributes: {src: "/static/codemirror/htmlmixed.min.js"}},
], function() {
load();
});

View File

@ -0,0 +1 @@
!function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],t):t(CodeMirror)}(function(t){"use strict";function e(t,e){function i(t){clearTimeout(n.doRedraw),n.doRedraw=setTimeout(function(){n.redraw()},t)}this.cm=t,this.options=e,this.buttonHeight=e.scrollButtonHeight||t.getOption("scrollButtonHeight"),this.annotations=[],this.doRedraw=this.doUpdate=null,this.div=t.getWrapperElement().appendChild(document.createElement("div")),this.div.style.cssText="position: absolute; right: 0; top: 0; z-index: 7; pointer-events: none",this.computeScale();var n=this;t.on("refresh",this.resizeHandler=function(){clearTimeout(n.doUpdate),n.doUpdate=setTimeout(function(){n.computeScale()&&i(20)},100)}),t.on("markerAdded",this.resizeHandler),t.on("markerCleared",this.resizeHandler),!1!==e.listenForChanges&&t.on("changes",this.changeHandler=function(){i(250)})}t.defineExtension("annotateScrollbar",function(t){return"string"==typeof t&&(t={className:t}),new e(this,t)}),t.defineOption("scrollButtonHeight",0),e.prototype.computeScale=function(){var t=this.cm,e=(t.getWrapperElement().clientHeight-t.display.barHeight-2*this.buttonHeight)/t.getScrollerElement().scrollHeight;if(e!=this.hScale)return this.hScale=e,!0},e.prototype.update=function(t){this.annotations=t,this.redraw()},e.prototype.redraw=function(t){!1!==t&&this.computeScale();var n=this.cm,e=this.hScale,i=document.createDocumentFragment(),o=this.annotations,r=n.getOption("lineWrapping"),a=r&&1.5*n.defaultTextHeight(),s=null,h=null;function l(t,e){var i;return s!=t.line&&(s=t.line,h=n.getLineHandle(t.line),(i=n.getLineHandleVisualStart(h))!=h&&(s=n.getLineNumber(i),h=i)),h.widgets&&h.widgets.length||r&&h.height>a?n.charCoords(t,"local")[e?"top":"bottom"]:n.heightAtLine(h,"local")+(e?0:h.height)}var d=n.lastLine();if(n.display.barWidth)for(var c,p=0;p<o.length;p++){var u=o[p];if(!(u.to.line>d)){for(var m,f,g=c||l(u.from,!0)*e,H=l(u.to,!1)*e;p<o.length-1&&!(o[p+1].to.line>d)&&!(H+.9<(c=l(o[p+1].from,!0)*e));)H=l((u=o[++p]).to,!1)*e;H!=g&&(m=Math.max(H-g,3),(f=i.appendChild(document.createElement("div"))).style.cssText="position: absolute; right: 0px; width: "+Math.max(n.display.barWidth-1,2)+"px; top: "+(g+this.buttonHeight)+"px; height: "+m+"px",f.className=this.options.className,u.id&&f.setAttribute("annotation-id",u.id))}}this.div.textContent="",this.div.appendChild(i)},e.prototype.clear=function(){this.cm.off("refresh",this.resizeHandler),this.cm.off("markerAdded",this.resizeHandler),this.cm.off("markerCleared",this.resizeHandler),this.changeHandler&&this.cm.off("changes",this.changeHandler),this.div.parentNode.removeChild(this.div)}});

1
core/codemirror/base16-dark.min.css vendored Normal file
View File

@ -0,0 +1 @@
.cm-s-base16-dark.CodeMirror{background:#151515;color:#e0e0e0}.cm-s-base16-dark div.CodeMirror-selected{background:#303030}.cm-s-base16-dark .CodeMirror-line::selection,.cm-s-base16-dark .CodeMirror-line>span::selection,.cm-s-base16-dark .CodeMirror-line>span>span::selection{background:rgba(48,48,48,.99)}.cm-s-base16-dark .CodeMirror-line::-moz-selection,.cm-s-base16-dark .CodeMirror-line>span::-moz-selection,.cm-s-base16-dark .CodeMirror-line>span>span::-moz-selection{background:rgba(48,48,48,.99)}.cm-s-base16-dark .CodeMirror-gutters{background:#151515;border-right:0}.cm-s-base16-dark .CodeMirror-guttermarker{color:#ac4142}.cm-s-base16-dark .CodeMirror-guttermarker-subtle{color:#505050}.cm-s-base16-dark .CodeMirror-linenumber{color:#505050}.cm-s-base16-dark .CodeMirror-cursor{border-left:1px solid #b0b0b0}.cm-s-base16-dark span.cm-comment{color:#8f5536}.cm-s-base16-dark span.cm-atom{color:#aa759f}.cm-s-base16-dark span.cm-number{color:#aa759f}.cm-s-base16-dark span.cm-attribute,.cm-s-base16-dark span.cm-property{color:#90a959}.cm-s-base16-dark span.cm-keyword{color:#ac4142}.cm-s-base16-dark span.cm-string{color:#f4bf75}.cm-s-base16-dark span.cm-variable{color:#90a959}.cm-s-base16-dark span.cm-variable-2{color:#6a9fb5}.cm-s-base16-dark span.cm-def{color:#d28445}.cm-s-base16-dark span.cm-bracket{color:#e0e0e0}.cm-s-base16-dark span.cm-tag{color:#ac4142}.cm-s-base16-dark span.cm-link{color:#aa759f}.cm-s-base16-dark span.cm-error{background:#ac4142;color:#b0b0b0}.cm-s-base16-dark .CodeMirror-activeline-background{background:#202020}.cm-s-base16-dark .CodeMirror-matchingbracket{text-decoration:underline;color:#fff!important}

1
core/codemirror/codemirror.min.css vendored Normal file

File diff suppressed because one or more lines are too long

1
core/codemirror/codemirror.min.js vendored Normal file

File diff suppressed because one or more lines are too long

1
core/codemirror/css.min.js vendored Normal file

File diff suppressed because one or more lines are too long

1
core/codemirror/dialog.min.css vendored Normal file
View File

@ -0,0 +1 @@
.CodeMirror-dialog{position:absolute;left:0;right:0;background:inherit;z-index:15;padding:.1em .8em;overflow:hidden;color:inherit}.CodeMirror-dialog-top{border-bottom:1px solid #eee;top:0}.CodeMirror-dialog-bottom{border-top:1px solid #eee;bottom:0}.CodeMirror-dialog input{border:none;outline:0;background:0 0;width:20em;color:inherit;font-family:monospace}.CodeMirror-dialog button{font-size:70%}

1
core/codemirror/dialog.min.js vendored Normal file
View File

@ -0,0 +1 @@
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(s){function f(e,o,n){var t=e.getWrapperElement(),i=t.appendChild(document.createElement("div"));return i.className=n?"CodeMirror-dialog CodeMirror-dialog-bottom":"CodeMirror-dialog CodeMirror-dialog-top","string"==typeof o?i.innerHTML=o:i.appendChild(o),s.addClass(t,"dialog-opened"),i}function p(e,o){e.state.currentNotificationClose&&e.state.currentNotificationClose(),e.state.currentNotificationClose=o}s.defineExtension("openDialog",function(e,o,n){n=n||{},p(this,null);var t=f(this,e,n.bottom),i=!1,r=this;function u(e){if("string"==typeof e)a.value=e;else{if(i)return;i=!0,s.rmClass(t.parentNode,"dialog-opened"),t.parentNode.removeChild(t),r.focus(),n.onClose&&n.onClose(t)}}var l,a=t.getElementsByTagName("input")[0];return a?(a.focus(),n.value&&(a.value=n.value,!1!==n.selectValueOnOpen&&a.select()),n.onInput&&s.on(a,"input",function(e){n.onInput(e,a.value,u)}),n.onKeyUp&&s.on(a,"keyup",function(e){n.onKeyUp(e,a.value,u)}),s.on(a,"keydown",function(e){n&&n.onKeyDown&&n.onKeyDown(e,a.value,u)||((27==e.keyCode||!1!==n.closeOnEnter&&13==e.keyCode)&&(a.blur(),s.e_stop(e),u()),13==e.keyCode&&o(a.value,e))}),!1!==n.closeOnBlur&&s.on(t,"focusout",function(e){null!==e.relatedTarget&&u()})):(l=t.getElementsByTagName("button")[0])&&(s.on(l,"click",function(){u(),r.focus()}),!1!==n.closeOnBlur&&s.on(l,"blur",u),l.focus()),u}),s.defineExtension("openConfirm",function(e,o,n){p(this,null);var t=f(this,e,n&&n.bottom),i=t.getElementsByTagName("button"),r=!1,u=this,l=1;function a(){r||(r=!0,s.rmClass(t.parentNode,"dialog-opened"),t.parentNode.removeChild(t),u.focus())}i[0].focus();for(var c=0;c<i.length;++c){var d=i[c];!function(o){s.on(d,"click",function(e){s.e_preventDefault(e),a(),o&&o(u)})}(o[c]),s.on(d,"blur",function(){--l,setTimeout(function(){l<=0&&a()},200)}),s.on(d,"focus",function(){++l})}}),s.defineExtension("openNotification",function(e,o){p(this,u);var n,t=f(this,e,o&&o.bottom),i=!1,r=o&&void 0!==o.duration?o.duration:5e3;function u(){i||(i=!0,clearTimeout(n),s.rmClass(t.parentNode,"dialog-opened"),t.parentNode.removeChild(t))}return s.on(t,"click",function(e){s.e_preventDefault(e),u()}),r&&(n=setTimeout(u,r)),u})});

1
core/codemirror/htmlmixed.min.js vendored Normal file
View File

@ -0,0 +1 @@
!function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror"),require("../xml/xml"),require("../javascript/javascript"),require("../css/css")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../xml/xml","../javascript/javascript","../css/css"],t):t(CodeMirror)}(function(f){"use strict";var l={script:[["lang",/(javascript|babel)/i,"javascript"],["type",/^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i,"javascript"],["type",/./,"text/plain"],[null,null,"javascript"]],style:[["lang",/^css$/i,"css"],["type",/^(text\/)?(x-)?(stylesheet|css)$/i,"css"],["type",/./,"text/plain"],[null,null,"css"]]};var o={};function g(t,e){var a,n=t.match(o[a=e]||(o[a]=new RegExp("\\s+"+a+"\\s*=\\s*('|\")?([^'\"]+)('|\")?\\s*")));return n?/^\s*(.*?)\s*$/.exec(n[2])[1]:""}function h(t,e){return new RegExp((e?"^":"")+"</s*"+t+"s*>","i")}function r(t,e){for(var a in t)for(var n=e[a]||(e[a]=[]),l=t[a],o=l.length-1;0<=o;o--)n.unshift(l[o])}f.defineMode("htmlmixed",function(u,t){var m=f.getMode(u,{name:"xml",htmlMode:!0,multilineTagIndentFactor:t.multilineTagIndentFactor,multilineTagIndentPastTag:t.multilineTagIndentPastTag}),d={},e=t&&t.tags,a=t&&t.scriptTypes;if(r(l,d),e&&r(e,d),a)for(var n=a.length-1;0<=n;n--)d.script.unshift(["type",a[n].matches,a[n].mode]);function p(t,e){var a,n,l,o,c,i,r=m.token(t,e.htmlState),s=/\btag\b/.test(r);return s&&!/[<>\s\/]/.test(t.current())&&(a=e.htmlState.tagName&&e.htmlState.tagName.toLowerCase())&&d.hasOwnProperty(a)?e.inTag=a+" ":e.inTag&&s&&/>$/.test(t.current())?(n=/^([\S]+) (.*)/.exec(e.inTag),e.inTag=null,l=">"==t.current()&&function(t,e){for(var a=0;a<t.length;a++){var n=t[a];if(!n[0]||n[1].test(g(e,n[0])))return n[2]}}(d[n[1]],n[2]),o=f.getMode(u,l),c=h(n[1],!0),i=h(n[1],!1),e.token=function(t,e){return t.match(c,!1)?(e.token=p,e.localState=e.localMode=null,null):(a=t,n=i,l=e.localMode.token(t,e.localState),o=a.current(),-1<(r=o.search(n))?a.backUp(o.length-r):o.match(/<\/?$/)&&(a.backUp(o.length),a.match(n,!1)||a.match(o)),l);var a,n,l,o,r},e.localMode=o,e.localState=f.startState(o,m.indent(e.htmlState,"",""))):e.inTag&&(e.inTag+=t.current(),t.eol()&&(e.inTag+=" ")),r}return{startState:function(){return{token:p,inTag:null,localMode:null,localState:null,htmlState:f.startState(m)}},copyState:function(t){var e;return t.localState&&(e=f.copyState(t.localMode,t.localState)),{token:t.token,inTag:t.inTag,localMode:t.localMode,localState:e,htmlState:f.copyState(m,t.htmlState)}},token:function(t,e){return e.token(t,e)},indent:function(t,e,a){return!t.localMode||/^\s*<\//.test(e)?m.indent(t.htmlState,e,a):t.localMode.indent?t.localMode.indent(t.localState,e,a):f.Pass},innerMode:function(t){return{state:t.localState||t.htmlState,mode:t.localMode||m}}}},"xml","javascript","css"),f.defineMIME("text/html","htmlmixed")});

1
core/codemirror/javascript.min.js vendored Normal file

File diff suppressed because one or more lines are too long

1
core/codemirror/jump-to-line.min.js vendored Normal file
View File

@ -0,0 +1 @@
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("../dialog/dialog")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../dialog/dialog"],e):e(CodeMirror)}(function(e){"use strict";function u(e,o){var r=Number(o);return/^[-+]/.test(o)?e.getCursor().line+r:r-1}e.commands.jumpToLine=function(t){var e,o,r,s,i,n,l=t.getCursor();o=(n=e=t).phrase("Jump to line:")+' <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">'+n.phrase("(Use line:column or scroll% syntax)")+"</span>",r=t.phrase("Jump to line:"),s=l.line+1+":"+l.ch,i=function(e){var o,r;e&&((o=/^\s*([\+\-]?\d+)\s*\:\s*(\d+)\s*$/.exec(e))?t.setCursor(u(t,o[1]),Number(o[2])):(o=/^\s*([\+\-]?\d+(\.\d+)?)\%\s*/.exec(e))?(r=Math.round(t.lineCount()*Number(o[1])/100),/^[-+]/.test(o[1])&&(r=l.line+r+1),t.setCursor(r-1,l.ch)):(o=/^\s*\:?\s*([\+\-]?\d+)\s*/.exec(e))&&t.setCursor(u(t,o[1]),l.ch))},e.openDialog?e.openDialog(o,i,{value:s,selectValueOnOpen:!0}):i(prompt(r,s))},e.keyMap.default["Alt-G"]="jumpToLine"});

View File

@ -0,0 +1 @@
.CodeMirror-search-match{background:gold;border-top:1px solid orange;border-bottom:1px solid orange;-moz-box-sizing:border-box;box-sizing:border-box;opacity:.5}

View File

@ -0,0 +1 @@
!function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror"),require("./searchcursor"),require("../scroll/annotatescrollbar")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","./searchcursor","../scroll/annotatescrollbar"],t):t(CodeMirror)}(function(c){"use strict";function o(t,e,i,o){this.cm=t,this.options=o;var a={listenForChanges:!1};for(var n in o)a[n]=o[n];a.className||(a.className="CodeMirror-search-match"),this.annotation=t.annotateScrollbar(a),this.query=e,this.caseFold=i,this.gap={from:t.firstLine(),to:t.lastLine()+1},this.matches=[],this.update=null,this.findMatches(),this.annotation.update(this.matches);var s=this;t.on("change",this.changeHandler=function(t,e){s.onChange(e)})}c.defineExtension("showMatchesOnScrollbar",function(t,e,i){return"string"==typeof i&&(i={className:i}),new o(this,t,e,i=i||{})});function f(t,e,i){return t<=e?t:Math.max(e,t+i)}o.prototype.findMatches=function(){if(this.gap){for(var t=0;t<this.matches.length;t++){if((e=this.matches[t]).from.line>=this.gap.to)break;e.to.line>=this.gap.from&&this.matches.splice(t--,1)}for(var e,i=this.cm.getSearchCursor(this.query,c.Pos(this.gap.from,0),{caseFold:this.caseFold,multiline:this.options.multiline}),o=this.options&&this.options.maxMatches||1e3;i.findNext();){if((e={from:i.from(),to:i.to()}).from.line>=this.gap.to)break;if(this.matches.splice(t++,0,e),this.matches.length>o)break}this.gap=null}},o.prototype.onChange=function(t){var e=t.from.line,i=c.changeEnd(t).line,o=i-t.to.line;if(this.gap?(this.gap.from=Math.min(f(this.gap.from,e,o),t.from.line),this.gap.to=Math.max(f(this.gap.to,e,o),t.from.line)):this.gap={from:t.from.line,to:i+1},o)for(var a=0;a<this.matches.length;a++){var n=this.matches[a],s=f(n.from.line,e,o);s!=n.from.line&&(n.from=c.Pos(s,n.from.ch));var r=f(n.to.line,e,o);r!=n.to.line&&(n.to=c.Pos(r,n.to.ch))}clearTimeout(this.update);var h=this;this.update=setTimeout(function(){h.updateAfterChange()},250)},o.prototype.updateAfterChange=function(){this.findMatches(),this.annotation.update(this.matches)},o.prototype.clear=function(){this.cm.off("change",this.changeHandler),this.annotation.clear()}});

1
core/codemirror/search.min.js vendored Normal file

File diff suppressed because one or more lines are too long

1
core/codemirror/searchcursor.min.js vendored Normal file

File diff suppressed because one or more lines are too long

1
core/codemirror/trailingspace.min.js vendored Normal file
View File

@ -0,0 +1 @@
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(o){o.defineOption("showTrailingSpace",!1,function(e,i,n){n==o.Init&&(n=!1),n&&!i?e.removeOverlay("trailingspace"):!n&&i&&e.addOverlay({token:function(e){for(var i=e.string.length,n=i;n&&/\s/.test(e.string.charAt(n-1));--n);return n>e.pos?(e.pos=n,null):(e.pos=i,"trailingspace")},name:"trailingspace"})})});

1
core/codemirror/xml.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -280,10 +280,27 @@ function setGlobalSettings(settings) {
var kStaticFiles = [
{uri: '/', path: 'index.html', type: 'text/html; charset=UTF-8'},
{uri: '/style.css', path: 'style.css', type: 'text/css; charset=UTF-8'},
{uri: '/favicon.png', path: 'favicon.png', type: 'image/png'},
{uri: '/client.js', path: 'client.js', type: 'text/javascript; charset=UTF-8'},
{uri: '/robots.txt', path: 'robots.txt', type: 'text/plain; charset=UTF-8'},
{uri: '/style.css', type: 'text/css; charset=UTF-8'},
{uri: '/favicon.png', type: 'image/png'},
{uri: '/client.js', type: 'text/javascript; charset=UTF-8'},
{uri: '/robots.txt', type: 'text/plain; charset=UTF-8'},
{uri: '/codemirror/codemirror.min.js'},
{uri: '/codemirror/base16-dark.min.css'},
{uri: '/codemirror/matchesonscrollbar.min.css'},
{uri: '/codemirror/dialog.min.css'},
{uri: '/codemirror/codemirror.min.css'},
{uri: '/codemirror/trailingspace.min.js'},
{uri: '/codemirror/dialog.min.js'},
{uri: '/codemirror/search.min.js'},
{uri: '/codemirror/searchcursor.min.js'},
{uri: '/codemirror/jump-to-line.min.js'},
{uri: '/codemirror/matchesonscrollbar.min.js'},
{uri: '/codemirror/annotatescrollbar.min.js'},
{uri: '/codemirror/javascript.min.js'},
{uri: '/codemirror/css.min.js'},
{uri: '/codemirror/xml.min.js'},
{uri: '/codemirror/htmlmixed.min.js'},
];
function startsWithBytes(data, bytes) {
@ -301,8 +318,10 @@ function startsWithBytes(data, bytes) {
async function staticFileHandler(request, response, blobId, uri) {
for (var i in kStaticFiles) {
if (uri === kStaticFiles[i].uri) {
var data = await File.readFile("core/" + kStaticFiles[i].path);
response.writeHead(200, {"Content-Type": kStaticFiles[i].type, "Content-Length": data.byteLength});
var path = kStaticFiles[i].path || uri.substring(1);
var type = kStaticFiles[i].type || guessType(path);
var data = await File.readFile("core/" + path);
response.writeHead(200, {"Content-Type": type, "Content-Length": data.byteLength});
response.end(data);
return;
}
@ -374,6 +393,8 @@ async function getBlobOrContent(id) {
function guessType(path) {
const k_extension_to_type = {
'css': 'text/css',
'html': 'text/html',
'js': 'text/javascript',
};
var extension = path.split('.').pop();
return k_extension_to_type[extension];