User:Polygnotus/Scripts/Claude6.js: Difference between revisions

Content deleted Content added
OOUI ProcessDialog needs a static name property
No edit summary
Line 420:
setApiKey() {
// Create OOUI dialog for API key input using proper MediaWiki inheritance
classfunction ApiKeyDialog(proofreader, extends OO.ui.ProcessDialogconfig) {
staticApiKeyDialog.super.call(this, name = 'ApiKeyDialog'config);
this.proofreader = proofreader;
constructor(proofreader, config) {
super(config);
this.proofreader = proofreader;
this.title = 'Set Claude API Key';
}
initialize() {
super.initialize();
this.textInput = new OO.ui.TextInputWidget({
placeholder: 'Enter your Claude API Key...',
type: 'password',
value: this.proofreader.apiKey || ''
});
this.content = new OO.ui.PanelLayout({
padded: true,
expanded: false
});
this.content.$element.append(
$('<p>').text('Enter your Claude API Key to enable proofreading:'),
this.textInput.$element
);
this.$body.append(this.content.$element);
}
getActionProcess(action) {
if (action === 'save') {
return new OO.ui.Process(() => {
const key = this.textInput.getValue().trim();
if (key) {
this.proofreader.apiKey = key;
localStorage.setItem('claude_api_key', this.proofreader.apiKey);
this.proofreader.updateButtonVisibility();
this.proofreader.updateStatus('API key set successfully!');
this.close();
} else {
this.textInput.setValidityFlag(false);
return OO.ui.Process.static.createRejectProcess('Please enter a valid API key');
}
});
}
return super.getActionProcess(action);
}
getSetupProcess(data) {
return super.getSetupProcess(data)
.next(() => {
this.actions.setMode('save');
});
}
}
constOO.inheritClass(ApiKeyDialog, dialog = new ApiKeyDialog(thisOO.ui.ProcessDialog);
const windowManager = new OO.ui.WindowManager();
$('body').append(windowManager.$element);
windowManager.addWindows([dialog]);
dialogApiKeyDialog.getActions()static.add([name = 'ApiKeyDialog';
ApiKeyDialog.static.title = 'Set Claude API Key';
ApiKeyDialog.static.actions = [
{
action: 'save',
Line 492 ⟶ 440:
flags: ['safe']
}
]);
ApiKeyDialog.prototype.initialize = function() {
ApiKeyDialog.super.prototype.initialize.call(this);
this.textInput = new OO.ui.TextInputWidget({
placeholder: 'Enter your Claude API Key...',
type: 'password',
value: this.proofreader.apiKey || ''
});
this.content = new OO.ui.PanelLayout({
padded: true,
expanded: false
});
this.content.$element.append(
$('<p>').text('Enter your Claude API Key to enable proofreading:'),
this.textInput.$element
);
this.$body.append(this.content.$element);
};
ApiKeyDialog.prototype.getActionProcess = function(action) {
if (action === 'save') {
return new OO.ui.Process(() => {
const key = this.textInput.getValue().trim();
if (key) {
this.proofreader.apiKey = key;
localStorage.setItem('claude_api_key', this.proofreader.apiKey);
this.proofreader.updateButtonVisibility();
this.proofreader.updateStatus('API key set successfully!');
this.close();
} else {
this.textInput.setValidityFlag(false);
return OO.ui.Process.static.createRejectProcess('Please enter a valid API key');
}
});
}
return ApiKeyDialog.super.prototype.getActionProcess.call(this, action);
};
ApiKeyDialog.prototype.getSetupProcess = function(data) {
return ApiKeyDialog.super.prototype.getSetupProcess.call(this, data)
.next(() => {
this.actions.setMode('save');
});
};
const dialog = new ApiKeyDialog(this);
const windowManager = new OO.ui.WindowManager();
$('body').append(windowManager.$element);
windowManager.addWindows([dialog]);
windowManager.openWindow(dialog);
}