Compress source for permalink

Use lz-string (http://pieroxy.net/blog/pages/lz-string/index.html) to
compress source code for permalink usage.
dev/git-series/gccdum
Ali Utku Selen 10 years ago
parent 03b54de68a
commit 6816c58503

@ -219,7 +219,7 @@ function Compiler(domRoot, origFilters, windowLocalPrefix, onChangeCallback) {
function serialiseState() {
var state = {
source: cppEditor.getValue(),
sourcez: LZString.compressToBase64(cppEditor.getValue()),
compiler: domRoot.find('.compiler').val(),
options: domRoot.find('.compiler_options').val(),
};
@ -227,7 +227,11 @@ function Compiler(domRoot, origFilters, windowLocalPrefix, onChangeCallback) {
}
function deserialiseState(state) {
cppEditor.setValue(state.source);
if (state.hasOwnProperty('sourcez')) {
cppEditor.setValue(LZString.decompressFromBase64(state.sourcez));
} else {
cppEditor.setValue(state.source);
}
domRoot.find('.compiler').val(state.compiler);
domRoot.find('.compiler_options').val(state.options);
// Somewhat hackily persist compiler into local storage else when the ajax response comes in

File diff suppressed because one or more lines are too long

@ -13,6 +13,7 @@
<script src="compiler.js"></script>
<script src="gcc.js"></script>
<script src="ext/bootstrap/js/bootstrap.js"></script>
<script src="ext/lz-string/lz-string-1.3.3-min.js"></script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-55180-6']);

Loading…
Cancel
Save