Page MenuHomePhabricator

Creating and Installing onScreen Keyboard on personal computers for Special Characters for editing Language description on wikidata
Closed, ResolvedPublic

Assigned To
Authored By
AgnesAbah
May 8 2024, 11:31 AM
Referenced Files
F51390888: last.png
May 9 2024, 12:31 PM
F51390851: last.png
May 9 2024, 12:31 PM
F51389998: aj5.png
May 9 2024, 12:31 PM
F51389174: aj4.png
May 9 2024, 12:31 PM
F51386976: aj3.png
May 9 2024, 12:31 PM
F51385172: aj2.png
May 9 2024, 12:31 PM
F51384398: aj 1.png
May 9 2024, 12:31 PM
F50969392: onscreen keyboard.jpg
May 8 2024, 11:31 AM

Description

We've identified the necessity of installing an on-screen keyboard for language description on Wikidata.

onscreen keyboard.jpg (106×685 px, 12 KB)

Event Timeline

AgnesAbah renamed this task from Creating and Installing onScreen Keyboard for Special Characters for Igala Language description on wikidata to Creating and Installing onScreen Keyboard for Special Characters in Language description on wikidata.May 8 2024, 11:44 AM
AgnesAbah triaged this task as High priority.
AgnesAbah renamed this task from Creating and Installing onScreen Keyboard for Special Characters in Language description on wikidata to Creating and Installing onScreen Keyboard on personal computers for Special Characters for editing Language description on wikidata.May 8 2024, 11:50 AM

Here are the steps to create an onscreen keyboard for incorporating special characters into editing Wikidata descriptions. If you wish to utilize this code in your preferred language, you'll need to adjust the special characters to match those in your language.

  1. You need to login to your wikidata account
    aj 1.png (127×1 px, 18 KB)
  1. The second Step is to is to create a .js Script on wikidata
    aj2.png (175×1 px, 45 KB)
  1. The next step is to write the code in the wikidata .js script
    aj3.png (694×1 px, 119 KB)

To enable this script, put the following line on your common.js User subpage: importScript('User:AgnesAbah/copy-IglChar.js');
To fork this tool for your language, simply change the characters in the chars array.
//Code inspired by [[User:Masssly/copy-DagChar.js]]

const chars = [

{ text: 'á', capitalizedText: 'Ɛ' },
{ text: 'ā', capitalizedText: 'Ɣ' },
{ text: 'à', capitalizedText: 'Ŋ' },
{ text: 'é', capitalizedText: 'Ɔ' },
{ text: 'ē', capitalizedText: 'Ʒ' },
{ text: 'ẹ́', capitalizedText: 'Ẹ́' },
{ text: 'ē', capitalizedText: 'Gb' },
{ text: 'ẹ', capitalizedText: 'Kp' },
{ text: 'è', capitalizedText: 'Ŋm' },
{ text: 'ẹ̄', capitalizedText: 'Sh' },
{ text: 'ẹ̀', capitalizedText: 'Ny' },
{ text: 'ị̄̀', capitalizedText: 'Ny' },
{ text: 'ẹ', capitalizedText: 'Kp' },
{ text: 'ṑ', capitalizedText: 'Ŋm' },
{ text: 'ọ̣́̄', capitalizedText: 'Sh' },
{ text: 'ọ̣', capitalizedText: 'Ny' },
{ text: 'ọ̄̀', capitalizedText: 'Ny' },

];

let isCapitalized = false;

mw.loader.using('oojs-ui-core').done(() => {

const container = $('<div>').attr('id', 'dag-char-buttons').css({ position: 'fixed', right: '10px', bottom: '10px', zIndex: '1000' }).appendTo('.mw-indicators');

const capsButton = $('<button>').addClass('oo-ui-buttonElement oo-ui-widget oo-ui-widget-enabled oo-ui-buttonWidget oo-ui-buttonWidget-framed').appendTo(container);

updateCapsButtonText();

capsButton.click(() => {
  isCapitalized = !isCapitalized;
  updateCapsButtonText();
  chars.forEach((char, index) => $(`#dag-char-button-${index}`).text(isCapitalized ? char.capitalizedText : char.text));
});

chars.forEach((char, index) => {
  $('<button>').attr('id', `dag-char-button-${index}`).addClass('oo-ui-buttonElement oo-ui-widget oo-ui-widget-enabled oo-ui-buttonWidget oo-ui-buttonWidget-framed').text(char.text).click(() => {
    navigator.clipboard.writeText(isCapitalized ? char.capitalizedText : char.text).then(
      () => $('<div>').addClass('copy-popup').text('Copied!').css({ width: 80, position: 'fixed', bottom: '10px', right: '10px', textAlign: 'center', backgroundColor: 'rgba(0, 0, 0, 0.7)', color: '#fff', padding: '10px', borderRadius: '5px', zIndex: '1001' }).appendTo('body').fadeIn(1000).fadeOut(1000, () => $(this).remove()),
      () => $('<div>').addClass('copy-popup').text('Copy failed').css({ width: 80 }).appendTo('.mw-indicators').fadeIn(1000).fadeOut(1000, () => $(this).remove())
    );
  }).appendTo(container);
});

function updateCapsButtonText() {
  capsButton.text(`Caps: ${isCapitalized ? 'On' : 'Off'}`);
}

});

  1. the next step is to create common.js script on wikidata
    aj4.png (113×1 px, 13 KB)
  1. import script to common.js and publish
    aj5.png (571×729 px, 10 KB)

Note: After publishing, you may have to bypass your browser's cache to see the changes.

Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
Opera: Press Ctrl-F5.

last.png (721×1 px, 162 KB)

last.png (721×1 px, 162 KB)

AgnesAbah raised the priority of this task from High to Needs Triage.May 9 2024, 12:32 PM

@AgnesAbah: Thanks for participating in the Hackathon! We hope you had a great time.

  • If this task was being worked on and resolved at the Hackathon: Please change the task status to resolved via the Add Action...Change Status dropdown, and make sure that this task has a link to the public codebase.
  • If this task is still valid and should stay open: Please add another active project tag to this task, so others can find this task (as likely nobody in the future will look back at the Hackathon workboard when trying to find something they are interested in).
  • In case there is nothing else to do for this task, or nobody plans to work on this task anymore: Please set the task status to declined.

Thank you,
Phabricator housekeeping service