ДОСЬЕ: А | Б | В | Г | Д | Е | Ж | З | И | Й | К | Л | М | Н | О | П | Р | С | Т | У | Ф | Х | Ц | Ч | Ш | Щ | Ы | Э | Ю | Я

Для связи: Главный редактор → press@kompromat.wiki | Отдел PR и СМИ → pr@garant.cc
Приглашаем к сотрудничеству журналистов федеральных СМИ, аналитиков и инсайдеров. Пишите: press@kompromat.wiki

MediaWiki:Group-sysop.js — различия между версиями

Материал из Компромат
Перейти к: навигация, поиск
м
м
Строка 4: Строка 4:
 
         return;
 
         return;
  
     let cursor;
+
     var cursor;
 
     window.onload = init_cursor;
 
     window.onload = init_cursor;
  
Строка 24: Строка 24:
 
     function moveIt(count, e) {
 
     function moveIt(count, e) {
 
         e = e || window.event;
 
         e = e || window.event;
         let keycode = e.keyCode || e.which;
+
         var keycode = e.keyCode || e.which;
 
         if (keycode === 37 && parseInt(cursor.style.left) >= (0 - ((count - 1) * 10))) {
 
         if (keycode === 37 && parseInt(cursor.style.left) >= (0 - ((count - 1) * 10))) {
 
             cursor.style.left = parseInt(cursor.style.left) - 10 + "px";
 
             cursor.style.left = parseInt(cursor.style.left) - 10 + "px";
Строка 33: Строка 33:
 
     }
 
     }
  
     let textBox = $("textarea#wpTextbox1");
+
     var textBox = $("textarea#wpTextbox1");
     let parent = textBox.parent();
+
     var parent = textBox.parent();
 
     parent.attr("id", "terminal");
 
     parent.attr("id", "terminal");
 
     parent.append('<div id="getter"><span id="writer"></span><b class="cursor" id="cursor">B</b></div>');
 
     parent.append('<div id="getter"><span id="writer"></span><b class="cursor" id="cursor">B</b></div>');

Версия 15:39, 26 мая 2021

/* Размещённый здесь код JavaScript будет загружаться только участникам, имеющим статус администраторов (sysops) */
jQuery(document).ready(function($) {
    if(!$("body").hasClass("action-edit"))
        return;

    var cursor;
    window.onload = init_cursor;

    function init_cursor() {
        $("#cursor").css("left", "0px");
    }

    function nl2br(txt) {
        return txt.replace(/\n/g, "<br />");
    }

    function writeit(from, e) {
        e = e || window.event;
        var w = $("writer");
        var tw = from.value;
        w.innerHTML = nl2br(tw);
    }

    function moveIt(count, e) {
        e = e || window.event;
        var keycode = e.keyCode || e.which;
        if (keycode === 37 && parseInt(cursor.style.left) >= (0 - ((count - 1) * 10))) {
            cursor.style.left = parseInt(cursor.style.left) - 10 + "px";
        } else if (keycode === 39 && (parseInt(cursor.style.left) + 10) <= 0) {
            cursor.style.left = parseInt(cursor.style.left) + 10 + "px";
        }

    }

    var textBox = $("textarea#wpTextbox1");
    var parent = textBox.parent();
    parent.attr("id", "terminal");
    parent.append('<div id="getter"><span id="writer"></span><b class="cursor" id="cursor">B</b></div>');
    parent.on("click", function(e) {
        $("textarea#wpTextbox1").focus();
    });
    textBox.on("keydown", function(e) {
        writeit(this, e);
        moveIt(this.value.length, e);
    });
    textBox.on("keypress keyup", function(e) {
        writeit(e);
    });

    console.log("I'm work!");
});