Example #1
0
 function convertOldState(state) {
     var sc = state.compilers[0];
     if (!sc) return false;
     var content = [];
     var source;
     if (sc.sourcez) {
         source = lzstring.decompressFromBase64(sc.sourcez);
     } else {
         source = sc.source;
     }
     var options = {compileOnChange: true, colouriseAsm: state.filterAsm.colouriseAsm};
     var filters = _.clone(state.filterAsm);
     delete filters.colouriseAsm;
     content.push(editor.getComponentWith(1, source, options));
     content.push(compiler.getComponentWith(1, filters, sc.options, sc.compiler));
     return {version: 4, content: [{type: 'row', content: content}]};
 }
Example #2
0
    function deserialiseState(stateText) {
        var state;
        try {
            state = unrisonify(stateText);
            if (state && state.z) {
                state = unrisonify(lzstring.decompressFromBase64(state.z));
            }
        } catch (ignored) {
        }


        if (!state) {
            try {
                state = $.parseJSON(decodeURIComponent(stateText));
            } catch (ignored) {
            }
        }
        return loadState(state);
    }
Example #3
0
function deserialiseState(stateText) {
    var state;
    var exception;
    try {
        state = unrisonify(stateText);
        if (state && state.z) {
            state = unrisonify(lzstring.decompressFromBase64(state.z));
        }
    } catch (ex) {
        exception = ex;
    }

    if (!state) {
        try {
            state = $.parseJSON(decodeURIComponent(stateText));
        } catch (ex) {
            if (!exception) exception = ex;
        }
    }
    if (!state && exception) throw exception;
    return loadState(state);
}