2018-11-21 16:53:33 +00:00
|
|
|
"use strict";
|
|
|
|
|
2019-10-26 01:55:50 +00:00
|
|
|
import { PLATFORMS } from "../common/emu";
|
|
|
|
import { Platform } from "../common/baseplatform";
|
2018-11-21 16:53:33 +00:00
|
|
|
|
|
|
|
class MarkdownPlatform implements Platform {
|
2020-07-10 20:19:01 +00:00
|
|
|
mainElement : HTMLElement;
|
|
|
|
iframe : HTMLIFrameElement;
|
2018-11-21 16:53:33 +00:00
|
|
|
|
|
|
|
constructor(mainElement:HTMLElement) {
|
|
|
|
this.mainElement = mainElement;
|
2020-07-10 20:19:01 +00:00
|
|
|
this.iframe = $('<iframe sandbox seamless src="javascript:void(0);" width="100%" height="100%"/>').appendTo(mainElement)[0] as HTMLIFrameElement;
|
|
|
|
//this.iframe = $('<iframe sandbox src="res/markdown-iframe.html" width="100%" height="100%"/>').appendTo(mainElement)[0] as HTMLIFrameElement;
|
|
|
|
this.iframe.style.backgroundColor = 'white';
|
|
|
|
mainElement.classList.add("vertical-scroll"); //100% height
|
|
|
|
mainElement.style.overflowY = 'auto';
|
2018-11-21 16:53:33 +00:00
|
|
|
}
|
|
|
|
start() {
|
|
|
|
}
|
|
|
|
reset() {
|
|
|
|
}
|
|
|
|
pause() {
|
|
|
|
}
|
|
|
|
resume() {
|
|
|
|
}
|
2020-07-10 20:19:01 +00:00
|
|
|
loadROM(title, data:string) {
|
|
|
|
// have to do this b/c sandboxed without same origin
|
|
|
|
// TODO: preserve scroll position
|
|
|
|
if (this.iframe.srcdoc)
|
|
|
|
this.iframe.srcdoc = data;
|
|
|
|
else
|
|
|
|
this.iframe.src = "data:text/html;charset=utf-8," + escape(data);
|
|
|
|
//this.iframe.contentWindow.postMessage({body:data}, "*");
|
|
|
|
//$(this.iframe).contents().find('body').html(data);
|
2018-11-21 16:53:33 +00:00
|
|
|
}
|
|
|
|
isRunning() {
|
|
|
|
return false;
|
|
|
|
}
|
2018-11-22 12:39:06 +00:00
|
|
|
isDebugging() : boolean {
|
|
|
|
return false;
|
|
|
|
}
|
2018-11-21 16:53:33 +00:00
|
|
|
getToolForFilename(fn : string) : string {
|
|
|
|
return "markdown";
|
|
|
|
}
|
|
|
|
getDefaultExtension() : string {
|
|
|
|
return ".md";
|
|
|
|
}
|
|
|
|
getPresets() {
|
|
|
|
return [
|
|
|
|
{id:'hello.md', name:'Hello'},
|
|
|
|
];
|
|
|
|
}
|
2018-11-22 16:22:54 +00:00
|
|
|
showHelp() {
|
|
|
|
window.open("https://github.com/showdownjs/showdown/wiki/Showdown's-Markdown-syntax", "_help");
|
|
|
|
}
|
2018-11-21 16:53:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PLATFORMS['markdown'] = MarkdownPlatform;
|