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

Content deleted Content added
v5 but with OOUI buttons
OOUI ProcessDialog needs a static name property
Line 421:
setApiKey() {
// Create OOUI dialog for API key input
constclass dialogApiKeyDialog = newextends OO.ui.ProcessDialog(); {
dialog.title = 'Set Claude APIstatic Keyname = 'ApiKeyDialog';
const textInput = new OO.ui.TextInputWidgetconstructor(proofreader, config) {
placeholder: 'Enter your Claude API Key...',super(config);
type: 'password', this.proofreader = proofreader;
value: this.apiKeytitle ||= 'Set Claude API Key';
});
dialog.initialize = function initialize() {
OO.ui.ProcessDialog.prototype super.initialize.call(this);
this.contenttextInput = new OO.ui.PanelLayoutTextInputWidget({
padded placeholder: true'Enter your Claude API Key...',
expanded type: false'password',
}); value: this.proofreader.apiKey || ''
this.content.$element.append(
$('<p>').text('Enter your Claude API Key to enable proofreading:'),
textInput.$element
);
this.$body.append(this.content.$element);
};
dialog.getActionProcess = (action) => {
if (action === 'save') {
return new OO.ui.Process(() => {
const key = textInput.getValue().trim();
if (key) {
this.apiKey = key;
localStorage.setItem('claude_api_key', this.apiKey);
this.updateButtonVisibility();
this.updateStatus('API key set successfully!');
windowManager.closeWindow(dialog);
} else {
textInput.setValidityFlag(false);
return OO.ui.Process.static.createRejectProcess('Please enter a valid API key');
}
});
if (action === 'save') {
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);
}
);
return OO.ui.ProcessDialog.prototype.getActionProcess.call(this, action);
}; getActionProcess(action) {
if (action === 'save') {
dialog.getSetupProcess = function return new OO.ui.Process((data) => {
const key = this.textInput.getValue().trim();
return OO.ui.ProcessDialog.prototype.getSetupProcess.call(this, data)
.next( if (key) => {
this.actionsproofreader.setMode('save')apiKey = key;
} localStorage.setItem('claude_api_key', this.proofreader.apiKey);
this.proofreader.updateButtonVisibility();
};
this.proofreader.updateStatus('API key set successfully!');
localStorage.setItem('claude_api_key', this.apiKeyclose();
this.apiKey} =else key;{
this.textInput.setValidityFlag(false);
return OO.ui.Process.static.createRejectProcess('Please enter a valid API key');
}
if (key}) {;
}
return OO.ui.ProcessDialog.prototypesuper.getActionProcess.call(this, action);
};
getSetupProcess(data) {
return OO.ui.ProcessDialog.prototypesuper.getSetupProcess.call(this, data)
return new OO.ui .Processnext(() => {
windowManagerthis.closeWindowactions.setMode(dialog'save');
} else {);
}
};
const dialog = new ApiKeyDialog(this);
const windowManager = new OO.ui.WindowManager();
$('body').append(windowManager.$element);