MediaWiki:Common.js: различия между версиями

Материал из Space Station 14 Вики
мНет описания правки
мНет описания правки
Строка 1: Строка 1:
function kerisar() {
function kerisar() {
console.log("Проверка консоли");
  console.log("Проверка консоли");
//alert("Проверка алерта");
  //alert("Проверка алерта");
const jsTest = document.getElementById("jsTest");
  const jsTest = document.getElementById("jsTest");
console.log("jsTest", jsTest);
  console.log("jsTest", jsTest);
const buttonTest = document.createElement('button');
  const buttonTest = document.createElement('button');
buttonTest.classList.add('testButtonJs');
  buttonTest.classList.add('testButtonJs');
jsTest.appendChild(buttonTest);
  jsTest.appendChild(buttonTest);
const kerisarPicture = document.createElement('img');
  const kerisarPicture = document.createElement('img');
kerisarPicture.setAttribute('src',
  kerisarPicture.setAttribute('src',
"https://thumb.cloud.mail.ru/weblink/thumb/xw1/LLmd/Qui7Xbp6g");
    "https://thumb.cloud.mail.ru/weblink/thumb/xw1/LLmd/Qui7Xbp6g");
//kerisarPicture.src = "Default.aspx?q=" + Math.random();
  //kerisarPicture.src = "Default.aspx?q=" + Math.random();
jsTest.appendChild(kerisarPicture);
  jsTest.appendChild(kerisarPicture);
}
}
const serversConnectors = ['https://game2.station14.ru/main/server/status',
const serversConnectors = ['https://game2.station14.ru/main/server/status',
'https://game2.station14.ru/nova/server/status',
  'https://game2.station14.ru/nova/server/status',
'https://game2.station14.ru/athara/server/status',
  'https://game2.station14.ru/athara/server/status',
'https://game2.station14.ru/solaris/server/status',
  'https://game2.station14.ru/solaris/server/status',
'https://game2.station14.ru/echo/server/status',
  'https://game2.station14.ru/echo/server/status',
'https://game2.station14.ru/elysium/server/status',
  'https://game2.station14.ru/elysium/server/status',
'https://game2.station14.ru/nebula/server/status',
  'https://game2.station14.ru/nebula/server/status',
'https://game2.station14.ru/wl/server/status',
  'https://game2.station14.ru/wl/server/status',
'https://arles.station14.ru/frontier-main/server/status',
  'https://arles.station14.ru/frontier-main/server/status',
'https://game1.station14.ru/marines-main/server/status',
  'https://game1.station14.ru/marines-main/server/status',
'https://game.stalkers14.xyz/status',
  'https://game.stalkers14.xyz/status',
 
];
];


function getServersStatus() {
function getServersStatus() {
//console.log(serversConnectors);
  //console.log(serversConnectors);
const responseDataServers = [];
  const responseDataServers = [];
for (var i = 0; i < serversConnectors.length; i++) {
  for (var i = 0; i < serversConnectors.length; i++) {
//console.log(serversConnectors[i]);
    //console.log(serversConnectors[i]);
const xhr = new XMLHttpRequest();
    const xhr = new XMLHttpRequest();
xhr.open('GET', serversConnectors[i], true);
    xhr.open('GET', serversConnectors[i], true);
xhr.onload = function() {
    xhr.onload = function() {
if (xhr.status >= 200 && xhr.status < 300) {
      if (xhr.status >= 200 && xhr.status < 300) {
const responseData = JSON.parse(xhr.responseText);
        const responseData = JSON.parse(xhr.responseText);
const stringData = JSON.stringify(responseData);
        const stringData = JSON.stringify(responseData);
responseDataServers.push(stringData);
        responseDataServers.push(stringData);
//console.log(responseData);
        //console.log(responseData);
const jsTest = document.getElementById("jsTest");
        const jsTest = document.getElementById("jsTest");
const divServer = document.createElement('div');
        const divServer = document.createElement('div');
divServer.textContent = stringData;
        divServer.textContent = stringData;
jsTest.appendChild(divServer);
        jsTest.appendChild(divServer);
} else {
      } else {
console.error('Ошибка при выполнении запроса: ' + xhr.status);
        console.error('Ошибка при выполнении запроса: ' + xhr.status);
}
      }
};
    };
xhr.onerror = function() {
    xhr.onerror = function() {
console.error('Ошибка при выполнении запроса');
      console.error('Ошибка при выполнении запроса');
};
    };
xhr.send();
    xhr.send();
}
  }
console.log(responseDataServers);
  console.log(responseDataServers);
}
}
window.onload = function() {
// window.onload = function() {
const currentUrl = window.location.href;
// const currentUrl = window.location.href;
console.log("currentUrl", currentUrl);
// console.log("currentUrl", currentUrl);
if (currentUrl.includes("Kerisar")) {
// if (currentUrl.includes("Kerisar")) {
kerisar();
// kerisar();
getServersStatus();
// getServersStatus();
}
// }
};
// };
 
 
document.addEventListener('DOMContentLoaded', function() {
  const currentUrl = window.location.href;
  console.log("currentUrl", currentUrl);
  if (currentUrl.includes("Kerisar")) {
    kerisar();
    getServersStatus();
  }
});
 
 
 
/*WikiEditor/Викификатор*/
/*WikiEditor/Викификатор*/
if ($.inArray(mw.config.get('wgAction'), ['edit', 'submit']) !== -1) {
if ($.inArray(mw.config.get('wgAction'), ['edit', 'submit']) !== -1) {
mw.loader.load(
  mw.loader.load(
'//ru.wikipedia.org/w/index.php?title=MediaWiki:Gadget-wikificator.js&action=raw&ctype=text/javascript'
    '//ru.wikipedia.org/w/index.php?title=MediaWiki:Gadget-wikificator.js&action=raw&ctype=text/javascript'
);
  );
}
}
var customizeToolbar = function() {
var customizeToolbar = function() {
$('#wpTextbox1').wikiEditor('addToToolbar', {
  $('#wpTextbox1').wikiEditor('addToToolbar', {
'section': 'advanced',
    'section': 'advanced',
'group': 'format',
    'group': 'format',
'tools': {
    'tools': {
'wikify': {
      'wikify': {
label: 'Викификатор',
        label: 'Викификатор',
type: 'button',
        type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/0/06/Wikify-toolbutton.png',
        icon: '//upload.wikimedia.org/wikipedia/commons/0/06/Wikify-toolbutton.png',
action: {
        action: {
type: 'callback',
          type: 'callback',
execute: function(context) {
          execute: function(context) {
Wikify();
            Wikify();
}
          }
}
        }
}
      }
}
    }
});
  });
};
};
if ($.inArray(mw.config.get('wgAction'), ['edit', 'submit']) !== -1) {
if ($.inArray(mw.config.get('wgAction'), ['edit', 'submit']) !== -1) {
mw.loader.using('user.options', function() {
  mw.loader.using('user.options', function() {
if (mw.user.options.get('usebetatoolbar')) {
    if (mw.user.options.get('usebetatoolbar')) {
mw.loader.using('ext.wikiEditor.toolbar', function() {
      mw.loader.using('ext.wikiEditor.toolbar', function() {
$(document).ready(customizeToolbar);
        $(document).ready(customizeToolbar);
});
      });
}
    }
});
  });
}
}

Версия от 12:25, 20 июня 2024

function kerisar() {
  console.log("Проверка консоли");
  //alert("Проверка алерта");
  const jsTest = document.getElementById("jsTest");
  console.log("jsTest", jsTest);
  const buttonTest = document.createElement('button');
  buttonTest.classList.add('testButtonJs');
  jsTest.appendChild(buttonTest);
  const kerisarPicture = document.createElement('img');
  kerisarPicture.setAttribute('src',
    "https://thumb.cloud.mail.ru/weblink/thumb/xw1/LLmd/Qui7Xbp6g");
  //kerisarPicture.src = "Default.aspx?q=" + Math.random();
  jsTest.appendChild(kerisarPicture);
}
const serversConnectors = ['https://game2.station14.ru/main/server/status',
  'https://game2.station14.ru/nova/server/status',
  'https://game2.station14.ru/athara/server/status',
  'https://game2.station14.ru/solaris/server/status',
  'https://game2.station14.ru/echo/server/status',
  'https://game2.station14.ru/elysium/server/status',
  'https://game2.station14.ru/nebula/server/status',
  'https://game2.station14.ru/wl/server/status',
  'https://arles.station14.ru/frontier-main/server/status',
  'https://game1.station14.ru/marines-main/server/status',
  'https://game.stalkers14.xyz/status',

];

function getServersStatus() {
  //console.log(serversConnectors);
  const responseDataServers = [];
  for (var i = 0; i < serversConnectors.length; i++) {
    //console.log(serversConnectors[i]);
    const xhr = new XMLHttpRequest();
    xhr.open('GET', serversConnectors[i], true);
    xhr.onload = function() {
      if (xhr.status >= 200 && xhr.status < 300) {
        const responseData = JSON.parse(xhr.responseText);
        const stringData = JSON.stringify(responseData);
        responseDataServers.push(stringData);
        //console.log(responseData);
        const jsTest = document.getElementById("jsTest");
        const divServer = document.createElement('div');
        divServer.textContent = stringData;
        jsTest.appendChild(divServer);
      } else {
        console.error('Ошибка при выполнении запроса: ' + xhr.status);
      }
    };
    xhr.onerror = function() {
      console.error('Ошибка при выполнении запроса');
    };
    xhr.send();
  }
  console.log(responseDataServers);
}
// window.onload = function() {
// 	const currentUrl = window.location.href;
// 	console.log("currentUrl", currentUrl);
// 	if (currentUrl.includes("Kerisar")) {
// 		kerisar();
// 		getServersStatus();
// 	}
// };


document.addEventListener('DOMContentLoaded', function() {
  const currentUrl = window.location.href;
  console.log("currentUrl", currentUrl);
  if (currentUrl.includes("Kerisar")) {
    kerisar();
    getServersStatus();
  }
});



/*WikiEditor/Викификатор*/
if ($.inArray(mw.config.get('wgAction'), ['edit', 'submit']) !== -1) {
  mw.loader.load(
    '//ru.wikipedia.org/w/index.php?title=MediaWiki:Gadget-wikificator.js&action=raw&ctype=text/javascript'
  );
}
var customizeToolbar = function() {
  $('#wpTextbox1').wikiEditor('addToToolbar', {
    'section': 'advanced',
    'group': 'format',
    'tools': {
      'wikify': {
        label: 'Викификатор',
        type: 'button',
        icon: '//upload.wikimedia.org/wikipedia/commons/0/06/Wikify-toolbutton.png',
        action: {
          type: 'callback',
          execute: function(context) {
            Wikify();
          }
        }
      }
    }
  });
};
if ($.inArray(mw.config.get('wgAction'), ['edit', 'submit']) !== -1) {
  mw.loader.using('user.options', function() {
    if (mw.user.options.get('usebetatoolbar')) {
      mw.loader.using('ext.wikiEditor.toolbar', function() {
        $(document).ready(customizeToolbar);
      });
    }
  });
}