MediaWiki:AboutText.js

Материал из ЕЖЕВИКИ - EJWiki.org - Академической Вики-энциклопедии по еврейским и израильским темам
Версия от 16:09, 14 июля 2011; Arielybot (обсуждение | вклад) (Замена текста — «| АВТОР1» на «| АВТОР»)
(разн.) ← Предыдущая версия | Текущая версия (разн.) | Следующая версия → (разн.)
Перейти к навигацииПерейти к поиску

Замечание: Возможно, после публикации вам придётся очистить кэш своего браузера, чтобы увидеть изменения.

  • Firefox / Safari: Удерживая клавишу Shift, нажмите на панели инструментов Обновить либо нажмите Ctrl+F5 или Ctrl+R (⌘+R на Mac)
  • Google Chrome: Нажмите Ctrl+Shift+R (⌘+Shift+R на Mac)
  • Internet Explorer / Edge: Удерживая Ctrl, нажмите Обновить либо нажмите Ctrl+F5
  • Opera: Нажмите Ctrl+F5.
//  ____________________________________________________________________________________________
// |                                                                                            |
// |                    Основано на версии 264413579 гаджета refToolbar.js                      |
// | (http://en.wikipedia.org/w/index.php?title=MediaWiki:Gadget-refToolbar.js&oldid=264413579) |
// |____________________________________________________________________________________________|
//
// Imported from revision 264412998 as of 2009-01-16T05:53:39 from [[User:Mr.Z-man/refToolbar.js]]
// For a description, see [[User:Mr.Z-man/refToolbar]]

var anumforms = 0;
var anumforms1 = 0;

function Textbutton() {
  if (mwCustomEditButtons && document.getElementById('toolbar') ) {
    button = document.createElement('a');
    button.href = "javascript:easyTextMain()";
    button.title = "Добавить шаблон О_тексте";
    buttonimage = document.createElement('img');
    buttonimage.src = "http://upload.wikimedia.org/wikipedia/commons/3/34/Vector_toolbar_insert_reference_button.png";
    buttonimage.alt = "Вставить описание текста";
    button.appendChild(buttonimage);
    var toolbar = document.getElementById('toolbar');
    if (navigator.userAgent.indexOf('MSIE') == -1) {
      if (toolbar.style != null) {
        toolbar.style.height = 'auto';
      }
      else {
      	toolbar.setAttribute('style', 'margin-bottom: 6px; height: auto;');
      }
      toolbar.appendChild(button);
      Textmain = document.createElement('div');
      Textmain.style.display = 'none';
      Textmain.style.margin = '0.2em 0 -0.2em 0';
      Textmain.setAttribute('Id', 'Textselect');
      Textmain.appendChild( addOption("aboutText()", "О тексте") );
      Textmain.appendChild( addOption("aboutTemplate2()", "?") );
      Textmain.appendChild( addOption("hideInit2()", "Отмена") );
      toolbar.appendChild(Textmain);
    }
    else {
      toolbar.appendChild(button);
      selection = '<div id="Textselect" style="display:none"><input type="button" value="О тексте" onclick="aboutText()" />'+
      '<input type="button" value="?" onclick="aboutTemplate2()" />'+
      '<input type="button" value="Отмена" onclick="hideInit()" /></div>';
      document.getElementById('editform').innerHTML = selection + document.getElementById('editform').innerHTML;
    }
  }
}

function addOption(script, text) {
  option = document.createElement('input');
  option.setAttribute('type', 'button');
  option.setAttribute('onclick', script);
  option.setAttribute("value", text);
  return option;
}

function hideInit2() {
  document.getElementById('Textselect').style.display = 'none';
  oldFormHide1();
}

function oldFormHide1() {
  if (anumforms != 0) {
    document.getElementById('Textdiv'+anumforms).style.display = 'none';
  }
  if (anumforms1 != 0) {
    document.getElementById('helpdiv2'+anumforms1).style.display = 'none';
  }

}

function easyTextMain() {
  document.getElementById('Textselect').style.display = '';
}

function getTime() {
  var time = new Date();
  var nowdate = time.getUTCDate();
  if (nowdate<10) { nowdate = "0"+ nowdate.toString(); }
  var nowmonth = time.getUTCMonth()+1;
  if (nowmonth<10) { nowmonth = "0"+ nowmonth.toString(); }
  var nowyear = time.getUTCFullYear();
  newtime =  nowdate + '/' + nowmonth + '/' + nowyear;
  return (newtime);
}

function aboutTemplate2() {
  oldFormHide1();
  var legend;

  legend = "Справка";
  anumforms1++;

  form = '<div id="helpdiv2'+anumforms1+'">'+
    '<fieldset><legend>'+legend+'</legend>'+
      '{{О_тексте  <br>'+
'| ТИП СТАТЬИ            =  <br>'+
  '&nbsp;&nbsp;&nbsp;1. Регулярная статья<br>'+
  '&nbsp;&nbsp;&nbsp;2. Регулярная исправленная статья<br>'+
  '&nbsp;&nbsp;&nbsp;3. Статья-справка<br>'+
  '&nbsp;&nbsp;&nbsp;4. Текст унаследован из Википедии<br>'+
  '&nbsp;&nbsp;&nbsp;5. Служебная статья<br>'+
'| АВТОР                =  <br>'+
'| АВТОР2                =  <br>'+
'| АВТОР3                =  <br>'+
'| СУПЕРВАЙЗЕР           =  <br>'+
'| ПРОЕКТ                =  <br>'+
'| ПОДТЕМА               =  <br>'+
'| КАЧЕСТВО              =  <br>'+
'| УРОВЕНЬ               =  <br>'+
'| ДАТА СОЗДАНИЯ         =  <br>'+
'| ВИКИПЕДИЯ             =  <br>'+
'| НЕОДНОЗНАЧНОСТЬ       =  <br>'+
'}} <br> <br>'+
    '</fieldset></div>';
    document.getElementById('Textselect').innerHTML += form;
}

function aboutText() {
  oldFormHide1();
  var legend;
  template = "О_тексте";

  legend = "Описание текста";
  newtime = getTime();
  anumforms++;

  form = '<div id="Textdiv'+anumforms+'">'+
    '<fieldset><legend>'+legend+'</legend>'+
    '<table cellspacing="6">'+
    '<input type="hidden" value="'+template+'" id="template">'+
    '<tr><td width="150"><label for="АВТОР1">&nbsp;основной автор: </label></td>'+
      '<td width="300"><input type="text" tabindex=1 style="width:100%" id="АВТОР1"></td>'+
    '<td width="150"><label for="ТИП СТАТЬИ">&nbsp;&nbsp;&nbsp;тип статьи: </label></td>'+
      '<td width="80"><SELECT NAME="ТИП СТАТЬИ" SIZE=0 id="typebox">'+
            '<OPTION VALUE="0"></option>'+
            '<OPTION VALUE="1">1. Регулярная статья</option>'+
            '<OPTION VALUE="2">2. Регулярная исправленная статья</option>'+
            '<OPTION VALUE="3">3. Статья-справка</option>'+
            '<OPTION VALUE="4">4. Текст унаследован из Википедии</option>'+
            '<OPTION VALUE="5">5. Служебная статья</option></SELECT></td></tr>'+
    '<tr><td width="150"><label for="АВТОР2">&nbsp;автор 2: </label></td>'+
      '<td width="300"><input type="text" tabindex=1 style="width:100%" id="АВТОР2"></td>'+
    '<td width="150"><label for="УРОВЕНЬ">&nbsp;&nbsp;&nbsp;энциклопедический &nbsp;&nbsp;&nbsp;уровень: </label></td>'+
      '<td width="80"><SELECT NAME="УРОВЕНЬ" SIZE=0 id="level">'+
            '<OPTION VALUE="0"></option>'+
            '<OPTION VALUE="1">I. Общий обзор темы</option>'+
            '<OPTION VALUE="2">II. Начальное введение в тему</option>'+
            '<OPTION VALUE="3">III. Популярное изложение темы</option>'+
            '<OPTION VALUE="4">IV. Академическая статья</option></SELECT></td></tr>'+

    '<tr><td width="150"><label for="АВТОР3">&nbsp;автор 3: </label></td>'+
      '<td width="300"><input type="text" tabindex=1 style="width:100%" id="АВТОР3"></td>'+
    '<td width="150"><label for="КАЧЕСТВО">&nbsp;&nbsp;&nbsp;качество: </label></td>'+
      '<td width="80"><SELECT NAME="КАЧЕСТВО" SIZE=0 id="quality">'+
            '<OPTION VALUE="0"></option>'+
            '<OPTION VALUE="1">25%</option>'+
            '<OPTION VALUE="2">50%</option>'+
            '<OPTION VALUE="3">75%</option>'+
            '<OPTION VALUE="4">100%</option></SELECT></td></tr>'+

    '<tr><td width="200"><label for="СУПЕРВАЙЗЕР">&nbsp;академический &nbsp;супервайзер: </label></td>'+
      '<td width="100"><SELECT NAME="СУПЕРВАЙЗЕР" SIZE=0 id="supervisor">'+
            '<OPTION VALUE="0"></option>'+
            '<OPTION VALUE="1">Пинхас Полонский</option></SELECT></td>'+
    '<td width="150"><label for="ВИКИПЕДИЯ">&nbsp;&nbsp;&nbsp;в Википедии: </label></td>'+
      '<td width="300"><input type="text" tabindex=1 style="width:100%" id="ВИКИПЕДИЯ"></td></tr>'+

    '<tr><td width="150"><label for="ПРОЕКТ">&nbsp;тематический &nbsp;проект: </label></td>'+
      '<td width="300"><input type="text" tabindex=1 style="width:100%" id="ПРОЕКТ"></td>'+
    '<td width="150"><label for="НЕОДНОЗНАЧНОСТЬ">&nbsp;&nbsp;&nbsp;разрешение &nbsp;&nbsp;&nbsp;неоднозначности: </label></td>'+
      '<td width="300"><input type="text" tabindex=1 style="width:100%" id="НЕОДНОЗНАЧНОСТЬ"></td></tr>'+

    '<tr><td width="150"><label for="ПОДТЕМА">&nbsp;подтема: </label></td>'+
      '<td width="300"><input type="text" tabindex=1 style="width:100%" id="ПОДТЕМА"></td>'+
    '<td width="150"><label for="ДАТА СОЗДАНИЯ">&nbsp;&nbsp;&nbsp;дата &nbsp;&nbsp;&nbsp;создания: </label></td>'+
      '<td width="300"><input type="text" tabindex=1 style="width:100%" id="ДАТА СОЗДАНИЯ" value="'+ newtime +'"></td></tr>'+

    '</table>'+
    '<input type="button" value="Добавить" onClick="addtemplate1()">'+
 '</fieldset></div>';
   document.getElementById('Textselect').innerHTML += form;
}

function addtemplate1() {
  cites = document.getElementById('Textdiv'+anumforms).getElementsByTagName('input');
  var citebegin = '';
  var citeinner = '';

if (document.getElementById ('typebox').selectedIndex !="0") {
      citeinner += "\n|" + document.getElementById ('typebox').name + "=" + document.getElementById ('typebox').selectedIndex;
  }
else {
  citeinner += "\n|" + document.getElementById ('typebox').name + "="
  }
if (document.getElementById ('supervisor').selectedIndex !="0") {
      citeinner += "\n|" + document.getElementById ('supervisor').name + "=" + document.getElementById ('supervisor').selectedIndex;
  }
else {
  citeinner += "\n|" + document.getElementById ('supervisor').name + "="
  }
if (document.getElementById ('level').selectedIndex !="0") {
      citeinner += "\n|" + document.getElementById ('level').name + "=" + document.getElementById ('level').selectedIndex;
  }
else {
  citeinner += "\n|" + document.getElementById ('level').name + "="
  }
if (document.getElementById ('quality').selectedIndex !="0") {
      citeinner += "\n|" + document.getElementById ('quality').name + "=" + document.getElementById ('quality').selectedIndex;
  }
else {
  citeinner += "\n|" + document.getElementById ('quality').name + "="
  }

  for (var i=0; i<cites.length-1; i++) {
    if (cites[i].id != "template") {
      citeinner += "\n|" + cites[i].id + "=" + cites[i].value;
    }
    else if (cites[i].id == "template") {
      citebegin = '{{' + cites[i].value;
    }
  }

  cite = citebegin + citeinner + "\n}}\n";
  insertTags(cite, '', '');
  document.getElementById('Textdiv'+anumforms).style.display = 'none';
}

//hookEvent("load", Textbutton);
addOnloadHook(Textbutton);