Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
serialize() {
return LZString.compressToEncodedURIComponent(JSON.stringify(mobx.toJS({
playbackPosition: this.playbackPosition,
followPlayback: this.followPlayback,
conversation: this.conversation,
uis: this.uis, // TODO: remove uuids
zoom: this.zoom,
//totalTimeSeconds: this.totalTimeSeconds
})));
}
@mobx.action
const examples = node.getElementsByTagName("EXAMPLE");
const exampleArr = [];
for (let i = 0; examples[i]; i++) {
const example = examples[i].firstChild.nodeValue;
if (snippetStore[example]) {
exampleArr.push("\n\n");
exampleArr.push(snippetStore[example].codeStr);
} else {
missingExampleWarning(example);
}
}
const exampleStr = exampleArr.join("");
// make url for source academy link
const compressed = lzString.compressToEncodedURIComponent(
reqStr + codeStr + exampleStr
);
const chap = "4";
const ext = "";
const url =
sourceAcademyURL +
"/playground#chap=" +
chap +
ext +
"&prgrm=" +
compressed;
const chunks = (codeStr + "\n").match(/^((?:.*?[\r\n]+){1,6})((?:.|\n|\r)*)$/);
// 6 lines plus rest
writeTo.push(
"\n\\begin{lrbox}{\\lstbox}\\begin{lstlisting}[mathescape=true, language=JavaScript]\n"
url_parameters_1.setupModelLink(editor, function (event) {
return {
compressedContent: LZString.compressToEncodedURIComponent(editor.getValue())
};
});
// Create the web socket
render() {
let shortURL = window.location.origin + '/violation/v/' + lzw.compressToEncodedURIComponent(JSON.stringify(this.props.params)),
shareURL = shortURL.length < window.location.href.length ? shortURL : window.location.href,
selectedViolation = this.state.selectedViolation ?
this.props.fullstopStore.getViolation(this.state.selectedViolation) :
null;
return <div>
<h2>Violations {this.props.loading ? <small></small> : null}</h2>
<div>
Copy sharing URL
</div>
<div style="{{display:">
{this.props.error && this.props.error.message || 'Error'}
</div></div>
export const replaceState = code => {
const hash = code ? LZString.compressToEncodedURIComponent(code) : ''
if (
typeof URL === 'function' &&
typeof window.history === 'object' &&
typeof window.history.replaceState === 'function'
) {
const url = new URL(document.location)
url.hash = hash
window.history.replaceState(null, null, url)
} else {
document.location.hash = hash
}
}
export function compress(input) {
return LZString.compressToEncodedURIComponent(input);
}
export const encodeUrl = (code: string, config: string) => {
const toCompress = JSON.stringify({ code, config });
const compressed = lzString.compressToEncodedURIComponent(toCompress);
return `?saved=${compressed}`;
};
const createUrl = ({ baseUrl, code, themes, widths }) => {
let path = '';
if (code || themes || widths) {
const data = JSON.stringify({
...(code ? { code } : {}),
...(themes ? { themes } : {}),
...(widths ? { widths } : {})
});
const compressedData = lzString.compressToEncodedURIComponent(data);
path = `#?code=${compressedData}`;
}
if (baseUrl) {
const trimmedBaseUrl = baseUrl.replace(/\/$/, '');
return `${trimmedBaseUrl}/${path}`;
}
return path;
};
export function replace(state) {
const hash = LZString.compressToEncodedURIComponent(JSON.stringify(state));
if (
typeof URL === "function" &&
typeof history === "object" &&
typeof history.replaceState === "function"
) {
const url = new URL(location);
url.hash = hash;
history.replaceState(null, null, url);
} else {
location.hash = hash;
}
}