mirror of
https://gitlab.com/Oreolek/salet-playground.git
synced 2024-04-25 21:59:40 +03:00
Removed saving functionality
This commit is contained in:
parent
ac8d6b032a
commit
e4d0594414
|
@ -4,9 +4,6 @@ An open source clone of [JSFiddle](http://jsfiddle.net/), this project was made
|
|||
|
||||
## Features
|
||||
|
||||
* Offline "saving"
|
||||
|
||||
#### Mimicked Features
|
||||
* HTML/CSS/JS Editors
|
||||
* Preview
|
||||
* Syntax checks
|
||||
|
@ -36,8 +33,6 @@ Bootstrap 3.3.2 ([link](http://getbootstrap.com/))
|
|||
|
||||
JQuery 2.1.3 ([link](http://blog.jquery.com/2014/12/18/jquery-1-11-2-and-2-1-3-released-safari-fail-safe-edition/))
|
||||
|
||||
CryptoJS 3.1.2 ([link](https://code.google.com/p/crypto-js/))
|
||||
|
||||
#### Inspiration
|
||||
JSFiddle ([link](http://jsfiddle.net/))
|
||||
|
||||
|
|
15
index.html
15
index.html
|
@ -43,25 +43,10 @@
|
|||
<div class="collapse navbar-collapse" id="toolbar">
|
||||
<ul class="nav navbar-nav">
|
||||
<li id="btnRun"><a href=""><span class="glyphicon glyphicon-play" aria-hidden="true"></span> Run</a></li>
|
||||
<li id="btnSave"><a href=""><span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Save</a></li>
|
||||
<li id="btnTidyUp"><a href=""><span class="glyphicon glyphicon-flash" aria-hidden="true"></span> TidyUp</a></li>
|
||||
</ul>
|
||||
</div><!-- /.navbar-collapse -->
|
||||
</nav>
|
||||
<!-- Dialog Modals -->
|
||||
<div class="modal fade" id="modalSave" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true" style="display: none;">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title" id="mySmallModalLabel">Save URL</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<!-- Content provided by JS -->
|
||||
</div>
|
||||
</div><!-- /.modal-content -->
|
||||
</div><!-- /.modal-dialog -->
|
||||
</div>
|
||||
|
||||
<!-- Sidebar -->
|
||||
<div id="sidebar">
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
$("document").ready(function() {
|
||||
// Get code from Save URL
|
||||
var code = getUrlVars()["code"];
|
||||
|
||||
var libs = {};
|
||||
|
||||
// List of Frameworks & Extensions
|
||||
|
@ -208,22 +205,6 @@ $("document").ready(function() {
|
|||
}
|
||||
};
|
||||
|
||||
if (code) {
|
||||
var decrypted = CryptoJS.AES.decrypt(code, "secret_pass");
|
||||
var newCode = decrypted.toString(CryptoJS.enc.Utf8);
|
||||
var content = newCode.split("%%");
|
||||
|
||||
var css = content[0];
|
||||
var script = content[1];
|
||||
var html = content[2];
|
||||
|
||||
setContent(css, script, html);
|
||||
|
||||
var modalSave = $("#modalSave");
|
||||
modalSave.find(".modal-body").html(window.location.href);
|
||||
modalSave.modal('show');
|
||||
}
|
||||
|
||||
// Frameworks & Extensions Dropdown
|
||||
$(".dropdown-menu li a").click(function(event){
|
||||
event.preventDefault();
|
||||
|
@ -283,15 +264,6 @@ $("document").ready(function() {
|
|||
// Preview code on page load
|
||||
$("#btnRun").click();
|
||||
|
||||
// SAVE Button
|
||||
$("#btnSave").click(function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
var encrypted = CryptoJS.AES.encrypt(getSaveContent(), "secret_pass");
|
||||
|
||||
window.location.replace(window.location.protocol + "//" + window.location.host + "/?code=" + encrypted.toString());
|
||||
});
|
||||
|
||||
// TIDYUP Button
|
||||
$("#btnTidyUp").click(function(event) {
|
||||
event.preventDefault();
|
||||
|
@ -311,33 +283,4 @@ $("document").ready(function() {
|
|||
|
||||
ace.edit("js-editor").getSession().setValue(js2);
|
||||
});
|
||||
|
||||
// HELPER Functions
|
||||
function getSaveContent() {
|
||||
var css = ace.edit("css-editor").getSession().getValue();
|
||||
var script = ace.edit("js-editor").getSession().getValue();
|
||||
var html = ace.edit("html-editor").getSession().getValue();
|
||||
|
||||
return (css + "%%" + script + "%%" + html).toString();
|
||||
}
|
||||
|
||||
function setContent(css, script, html) {
|
||||
ace.edit("css-editor").getSession().setValue(css);
|
||||
ace.edit("js-editor").getSession().setValue(script);
|
||||
ace.edit("html-editor").getSession().setValue(html);
|
||||
}
|
||||
|
||||
// Read a page's GET URL variables and return them as an associative array.
|
||||
function getUrlVars() {
|
||||
var vars = [], hash;
|
||||
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
|
||||
|
||||
for(var i = 0; i < hashes.length; i++) {
|
||||
hash = hashes[i].split('=');
|
||||
vars.push(hash[0]);
|
||||
vars[hash[0]] = hash[1];
|
||||
}
|
||||
|
||||
return vars;
|
||||
}
|
||||
});
|
Loading…
Reference in a new issue