Discussioni MediaWiki:Gadget-LiveRC 1x.js/InserisciTemplate.js

Da Wikipedia, l'enciclopedia libera.
Vai alla navigazione Vai alla ricerca

Hello,

According to my response at frwiki, I've done some little changes :

The purpose of these mofications is to permit using two (or more) kinds of templates, each kind managed by its own function.

For that, I added a "Standard" className to the templates added by LiveRC. The function getLiveTag() has become a rooter function leading to another function called getLiveTagFunctions["TheClassNameOfTheOption"] (it checks if it is a function).

So, old templates (ie simple standard templates) are really managed within getLiveTagFunctions["Standard"] function.

So, I also edited the extension to :

  • avoid the total remplacement of all <option> and the main function under the <input>
  • add the new templates with their own classname (here "InserisciTemplateExtension")
  • create the proper function to manage them, ie rename myGetLiveTag in getLiveTagFunctions["InserisciTemplateExtension"]

I didn't test it but it should work fine with both types of templates

Additionnal nota : function names should be less standard, to avoid conflicts. The best way is to prefix them with the extension name :

  • dumpTemplateInserisciTemplate_dumpTemplate


The integration of this extension variables to the configuration panel will be far more difficult...

Dr Brains (msg) 15:01, 27 giu 2014 (CEST)[rispondi]

Notification Rotpunkt, Jalo
Dr Brains (msg) 15:09, 27 giu 2014 (CEST)[rispondi]
[@ Dr Brains]
Updated and tested. It works. Thanks Jalo 15:38, 27 giu 2014 (CEST)[rispondi]

[@ Rotpunkt, Jalo] I continue to work on the extension at Utente:Dr Brains/Sandbox.js. I've started to watch over the integration of the customization in the config panel.

What I've done for now :

  • I added in LiveRC code a new hook permitting to define some additionnal text to be saved in the /LiveRCparam.js page. This will permit to save our customized stuffs (see the todo list below).
  • I modified the way templates are declared in the extension :
    • The item "format" was a problem (difficult to save a function object, even more to customize it for noobs), so I deleted it, using a standard function.
    • I integrated time parameters in the "parameters" item, like all others.
  • Now a new panel/tab is created in the customization menu, where you can edit almost all templates params, add new params, delete existing params, etc...
  • Some CSS styles are used, fro now through Utente:Dr Brains/Sandbox.css

What is still to do :

If you have any idea or comment, you're welcome, of course.

Dr Brains (msg) 17:32, 29 giu 2014 (CEST)[rispondi]

[@ Jalo]
Hello,
I think I have finished the job at Utente:Dr Brains/Sandbox.js.
The only thing I still need is the italian translation for the texts (see at the end of my sandbox. You can do the translation directly in there before copying the code in the released extension). Once I get them, I will able to add them in fr:MediaWiki:Gadget-LiveRC.js/i18n/it.js (and en and fr translations pages).
A "problem" remains : the templates and their params are always saved in /LiveRCparam.js. There is no comparisons between the standard and the customized templates. This should be done to avoid non-customized params to be saved.
If you have any idea or comment, you're welcome, of course.
Dr Brains (msg) 16:39, 10 lug 2014 (CEST)[rispondi]
[@ Dr Brains]
Translation done. Tomorrow in the morning I'll copy it into the extension. Thanks Jalo 17:00, 10 lug 2014 (CEST)[rispondi]
[@ Jalo] OK. Don't forget to copy .css page too, and to change the related target at the beginning of the .js page.
Dr Brains (msg) 18:18, 10 lug 2014 (CEST)[rispondi]
I added french, english and of course italian translations for the extension at fr:MediaWiki:Gadget-LiveRC.js/i18n sub-pages.
Note that somme CSS styles descriptions still need to be translated in italian.
Dr Brains (msg) 18:49, 10 lug 2014 (CEST)[rispondi]
[@ Dr Brains]
Done Jalo 09:59, 11 lug 2014 (CEST)[rispondi]
[@ Jalo]
I tried to adapt the gadget to fr.wiki and I found three other texts I didn't put in translation system (see the diff).
  • The text "Parametri", added in the <legend> of the dialog box (param description lrcParamDesc["DescIT_InsertTemplateParams"] is perhaps to be checked)
  • the text for the two "buttons" of the dialog box ("Inserisci" and "Annulla")
Please update the gadget with these new modifs.
Dr Brains (msg) 18:27, 12 lug 2014 (CEST)[rispondi]
Edit : Update with this oldid, because I continue working on the param saving function.
Dr Brains (msg) 17:32, 13 lug 2014 (CEST)[rispondi]
Edit (2) : The actual code seems to be OK (I added a function to compare old templates and new templates, and prevent non-customized templates to be saved).
Dr Brains (msg) 18:39, 13 lug 2014 (CEST)[rispondi]
[@ Jalo]
Hello,
I noticed a problem in the functions lrcRunInsertTemplate and getLiveTagFunctions["InserisciTemplateExtension"]
The actual code doesn't check if there is customized templates when it creates and checks the "tag" tool options.
The changes to do are (lines 5-6-7 and 28-29-30) :
Before
// Add options in the "Tag" form
 
function lrcRunInsertTemplate(data){
    var TagSelect = document.getElementById('LiveTagReason');


    jQuery.each(lstMyTemplate, function(i, val) {
        var optTag = document.createElement('option');
        optTag.value = i;
        optTag.className = "InserisciTemplateExtension";
        optTag.innerHTML = val.string;
        TagSelect.appendChild(optTag);
    });
    // setup dialog
    mw.loader.using(['jquery.ui.dialog'], function () {
        $('<div>')
            .attr('id', 'gtb-dialog')
            .appendTo('body');
    });
}
LiveRC_AddHook("AfterPreviewArticle", lrcRunInsertTemplate); 
 
// Function launched when choosing one of this extension options
 
getLiveTagFunctions["InserisciTemplateExtension"] = function(page, option){
  lrcDisableLink("LiveTagReason");
  lrcDisableLink("LiveTagLink");


  var message = lstMyTemplate[option.value];
  wpajax.http({ url: wgServer + wgScriptPath + '/api.php?format=xml'
                     + '&action=query&prop=info&intoken=edit'
                     + '&inprop=protection'
                     + '&titles=' + encodeURIComponent(page),
                onSuccess: InserisciTemplate_PostTagPage,
                page: page,
                message: message});
  return false;
}
After
// Add options in the "Tag" form
 
function lrcRunInsertTemplate(data){
    var TagSelect = document.getElementById('LiveTagReason');
    var TemplateList = Custom_lstMyTemplate;
    if(!lrcGetObjectLength(TemplateList)) TemplateList = lstMyTemplate;
    jQuery.each(TemplateList, function(i, val) {
        var optTag = document.createElement('option');
        optTag.value = i;
        optTag.className = "InserisciTemplateExtension";
        optTag.innerHTML = val.string;
        TagSelect.appendChild(optTag);
    });
    // setup dialog
    mw.loader.using(['jquery.ui.dialog'], function () {
        $('<div>')
            .attr('id', 'gtb-dialog')
            .appendTo('body');
    });
}
LiveRC_AddHook("AfterPreviewArticle", lrcRunInsertTemplate); 
 
// Function launched when choosing one of this extension options
 
getLiveTagFunctions["InserisciTemplateExtension"] = function(page, option){
  lrcDisableLink("LiveTagReason");
  lrcDisableLink("LiveTagLink");
  var TemplateList = Custom_lstMyTemplate;
  if(!lrcGetObjectLength(TemplateList)) TemplateList = lstMyTemplate;
  var message = TemplateList[option.value];
  wpajax.http({ url: wgServer + wgScriptPath + '/api.php?format=xml'
                     + '&action=query&prop=info&intoken=edit'
                     + '&inprop=protection'
                     + '&titles=' + encodeURIComponent(page),
                onSuccess: InserisciTemplate_PostTagPage,
                page: page,
                message: message});
  return false;
}
Dr Brains (msg) 01:41, 10 ago 2014 (CEST)[rispondi]
PS: Note that there are new italian translations needed here.
Done Jalo 18:29, 10 ago 2014 (CEST)[rispondi]

New management system for installed extensions[modifica wikitesto]

[@ Jalo] Hello,

I'm about to create a new system to manage the installed LiveRC extensions.

What does the actual system :

  1. get the /LiveRCparam.js last oldid,
  2. get the /LiveRCparam.js (last oldid) wikitext
  3. parse the wikitext, searching the line beginning with //EXTENSIONS SETUP :
  4. set an "installed" item in lrcExtensions or Custom_lrcExtensions to true if each extension name is found in the line, or false if not found

The new system will be based on the LiveRC_Config["InstalledLiveRCExtensions"] global variable:

  1. each extension (if installed and loaded) add an item to the Array
  2. LiveRC search the Array and set an "installed" item in lrcExtensions and/or Custom_lrcExtensions to true if its name is found, or false if not

As you can see, this way, two ajax requests will be saved, so it will be far better for LiveRC launching. I already set the LiveRC_Config["InstalledLiveRCExtensions"] global variable, to prevent errors due to adding an item in a non-existent Array. Now, I need that all extensions add an item with their name to this Array.

So I need that you edit MediaWiki:Gadget-LiveRC_1x.js/InserisciTemplate.js to add the code below just after the if (typeof(lrcHooks)!="undefined") test :

LiveRC_Config["InstalledLiveRCExtensions"].push("InserisciTemplate");

Please, warn me when it's done, so that I could start the main code update.

Thank you

Dr Brains (msg) 01:57, 6 set 2014 (CEST)[rispondi]

[@ Dr Brains]
Done. Bye Jalo 09:17, 8 set 2014 (CEST)[rispondi]

Obsolete functions[modifica wikitesto]

[@ Jalo]

Hello ,

I started to replace some functions that are noted as obsolète. This extension is the last one to be corrected.

Could you replace all occurrences of :

  • getElementsByClass by lrcGetElementsByClass (2 times)
  • hasClass by lrcHasClass (1 time)

Thank you.

Perhaps you noticed that I have created a nex extension, ToolbarExtension, and added some other little stuffs. I tried to do the italian translation myself, but perhaps it has to be checked. If you have some time to waste...

Dr Brains (msg) 23:58, 13 set 2014 (CEST)[rispondi]

[@ Jalo]
Additionnal translation needed |here.
Thank you.
Dr Brains (msg) 15:27, 14 set 2014 (CEST)[rispondi]
✔ Fatto Jalo 09:13, 15 set 2014 (CEST)[rispondi]