MediaWiki:Common.js: Revizyonlar arasındaki fark

TIPlopedi sitesinden
Gezinti kısmına atla Arama kısmına atla
(" →‎Buraya konulacak JavaScript kodu sitedeki her kullanıcı için her sayfa yüklendiğinde çalışacaktır: function addLink() { var body_element = doc..." içeriğiyle yeni sayfa oluşturdu)
 
Değişiklik özeti yok
1. satır: 1. satır:


/* Buraya konulacak JavaScript kodu sitedeki her kullanıcı için her sayfa yüklendiğinde çalışacaktır */
function addLink() {
function addLink() {


var body_element = document.getElementsByTagName(‘body’)[0];
var body_element = document.getElementsByTagName('body')[0];


var selection;
var selection;
9. satır: 8. satır:
selection = window.getSelection();
selection = window.getSelection();


var pagelink = <br /><br /> Kaynak: <a href='+document.location.href+”‘>+document.location.href+</a><br />;
var pagelink = "<br /><br /> Kaynak: <a href='"+document.location.href+"'>"+document.location.href+"</a><br />";
if(selection.toString().length>150)
{
        var copytext = selection + pagelink;


var copytext = selection + pagelink;
        var newdiv = document.createElement('div');


var newdiv = document.createElement(‘div’);
        newdiv.style.position='absolute';


newdiv.style.position=’absolute’;
        newdiv.style.left='-99999px';


newdiv.style.left=’-99999px’;
        body_element.appendChild(newdiv);


body_element.appendChild(newdiv);
        newdiv.innerHTML = copytext;


newdiv.innerHTML = copytext;
        selection.selectAllChildren(newdiv);


selection.selectAllChildren(newdiv);
        window.setTimeout(function() {


window.setTimeout(function() {
        body_element.removeChild(newdiv);


body_element.removeChild(newdiv);
        },0);
 
},0);


}
}
}


document.oncopy = addLink;
document.oncopy = addLink;

00.38, 30 Kasım 2018 tarihindeki hâli


function addLink() {

var body_element = document.getElementsByTagName('body')[0];

var selection;

selection = window.getSelection();

var pagelink = "<br /><br /> Kaynak: <a href='"+document.location.href+"'>"+document.location.href+"</a><br />"; 
if(selection.toString().length>150)
 {
        var copytext = selection + pagelink;

        var newdiv = document.createElement('div');

        newdiv.style.position='absolute';

        newdiv.style.left='-99999px';

        body_element.appendChild(newdiv);

        newdiv.innerHTML = copytext;

        selection.selectAllChildren(newdiv);

        window.setTimeout(function() {

        body_element.removeChild(newdiv);

        },0);

 }
}

document.oncopy = addLink;