MediaWiki:Block.js

ХӀара гӀирс Википеди чуьра бу — маьрша энциклопеди

Билгалдаккхар: Ӏалашйинчул тӀаьхьа хийцамаш га браузеран кэш цӀанйан йезаш хила мега.

  • Firefox / Safari: Shift тӀетаӀийна йитина, гӀирсийн панелан тӀера тӀетаӀайе Карлайаккха йа Ctrl+F5 йа Ctrl+R (⌘+R Mac тӀехь)
  • Google Chrome: тӀетаӀайе Ctrl+Shift+R (⌘+Shift+R Mac тӀехь)
  • Internet Explorer / Edge: тӀетаӀийна йитина Ctrl, тӀетаӀайе Карлайаккха йа тӀетаӀайе Ctrl+F5
  • Opera: тӀетаӀайе Ctrl+F5.
//for [[special:block]]

elem('Reason').change( function(){

  if( /тӀеэца йиш йоцу цӀе/.test(this.value) ){
    elem('Expiry', 'indefinite')
    if( /\(рекламин\)/.test(this.value) ) {
      elem('CreateAccount', false)
      elem('DisableEmail', false)
      elem('AutoBlock', false)
    }

  }else if( /къайлайокху сервер/.test(this.value) ){
    elem('CreateAccount', true)
    elem('DisableEmail', true)
    elem('HardBlock', true)
    if( elem('Expiry').val() == 'other' && ! elem('Expiry-other').val() )
      elem('Expiry', '5 years')
  }

})



// get/set MW input element
function elem(name, value){ 
 var $el = $('#mw-input-wp' + name)
 if( !$el.length ) $el = $('[name="wp' + name + '"]')
 if( value !== undefined ){ //set value
   if( $el.prop('tagName') == 'SELECT' ){
     $el.find('option[value*="'+value+'"]').attr('selected', 'selected').end().change()
   }else if( $el.prop('type') == 'checkbox' ){
     $el.setAndHighlight(value)
   }else{ //text
     if( /-other$/.test(name) ) elem( name.replace(/-other$/,''), 'other') //set 'select' above
     $el.val(value)
   }	 
 } 
 return $el  
}


//highlighting changed checkboxes
mw.util.addCSS('input.highlighted {background-color:#aaa}')
jQuery.fn.setAndHighlight = function(val){
 if( $(this).prop('checked') == !! val ) return
 $(this).prop('checked', val).addClass('highlighted')
 setTimeout(function(){ $('.highlighted').removeClass('highlighted')}, 1000)
}