-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Krasimir Tsonev
committed
Nov 14, 2018
1 parent
8247e7c
commit 7c08f2c
Showing
34 changed files
with
1,224 additions
and
243 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>demoit</title> | ||
<link rel="stylesheet" href="./vendor/codemirror/codemirror.css"> | ||
<link rel="stylesheet" href="./styles.css"> | ||
<link rel="shortcut icon" type="image/png" href="./img/demoit_64x64.png"/> | ||
</head> | ||
<body> | ||
|
||
<div class="container"> | ||
<div class="left"> | ||
<div class="output" id="output"> | ||
<div class="hint"><div id="output" /></div> | ||
</div> | ||
<div class="console"> | ||
<div class="hint">console.log</div> | ||
</div> | ||
</div> | ||
<div class="right"> | ||
<div class="files"> | ||
<div class="nav"></div> | ||
<div class="options"> | ||
<ul> | ||
<li class="dependencies"> | ||
<a href="javascript:void(0);" title="Manage your dependencies"> | ||
<svg width="24" height="24" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path d="M896 1629l640-349v-636l-640 233v752zm-64-865l698-254-698-254-698 254zm832-252v768q0 35-18 65t-49 47l-704 384q-28 16-61 16t-61-16l-704-384q-31-17-49-47t-18-65v-768q0-40 23-73t61-47l704-256q22-8 44-8t44 8l704 256q38 14 61 47t23 73z"/></svg> | ||
<!-- <span>Dependencies</span> --> | ||
</a> | ||
</li> | ||
<li class="storage"> | ||
<a href="javascript:void(0);" title="Storage"> | ||
<svg width="24" height="24" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path d="M128 1408h1024v-128h-1024v128zm0-512h1024v-128h-1024v128zm1568 448q0-40-28-68t-68-28-68 28-28 68 28 68 68 28 68-28 28-68zm-1568-960h1024v-128h-1024v128zm1568 448q0-40-28-68t-68-28-68 28-28 68 28 68 68 28 68-28 28-68zm0-512q0-40-28-68t-68-28-68 28-28 68 28 68 68 28 68-28 28-68zm96 832v384h-1792v-384h1792zm0-512v384h-1792v-384h1792zm0-512v384h-1792v-384h1792z"/></svg> | ||
<!-- <span>Local storage</span> --> | ||
</a> | ||
</li> | ||
<li class="github"> | ||
<a href="https://github.com/krasimir/demoit" title="Check out Demoit on Github" target="_blank"> | ||
<svg width="24" height="24" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path d="M896 128q209 0 385.5 103t279.5 279.5 103 385.5q0 251-146.5 451.5t-378.5 277.5q-27 5-40-7t-13-30q0-3 .5-76.5t.5-134.5q0-97-52-142 57-6 102.5-18t94-39 81-66.5 53-105 20.5-150.5q0-119-79-206 37-91-8-204-28-9-81 11t-92 44l-38 24q-93-26-192-26t-192 26q-16-11-42.5-27t-83.5-38.5-85-13.5q-45 113-8 204-79 87-79 206 0 85 20.5 150t52.5 105 80.5 67 94 39 102.5 18q-39 36-49 103-21 10-45 15t-57 5-65.5-21.5-55.5-62.5q-19-32-48.5-52t-49.5-24l-20-3q-21 0-29 4.5t-5 11.5 9 14 13 12l7 5q22 10 43.5 38t31.5 51l10 23q13 38 44 61.5t67 30 69.5 7 55.5-3.5l23-4q0 38 .5 88.5t.5 54.5q0 18-13 30t-40 7q-232-77-378.5-277.5t-146.5-451.5q0-209 103-385.5t279.5-279.5 385.5-103zm-477 1103q3-7-7-12-10-3-13 2-3 7 7 12 9 6 13-2zm31 34q7-5-2-16-10-9-16-3-7 5 2 16 10 10 16 3zm30 45q9-7 0-19-8-13-17-6-9 5 0 18t17 7zm42 42q8-8-4-19-12-12-20-3-9 8 4 19 12 12 20 3zm57 25q3-11-13-16-15-4-19 7t13 15q15 6 19-6zm63 5q0-13-17-11-16 0-16 11 0 13 17 11 16 0 16-11zm58-10q-2-11-18-9-16 3-14 15t18 8 14-14z"/></svg> | ||
</a> | ||
</li> | ||
</ul> | ||
</div> | ||
</div> | ||
<div class="js-code-editor"></div> | ||
</div> | ||
</div> | ||
|
||
<div class="modal edit-file"> | ||
<section> | ||
<input name="filename"/> | ||
<button class="save">Save</button> | ||
<button class="cancel secondary"><svg width="24" height="24" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path d="M1490 1322q0 40-28 68l-136 136q-28 28-68 28t-68-28l-294-294-294 294q-28 28-68 28t-68-28l-136-136q-28-28-28-68t28-68l294-294-294-294q-28-28-28-68t28-68l136-136q28-28 68-28t68 28l294 294 294-294q28-28 68-28t68 28l136 136q28 28 28 68t-28 68l-294 294 294 294q28 28 28 68z"/></svg></button> | ||
<hr /> | ||
<button class="delete secondary"><svg width="24" height="24" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path d="M704 1376v-704q0-14-9-23t-23-9h-64q-14 0-23 9t-9 23v704q0 14 9 23t23 9h64q14 0 23-9t9-23zm256 0v-704q0-14-9-23t-23-9h-64q-14 0-23 9t-9 23v704q0 14 9 23t23 9h64q14 0 23-9t9-23zm256 0v-704q0-14-9-23t-23-9h-64q-14 0-23 9t-9 23v704q0 14 9 23t23 9h64q14 0 23-9t9-23zm-544-992h448l-48-117q-7-9-17-11h-317q-10 2-17 11zm928 32v64q0 14-9 23t-23 9h-96v948q0 83-47 143.5t-113 60.5h-832q-66 0-113-58.5t-47-141.5v-952h-96q-14 0-23-9t-9-23v-64q0-14 9-23t23-9h309l70-167q15-37 54-63t79-26h320q40 0 79 26t54 63l70 167h309q14 0 23 9t9 23z"/></svg></button> | ||
</section> | ||
</div> | ||
|
||
<div class="modal manage-storage"> | ||
<section> | ||
<h2>Type of storage</h2> | ||
<p>At the moment Demoit uses <a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage">localStorage API</a> to save your progress.</p> | ||
<hr /> | ||
<h2>Transfer your work</h2> | ||
<p>Download <a href="https://github.com/krasimir/demoit/raw/master/demoit.zip">Demoit.zip</a>. Unzip. Get the JSON below and save it in <i>settings.json</i> file.</p> | ||
<textarea class="settings-json"></textarea> | ||
<button class="cancel secondary"><svg width="24" height="24" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path d="M1490 1322q0 40-28 68l-136 136q-28 28-68 28t-68-28l-294-294-294 294q-28 28-68 28t-68-28l-136-136q-28-28-28-68t28-68l294-294-294-294q-28-28-28-68t28-68l136-136q28-28 68-28t68 28l294 294 294-294q28-28 68-28t68 28l136 136q28 28 28 68t-28 68l-294 294 294 294q28 28 28 68z"/></svg></button> | ||
<hr /> | ||
<p>You can reset to the data in your <a href="./settings.json" target="_blank">settings.json</a> file.</p> | ||
<button class="clear-storage secondary"><svg width="24" height="24" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path d="M704 1376v-704q0-14-9-23t-23-9h-64q-14 0-23 9t-9 23v704q0 14 9 23t23 9h64q14 0 23-9t9-23zm256 0v-704q0-14-9-23t-23-9h-64q-14 0-23 9t-9 23v704q0 14 9 23t23 9h64q14 0 23-9t9-23zm256 0v-704q0-14-9-23t-23-9h-64q-14 0-23 9t-9 23v704q0 14 9 23t23 9h64q14 0 23-9t9-23zm-544-992h448l-48-117q-7-9-17-11h-317q-10 2-17 11zm928 32v64q0 14-9 23t-23 9h-96v948q0 83-47 143.5t-113 60.5h-832q-66 0-113-58.5t-47-141.5v-952h-96q-14 0-23-9t-9-23v-64q0-14 9-23t23-9h309l70-167q15-37 54-63t79-26h320q40 0 79 26t54 63l70 167h309q14 0 23 9t9 23z"/></svg><span>Clean up localStorage</span></button> | ||
</section> | ||
</div> | ||
|
||
<div class="modal manage-dependencies"> | ||
<section> | ||
<h2>Dependencies</h2> | ||
<button class="cancel secondary"><svg width="24" height="24" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path d="M1490 1322q0 40-28 68l-136 136q-28 28-68 28t-68-28l-294-294-294 294q-28 28-68 28t-68-28l-136-136q-28-28-28-68t28-68l294-294-294-294q-28-28-28-68t28-68l136-136q28-28 68-28t68 28l294 294 294-294q28-28 68-28t68 28l136 136q28 28 28 68t-28 68l-294 294 294 294q28 28 28 68z"/></svg></button> | ||
<textarea class="dependencies-list"></textarea> | ||
<p><small>(Separate your dependencies by a new line)</small></p> | ||
<button class="save">Save</button> | ||
</section> | ||
</div> | ||
|
||
<div class="preloader"> | ||
<img src="./img/demoit_100x100.png" alt="demoit" class="logo"/> | ||
<div class="progress"> | ||
<div class="value"></div> | ||
</div> | ||
<p class="file">...</p> | ||
</div> | ||
|
||
<script src="./demoit.js"></script> | ||
|
||
</body> | ||
</html> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
import { el } from './utils'; | ||
|
||
const LOADED_FILES_CACHE = {}; | ||
|
||
export const addJSFile = function (path, done) { | ||
if (LOADED_FILES_CACHE[path]) return done(); | ||
|
||
const node = document.createElement('script'); | ||
|
||
node.src = path; | ||
node.addEventListener('load', () => { | ||
LOADED_FILES_CACHE[path] = true; | ||
done(); | ||
}); | ||
document.body.appendChild(node); | ||
} | ||
export const addCSSFile = function (path, done) { | ||
if (LOADED_FILES_CACHE[path]) return done(); | ||
|
||
const node = document.createElement('link'); | ||
|
||
node.setAttribute('rel', 'stylesheet'); | ||
node.setAttribute('type', 'text/css'); | ||
node.setAttribute('href', path); | ||
node.addEventListener('load', () => { | ||
LOADED_FILES_CACHE[path] = true; | ||
done(); | ||
}); | ||
document.body.appendChild(node); | ||
} | ||
export const addStyleString = function (str) { | ||
const node = document.createElement('style'); | ||
|
||
node.innerHTML = str; | ||
document.body.appendChild(node); | ||
} | ||
export const addScriptString = function (str) { | ||
const node = document.createElement('script'); | ||
|
||
node.innerHTML = str; | ||
document.body.appendChild(node); | ||
} | ||
export const getDistFolderURL = function () { | ||
try { | ||
return [].slice.call(document.querySelectorAll('script[src]')) | ||
.map(({ src }) => src) | ||
.find(url => url.match('demoit.js')) | ||
.replace('demoit.js', ''); | ||
} catch(error) { | ||
return './'; | ||
} | ||
} | ||
export const load = async function (dependencies, status = () => {}) { | ||
return new Promise(done => { | ||
(function load(index) { | ||
status(index); | ||
if (index === dependencies.length) { | ||
done(); | ||
return; | ||
} | ||
|
||
const resource = dependencies[index]; | ||
const extension = resource.split('.').pop().toLowerCase(); | ||
|
||
if (extension === 'js') { | ||
addJSFile(resource, () => load(index + 1)) | ||
} else if (extension === 'css') { | ||
addCSSFile(resource, () => load(index + 1)); | ||
} else { | ||
load(index + 1) | ||
} | ||
})(0); | ||
}); | ||
} | ||
|
||
export default async function dependencies(storage) { | ||
const preloader = el('.preloader'); | ||
const progress = el('.value'); | ||
const currentFile = el('.file'); | ||
const dependencies = [ | ||
'./vendor/codemirror/codemirror.js', | ||
'./vendor/codemirror/javascript.js', | ||
'./vendor/codemirror/xml.js', | ||
'./vendor/codemirror/jsx.js', | ||
'./vendor/codemirror/mark-selection.js', | ||
'./vendor/split.js', | ||
'./vendor/babel-6.26.0.min.js', | ||
'./vendor/babel-polyfill@6.26.0.js', | ||
`./vendor/codemirror/theme/${ storage.getEditorSettings().theme }.css`, | ||
...storage.getDependencies() | ||
]; | ||
|
||
preloader.style.opacity = 1; | ||
|
||
await load(dependencies, index => { | ||
progress.style.width = (100 * (index / dependencies.length)) + '%'; | ||
if (index < dependencies.length) { | ||
currentFile.innerHTML = dependencies[index].split(/\//).pop(); | ||
} else { | ||
currentFile.style.display = 'none'; | ||
preloader.style.opacity = 0; | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.