Show correct link for codepen button

This commit is contained in:
Maximilian Krög
2020-07-25 19:48:44 +02:00
parent e39e3ea152
commit e51643dfca
2 changed files with 9 additions and 8 deletions
+5 -4
View File
@@ -38,16 +38,17 @@
}) })
} }
var codepenButton = document.getElementsByClassName('codepen-button')[0]; const codepenButton = document.getElementById('codepen-button');
if (codepenButton) { if (codepenButton) {
codepenButton.onclick = function(event) { const form = document.getElementById('codepen-form');
codepenButton.href = form.action;
codepenButton.addEventListener('click', function(event) {
event.preventDefault(); event.preventDefault();
const html = document.getElementById('example-html-source').innerText; const html = document.getElementById('example-html-source').innerText;
const js = document.getElementById('example-js-source').innerText; const js = document.getElementById('example-js-source').innerText;
const workerContainer = document.getElementById('example-worker-source'); const workerContainer = document.getElementById('example-worker-source');
const worker = workerContainer ? workerContainer.innerText : undefined; const worker = workerContainer ? workerContainer.innerText : undefined;
const pkgJson = document.getElementById('example-pkg-source').innerText; const pkgJson = document.getElementById('example-pkg-source').innerText;
const form = document.getElementById('codepen-form');
const localResources = (js.match(/'data\/[^']*/g) || []) const localResources = (js.match(/'data\/[^']*/g) || [])
.concat(js.match(/'resources\/[^']*/g) || []) .concat(js.match(/'resources\/[^']*/g) || [])
@@ -87,6 +88,6 @@
form.parameters.value = compress(data); form.parameters.value = compress(data);
form.submit(); form.submit();
}); });
}; });
} }
})(); })();
+4 -4
View File
@@ -127,11 +127,11 @@
{{/if}} {{/if}}
<div class="row-fluid"> <div class="row-fluid">
<a href="" class="codepen-button float-right"><i class="fa fa-codepen fa-lg"></i> Edit</a> <a href="#" id="codepen-button" class="btn btn-link float-right">
<i class="fa fa-codepen fa-lg"></i> Edit
</a>
<div class="span12"> <div class="span12">
<h4 id="title"> <h4 id="title">{{ title }}</h4>
{{ title }}
</h4>
<p class="tags"> <p class="tags">
{{#each tags}} {{#each tags}}
<span class="badge-group"> <span class="badge-group">