Użytkownik:Bart-W/dalekopis.js: Różnice pomiędzy wersjami
Z Nonsensopedii, polskiej encyklopedii humoru
Linia 14: | Linia 14: | ||
// ticker_custompages['Portal:PORTALNAME'] = 'Portal:PORTALNAME/Tickersource'; |
// ticker_custompages['Portal:PORTALNAME'] = 'Portal:PORTALNAME/Tickersource'; |
||
// Make sure that the /Tickersource page is formatted like [[User:TheFearow/Tickersource]] (NA ENGILSKIEJ WIKINEWS) using DPLs |
// Make sure that the /Tickersource page is formatted like [[User:TheFearow/Tickersource]] (NA ENGILSKIEJ WIKINEWS) using DPLs |
||
//ticker_custompages['Portal:Mundial 2010'] = 'Portal:2010/Tickersource'; |
//ticker_custompages['Portal:Mundial 2010'] = 'Portal:Mundial 2010/Tickersource'; |
||
//Add custommsgs for all custom pages |
//Add custommsgs for all custom pages |
Aktualna wersja na dzień 20:27, 7 cze 2010
*************************************************************************************/
/* DALEKOPIS SKRADZIONY Z http://pl.wikinews.org/wiki/MediaWiki:Common.js */
/*************************************************************************************/
if(navigator.userAgent.indexOf("MSIE") == -1){ //Disables for IE, AJAX etc is really bugged in IE, wont work without major rewrite and server-side extension.
var ticker_tl=new Array(); //Dont touch
var ticker_speed=20; //Increase to slow down, too low makes it go incredibly slow, 15 is about right
var ticker_index=0; ticker_text_pos=0; //Dont touch
var ticker_str_length; //Dont touch
var ticker_contents, ticker_row; //Dont touch
var ticker_custompages = Array();
var ticker_custommsg = Array();
// Add lines like the following to add custom tickers:
// ticker_custompages['Portal:PORTALNAME'] = 'Portal:PORTALNAME/Tickersource';
// Make sure that the /Tickersource page is formatted like [[User:TheFearow/Tickersource]] (NA ENGILSKIEJ WIKINEWS) using DPLs
//ticker_custompages['Portal:Mundial 2010'] = 'Portal:Mundial 2010/Tickersource';
//Add custommsgs for all custom pages
//ticker_custommsg['Portal:Mundial 2010'] = 'Ostatnie wiadomości z mundialu';
function ticker_prepare(){
ticker_str_length=ticker_tl[0].length
var content = document.getElementById('wstawdalekopis').innerHTML;
if(content != ""){
content += "<br/>\n";
}
var start = "Najnowsze wiadomości";
if(ticker_custommsg[wgBasePageName]){
start = ticker_custommsg[wgBasePageName];
}
var month=['Styczeń', 'Luty', 'Marzec', 'Kwiecień', 'Maj', 'Czerwiec', 'Lipiec', 'Sierpień', 'Wrzesień', 'Październik', 'Listopad', 'Grudzień'];
var monthgen=['stycznia', 'lutego', 'marca', 'kwietnia', 'maja', 'czerwca', 'lipca', 'sierpnia', 'września', 'października', 'listopada', 'grudnia'];
var today = new Date();
var page=encodeURI('#'+today.getDate()+'_'+monthgen[today.getMonth()]+'_'+today.getFullYear());
page = page.replace(/\%/g,'.');
page = 'Portal:'+month[today.getMonth()]+'_'+today.getFullYear() + page;
content += "<div id='ticker_start' style='font-weight: bold; font-size: 120%; display: inline;'>" + start + " <div style='font-size: smaller; display: inline;'>(<a href='" + wgServer + wgScript + "?title=" + page + "'>pełna lista</a>)</div>: </div><div id='ticker_content' style='font-size: 120%; color: blue; display: inline;'></div>";
document.getElementById('wstawdalekopis').innerHTML = content;
}
wgBasePageName = wgPageName;
if(wgPageName.indexOf("/") != -1){
wgBasePageName = wgPageName.substring(0,wgPageName.indexOf("/"));
}
var ticker_toload = "";
function ticker_load(){
try{
var randomunusedtickervariable = document.getElementById('wstawdalekopis').innerHTML;
}catch(err){
return;
}
ticker_toload = "Szablon:Najnowsze_wiadomości";
if(ticker_custompages[wgBasePageName]){
ticker_toload = ticker_custompages[wgBasePageName];
}
xmlhttp = sajax_init_object();
xmlhttp.overrideMimeType('text/xml');
xmlhttp.open( 'GET' , wgServer + wgScriptPath + '/index.php?title=' + ticker_toload + '&action=render', true);
xmlhttp.onload = function() {
//this.responseXML is the DOM
var entries = this.responseText.split("\n");
//window.alert(this.responseText);
for(var i = 0; i < entries.length; i++){
var val = entries[i];
if(val.indexOf("<li>") == 0 && val.indexOf("<a") != -1){
val = val.substring(val.indexOf("\">")+2, val.indexOf("</a>"));
ticker_tl[ticker_tl.length] = val;
}
}
ticker_prepare();
ticker_tick(false, true);
}
xmlhttp.send( null );
}
function ticker_tick(reset, first)
{
if(reset){
document.getElementById("ticker_content").innerHTML = "";
}
if(first){
ticker_index = Math.floor(Math.random() * ticker_tl.length);
ticker_text_pos=0;
ticker_str_length=ticker_tl[ticker_index].length;
}
ticker_contents='';
ticker_row=Math.max(0,ticker_index-7);
//window.alert("TL: "+ticker_tl[ticker_index]);
document.getElementById("ticker_content").innerHTML = ("<a href=\"" + wgServer + wgArticlePath.replace("$1", encodeURIComponent(ticker_tl[ticker_index])) + "\" title=\"" + ticker_tl[ticker_index] + "\">" + ticker_tl[ticker_index].substring(0,ticker_text_pos) + "_</a>").replace("\n", "");
if(ticker_text_pos++>=ticker_str_length)
{
ticker_index++;
if(ticker_index!=ticker_tl.length)
{
ticker_text_pos=0;
ticker_str_length=ticker_tl[ticker_index].length;
if(first){
setTimeout("ticker_tick(true, false)",3);
}else{
setTimeout("ticker_tick(true, false)",7000);
}
}else{
ticker_index = Math.floor(Math.random() * ticker_tl.length);
ticker_text_pos=ticker_tl[ticker_index].indexOf("\">");
ticker_str_length=ticker_tl[ticker_index].length;
setTimeout("ticker_tick(true, false)",3000);
}
} else
setTimeout("ticker_tick(false, false)",ticker_speed);
}
addOnloadHook(ticker_load);
function sajax_init_object() {
var A;
try {
// Try the new style before ActiveX so we don't
// unnecessarily trigger warnings in IE 7 when
// set to prompt about ActiveX usage
A = new XMLHttpRequest();
} catch (e) {
try {
A=new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
A=new ActiveXObject("Microsoft.XMLHTTP");
} catch (oc) {
A=null;
}
}
}
return A;
}
}
/*************************************************************************************/
/* DALEKOPIS KONIEC */
/*************************************************************************************/