fiddle.html 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <!doctype html>
  2. <html lang="en-us">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  6. <title>pikchr fiddle</title>
  7. <link rel="shortcut icon" href="data:image/x-icon;," type="image/x-icon">
  8. <link rel="stylesheet" href="emscripten.css"/>
  9. <style>
  10. /* The following styles are for app-level use. */
  11. textarea {
  12. font-family: monospace;
  13. flex: 1 1 auto;
  14. }
  15. header {
  16. font-size: 130%;
  17. font-weight: bold;
  18. }
  19. #main-wrapper {
  20. display: flex;
  21. flex-direction: column-reverse;
  22. flex: 1 1 auto;
  23. }
  24. #main-wrapper.side-by-side {
  25. flex-direction: row-reverse;
  26. }
  27. #main-wrapper.swapio {
  28. flex-direction: column;
  29. }
  30. #main-wrapper.side-by-side.swapio {
  31. flex-direction: row;
  32. }
  33. .zone-wrapper{
  34. display: flex;
  35. flex-direction: column;
  36. align-items: stretch;
  37. margin: 0 0.25em;
  38. flex: 1 1 auto;
  39. }
  40. .zone-wrapper.output {
  41. }
  42. #pikchr-output {
  43. /*flex: 1 1 auto;*/
  44. /*overflow: auto;*/
  45. padding: 0;
  46. margin: 0;
  47. }
  48. #pikchr-output-wrapper {
  49. flex: 1 1 auto;
  50. overflow: auto;
  51. }
  52. #pikchr-output-wrapper.text {
  53. display: flex;
  54. align-items: stretch;
  55. }
  56. #pikchr-output-wrapper.text > #pikchr-output {
  57. display: flex;
  58. align-items: stretch;
  59. flex: 1 1 auto;
  60. }
  61. #pikchr-output-wrapper.text > #pikchr-output > textarea {
  62. flex: 1 1 auto;
  63. }
  64. .zone-wrapper textarea {
  65. font-size: 110%;
  66. filter: invert(100%);
  67. flex: 10 1 auto;
  68. font-family: monospace;
  69. }
  70. .zone-wrapper.input {
  71. /*min-height: 10em;*/
  72. min-width: 20em;
  73. }
  74. .zone-wrapper.output {
  75. overflow: auto;
  76. justify-content: space-between;
  77. }
  78. .button-bar {
  79. display: flex;
  80. justify-content: center;
  81. flex: 0 1 auto;
  82. flex-wrap: wrap;
  83. }
  84. .button-bar button {
  85. margin: 0.25em 1em;
  86. }
  87. label[for] {
  88. cursor: pointer;
  89. }
  90. .error {
  91. color: red;
  92. background-color: yellow;
  93. }
  94. .hidden, .initially-hidden {
  95. position: absolute !important;
  96. opacity: 0 !important;
  97. pointer-events: none !important;
  98. display: none !important;
  99. }
  100. /* Safari supports neither styling of nor event handling on a
  101. fieldset legend, so we emulate a fieldset-like widget. */
  102. .fieldset {
  103. border-radius: 0.5em;
  104. border: 1px inset;
  105. display: flex;
  106. flex-direction: column;
  107. }
  108. .fieldset > .legend {
  109. position: relative;
  110. top: -1.5ex;
  111. padding: 0 0.5em;
  112. font-size: 85%;
  113. margin-left: 0.5em;
  114. flex: 0 1 auto;
  115. align-self: self-start;
  116. cursor: pointer;
  117. }
  118. .fieldset.options > div {
  119. display: flex;
  120. flex-wrap: wrap;
  121. font-size: 70%;
  122. margin: 0 0.5em 0.5em 0.5em;
  123. }
  124. .fieldset > .legend > span {
  125. position: relative;
  126. }
  127. .fieldset > .legend::before {
  128. /* Hide the parent element's top border where this
  129. element intersects it. */
  130. content: ' ';
  131. width: 100%;
  132. height: 100%;
  133. background-color: white
  134. /* REALLY want to 'inherit' the color from the fieldset's
  135. parent, but inherit leads to a transparent bg, which is
  136. exactly what we're trying to avoid here. */;
  137. opacity: 1;
  138. position: absolute;
  139. top: 0;
  140. left: 0;
  141. }
  142. .fieldset > .legend::after {
  143. content: " [hide]";
  144. position: relative;
  145. }
  146. .fieldset.collapsed > .legend::after {
  147. content: " [show]";
  148. position: relative;
  149. }
  150. span.labeled-input {
  151. padding: 0.25em;
  152. margin: 0.25em 0.5em;
  153. border-radius: 0.25em;
  154. white-space: nowrap;
  155. background: #0002;
  156. }
  157. .center { text-align: center; }
  158. .app-view {
  159. flex: 20 1 auto;
  160. }
  161. #titlebar {
  162. display: flex;
  163. justify-content: space-between;
  164. margin-bottom: 0.5em;
  165. }
  166. #view-split {
  167. display: flex;
  168. flex-direction: column-reverse;
  169. }
  170. #view-split > .fieldset.options {
  171. margin-top: 0.5em;
  172. }
  173. </style>
  174. </head>
  175. <body>
  176. <header id='titlebar'><span>pikchr fiddle</span></header>
  177. <!-- emscripten bits -->
  178. <figure id="module-spinner">
  179. <div class="spinner"></div>
  180. <div class='center'><strong>Initializing app...</strong></div>
  181. <div class='center'>
  182. On a slow internet connection this may take a moment. If this
  183. message displays for "a long time", intialization may have
  184. failed and the JavaScript console may contain clues as to why.
  185. </div>
  186. </figure>
  187. <div class="emscripten" id="module-status">Downloading...</div>
  188. <div class="emscripten">
  189. <progress value="0" max="100" id="module-progress" hidden='1'></progress>
  190. </div><!-- /emscripten bits -->
  191. <div id='view-split' class='app-view initially-hidden'>
  192. <div class='fieldset options collapsible'>
  193. <span class='legend'><span>Options</span></span>
  194. <div>
  195. <span class='labeled-input'>
  196. <input type='checkbox' id='opt-cb-sbs'
  197. data-csstgt='#main-wrapper'
  198. data-cssclass='side-by-side'
  199. data-config='sideBySide'>
  200. <label for='opt-cb-sbs'>Side-by-side</label>
  201. </span>
  202. <span class='labeled-input'>
  203. <input type='checkbox' id='opt-cb-swapio'
  204. data-csstgt='#main-wrapper'
  205. data-cssclass='swapio'
  206. data-config='swapInOut'>
  207. <label for='opt-cb-swapio'>Swap in/out</label>
  208. </span>
  209. <span class='labeled-input'>
  210. <input type='checkbox' id='opt-cb-autoscale'
  211. data-config='renderAutoScale'>
  212. <label for='opt-cb-autoscale'>Auto-scale SVG</label>
  213. </span>
  214. <span class='labeled-input'>
  215. <input type='checkbox' id='opt-cb-autorender'
  216. data-config='renderWhileTyping'>
  217. <label for='opt-cb-autorender'>Render while typing</label>
  218. </span>
  219. <!--span class='labeled-input'>
  220. <input type='file' id='load-pikchr'/>
  221. <label>Load pikchr</label>
  222. </span-->
  223. <!--span class='labeled-input'>
  224. <select id='select-examples'></select>
  225. </span-->
  226. </div>
  227. </div><!-- .fieldset -->
  228. <div id='main-wrapper' class=''>
  229. <div class='zone-wrapper input'>
  230. <textarea id="input"
  231. placeholder="Shell input. Ctrl-enter/shift-enter runs it.">
  232. /**
  233. Use ctrl-enter or shift-enter to execute
  234. pikchr code. If only a subset is currently
  235. selected, only that part is evaluated.
  236. TODOs include, but are not limited to...:
  237. - Solve various layout quirks, in particular
  238. in auto-render mode.
  239. */
  240. arrow right 200% "Markdown" "Source"
  241. box rad 10px "Markdown" "Formatter" "(markdown.c)" fit
  242. arrow right 200% "HTML+SVG" "Output"
  243. arrow <-> down from last box.s
  244. box same "Pikchr" "Formatter" "(pikchr.c)" fit
  245. </textarea>
  246. <div class='button-bar'>
  247. <button id='btn-render'>Render</button>
  248. <button id='btn-clear'>Clear Input</button>
  249. </div>
  250. </div>
  251. <div class='zone-wrapper output'>
  252. <div id='pikchr-output-wrapper'>
  253. <div id='pikchr-output'></div>
  254. </div>
  255. <div class='button-bar'>
  256. <button id='btn-render-mode'>Toggle Render Mode</button>
  257. </div>
  258. </div>
  259. </div>
  260. </div> <!-- #view-split -->
  261. <script src="fiddle.js"></script>
  262. </body>
  263. </html>