Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/** 

  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.

**/


var fb_comment_url =  wgScript+
  "?title=Wiktionary:Feedback"+
  "&action=edit&section=new"+
  "&preload=Wiktionary:Feedback%2Fpreload"+
  "&editintro=Wiktionary:Feedback%2Fintro"+
  "&preloadtitle="+
   encodeURIComponent("[[:"+wgPageName.replace(/_/g, ' ')+"]]");

var fb_thanks = "Thank you for giving us some of your time.";
var fb_comment = "If you have time, leave us a note.";

var fb_questions = new Array();

fb_questions[0] = 
["Submit anonymous feedback about Wiktionary:",
  ['Good', 
   'Bad', 
   'Messy', 
   'Mistake in definition',
   'Confusing',
   'Could not find the word I want', 
   'Incomplete', 
   'Entry has inaccurate information',
   'Definition is too complicated']
];

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

function fb_init(){
  var index = Math.floor(Math.random()*(fb_questions.length)); 
  fb_text = fb_questions[index][0];
  fb_options = fb_questions[index][1]; 
  fb_buildBox();
}

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':"FB"+i},fb_options[i]) 
      )
    );
  }
  sidebar.appendChild(    
    newNode('div',{'class':"portlet",'id':"p-feedback"},
      newNode('a',{'name':"feedback"}),
      newNode('h5',"feedback"),
      newNode('div',{'class':"pBody"},
        newNode('p',{'style':'font-size: 90%'},fb_text),
        list,
        newNode('p',{'style':'font-size: 80%'},
          newNode('a',{'href':fb_comment_url},fb_comment)
        )
      )
    )
  );
}
$(fb_init);
function fb_click(e){
  var fb = false;
  var fbi = false;
  
  try{
    fb = e.target.childNodes[0].nodeValue;
    fbi = e.target.getAttribute('id').replace("FB",'');
  }catch(e){ try{
    fb = window.event.srcElement.childNodes[0].nodeValue;
    fbi = window.event.srcElement.getAttribute('id').replace("FB",'');
  } catch(e){ }}
  
  if(fb){
    fb_send(fb);
    fb_send2(fb,fbi);
  }
  
  var list = document.getElementById('fb_list');
  
  list.parentNode.insertBefore(
    newNode('p',fb_thanks),list
  );
  list.parentNode.removeChild(list);
  
  return false;  
}
//Send to ~cmackenzie
function fb_send(string){
  if(fb_sent) return false;
  fb_sent=true;
  
  var wiki = wgServer.replace(/https?:\/\/([^\.]*)\.([^\.]*)\.org/,"$1$2").replace(/pedia$/,'');
  
  var page = wgPageName;
  if(wgPageName == 'Special:Search'){
    var sb = document.getElementById('lsearchbox');
    if(sb) page+='/'+sb.value;
  }
  var url = "http://toolserver.org/~andrew/simplewikt/"+
    "?action=feedback&wiki=simple.wiktionary" +
    "&title="+encodeURI(page)+
    "&feedback="+encodeURI(string);

  document.body.appendChild(
    newNode('iframe',{'src':url,'style':'display:none'})
 ); 
}
//Send to ~daveross
function fb_send2(string,indx){
  if(fb_sent2) return false;
  fb_sent2  =true;
  var lang = wgServer.replace(/^https?:\/\/([^\.]*).*$/,"$1");
  var wiki = wgServer.replace(/https?:\/\/[^\.]*\.([^\.]*)\.org/,"$1");
  
  var page = wgPageName;
  if(wgPageName == 'Special:Search'){
    var sb = document.getElementById('lsearchbox');
    if(sb) page+='/'+sb.value;
  }
  
  var url = 'http://tools.wikimedia.de/~daveross/feedback.php'
          + '?mode=submit'
          + '&lang='+encodeURI(lang)
          + '&wiki='+encodeURI(wiki)
          + '&page='+encodeURI(page)
          + '&revid='+encodeURI(wgCurRevisionId)
          + '&comment='+encodeURI(string)
          + '&comment_index='+encodeURI(indx*1+1);

  document.body.appendChild(
    newNode('iframe',{'src':url,'style':'display:none'})
  );

}