MediaWiki:Gadget-TciTest.js: Difference between revisions
Appearance
No edit summary Tag: Reverted |
No edit summary Tag: Reverted |
||
Line 1: | Line 1: | ||
// Gadget-TciTest.js — TCI Calculator ( | // Gadget-TciTest.js — TCI Calculator (VISIBLE version fix) | ||
(function ($, mw, OO) { | (function ($, mw, OO) { | ||
"use strict"; | "use strict"; | ||
Line 16: | Line 16: | ||
]; | ]; | ||
TCICalculatorTestDialog.prototype.initialize = function () { | |||
TCICalculatorTestDialog.super.prototype.initialize.call(this); | |||
this.content = new OO.ui.PanelLayout({ | |||
padded: true, | |||
expanded: true, | |||
scrollable: true | |||
}); | |||
this.$body.append(this.content.$element); | |||
this.abcInput = new OO.ui.MultilineTextInputWidget({ | |||
placeholder: 'Paste ABC notation here...', | |||
autosize: true, | |||
rows: 10, | |||
classes: ['tci-abc-input'] | |||
}); | |||
this.octaveChoice = new OO.ui.DropdownInputWidget({ | |||
options: [ | |||
{ data: 'standard', label: 'Standard fiddle range (default)' }, | |||
{ data: 'visual', label: 'Based on ABC visual octave' }, | |||
{ data: 'shiftUp', label: 'Force high octave (+1)' }, | |||
{ data: 'shiftDown', label: 'Force low octave (-1)' } | |||
] | |||
}); | |||
this.resultOutput = new OO.ui.MultilineTextInputWidget({ | |||
readOnly: true, | |||
autosize: true, | |||
rows: 6, | |||
classes: ['tci-output'] | |||
}); | |||
this.content.$element.append( | |||
new OO.ui.FieldsetLayout({ | |||
label: 'TCI Calculator Options', | |||
items: [ | |||
new OO.ui.FieldLayout(this.abcInput, { label: 'ABC Notation', align: 'top' }), | |||
new OO.ui.FieldLayout(this.octaveChoice, { label: 'Octave Interpretation', align: 'top' }), | |||
new OO.ui.FieldLayout(this.resultOutput, { label: 'Theme Code Index (TCI)', align: 'top' }) | |||
] | |||
}).$element | |||
); | |||
}; | |||
// CSS fix | |||
mw.util.addCSS(` | |||
.tci-abc-input textarea { | |||
min-height: 150px; | |||
} | } | ||
.tci-output textarea { | |||
min-height: 100px; | |||
background: #f5f5f5; | |||
} | } | ||
.oo-ui-window-body { | |||
max-height: 90vh !important; | |||
overflow-y: auto; | |||
} | } | ||
`); | |||
// ... (rest of script unchanged, parser + logs) | |||
function openTCICalculatorTestDialog() { | function openTCICalculatorTestDialog() { |
Revision as of 18:19, 10 April 2025
// Gadget-TciTest.js — TCI Calculator (VISIBLE version fix)
(function ($, mw, OO) {
"use strict";
mw.loader.using(["oojs-ui-core", "oojs-ui-widgets", "oojs-ui-windows"]).done(function () {
function TCICalculatorTestDialog(config) {
TCICalculatorTestDialog.super.call(this, config);
}
OO.inheritClass(TCICalculatorTestDialog, OO.ui.ProcessDialog);
TCICalculatorTestDialog.static.name = 'tciCalculatorTestDialog';
TCICalculatorTestDialog.static.title = 'Theme Code Index Calculator — LIVE VERSION';
TCICalculatorTestDialog.static.actions = [
{ action: 'cancel', label: 'Cancel', flags: 'safe' },
{ action: 'calculate', label: 'Calculate TCI', flags: ['primary', 'progressive'] }
];
TCICalculatorTestDialog.prototype.initialize = function () {
TCICalculatorTestDialog.super.prototype.initialize.call(this);
this.content = new OO.ui.PanelLayout({
padded: true,
expanded: true,
scrollable: true
});
this.$body.append(this.content.$element);
this.abcInput = new OO.ui.MultilineTextInputWidget({
placeholder: 'Paste ABC notation here...',
autosize: true,
rows: 10,
classes: ['tci-abc-input']
});
this.octaveChoice = new OO.ui.DropdownInputWidget({
options: [
{ data: 'standard', label: 'Standard fiddle range (default)' },
{ data: 'visual', label: 'Based on ABC visual octave' },
{ data: 'shiftUp', label: 'Force high octave (+1)' },
{ data: 'shiftDown', label: 'Force low octave (-1)' }
]
});
this.resultOutput = new OO.ui.MultilineTextInputWidget({
readOnly: true,
autosize: true,
rows: 6,
classes: ['tci-output']
});
this.content.$element.append(
new OO.ui.FieldsetLayout({
label: 'TCI Calculator Options',
items: [
new OO.ui.FieldLayout(this.abcInput, { label: 'ABC Notation', align: 'top' }),
new OO.ui.FieldLayout(this.octaveChoice, { label: 'Octave Interpretation', align: 'top' }),
new OO.ui.FieldLayout(this.resultOutput, { label: 'Theme Code Index (TCI)', align: 'top' })
]
}).$element
);
};
// CSS fix
mw.util.addCSS(`
.tci-abc-input textarea {
min-height: 150px;
}
.tci-output textarea {
min-height: 100px;
background: #f5f5f5;
}
.oo-ui-window-body {
max-height: 90vh !important;
overflow-y: auto;
}
`);
// ... (rest of script unchanged, parser + logs)
function openTCICalculatorTestDialog() {
const windowManager = new OO.ui.WindowManager();
$(document.body).append(windowManager.$element);
const dialog = new TCICalculatorTestDialog();
windowManager.addWindows([dialog]);
windowManager.openWindow(dialog);
}
mw.util.addPortletLink('p-cactions', '#', '🎼 TCI Test', 'ca-tcitest', 'Open TCI test');
$(document).on('click', '#ca-tcitest', function (e) {
e.preventDefault();
openTCICalculatorTestDialog();
});
});
})(jQuery, mediaWiki, OO);