Assign first popup on the search page as a depth of 1
This commit is contained in:
parent
099909287f
commit
16521fec93
@ -25,6 +25,8 @@ async function searchFrontendSetup() {
|
|||||||
const options = await apiOptionsGet(optionsContext);
|
const options = await apiOptionsGet(optionsContext);
|
||||||
if (!options.scanning.enableOnSearchPage) { return; }
|
if (!options.scanning.enableOnSearchPage) { return; }
|
||||||
|
|
||||||
|
window.frontendInitializationData = {depth: 1, proxy: false};
|
||||||
|
|
||||||
const scriptSrcs = [
|
const scriptSrcs = [
|
||||||
'/fg/js/frontend-api-receiver.js',
|
'/fg/js/frontend-api-receiver.js',
|
||||||
'/fg/js/popup.js',
|
'/fg/js/popup.js',
|
||||||
|
@ -49,11 +49,10 @@ class Frontend {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static create() {
|
static create() {
|
||||||
const initializationData = window.frontendInitializationData;
|
const data = window.frontendInitializationData || {};
|
||||||
const isNested = (initializationData !== null && typeof initializationData === 'object');
|
const {id, depth=0, parentFrameId, ignoreNodes, url, proxy=false} = data;
|
||||||
const {id, depth, parentFrameId, ignoreNodes, url} = isNested ? initializationData : {};
|
|
||||||
|
|
||||||
const popup = isNested ? new PopupProxy(depth + 1, id, parentFrameId, url) : PopupProxyHost.instance.createPopup(null);
|
const popup = proxy ? new PopupProxy(depth + 1, id, parentFrameId, url) : PopupProxyHost.instance.createPopup(null, depth);
|
||||||
const frontend = new Frontend(popup, ignoreNodes);
|
const frontend = new Frontend(popup, ignoreNodes);
|
||||||
frontend.prepare();
|
frontend.prepare();
|
||||||
return frontend;
|
return frontend;
|
||||||
|
@ -35,7 +35,7 @@ async function popupNestedInitialize(id, depth, parentFrameId, url) {
|
|||||||
|
|
||||||
const ignoreNodes = options.scanning.enableOnPopupExpressions ? [] : [ '.expression', '.expression *' ];
|
const ignoreNodes = options.scanning.enableOnPopupExpressions ? [] : [ '.expression', '.expression *' ];
|
||||||
|
|
||||||
window.frontendInitializationData = {id, depth, parentFrameId, ignoreNodes, url};
|
window.frontendInitializationData = {id, depth, parentFrameId, ignoreNodes, url, proxy: true};
|
||||||
|
|
||||||
const scriptSrcs = [
|
const scriptSrcs = [
|
||||||
'/fg/js/frontend-api-sender.js',
|
'/fg/js/frontend-api-sender.js',
|
||||||
|
@ -50,10 +50,12 @@ class PopupProxyHost {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
createPopup(parentId) {
|
createPopup(parentId, depth) {
|
||||||
const parent = (typeof parentId === 'string' && this.popups.hasOwnProperty(parentId) ? this.popups[parentId] : null);
|
const parent = (typeof parentId === 'string' && this.popups.hasOwnProperty(parentId) ? this.popups[parentId] : null);
|
||||||
const depth = (parent !== null ? parent.depth + 1 : 0);
|
|
||||||
const id = `${this.nextId}`;
|
const id = `${this.nextId}`;
|
||||||
|
if (parent !== null) {
|
||||||
|
depth = parent.depth + 1;
|
||||||
|
}
|
||||||
++this.nextId;
|
++this.nextId;
|
||||||
const popup = new Popup(id, depth, this.frameIdPromise);
|
const popup = new Popup(id, depth, this.frameIdPromise);
|
||||||
if (parent !== null) {
|
if (parent !== null) {
|
||||||
@ -65,7 +67,7 @@ class PopupProxyHost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async createNestedPopup(parentId) {
|
async createNestedPopup(parentId) {
|
||||||
return this.createPopup(parentId).id;
|
return this.createPopup(parentId, 0).id;
|
||||||
}
|
}
|
||||||
|
|
||||||
getPopup(id) {
|
getPopup(id) {
|
||||||
|
Loading…
Reference in New Issue
Block a user