کاربر:Shervinafshar/statuschanger.js

از ویکی‌پدیا، دانشنامهٔ آزاد.

نکته: پس از ذخیره‌سازی ممکن است برای دیدن تغییرات نیاز باشد که حافظهٔ نهانی مرورگر خود را خالی کنید. موزیلا / فایرفاکس / Safari: کلید Shift را نگه‌دارید و روی دکمهٔ Reload کلیک کنید، یا کلید‌های Ctrl-Shift-R را با هم فشار دهید (در رایانه‌های اپل مکینتاش کلید‌های Cmd-Shift-Rاینترنت اکسپلورر: کلید Ctrl نگه‌دارید و روی دکمهٔ Refresh کلیک‌ کنید، یا کلید‌های Ctrl-F5 را با هم فشار دهید؛ Konqueror: روی دکمهٔ Reload کلیک کنید و یا کلید F5 را فشار دهید؛ اُپرا: کاربران اُپرا ممکن است لازم باشد که بطور کامل حافظهٔ نهانی مرورگر را در منوی Tools→Preferences خالی کنند.

function addlilink(tabs, url, name, id, title, key){
    var na = document.createElement('a');
    na.href = url;
    na.appendChild(document.createTextNode(name));
    var li = document.createElement('li');
    if(id) li.id = id;
    li.appendChild(na);
    tabs.appendChild(li);
    if(id)
    {
        if(key && title)
        {
            ta[id] = [key, title];
        }
        else if(key)
        {
            ta[id] = [key, ''];
        }
        else if(title)
        {
            ta[id] = ['', title];
        }
    }
    // re-render the title and accesskeys from existing code in wikibits.js
    akeytt();
    return li;
}

/* <pre><nowiki> */

addOnloadHook(StatusChange);

/*** Status changer ***/
function StatusChange() {
  var user = document.getElementById( 'pt-userpage' ).firstChild.firstChild.data;
  var subpage = "/Status";
  var scheme = "/StatusTemplate";
  var table = "/StatusTable";
  var linkprefix = "http://fa.wikipedia.org/w/index.php?title=User:";
  var wheretoadd = document.getElementById( 'p-personal' );
  //Add the links
  addlilink(wheretoadd, linkprefix+user+subpage+"&action=edit&newstatus=away", "دور )", "pt-status-away", "دور از رایانه", "");
  addlilink(wheretoadd, linkprefix+user+subpage+"&action=edit&newstatus=out", "غیرفعال", "pt-status-out", "غیرفعال", "");
  addlilink(wheretoadd, linkprefix+user+subpage+"&action=edit&newstatus=patrol", "نگهبانی", "pt-status-hide", "نگهبانی", "");
  addlilink(wheretoadd, linkprefix+user+subpage+"&action=edit&newstatus=in", " فعال", "pt-status-in", "فعال", "");
  addlilink(wheretoadd, linkprefix+user+subpage+"&action=edit&newstatus=busy", "( مشغول", "pt-status-busy", "مشغول", "");


  if (location.href.indexOf("User:"+user+subpage+"&action=edit&newstatus=") == -1) return; //Are we here to auto-edit the status?
  //Get new status
  status = location.href.split("=");
  status = status[status.length-1];
  //Modify the form
  document.getElementById('wpTextbox1').value = "{{User:"+user+scheme+"|"+status+"}}";
  document.getElementById('wpSummary').value = "وضعیت :  "+status;
  document.getElementById('wpMinoredit').checked = 'checked';
  //Submit it!
  document.getElementById('editform').submit();
}

/* </nowiki></pre> */