'use strict'; helper.multipleUsers = { _user0: null, _user1: null, // open the same pad on different frames (allows concurrent editions to pad) async init() { this._user0 = { $frame: $('#iframe-container iframe'), token: getToken(), // we'll switch between pads, need to store current values of helper.pad* // to be able to restore those values later padChrome$: helper.padChrome$, padOuter$: helper.padOuter$, padInner$: helper.padInner$, }; this._user1 = {}; // Force generation of a new token. clearToken(); // need to perform as the other user, otherwise we'll get the userdup error message await this.performAsOtherUser(this._createUser1Frame.bind(this)); }, async performAsOtherUser(action) { startActingLike(this._user1); await action(); startActingLike(this._user0); }, close() { this._user0.$frame.attr('style', ''); // make the default ocopy the full height this._user1.$frame.remove(); }, async _loadJQueryForUser1Frame() { const code = await $.get('/static/js/jquery.js'); // make sure we don't override existing jquery const jQueryCode = `if(typeof $ === "undefined") {\n${code}\n}`; const sendkeysCode = await $.get('/tests/frontend/lib/sendkeys.js'); const codesToLoad = [jQueryCode, sendkeysCode]; this._user1.padChrome$ = getFrameJQuery(codesToLoad, this._user1.$frame); this._user1.padOuter$ = getFrameJQuery(codesToLoad, this._user1.padChrome$('iframe[name="ace_outer"]')); this._user1.padInner$ = getFrameJQuery(codesToLoad, this._user1.padOuter$('iframe[name="ace_inner"]')); // update helper vars now that they are available helper.padChrome$ = this._user1.padChrome$; helper.padOuter$ = this._user1.padOuter$; helper.padInner$ = this._user1.padInner$; }, async _createUser1Frame() { // create the iframe const padUrl = this._user0.$frame.attr('src'); this._user1.$frame = $('