MediaWiki:Common.js: Difference between revisions

From The Jolly Contrarian
Jump to navigation Jump to search
Undo revision 10162 by Amwelladmin (talk)
No edit summary
 
(104 intermediate revisions by the same user not shown)
Line 1: Line 1:
var customizeToolbar = function() {
var customizeToolbar = function() {
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'sections': {
'manual': {
'type': 'toolbar', // Can also be 'booklet'
'label': 'Manual'
// or 'labelMsg': 'section-manual-label' for a localized label
}
}
} );
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'manual',
'groups': {
'tags': {
'label': 'Tags' // or use labelMsg for a localized label, see above
}
}
} );
$('#wpTextbox1').wikiEditor('addToToolbar', {
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'advanced',
section: 'advanced',
group: 'format',
group: 'format',
tools: {
tools: {
"strikethrough": {
"template": {
label: 'Strike',
label: 'long dash',
type: 'button',
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/3/30/Btn_toolbar_rayer.png',
icon: 'https://jollycontrarian.com/images/5/55/Dash.png',
action: {
action: {
type: 'encapsulate',
type: 'encapsulate',
options: {
options: {
pre: "<s>",
pre: "—",
post: "</s>"
post: ""
}
}
}
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'advanced',
group: 'format',
tools: {
"template": {
label: 'scarequotes',
type: 'button',
icon: 'https://jollycontrarian.com/images/b/ba/Scare.png',
action: {
type: 'encapsulate',
options: {
pre: "“",
post: "”"
}
}
}
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'advanced',
group: 'format',
tools: {
"template": {
label: 'apostrophe',
type: 'button',
icon: 'https://jollycontrarian.com/images/5/5b/Apo.png',
action: {
type: 'encapsulate',
options: {
pre: "’",
post: ""
}
}
}
}
});
 
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'advanced',
group: 'format',
tools: {
"template": {
label: '{{ - }}',
type: 'button',
icon: 'https://jollycontrarian.com/images/3/30/Template.png',
action: {
type: 'encapsulate',
options: {
pre: "{{",
post: "}}"
}
}
}
}
});
 
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'advanced',
group: 'format',
tools: {
"Substitute": {
label: 'subst:',
type: 'button',
icon: 'https://jollycontrarian.com/images/0/03/Sbs.png',
action: {
type: 'encapsulate',
options: {
pre: "{{subst:",
post: "}}"
}
}
}
}
});
 
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'advanced',
group: 'format',
tools: {
"redirect": {
label: '==>',
type: 'button',
icon: 'https://jollycontrarian.com/images/9/91/Redirect.png',
action: {
type: 'encapsulate',
options: {
pre: "#redirect[[",
post: "]]"
}
}
}
}
});
 
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'advanced',
group: 'format',
tools: {
"template": {
label: 'tag',
type: 'button',
icon: 'https://jollycontrarian.com/images/7/76/Tag.png',
action: {
type: 'encapsulate',
options: {
pre: "{{t|",
post: "}}"
}
}
}
}
Line 18: Line 150:
}
}
});
});
};


/* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar … */
$('#wpTextbox1').wikiEditor('addToToolbar', {
if ( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) !== -1 ) {
section: 'advanced',
mw.loader.using( 'user.options', function () {
group: 'format',
// This can be the string "0" if the user disabled the preference ([[phab:T54542#555387]])
tools: {
if ( mw.user.options.get( 'usebetatoolbar' ) == 1 ) {
"Prov": {
$.when(
label: 'isdaprov',
mw.loader.using( 'ext.wikiEditor.toolbar' ), $.ready
type: 'button',
).then( customizeToolbar );
icon: 'https://jollycontrarian.com/images/5/50/Isd.png',
action: {
type: 'encapsulate',
options: {
pre: "{{isdaprov|",
post: "}}"
}
}
}
}
} );
}
}
});
// Add the customizations to LiquidThreads' edit toolbar, if available
mw.hook( 'ext.lqt.textareaCreated' ).add( customizeToolbar );


$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'advanced',
group: 'format',
tools: {
"Prov": {
label: 'euaprov',
type: 'button',
icon: 'https://jollycontrarian.com/images/5/50/eua.png',
action: {
type: 'encapsulate',
options: {
pre: "{{euaprov|",
post: "}}"
}
}
}
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'advanced',
group: 'format',
tools: {
"ietaprov": {
label: 'ietaprov',
type: 'button',
icon: 'https://jollycontrarian.com/images/e/e9/Gms.png',
action: {
type: 'encapsulate',
options: {
pre: "{{ietaprov|",
post: "}}"
}
}
}
}
});


$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'advanced',
group: 'format',
tools: {
"gmraprov": {
label: '{{{1}}}|',
type: 'button',
icon: 'https://jollycontrarian.com/images/4/49/blank.png',
action: {
type: 'encapsulate',
options: {
pre: "{{{{{1}}}|",
post: "}}"
}
}
}
}
});


$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'advanced',
group: 'format',
tools: {
"Equity Derivs": {
label: 'eqderivprov',
type: 'button',
icon: 'https://jollycontrarian.com/images/c/c3/Eqd.png',
action: {
type: 'encapsulate',
options: {
pre: "{{eqderivprov|",
post: "}}"
}
}
}
}
});




/* Any JavaScript here will be loaded for all users on every page load. */
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'advanced',
group: 'format',
tools: {
"template": {
label: 'vmcsaprov',
type: 'button',
icon: 'https://jollycontrarian.com/images/3/37/Csa.png',
action: {
type: 'encapsulate',
options: {
pre: "{{vmcsaprov|",
post: "}}"
}
}
}
}
});


/* Any JavaScript here will be loaded for all users on every page load. */
$('#wpTextbox1').wikiEditor('addToToolbar', {
/* Good site for buttons: http://commons.wikimedia.org/wiki/Mediawiki_edit_toolbar */
section: 'advanced',
group: 'format',
if (mwCustomEditButtons) {
tools: {
"template": {
  mwCustomEditButtons[mwCustomEditButtons.length] = {
label: 'hotlink',
    "imageFile": "http://amwellclear.co.uk/w/images/e/e2/Button_Tag.PNG",
type: 'button',
    "speedTip": "tag (links and categorises)",
icon: 'https://jollycontrarian.com/images/3/37/Csa.png',
    "tagOpen": "{{tag|",
action: {
    "tagClose": "}}",
type: 'encapsulate',
    "sampleText": "text"}
options: {
pre: "{{pjchotlink|}}<li>{{pjchotlink|}}<li>{{pjchotlink|}}<li>{{pjchotlink|}}<li>{{pjchotlink|}}<li>",
  mwCustomEditButtons[mwCustomEditButtons.length] = {
post: "{{pjchotlink|}}"
    "imageFile": "http://amwellclear.co.uk/w/images/b/b8/Button_Tg2.PNG",
}
    "speedTip": "tag (links and categorises and allows a short name)",
}
    "tagOpen": "{{t2|",
}
    "tagClose": "}}",
}
    "sampleText": "LongText|Shorttext"}
});
 
  mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageFile": "http://images.wikia.com/central/images/c/c8/Button_redirect.png",
    "speedTip": "Redirect",
    "tagOpen": "#REDIRECT [[",
    "tagClose": "]]",
    "sampleText": "Insert text"};
  mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageFile": "http://amwellclear.co.uk/w/images/e/ed/Button_I.PNG",
    "speedTip": "isdaprov",
    "tagOpen": "{{isdaprov|",
    "tagClose": "}}",
    "sampleText": "provision"};
  mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageFile": "http://amwellclear.co.uk/w/images/5/56/Button_Ia.PNG",
    "speedTip": "isdaanatomy",
    "tagOpen": "{{isdaanatomy}}",
    "tagClose": "",
    "sampleText": ""};


  mwCustomEditButtons[mwCustomEditButtons.length] = {
};
    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/2/29/Button_double_angle_quotes_with_ellipsis.png",
    "speedTip": "isdaquote",
    "tagOpen": "{{isdaquote|",
    "tagClose": "|SECTION|2002}}",
    "sampleText": "Provision"};
  mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageFile": "http://amwellclear.co.uk/w/images/a/a7/Button_G.PNG",
    "speedTip": "gmraprov",
    "tagOpen": "{{gmraprov|",
    "tagClose": "}}",
    "sampleText": "provision"};
  mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/9/94/Vector_toolbar_insert_new_line_button.png",
    "speedTip": "linebreak",
    "tagOpen": "<br>",
    "tagClose": "",
    "sampleText": ""};
  mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageFile": "http://amwellclear.co.uk/w/images/b/ba/Clausebutton.png",
    "speedTip": "clause",
    "tagOpen": "{{clause|",
    "tagClose": "}}",
    "sampleText": "SHORTNAME|AGREEMENT|EDITION|CLAUSE"};
  mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageFile": "http://amwellclear.co.uk/w/images/d/d6/Button_ccp.PNG",
    "speedTip": "ccp",
    "tagOpen": "{{ccp|",
    "tagClose": "}}",
    "sampleText": "text"};


  mwCustomEditButtons[mwCustomEditButtons.length] = {
if ( [ 'edit', 'submit' ].indexOf( mw.config.get( 'wgAction' ) ) !== -1 ) {
    "imageFile": "http://amwellclear.co.uk/w/images/c/cd/Button_cdea.PNG",
mw.loader.using( 'user.options' ).then( function () {
    "speedTip": "cassprov",
if ( mw.user.options.get( 'usebetatoolbar' ) == 1 ) {
    "tagOpen": "{{cassprov|",
$.when(
    "tagClose": "}}",
mw.loader.using( 'ext.wikiEditor' ), $.ready
    "sampleText": "text"};
).then( customizeToolbar );
}
} );
}


  mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/5/50/Vector_toolbar_italic_C_button.png",
    "speedTip": "csaprov",
    "tagOpen": "{{csaprov|",
    "tagClose": "}}",
    "sampleText": "text"};
  mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/7/74/Button_API_%C9%9B.png",
    "speedTip": "eqderivprov",
    "tagOpen": "{{eqderivprov|",
    "tagClose": "}}",
    "sampleText": "text"};
  mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/9/94/Subst-button-bg.png",
    "speedTip": "subst",
    "tagOpen": "{{subst:",
    "tagClose": "}}",
    "sampleText": "text"};
  mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/1/17/Button_small_2.png",
    "speedTip": "TOC",
    "tagOpen": "{{YEAR AGREEMENT Section NUMBER TOC}}",
    "tagClose": "",
    "sampleText": ""};
  mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/a/a4/Vector_toolbar_bold_G_button.png",
    "speedTip": "GMSLAprov",
    "tagOpen": "{{gmslaprov|",
    "tagClose": "}}",
    "sampleText": ""};


  mwCustomEditButtons[mwCustomEditButtons.length] = {
// Add the customizations to LiquidThreads' edit toolbar, if available
    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/f/fe/Button_context.png",
mw.hook( 'ext.lqt.textareaCreated' ).add( customizeToolbar );
    "speedTip": "CASS",
    "tagOpen": "{{cassprov|",
    "tagClose": "}}",
    "sampleText": ""};


  mwCustomEditButtons[mwCustomEditButtons.length] = {
/* Any JavaScript here will be loaded for all users on every page load. */
    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/b/b4/Button_category03.png",
    "speedTip": "BIPRU",
    "tagOpen": "{{bipruprov|",
    "tagClose": "}}",
    "sampleText": ""};


 
// JavaScript to dynamically adjust table layout
  mwCustomEditButtons[mwCustomEditButtons.length] = {
function adjustTableLayout() {
    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/7/77/Button_cyrillic_capital_fita.png",
    var staticTable = document.getElementById('static-table');
    "speedTip": "COBS Provision",
    var adaptiveTable = document.getElementById('adaptive-table');
    "tagOpen": "{{cobsprov|",
    "tagClose": "}}",
    "sampleText": ""};


  mwCustomEditButtons[mwCustomEditButtons.length] = {
    if (!staticTable || !adaptiveTable) return;
    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/c/cd/Button_recycler.png",
    "speedTip": "FCA Provision",
    "tagOpen": "{{fcaprov|",
    "tagClose": "}}",
    "sampleText": "text"};


  mwCustomEditButtons[mwCustomEditButtons.length] = {
    // Get the bounding rectangles of the tables
    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/b/bb/Wiki-button-italic-be.png",
    var staticRect = staticTable.getBoundingClientRect();
    "speedTip": "pca",
    var adaptiveRect = adaptiveTable.getBoundingClientRect();
    "tagOpen": "{{pcaprov|",
    "tagClose": "}}",
    "sampleText": "text"};


  mwCustomEditButtons[mwCustomEditButtons.length] = {
    // Check if the adaptive table is below the static table
    "imageFile": "https://upload.wikimedia.org/wikipedia/commons/1/14/Vector_toolbar_bold_A_button.png",
    if (adaptiveRect.top >= staticRect.bottom) {
    "speedTip": "aifmdprov",
        adaptiveTable.classList.add('stacked');
    "tagOpen": "{{aifmdprov|",
    } else {
    "tagClose": "}}",
        adaptiveTable.classList.remove('stacked');
    "sampleText": "text"}
    }
}


  mwCustomEditButtons[mwCustomEditButtons.length] = {
// Function to request a reflow and check layout
    "imageFile": "https://upload.wikimedia.org/wikipedia/commons/5/5c/Button_h2p.png",
function checkLayout() {
    "speedTip": "aifmdprov|DR",
    requestAnimationFrame(function() {
    "tagOpen": "{{aifmdprov|DR",
        adjustTableLayout();
    "tagClose": "}}",
    });
    "sampleText": "text"}
}


  mwCustomEditButtons[mwCustomEditButtons.length] = {
// Initial adjustment
    "imageFile": "https://upload.wikimedia.org/wikipedia/commons/4/41/Btn_toolbar_unicode.png",
checkLayout();
    "speedTip": "ucitsprov",
    "tagOpen": "{{ucitsprov|",
    "tagClose": "}}",
    "sampleText": "text"}


  mwCustomEditButtons[mwCustomEditButtons.length] = {
// Adjust on window resize
    "imageFile": "http://upload.wikimedia.org/wikipedia/commons/e/e1/Button_flag_of_France.png",
window.addEventListener('resize', checkLayout);
    "speedTip": "eudirprov/mifid",
    "tagOpen": "{{eudirprov|",
    "tagClose": "|MiFID}}",
    "sampleText": "text"}


// Adjust on content changes
document.addEventListener('DOMContentLoaded', checkLayout);


/* DIALOGUE MALARKEY */


  }
document.addEventListener("DOMContentLoaded", function() {
    document.querySelectorAll('.dialogue').forEach(dialogue => {
        const character = dialogue.querySelector('.character');
        const text = dialogue.querySelector('.text');
        const characterWidth = character.offsetWidth;
        text.style.marginLeft = `${characterWidth + 30}px`;
    });
});

Latest revision as of 17:50, 10 September 2024

var customizeToolbar = function() {

$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
	'sections': {
		'manual': {
			'type': 'toolbar', // Can also be 'booklet'
			'label': 'Manual'
			// or 'labelMsg': 'section-manual-label' for a localized label
		}
	}
} );
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
	'section': 'manual',
	'groups': {
		'tags': {
			'label': 'Tags' // or use labelMsg for a localized label, see above
		}
	}
} );

$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'advanced',
	group: 'format',
	tools: {
		"template": {
			label: 'long dash',
			type: 'button',
			icon: 'https://jollycontrarian.com/images/5/55/Dash.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: "—",
					post: ""
				}
			}
		}
	}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'advanced',
	group: 'format',
	tools: {
		"template": {
			label: 'scarequotes',
			type: 'button',
			icon: 'https://jollycontrarian.com/images/b/ba/Scare.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: "“",
					post: "”"
				}
			}
		}
	}
});	
$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'advanced',
	group: 'format',
	tools: {
		"template": {
			label: 'apostrophe',
			type: 'button',
			icon: 'https://jollycontrarian.com/images/5/5b/Apo.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: "’",
					post: ""
				}
			}
		}
	}
});

$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'advanced',
	group: 'format',
	tools: {
		"template": {
			label: '{{ - }}',
			type: 'button',
			icon: 'https://jollycontrarian.com/images/3/30/Template.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: "{{",
					post: "}}"
				}
			}
		}
	}
});	

$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'advanced',
	group: 'format',
	tools: {
		"Substitute": {
			label: 'subst:',
			type: 'button',
			icon: 'https://jollycontrarian.com/images/0/03/Sbs.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: "{{subst:",
					post: "}}"
				}
			}
		}
	}
});	

$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'advanced',
	group: 'format',
	tools: {
		"redirect": {
			label: '==>',
			type: 'button',
			icon: 'https://jollycontrarian.com/images/9/91/Redirect.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: "#redirect[[",
					post: "]]"
				}
			}
		}
	}
});	
	

$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'advanced',
	group: 'format',
	tools: {
		"template": {
			label: 'tag',
			type: 'button',
			icon: 'https://jollycontrarian.com/images/7/76/Tag.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: "{{t|",
					post: "}}"
				}
			}
		}
	}
});	

$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'advanced',
	group: 'format',
	tools: {
		"Prov": {
			label: 'isdaprov',
			type: 'button',
			icon: 'https://jollycontrarian.com/images/5/50/Isd.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: "{{isdaprov|",
					post: "}}"
				}
			}
		}
	}
});

$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'advanced',
	group: 'format',
	tools: {
		"Prov": {
			label: 'euaprov',
			type: 'button',
			icon: 'https://jollycontrarian.com/images/5/50/eua.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: "{{euaprov|",
					post: "}}"
				}
			}
		}
	}
});	
$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'advanced',
	group: 'format',
	tools: {
		"ietaprov": {
			label: 'ietaprov',
			type: 'button',
			icon: 'https://jollycontrarian.com/images/e/e9/Gms.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: "{{ietaprov|",
					post: "}}"
				}
			}
		}
	}
});	

$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'advanced',
	group: 'format',
	tools: {
		"gmraprov": {
			label: '{{{1}}}|',
			type: 'button',
			icon: 'https://jollycontrarian.com/images/4/49/blank.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: "{{{{{1}}}|",
					post: "}}"
				}
			}
		}
	}
});	

$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'advanced',
	group: 'format',
	tools: {
		"Equity Derivs": {
			label: 'eqderivprov',
			type: 'button',
			icon: 'https://jollycontrarian.com/images/c/c3/Eqd.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: "{{eqderivprov|",
					post: "}}"
				}
			}
		}
	}
});	


$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'advanced',
	group: 'format',
	tools: {
		"template": {
			label: 'vmcsaprov',
			type: 'button',
			icon: 'https://jollycontrarian.com/images/3/37/Csa.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: "{{vmcsaprov|",
					post: "}}"
				}
			}
		}
	}
});

$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'advanced',
	group: 'format',
	tools: {
		"template": {
			label: 'hotlink',
			type: 'button',
			icon: 'https://jollycontrarian.com/images/3/37/Csa.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: "{{pjchotlink|}}<li>{{pjchotlink|}}<li>{{pjchotlink|}}<li>{{pjchotlink|}}<li>{{pjchotlink|}}<li>",
					post: "{{pjchotlink|}}"
				}
			}
		}
	}
});

};

if ( [ 'edit', 'submit' ].indexOf( mw.config.get( 'wgAction' ) ) !== -1 ) {
	mw.loader.using( 'user.options' ).then( function () {
		if ( mw.user.options.get( 'usebetatoolbar' ) == 1 ) {
			$.when(
				mw.loader.using( 'ext.wikiEditor' ), $.ready
			).then( customizeToolbar );
		}
	} );
}


// Add the customizations to LiquidThreads' edit toolbar, if available
mw.hook( 'ext.lqt.textareaCreated' ).add( customizeToolbar );

/* Any JavaScript here will be loaded for all users on every page load. */

// JavaScript to dynamically adjust table layout
function adjustTableLayout() {
    var staticTable = document.getElementById('static-table');
    var adaptiveTable = document.getElementById('adaptive-table');

    if (!staticTable || !adaptiveTable) return;

    // Get the bounding rectangles of the tables
    var staticRect = staticTable.getBoundingClientRect();
    var adaptiveRect = adaptiveTable.getBoundingClientRect();

    // Check if the adaptive table is below the static table
    if (adaptiveRect.top >= staticRect.bottom) {
        adaptiveTable.classList.add('stacked');
    } else {
        adaptiveTable.classList.remove('stacked');
    }
}

// Function to request a reflow and check layout
function checkLayout() {
    requestAnimationFrame(function() {
        adjustTableLayout();
    });
}

// Initial adjustment
checkLayout();

// Adjust on window resize
window.addEventListener('resize', checkLayout);

// Adjust on content changes
document.addEventListener('DOMContentLoaded', checkLayout);

/* DIALOGUE MALARKEY */

document.addEventListener("DOMContentLoaded", function() {
    document.querySelectorAll('.dialogue').forEach(dialogue => {
        const character = dialogue.querySelector('.character');
        const text = dialogue.querySelector('.text');
        const characterWidth = character.offsetWidth;
        text.style.marginLeft = `${characterWidth + 30}px`;
    });
});