Kullanıcı:Satirdan kahraman/d1

Vikikaynak, özgür kütüphane

/********************* Bir kitaptan alıntı Yazar: Tpt

                                          • /

if(typeof ws == 'undefined') {

   ws = {};

}

ws.citeBox = {

 defaultTemplate: 'Liste',
 templates: {},
 data: {},
 i18n: { 
   title: 'Quote this book',
   description: 'Bu kitaba atıfta bulunun.',
   display_mode: 'Display mode:'
 },
 isInit: false,
 add: function(name, content) {
   this.templates[name] = content;
 },
 init: function( i18np ) {
   if( $('div#citeBox').length > 0) {
       return;
   }
   $.extend(this.i18n, i18np);
   $.getScript('//wikisource.org/w/index.php?title=MediaWiki:Wikisource.data.js&action=raw&ctype=text/javascript', function() {
     mw.loader.using(['jquery.ui', 'mediawiki.util'], function() {

var message = $('

').appendTo("#content");

       message.dialog({
         autoOpen: false,
         modal: true,
         width: 500,
         buttons: {
           Ok: function() {
             $(this).dialog("close");
           }
         }
       });
       var portletLink = mw.util.addPortletLink('p-tb', '#', ws.citeBox.i18n.title, 't-cite', ws.citeBox.i18n.description);
       ws.citeBox.data = ws.data.getAll();
       $(portletLink).click(function() {
         ws.citeBox.open();
       });
       ws.citeBox.isInit = true;
     });
   });
 },
 getContent: function() {

var content = '

<label for="citeBox-select">' + this.i18n.display_mode + '</label> <select id="citeBox-select">'; for(var id in this.templates) { content += '<option value="' + id + '">' + id + '</option>'; } content += '</select>

' + this.format(this.defaultTemplate) + '

';

   return content;
 },
 format: function(id) {
   var func = this.templates[id];
   return func(this.data);
 },
 open: function() {
 	if(!ws.citeBox.isInit) {
 		//Wait for initialization
 		setTimeout(ws.citeBox.open, 100);
 		return;
 	}
   var citeBox = $('div#citeBox');
   if(citeBox.text() == ) {
     citeBox.html(ws.citeBox.getContent());
     $("select#citeBox-select").change(function () {
       var node = $("select#citeBox-select option:selected");
       if(node.length)
         $('#citeBox-content').html(ws.citeBox.format(node.text()));
     });
   }
   citeBox.dialog("open");
 }

};

/* Configuration : utiliser la fonction ws.citeBox.add prenant en premier paramètre le nom du type de référence et sen second une fonction prenant en paramètre un tableau associatif des métadonnées et retournant la référence.

  • /

if((mw.config.get('wgNamespaceNumber') == 0 || mw.config.get('wgCanonicalNamespace') == 'Index') && (mw.config.get('wgAction') == 'view' || mw.config.get('wgAction') == 'purge')) {

 $(function() {
   ws.citeBox.add('Liste', function(data) {

content = '

    '; if(data.title) content += '
  • Başlık: ' + data.title + '
  • '; if(data.periodical) content += '
  • Dergi: ' + data.periodical + '
  • '; if(data.volume) content += '
  • Cilt: ' + data.volume + '
  • '; if(data.author) content += '
  • Yazar(lar) : ' + data.author + '
  • '; if(data.translator) content += '
  • Çevirmen(ler) : ' + data.translator + '
  • '; if(data.illustrator) content += '
  • Resimleyen(ler) : ' + data.illustrator + '
  • '; if(data.publisher) content += '
  • Editör: ' + data.publisher + '
  • '; if(data.school) content += '
  • Kurum: ' + data.school + '
  • '; if(data.year) content += '
  • Yayımcı: ' + data.year + '
  • '; if(data.place) content += '
  • Basım yeri: ' + data.place + '
  • '; if(data.chapter) content += '
  • Bölüm: ' + data.chapter + '
  • '; if(data.pages) { if(data.pages.length > 4) { content += '
  • Sayfalar: ' + data.pages + '
  • '; } else { content += '
  • Sayfa: ' + data.pages + '
  • '; } } content += '

';

     return content;
   });
   ws.citeBox.add('BibTeX', function(data) {

content = '

@Book{\n';
      if(data.type)
        content += '  type = "' + data.type + '",\n';
      if(data.title)
        content += '  title = "' + data.title + '",\n';
      if(data.volume)
        content += '  volume = "' + data.volume + '",\n';
      if(data.author)
        content += '  author = "' + data.author + '",\n';
      if(data.publisher)
        content += '  publisher = "' + data.publisher + '",\n';
      if(data.school)
        content += '  school = "' + data.school + '",\n';
      if(data.year)
        content += '  year = "' + data.year + '",\n';
      if(data.place)
        content += '  place = "' + data.place + '",\n';
      if(data.chapter)
        content += '  chapter = "' + data.chapter + '",\n';
      if(data.pages)
        content += '  pages = "' + data.pages + '",\n';
      content += '  url = "' + document.location.href + '",\n';
      content += '}

';

     return content;
   });
   ws.citeBox.add('Vikipedi', function(data) {

content = '

{{Ouvrage\n';
      content += '|başlık= ' + data.title + '\n';
      content += '|yazar= ' + data.author + '\n';
      if(data.translator)
        content += '|çevirmen= ' + data.translator + '\n';
      if(data.illustrator)
        content += '|resimleyen= ' + data.illustrator + '\n';
      content += '|editör= ' + data.publisher + '\n';
      content += '|yıl= ' + data.year + '\n';
      if(data.place)
        content += '|basım yeri= ' + data.place + '\n';
      if(data.volume)
        content += '|cilt= ' + data.volume + '\n';
      if(data.chapter)
        content += '|bölüm= ' + data.chapter + '\n';
      if(data.pages)
        content += '|kısım= ' + data.pages + '\n';
      content += '|langue= tr\n';
      content += '|wikisource= ' + mw.config.get('wgTitle') + '\n';
      content += '}}

';

     return content;
   });
   ws.citeBox.add('Vikisöz', function(data) {

content = '

{{Réf Livre\n';
      content += '|başlık= ' + data.title + '\n';
      content += '|yazar= ' + data.author + '\n';
      content += '|editör= ' + data.publisher + '\n';
      content += '|yıl= ' + data.year + '\n';
      content += '|sayfa= ' + data.pages + '\n';
      if(data.volume)
        content += '|cilt= ' + data.volume + '\n';
      if(data.chapter)
        content += '|kısım= ' + data.chapter + '\n';
      if(data.translator)
        content += '|çevirmen= ' + data.translator + '\n';
      content += '|s= ' + mw.config.get('wgTitle') + '\n';
      content += '}}

';

     return content;
   });
   ws.citeBox.add('Vikisözlük', function(data) {

content = '

{{source|';
      content += data.author;
      content += ", ''{{ws|" + mw.config.get('wgTitle') + '|' + data.title + "}}''";
      if(data.publisher)
        content += ', ' + data.publisher;
      if(data.year)
        content += ', ' + data.year;
      if(data.pages) {
      	if(isNaN(data.pages)) {
          content += ', pages ' + data.pages;
      	} else {
          content += ', page ' + data.pages;
      	}
      }
      content += '}}

';

     return content;
   });
   var i18n = {
     title: 'Bu metni alıntılayın',
     description: 'Bu metni farklı bir formatta alıntılayın.',
     display_mode: 'Görüntüleme biçimi :'
   };
   ws.citeBox.init( i18n );
 });

}