Skip to content

Commit

Permalink
Add selection options to choose version in demo
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashton Hunter committed Feb 8, 2019
1 parent c77a224 commit 3ddbb43
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
13 changes: 13 additions & 0 deletions docs/demo/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ if (!window.fetch) {
}

var $markdownElem = document.querySelector('#markdown');
var $markedVerElem = document.querySelector('#markedVersion');
var $markedVer = document.querySelector('#markedCdn');
var $optionsElem = document.querySelector('#options');
var $outputTypeElem = document.querySelector('#outputType');
var $inputTypeElem = document.querySelector('#inputType');
Expand Down Expand Up @@ -78,6 +80,11 @@ function handleOutputChange() {
updateLink();
}

function handleVersionChange() {
handleChange($markedVer, $markedVerElem.value);
updateVersion();
}

function handleChange(panes, visiblePane) {
var active = null;
for (var i = 0; i < panes.length; i++) {
Expand All @@ -95,6 +102,8 @@ $outputTypeElem.addEventListener('change', handleOutputChange, false);
handleOutputChange();
$inputTypeElem.addEventListener('change', handleInputChange, false);
handleInputChange();
$markedVerElem.addEventListener('change', handleVersionChange, false);
handleVersionChange();

function handleInput() {
inputDirty = true;
Expand Down Expand Up @@ -174,6 +183,10 @@ function updateLink() {
history.replaceState('', document.title, $permalinkElem.href);
}

function updateVersion() {
$markedVer.setAttribute('src', $markedVerElem.value);
}

var delayTime = 1;
var options = {};
function checkForChanges() {
Expand Down
8 changes: 7 additions & 1 deletion docs/demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ <h1>Marked Demo</h1>
<option value="markdown">Markdown</option>
<option value="options">Options</option>
</select>
<select id="markedVersion">
<option value="https://cdn.jsdelivr.net/npm/marked@master/marked.min.js">Marked@master</option>
<option value="https://cdn.jsdelivr.net/npm/[email protected]/marked.min.js">[email protected]</option>
<option value="https://cdn.jsdelivr.net/npm/[email protected]/marked.min.js">[email protected]</option>
<option value="https://cdn.jsdelivr.net/npm/[email protected]/marked.min.js">[email protected]</option>
</select>
</div>
<textarea id="markdown" class="inputPane"></textarea>
<textarea id="options" class="inputPane" placeholder="Options (as JSON)"></textarea>
Expand Down Expand Up @@ -57,7 +63,7 @@ <h2>You'll need to enable Javascript to use this tool.</h2>
<textarea id="quickref" class="pane" readonly="readonly"></textarea>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/marked/lib/marked.js"></script>
<script id="markedCdn" src="https://cdn.jsdelivr.net/npm/marked/lib/marked.js"></script>
<script src="https://cdn.jsdelivr.net/npm/es6-promise/dist/es6-promise.js"></script>
<script src="https://cdn.jsdelivr.net/npm/unfetch/dist/unfetch.umd.js"></script>
<script src="./demo.js"></script>
Expand Down

0 comments on commit 3ddbb43

Please sign in to comment.