User:Js/ajaxPreview.js

In this article, we will analyze the impact that User:Js/ajaxPreview.js has had in various areas of society. Since its appearance, User:Js/ajaxPreview.js has captured the attention of people of all ages and interests, becoming an omnipresent phenomenon in contemporary culture. Through an exhaustive analysis, we will explore the different perspectives and opinions that exist around User:Js/ajaxPreview.js, as well as its influence in fields as diverse as politics, technology, fashion and entertainment. Additionally, we will examine the role User:Js/ajaxPreview.js has played in the transformation of society and the way people interact with each other. This article will delve into the most relevant aspects of User:Js/ajaxPreview.js, offering a complete and updated vision of this topic that is so relevant today.
window.ajaxPreviewMsg = {
  emptydiff: 'No changes',
 difftip: 'shift-click the button to show changes compared to this old version',
 diff2old: 'comparison to old version',
 viewtip: 'shift-click the button to update interwiki and categories as well\
 (<a href="//en.wikipedia.orghttps://wikifreehand.com/en/User:Js/ajaxPreview#Preview" target=_blank>more</a>)'
};


function ajaxPreviewButtons(){

 var ajaxPreviewPos = window.ajaxPreviewPos || 'right'
 if( !document.getElementById('wpSave') ){
	return;
 }
 mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:Js/preview2.js&action=raw&ctype=text/javascript' );

 if( ajaxPreviewPos != 'bottom' ){
   var previewToolbar = $('<div style="float:'+ajaxPreviewPos+'" />')
   
   if ( mw.user.options.get('usebetatoolbar') ) {
     $('#wikiPreview').after('<div style="width:100%; clear:both" />', previewToolbar)
   } else {
     var el = $('#toolbar')
     if( el.length ) el.prepend(previewToolbar)
     else $('#editform').before(previewToolbar)
   }
 }

 addBtn(window.ajaxPreviewButton, 'wpPreview', window.ajaxPreviewKey || 'p')

 if( mw.config.get( 'wgArticleId' ) )
   addBtn(window.ajaxDiffButton, 'wpDiff', window.ajaxDiffKey || 'v')

 function addBtn(name, id, akey){
  var $btnOld = $(document.getElementById(id))
  if( $btnOld.length === 0 ) return
  var $btn = $('<input type="button" />')
   .attr('id', id + 'Live')
   .attr( 'title', $btnOld.val() + ' (ajax)');
  if( ajaxPreviewPos == 'bottom' ){
    $btn.val( $btnOld.val() ).insertBefore( $btnOld.val('>') )
  }else{
    if( !name ){ //extract last word from standard buttons
      var name = $btnOld.val(); var i = name.lastIndexOf(' ') + 1
      name = name.substring(i, i+1).toUpperCase() + name.substring(i+1)
    }
    $btn.val(name).css({height:'22px', padding:'0 1px'}).appendTo(previewToolbar)
  }
  if( akey ){ //reassign acces key
    if( $btnOld.attr('accesskey') == akey )
      $btnOld.removeAttr('accesskey').updateTooltipAccessKeys()
  $btn.attr('accesskey', akey).updateTooltipAccessKeys()
  }
 }
}



if( $.inArray(mw.config.get('wgAction'), ) !== -1 && mw.config.get('wgCanonicalNamespace') !== 'Special' ){
  mw.loader.using( , function () {
    $(ajaxPreviewButtons);
   } );
}