MediaWiki:If-anon-feedback.js/Schopf

Us der alemannische Wikipedia, der freie Dialäkt-Enzyklopedy

/*

Adds a feedback to to the bottom of the page on the left. This has only been tested with Monobook as it is intended for IPs only!
Based on wikt:en:User:Conrad.Irwin/feedback.js!
See also: w:als:MediaWiki:If-WikiPoll.js
  • /

var fb_thanks = "Merci vilmol!"; var fb_comment = "De Artikl kommentyre?"; var fb_page = mw.config.get('wgPageName'); if(fb_page == 'Spezial:Suche'){

 var sBox = document.getElementById('lsearchbox');
 if(sBox) fb_page+='/'+sBox.value;

} var fb_url = "http://tools.wikimedia.de/~cmackenzie/feedback.php?fb_wiki=alswiki&fb_page="+encodeURI(fb_page); var fb_url2 = "http://tools.wikimedia.de/~daveross/feedback.php?mode=submit&lang=als&wiki=wikipedia&page="+encodeURI(fb_page); var fb_url3 = "http://tools.wikimedia.de/~daveross/feedback.php?mode=view&langs=als&wikis=wikipedia&pages="+encodeURI(fb_page); if (document.URL.indexOf("oldid=") > 0) {

var oldID = document.URL.replace(/^.+?(diff|oldid)=([0-9]+).*$/, "$2"); // diff 99.99% comes first
var fb_result = fb_url+"&fb_revid="+oldID;
var fb_result2 = fb_url3+"&revids="+oldID;

} else {

var fb_result = fb_url+"&fb_revid="+wgCurRevisionId;
var fb_result2 = fb_url3+"&sort=revid";

} var fb_comment_url = "/wiki/Diskussion:"+mw.config.get('wgPageName');

var fb_questions = new Array();

fb_questions[0] = ["Dér Artikl isch",

 ['guet glunge',
  'akzeptaabl',
  'uugnou',
  'schleacht',
  'fählerhaft']

];

var fb_options; var fb_text; var fb_sent = false; var fb_sent2= false;

function fb_init(){

 fb_text = fb_questions[0][0];
 fb_options = fb_questions[0][1];
 if (!$("p-feedback")) {fb_buildBox();}

}

document.write('<style type="text/css">#p-feedback .pBody {background: #FFFFFF url(//upload.wikimedia.org/wikipedia/commons/f/f9/BG_comunit%C3%A0.jpg) center no-repeat;} #fb_list {margin: -0.3em 0 0.3em 2.7em;} #fb_text {color: #424242; font-size: 95%; font-weight: bold; margin-left: 0.8em;} #p-feedback a {cursor: pointer;} #fb_comment {font-size: 82%; margin-left: 0.7em;} #fb_thanks {margin: 0.5em 0 0.3em 1.7em;}<\/style>'); function fb_buildBox(){

 var sidebar = document.getElementById('column-one');
 if(!sidebar) return false;
 var list = newNode('ul',{'id':'fb_list'});
 for(var i=0;i<fb_options.length;i++){
   list.appendChild( 
     newNode('li',
       newNode('a',{'click':fb_click, 'id':i},fb_options[i])
     )
   );
 }
 sidebar.insertBefore(
   newNode('div',{'class':"portlet",'id':"p-feedback"},
     newNode('h5',
       newNode('a',{'href':fb_result2, 'target':'_blank'},"Ruckmäldig")
     ),
     newNode('div',{'class':"pBody"},
       newNode('p',{'id':'fb_text'},fb_text),
       list,
       newNode('p',{'id':'fb_comment'},
         newNode('a',{'href':fb_comment_url},fb_comment)
       )
     )
   ), document.getElementById("p-tb")
 );

} $(fb_init); function fb_click(e){

 var fb = false;
 var fbi = false;
 try{
   fb = e.target.childNodes[0].nodeValue;
   fbi = e.target.getAttribute('id');
 }catch(e){ try{
   fb = window.event.srcElement.childNodes[0].nodeValue;
   fbi = window.event.srcElement.getAttribute('id');
 } catch(e){ }}
 var ask = confirm("Dean Artikl as „"+fb+"“ mèlde?");
 if (ask == true) {
   if(fb){
     if (fbi > 1) {
       fb_enquiry = prompt("Bitte gib no kurz und knapp a, wo gnou ebbas „"+fb+"“ isch:", "allgmein");
       if (fb_enquiry != null && fb_enquiry != "") {fb += " ("+fb_enquiry+")";}
     }
     fb_send(fb);
     fb_send2(fb,fbi);
   }
   var list = document.getElementById('fb_list');
   list.parentNode.insertBefore(
     newNode('p',{'id':'fb_thanks'},
       newNode('a',{'href':fb_result2, 'target':'_blank'},fb_thanks)
     ),list
   );
   list.parentNode.removeChild(document.getElementById("fb_text"));
   list.parentNode.removeChild(list);
   return false;
 }

} // Send to ~cmackenzie function fb_send(string){

 if(fb_sent) return false;
 fb_sent=true;
 var date = new Date(); // Date parameter not required, if UTC
 var yr = date.getFullYear();
 var mth = date.getMonth()+1;
 mth=(mth<10)?"0"+mth.toString():mth;
 var day = date.getDate();
 day=(day<10)?"0"+day.toString():day;
 var url = fb_url+"&fb_revid="+wgCurRevisionId+"&fb_comment="+encodeURI(string)+"&fb_date="+yr+"-"+mth+"-"+day;
 document.body.appendChild(
   newNode('iframe',{'src':url,'class':'hiddenStructure'})
);

} // Send to ~daveross function fb_send2(string,indx){

 if(fb_sent2) return false;
 fb_sent2=true;
 var date = new Date(); // Date parameter not required, if UTC
 var yr = date.getFullYear();
 var mth = date.getMonth()+1;
 mth=(mth<10)?"0"+mth.toString():mth;
 var day = date.getDate();
 day=(day<10)?"0"+day.toString():day;
 indx++;
 var url = fb_url2+"&revid="+wgCurRevisionId+"&comment="+encodeURI(string)+"&comment_index="+indx+"&date="+yr+"-"+mth+"-"+day;
 document.body.appendChild(
   newNode('iframe',{'src':url,'class':'hiddenStructure'})
 );

}

// DOM abbreviation function function newNode(tagname){

 var node = document.createElement(tagname);
 for( var i=1;i<arguments.length;i++ ){
   if(typeof arguments[i] == 'string'){ //Text
     node.appendChild( document.createTextNode(arguments[i]) );
   }else if(typeof arguments[i] == 'object'){ 
     if(arguments[i].nodeName){ //If it is a DOM Node
       node.appendChild(arguments[i]);
     }else{ //Attributes (hopefully)
       for(var j in arguments[i]){
         if(j == 'class'){ //Classname different because...
           node.className = arguments[i][j];
         }else if(j == 'style'){ //Style is special
           node.style.cssText = arguments[i][j];
         }else if(typeof arguments[i][j] == 'function'){ //Basic event handlers
           try{ node.addEventListener(j,arguments[i][j],false); //W3C
           }catch(e){try{ node.attachEvent('on'+j,arguments[i][j],"Language"); //MSIE
           }catch(e){ node['on'+j]=arguments[i][j]; }}; //Legacy
         }else{
           node.setAttribute(j,arguments[i][j]); //Normal attributes
         }
       }
     }
   }
 }
 return node;

}