User:Iceblock/Scripts/Helpdesk.js

/*
 * Documentation: This script adds a link to the personal tools
 * with information about the latest Help desk post.
 * Clicking the tab will show the latest Help desk diff. 
 *
 *
 * This script is based on the script
 *
 * http://no.wikipedia.org/wiki/MediaWiki:Gadget-HurtigSlett.js
 *
 * In this script, the query string and links are modified to check the Help desk revision info.
 * In the function names, 'qd' is replaced with 'helpdesk'.
 *
 * An unused function (function displayQuickDelete()) is removed from this script.
 * 
 */







/* Memo to self, den som skal sjekkes mot er denne */
/* http://no.wikipedia.org/w/api.php?action=query&list=categorymembers&cmtitle=Kategori:Sider%20som%20er%20foresl%E5tt%20raskt%20slettet&format=xml */
 
/* Vi har to mulige valg å legge denne på: */
/* <div id="p-cactions" class="portlet"> <-- Brukerside, diskusjon, overvåk, etc. */
/* <div class="portlet" id="p-personal"> <-- Brukernavn, min diskusjonsside, innstillinger, etc. */


/* (function displayQuickDelete() removed) */




 
/* init ajax */
function helpdesk_create_request() {

  try {
    helpdesk_http = new XMLHttpRequest();
 
  } catch (e) {
    try {
      helpdesk_http = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        helpdesk_http = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e) {
        alert("Your browser does not support AJAX!");
        return false;
      }
    }
  }
 
  helpdesk_http.onreadystatechange = function() {
    if(helpdesk_http.readyState == 4) helpdesk_ajax_response();}
 
  return true;
}
 

/* make a request */
function helpdesk_ajax_request() {
  var api_link = mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/api.php?action=query&prop=revisions&titles=Wikipedia:Help%20desk&format=xml';
  if (helpdesk_create_request () == false) {
     return;
  }
 
  // Then make the request
  helpdesk_http.open("GET", api_link, true);
  helpdesk_http.send(null);
}



/* we have received a response */
function helpdesk_ajax_response() {


  var refresh_time = 60;
  var link = mw.config.get('wgServer') + mw.config.get('wgScript') + '?title=Wikipedia:Help_desk&diff=cur';
  var items = helpdesk_http.responseXML.getElementsByTagName('rev')[0].getAttribute('comment');
  var user = helpdesk_http.responseXML.getElementsByTagName('rev')[0].getAttribute('user');
  //items.length;

  var aNode = document.createElement('a');
  var liNode = document.createElement('li');
 
  aNode.appendChild(document.createTextNode('Latest Help desk post (by ' + user + ')' + (items.length>0?': ':'') + items));
  aNode.setAttribute('href', link);
  aNode.setAttribute('id', 'pt-helpdesk');
  liNode.appendChild(aNode);
  liNode.className='plainlinks';
  document.getElementById('p-personal').getElementsByTagName('ul')[0].insertBefore(liNode, document.getElementById('p-personal').getElementsByTagName('ul')[0].getElementsByTagName('li')[0]);
 

 
  /* Repeat */
  /* Actually, I think we should not repeat, check if it is updated on page refresh, and if that is enough */
//  setTimeout("helpdesk_ajax_request()", refresh_time * 1000);
}

$(helpdesk_ajax_request);

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.