ميدياويكي:RefToolbarConfig.js

من ويكيبيديا، الموسوعة الحرة

ملاحظة: بعد الحفظ، قد يلزمك إفراغ الكاش لرؤية التغييرات.

/* Sitewide options for the the Cite toolbar button:
* All options should be specified
*
* "date format" sets the date format used for the function to insert the current date
* Current available options:
* date - the day of the month
* zdate - day of the month, zero padded to 2 digits
* monthname - The month name
* month - The numberic month (1-12)
* zmonth - numeric month, zero padded to 2 digits
* year - The full year (4 digits)
*
* "autodate fields" is a list of template fields that should have a button to insert the current date
* 
* "months" is a list of localized month names
*
* "modal" - if true, the dialogs will be modal windows, blocking access to the rest of the window.
* See https://en.wikipedia.org/wiki/Modal_window
* All dialogs in the toolbar are modal by default
*
* "autoparse" - if true, previewing a ref will automatically trigger a preview of the parsed wikitext.
* It is not recommended to set this to true as a global setting as it may slow the script down for
* people with slow connections.
*
* "expandtemplates" - if true, templates and parser functions will be expanded when getting page text
* (templates inside of ref tags will not be expanded). This will allow references inside of templates or
* references using {{#tag:ref}} to be listed in the named refs dialog and searched by error checks.
* This may slow loading the named refs and error check dialogs.
*/

CiteTB.Options = {
    "date format" : "<year>-<zmonth>-<zdate>",
    "autodate fields" : ['تاريخ-الوصول'],
    "months" : ['يناير', 'فبراير', 'مارس', 'أبريل', 'مايو', 'يونيو', 'يوليو', 'أغسطس', 'سبتمبر', 'أكتوبر', 'نوفمبر', 'ديسمبر'],
    "modal" : true,
    "autoparse" : true,
    "expandtemplates" : false
    };
    
    // Cite template definitions
    new citeTemplate('استشهاد ويب', 'web',
    [ // Basic fields
    {"field": "مؤلف<N>", "autofillprop":"last-incr", 'increment_group':'author'},
    {"field": "الأول<N>", "autofillprop":"first-incr", 'increment_group':'author', 'increment_button':true}, 
    {"field": "عنوان", "autofillprop":"title"},
    {"field": "مسار", "autofillid":"url"},
    {"field": "موقع", "autofillprop":"journal"},
    {"field": "ناشر", "autofillprop":"publisher"},
    {"field": "تاريخ-الوصول"},
    {"field": "مرجع", "tooltip":"cite-ref-tooltip"}
    ],
    [ // Expanded fields
    //{"field": "مؤلف<N>", 'increment_group':'author_alt', 'increment_button':true},
    {"field": "وصلة مؤلف<N>", "tooltip":"cite-authorlink-tooltip", 'increment_group':'authorlink', 'increment_button':true},
    {"field": "مسار الأرشيف"},
    {"field": "تاريخ الأرشيف"},
    {"field": "موقع"},
    {"field": "صفحة", "tooltip":"cite-page-tooltip"},
    {"field": "صفحات", "autofillprop":"pages", "tooltip":"cite-pages-tooltip"},
    {"field": "اللغة", "autofillprop":"language"},
    {"field": "الصيغة"},
    {"field": "doi", "autofillid":"doi", "autofillprop":"doi"},
    {"field": "التاريخ", "autofillprop":"date"},
    {"field": "اقتباس"},
    {"field": "حالة المسار", "tooltip":"cite-urlstatus-tooltip"}
    ]);
    
    new citeTemplate('استشهاد بكتاب', 'book',
    [ // Basic fields
    {"field": "مؤلف<N>", "autofillprop":"last-incr", 'increment_group':'author'},
    {"field": "الأول<N>", "autofillprop":"first-incr", 'increment_group':'author', 'increment_button':true}, 
    {"field": "عنوان", "autofillprop":"title"},
    {"field": "التاريخ", "autofillprop":"date"},
    {"field": "ناشر", "autofillprop":"publisher"},
    {"field": "مكان", "autofillprop":"location"},
    {"field": "ردمك", "autofillid":"isbn", "autofillprop":"isbn"},
    {"field": "صفحة", "tooltip":"cite-page-tooltip"},
    {"field": "صفحات", "autofillprop":"pages", "tooltip":"cite-pages-tooltip"},
    {"field": "طبعة", "autofillprop":"edition"},
    {"field": "مسار", "autofillid":"url"},
    {"field": "تاريخ-الوصول"},
    {"field": "مرجع", "tooltip":"cite-ref-tooltip"}
    
    ],
    [ // Expanded fields
    //{"field": "مؤلف<N>", 'increment_group':'author_alt', 'increment_button':true},
    {"field": "وصلة مؤلف<N>", "tooltip":"cite-authorlink-tooltip", 'increment_group':'authorlink', 'increment_button':true},
    {"field": "محرر<N>", "increment_group":"editor"},
    {"field": "محرر-الأول<N>", "increment_group":"editor", "increment_button":true},
    {"field": "وصلة محرر<N>", 'increment_group':'editorlink', 'increment_button':true},
    {"field": "مسار الأرشيف"},
    {"field": "تاريخ الأرشيف"},
    {"field": "اللغة", "autofillprop":"language"},
    {"field": "صيغة"},
    {"field": "فصل", "autofillprop":"chapter"},
    {"field": "اقتباس"}
    ]);
    
    new citeTemplate('استشهاد بويكي بيانات', 'wikidata',
    [ // Basic fields
    {"field": "1", "label":"QID"},
    {"field": "ج"},
    {"field": "ص"},
    {"field": "مرجع", "tooltip":"cite-ref-tooltip"}
    ],
    []);

    new citeTemplate('استشهاد مختصر', 'mktsr',
    [ // Basic fields
    {"field": "1", "tooltip":"cite-mktsr1-tooltip", "label":"اسم المؤلف أو الكتاب مختصرًا "},
    {"field": "2", "tooltip":"cite-mktsr2-tooltip", "label":"السنة"}, 
    {"field": "ج"},
    {"field": "ص"},
    {"field": "لغة"}
    ],
    [ // Expanded fields
    {"field": "فصل"},
    {"field": "قسم"},
    {"field": "نص"}
    ]);

    new citeTemplate('استشهاد بدورية محكمة', 'journal',
    [ // Basic fields
    {"field": "مؤلف<N>", "autofillprop":"last-incr", 'increment_group':'author'},
    {"field": "الأول<N>", "autofillprop":"first-incr", 'increment_group':'author', 'increment_button':true}, 
    {"field": "عنوان", "autofillprop":"title"},
    {"field": "دورية", "autofillprop":"journal"},
    {"field": "تاريخ", "autofillprop":"date"},
    {"field": "مجلد", "autofillprop":"volume"},
    {"field": "عدد", "autofillprop":"issue"},
    {"field": "صفحة", "tooltip":"cite-page-tooltip"},
    {"field": "صفحات", "autofillprop":"pages", "tooltip":"cite-pages-tooltip"},
    {"field": "doi", "autofillid":"doi", "autofillprop":"doi"},
    {"field": "pmid", "autofillid":"pmid"},
    {"field": "مسار", "autofillid":"url"},
    {"field": "تاريخ-الوصول"},
    {"field": "مرجع", "tooltip":"cite-ref-tooltip"},
    ],
    [ // Expanded fields
    //{"field": "مؤلف<N>", 'increment_group':'author_alt', 'increment_button':true},
    {"field": "وصلة مؤلف<N>", "tooltip":"cite-authorlink-tooltip", 'increment_group':'authorlink', 'increment_button':true},
    {"field": "محرر<N>", "increment_group":"editor"},
    {"field": "محرر-الأول<N>", "increment_group":"editor", "increment_button":true},
    {"field": "وصلة محرر<N>", 'increment_group':'editorlink', 'increment_button':true},
    {"field": "سلسلة"},
    {"field": "في", "tooltip":"cite-at-tooltip"},
    {"field": "عنوان مترجم"},
    {"field": "ناشر", "autofillprop":"publisher"},
    {"field": "مكان"},
    {"field": "اللغة", "autofillprop":"language"},
    {"field": "صيفة"},
    {"field": "issn", "autofillprop":"issn"},
    {"field": "pmc"},
    {"field": "oclc"},
    {"field": "bibcode"},
    {"field": "id"},
    {"field": "اقتباس"},
    {"field": "postscript", "tooltip":"cite-postscript-tooltip"}
    ]);
    
    new citeTemplate('استشهاد بخبر', 'news',
    [ // Basic fields
    {"field": "مؤلف<N>", "autofillprop":"last-incr", 'increment_group':'author'},
    {"field": "الأول<N>", "autofillprop":"first-incr", 'increment_group':'author', 'increment_button':true}, 
    {"field": "عنوان", "autofillprop":"title"},
    {"field": "مسار", "autofillid":"url"},
    {"field": "تاريخ-الوصول"},
    {"field": "العمل", "tooltip":"cite-work-tooltip", "autofillprop":"journal"},
    {"field": "وكالة", "tooltip":"cite-agency-tooltip"},
    {"field": "العدد"},
    {"field": "ناشر", "tooltip":"cite-publisher-tooltip", "autofillprop":"publisher"},
    {"field": "تاريخ", "autofillprop":"date"},
    {"field": "مرجع", "tooltip":"cite-ref-tooltip"}
    ],
    [ // Expanded fields
    //{"field": "مؤلف<N>", 'increment_group':'author_alt', 'increment_button':true},
    {"field": "وصلة مؤلف#", "tooltip":"cite-authorlink-tooltip", 'increment_group':'authorlink', 'increment_button':true},
    {"field": "مسار الأرشيف"},
    {"field": "تاريخ الأرشيف"},
    {"field": "موقع"},
    {"field": "صفحة", "tooltip":"cite-page-tooltip"},
    {"field": "صفحات", "autofillprop":"pages", "tooltip":"cite-pages-tooltip"},
    {"field": "اللغة", "autofillprop":"language"},
    {"field": "الصيغة"},
    {"field": "doi", "autofillid":"doi", "autofillprop":"doi"},
    {"field": "اقتباس"}
    ]);

    new citeErrorCheck({'type':'reflist', 'testname':'samecontent', 'desc': 'cite-samecontent-desc',
    'func': function(reflist) {
      var errors = [];
      var refs2 = [];
      for(var i=0; i<reflist.length; i++) {
        if (!reflist[i].shorttag) {
          if ($.inArray(reflist[i].content, refs2) != -1) {
            if ($.inArray(reflist[i].content, errors) == -1) {
              errors.push(reflist[i].content);
            }
          } else {
            refs2.push(reflist[i].content);
          }
        }
      }
      ret = [];
      for(var j=0; j<errors.length; j++) {
        ret.push({'msg':'cite-samecontent-error', 'err':errors[j]});
      }
      return ret;
    }}
    );
    
    new citeErrorCheck({'type':'reflist', 'testname':'repeated', 'desc':'cite-repeated-desc',
    'func': function(reflist) {
      var errors = [];
      var refs2 = [];
      for(var i=0; i<reflist.length; i++) {
        if (!reflist[i].shorttag && reflist[i].refname) {
          if ($.inArray(reflist[i].refname, refs2) != -1) {
            if ($.inArray(reflist[i].refname, errors) == -1) {
              errors.push(reflist[i].refname);
            }
          } else {
            refs2.push(reflist[i].refname);
          }
        }
      }
      ret = [];
      for(var j=0; j<errors.length; j++) {
        ret.push({'msg':'cite-repeated-error', 'err':errors[j]});
      }
      return ret;
    }}
    );
    
    new citeErrorCheck({'type':'reflist', 'testname':'undefined', 'desc':'cite-undefined-desc',
    'func': function(reflist) {
      var errors = [];
      var longrefs = [];
      for(var i=0; i<reflist.length; i++) {
        if (!reflist[i].shorttag && reflist[i].refname) {
          longrefs.push(reflist[i].refname);
        }
      }
      for(var j=0; i<reflist.length; j++) {
        if (reflist[i].shorttag && $.inArray(reflist[i].refname, errors) == -1 && $.inArray(reflist[i].refname, longrefs) == -1) {
          errors.push(reflist[i].refname);
        }
      }
      ret = [];
      for(var j=0; j<errors.length; j++) {
        ret.push({'msg':'cite-undefined-error', 'err':errors[j]});
      }
      return ret;
    }}
    );
    
    CiteTB.init();