User:Legoktm/imtc.js

From Wikipedia, the free encyclopedia

Note: After saving, you have to bypass your browser's cache to see the changes. In Internet Explorer and Firefox, hold down the Ctrl key and click the Refresh or Reload button. Opera users have to clear their caches through Tools→Preferences, see the instructions for Opera. Konqueror and Safari users can just click the Reload button.

// Please do not use
// It has been customized by [[User:Legoktm]] for him.
if(wgNamespaceNumber == 6) {
  if(wgAction == 'edit' || wgAction == 'submit') {
    addOnloadHook(function () { addPortletLink('p-cactions','javascript:doiMtc()','imtc','ca-imtc'); });
  } else {
    var url = wgServer + wgScript + '?title=' + 'User:Legoktm/MTC/Done' + '&action=edit&autoimtc=true';
    addOnloadHook(function () { addPortletLink('p-cactions',url,'imtc','ca-imtc'); });
  }
}
if(queryString('autoimtc')) addOnloadHook(function() { doiMtc(); })
function doiMtc() {
  var txt = document.getElementById('wpTextbox1');
  if(!txt) return;
  txt.value = '<' + 'gallery>[[' + encodeURIComponent(wgPageName) + ']]</galler>\n\n' + txt.value;
  document.getElementById('wpSummary').value += 'adding to my gallery';
  document.getElementById('wpPreview').click();
}
 
function queryString(p) {
  var re = RegExp('[&?]' + p + '=([^&]*)');
  var matches;
  if (matches = re.exec(document.location)) {
    try { 
      return decodeURI(matches[1]);
    } catch (e) {
    }
  }
  return null;
}