মিডিয়াউইকি:Wikisource.citeBox.js

উইকিসংকলন থেকে
টীকা: সংরক্ষণ করার পর, পরিবর্তনসমূহ তৎক্ষণাৎ নাও দেখাতে পারে। আপনার ব্রাউজারের ক্যাশ কিভাবে এড়াবেন তা জানতে এখানে ক্লিক করুন।
  • ফায়ারফক্স / সাফারি: Shift ধরে রাখা অবস্থায়পুনঃলোড করুন-এ ক্লিক করুন, অথবা Ctrl-F5 বা Ctrl-R (ম্যাক-এ ⌘-R) চাপুন
  • গুগল ক্রোম: Ctrl-Shift-R (ম্যাক-এ ⌘-Shift-R) চাপুন
  • ইন্টারনেট এক্সপ্লোরার: Ctrl ধরে রাখা অবস্থায় Refresh-এ ক্লিক করুন, অথবা Ctrl-F5 চাপুন
  • অপেরা: মেনু → ব্যবস্থাপনাসমূহ-এ যান (ম্যাকে অপেরা → পছন্দসমূহ) এবং এরপর গোপনীয়তা ও সুরক্ষা → ব্রাউজিং-এর তথ্য পরিষ্কার করুন → ক্যাশে করা ছবি ও ফাইলগুলি

অন্যান্য ব্রাউজার সম্পর্কে বিশদ নির্দেশাবলীর জন্য, উইকিপিডিয়া:আপনার ক্যাশে বাইপাস করুন দেখুন।

/*********************
একটি বইয়ের উদ্ধৃতি
লেখক: Tpt
*********************/
if(typeof ws == 'undefined') {
    ws = {};
}

ws.citeBox = {
  defaultTemplate: 'তালিকা',
  templates: {},
  data: {},
  i18n: { 
    title: 'এই বই উদ্ধৃত করুন',
    description: 'এই বই উদ্ধৃত করুন।',
    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'], function() {
        var message = $('<div id="citeBox" title="' + ws.citeBox.i18n.title + '"></div>').appendTo("#content");
        message.dialog({
          autoOpen: false,
          modal: true,
          width: 500,
          buttons: {
            বন্ধ: 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 = '<p><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></p><div id="citeBox-content">' + this.format(this.defaultTemplate) + '</div>';
    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: use the function ws.citeBox.add taking first the name of the reference type and second a function taking an associative array of metadata and returning the reference.
*/
if((mw.config.get('wgNamespaceNumber') == 0 || mw.config.get('wgNamespaceNumber') == 112) && (mw.config.get('wgAction') == 'view' || mw.config.get('wgAction') == 'purge')) {
  $(function() {
    ws.citeBox.add('তালিকা', function(data) {
      content = '<ul>';
      if(data.title)
        content += '<li>শিরোনাম : ' + data.title + '</li>';
      if(data.periodical)
        content += '<li>পর্যায় : ' + data.periodical + '</li>';
      if(data.volume)
        content += '<li>খণ্ড : ' + data.volume + '</li>';
      if(data.author)
        content += '<li>লেখক : ' + data.author + '</li>';
      if(data.translator)
        content += '<li>অনুবাদক : ' + data.translator + '</li>';
      if(data.illustrator)
        content += '<li>প্রচ্ছদশিল্পী : ' + data.illustrator + '</li>';
      if(data.publisher)
        content += '<li>প্রকাশক : ' + data.publisher + '</li>';
      if(data.school)
        content += '<li>বিদ্যালয় : ' + data.school + '</li>';
      if(data.year)
        content += '<li>প্রকাশসাল : ' + data.year + '</li>';
      if(data.place)
        content += '<li>প্রকাশস্থান : ' + data.place + '</li>';
      if(data.chapter)
        content += '<li>অধ্যায় : ' + data.chapter + '</li>';
      if(data.pages) {
        if(data.pages.length > 4) {
          content += '<li>পৃষ্ঠাসমূহ : ' + data.pages + '</li>';
        } else {
          content += '<li>পৃষ্ঠা : ' + data.pages + '</li>';
        }
      }
      content += '</ul>';
      return content;
    });

    ws.citeBox.add('বিবটেক্স', function(data) {
      content = '<pre style="display:block;">@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 += '}</pre>';
      return content;
    });

    ws.citeBox.add('উইকিপিডিয়া', function(data) {
      content = '<pre>{{বই উদ্ধৃতি\n';
      content += '|শিরোনাম= ' + data.title + '\n';
      content += '|লেখক= ' + data.author + '\n';
      content += '|লেখক-সংযোগ= ' + data.author + '\n';
      if(data.translator)
        content += '|অনুবাদক= ' + data.translator + '\n';
      if(data.illustrator)
        content += '|illustrator= ' + data.illustrator + '\n';
      content += '|প্রকাশক= ' + data.publisher + '\n';
      content += '|তারিখ= ' + data.year + '\n';
      if(data.place)
        content += '|অবস্থান= ' + data.place + '\n';
      if(data.volume)
        content += '|খণ্ড= ' + data.volume + '\n';
      if(data.chapter)
        content += '|অধ্যায়= ' + data.chapter + '\n';
      if(data.pages)
        content += '|passage= ' + data.pages + '\n';
      content += '|ভাষা= bn\n';
      content += '|উইকিসংকলন= ' + mw.config.get('wgTitle') + '\n';
      content += '}}</pre>';
      return content;
    });

    ws.citeBox.add('উইকিঅভিধান', function(data) {
      content = '<pre>{{উৎস|';
      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)
        content += ', {{nobr|পৃ. ' + data.pages + '}}';
      content += '}}</pre>';
      return content;
    });

    var i18n = {
      title: 'লেখাটি উদ্ধৃত করুন',
      description: 'বিভিন্ন ফর্ম্যাটে লেখাটি উদ্ধৃত করুন।',
      display_mode: 'দেখুন :'
    };
    ws.citeBox.init( i18n );
  });
}