User:Hippietrail/citetab.js

Hello, you have come here looking for the meaning of the word User:Hippietrail/citetab.js. In DICTIOUS you will not only get to know all the dictionary meanings for the word User:Hippietrail/citetab.js, but we will also tell you about its etymology, its characteristics and you will know how to say User:Hippietrail/citetab.js in singular and plural. Everything you need to know about the word User:Hippietrail/citetab.js you have here. The definition of the word User:Hippietrail/citetab.js will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofUser:Hippietrail/citetab.js, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.
importScript('User:Hippietrail/hippajax.js');
 
// TODO support Citations:xxx namespace and xxx/Ciations pseudo-subpage
// TODO use api.php instead of lookforlink() so we can look for several links at once:
// TODO  format=jsonfm&action=query&redirects&titles=pyramid|Talk:pyramid|Citations:pyramid|pyramid/Citations

// look for a wiki link with a specific title attribute and return the link's class name
// possible returns: null, '', 'new', 'new selected', 'selected new'
function lookforlink(tabli, title) {
  var foundclass = 'dunno';
 
  var bc, allas = -1; 
 
  if (bc = document.getElementById('bodyContent'))
    allas = bc.getElementsByTagName('a'); 
 
  if (allas != -1) {
    for (var i = 0; i < allas.length; i++) {
      if (allas.title == title) {
        foundclass = allas.className;
        break;
      }
    }
  }
 
  // no link in this document so use ajax
  if (foundclass == 'dunno') {
    var li = tabli;
    var url = wgScriptPath + '/index.php?title=' + title + '&action=raw';
    function on200(req) {
      li.className = null;
    };
    function on404() {
      li.className = 'new';
      li.firstChild.href = li.firstChild.href.replace(/\/wiki\/(.*)/, 'https://en.wiktionary.org/w/index.php?title=$1&action=edit');
    };
    ajax(url, on200, on404);
  }
 
  return foundclass;
}
 
// set or change the class and href of a tab
function fixtab(li, classes, title)
{
  if (classes && classes.match(/\bnew\b/))
    li.firstChild.href = wgScriptPath + '/index.php?title=' + title + '&action=edit';
  else
    li.firstChild.href = 'https://dictious.com/en/' + title;
 
  if (classes != null)
    li.className = classes;
  else
    //li.removeAttribute('className');
    li.className = null;
}
 
// add citations tab
function addCiteTab() {
  var currentpagetype = 'dunno';
 
  var maintitle;
  var talktitle;
  var citetitle;
 
  // make the correct article names for each tab
  switch (wgNamespaceNumber)
  {
  case 0:
    if (wgTitle.search(/\/Citations$/) != -1) {
      currentpagetype = 'cite';
      maintitle = wgTitle.replace(/^(.*)\/Citations$/, '$1');
      talktitle = 'Talk:' + maintitle;
      citetitle = wgTitle;
    } else {
      currentpagetype = 'article';
      maintitle = wgTitle;
      talktitle = 'Talk:' + maintitle;
      citetitle = wgTitle + '/Citations';
    }
    break;
  case 1:
    currentpagetype = 'talk';
    maintitle = wgTitle;
    talktitle = 'Talk:' + maintitle;
    // TODO xxx/Citations if it exists and Citations:xxx doesn't, Citations:xxx otherwise
    citetitle = wgTitle + '/Citations';
    break;
  case 114:
    currentpagetype = 'newcite';
    maintitle = wgTitle;
    talktitle = 'Talk:' + maintitle;
    citetitle = 'Citations:' + maintitle;
    break;
  default:
    return;
  }
 
  var maintabli = document.getElementById('ca-nstab-main');
  var talktabli = document.getElementById('ca-talk');
  var newcitetabli = document.getElementById('ca-nstab-citations');
  var citetabli = document.createElement('li');
  citetabli.id = 'ca-cite';
  citetabli.appendChild(document.createElement('a'));
  citetabli.firstChild.appendChild(document.createTextNode('citations'));
 
  if (maintabli == null && newcitetabli != null) maintabli = newcitetabli;

  if (currentpagetype == 'article' || currentpagetype == 'talk') {
    fixtab(citetabli, lookforlink(citetabli, citetitle), citetitle);
 
  } else if (currentpagetype == 'cite' || currentpagetype == 'newcite') {
    // move article tab href and classes to cite tab
    fixtab(citetabli, maintabli.className, citetitle);
 
    fixtab(maintabli, lookforlink(maintabli, maintitle), maintitle);
    fixtab(talktabli, lookforlink(talktabli, talktitle), talktitle);
  }
 
  // add the cite tab
  talktabli.parentNode.insertBefore(citetabli, talktabli.nextSibling);
 
  localisecitetab(citetabli);
}
 
//////////////////////////////////////////////////////////////////////
 
//importScript('User:Hippietrail/wfMsgCentre.js');
document.write('<script type="text/javascript" src="https://en.wiktionary.org/w/index.php?title=User:Hippietrail/wfMsgCentre.js&action=raw&ctype=text/javascript"><\/script>');
 
var wgCiteTabMsgArray;
 
function localisecitetab(citetabli) {
  if (wgNamespaceNumber == 0 || wgNamespaceNumber == 1 || wgNamespaceNumber == 114) {
    var msgctr = wfMsgCentreFactory.create();
    wgCiteTabMsgArray = new Object();
 
    wgCiteTabMsgArray = { forcontent: true, obj: citetabli.firstChild.firstChild, attr: 'nodeValue' };
    wgCiteTabMsgArray = { forcontent: true, obj: citetabli.firstChild, attr: 'title' };
    // TODO accesskey
 
    msgctr.batch(wgCiteTabMsgArray);
  }
}