ବ୍ୟବହାରକାରୀ:Odisha1/cs.js

ଉଇକିପାଠାଗାର‌ରୁ

ସୂଚନା: ବଦଳଗୁଡ଼ିକ ଦେଖିବା ପାଇଁ ଆପଣଙ୍କୁ ହୁଏତ ନିଜ ବ୍ରାଉଜର କ୍ୟାସ ବାଇପାସ କରିବାକୁ ପଡ଼ିପାରେ ।

  • Firefox / Safari: Reload ଉପରେ କ୍ଲିକ କରିବା ବେଳେ Shift ଧରି କିମ୍ବା Ctrl-F5 ବା Ctrl-R ଦବାନ୍ତୁ (Macରେ ⌘-R)
  • Google Chrome: Ctrl-Shift-R ଦବାନ୍ତୁ (Macରେ ⌘-Shift-R)
  • Internet Explorer / Edge: Refresh ଉପରେ କ୍ଲିକ କଲା ବେଳେ Ctrl ଧରି ବା Ctrl-F5 ଦବାଇ
  • Opera: Ctrl-F5 ଦବାନ୍ତୁ ।
//<nowiki>
(function($,mw) {
	mw.chatsabha = {
		'questionform' : ' \
		<div class="ws-chatsabha-question-form"> \
			<p>ତଳେ ନିଜର ପ୍ରଶ୍ନଟି ଲେଖନ୍ତୁ</p>\
			<p><label for="ws-cs-question-title">ଆପଣଙ୍କ ପ୍ରଶ୍ନର ଛୋଟ ସାରକଥାଟିଏ: </label> \
			<input id="ws-cs-question-title" type="text" size="90" /></p>\
			<textarea rows="10" cols="20" id="ws-cs-question-text"></textarea> \
			<p>\
			<a href="#" id="ws-cs-question-ask">ପ୍ରଶ୍ନଟି ପଚାରନ୍ତୁ</a> \
			</p> \
		</div> \
		',

		addQuestion : function( title, text ) {
			var wikitext = '==' + title + "==\n" + text + '~~~~' + "\n";

			$('.ws-chatsabha-question-form').hide();

			$('.ws-chatsabha-ask')
				.find('.selflink')
				.empty()
				.addClass('mw-ajax-loader');

			var api = new mw.Api();

			api.get( {
				'action' : 'query',
				'titles' : 'ଉଇକିପାଠାଗାର:ଚାଟସଭା/ପ୍ରଶ୍ନ',
				'prop'   : 'revisions|info',
				'intoken' : 'edit',
				'rvprop' : 'content',
				'indexpageids' : 1
			}).done(
				function(result) {
					result = result.query;
					var page = result.pages[result.pageids[0]];
					var oldText = page.revisions[0]['*'];
					var newText = oldText.replace( /^==/m, wikitext+"==" );

					api.post(
						{
							'action' : 'edit',
							'title' : 'ଉଇକିପାଠାଗାର:ଚାଟସଭା/ପ୍ରଶ୍ନ',
							'text' : newText,
							'summary' : '/'+'* '+title+' *'+'/ new section',
							'token' : page.edittoken
						}).done(
							function() {location.reload();}
						);
				});
		}
	};

	$(function() {
		mw.loader.using( ['jquery.ui', 'mediawiki.api'], function() {
			if ( !$('.ws-chatsabha-ask').length ) {
				return;
			}

			var $form = $(mw.chatsabha.questionform);
			$('.ws-chatsabha-ask').after($form);

			// Prevent flash
			$form.css( 'left', '-10000px' );

			// Set up position
			setTimeout( function() {
				var $trigger = $('.ws-chatsabha-ask');
				var pos = $trigger.position();
				var hCenter = ( $trigger.parent().width() / 2 );
				$form.css( 'top', pos.top + $trigger.height() + 'px' );
				$form.css( 'left', (hCenter - ($form.width()) / 2) + 'px' );
				$form.hide();
			}, 0);

			$form.find('#ws-cs-question-ask')
				.button({
					disabled : true
				})
				.click( function(e) {
					e.preventDefault();

					var title = $form.find('#ws-cs-question-title').val();
					var text = $form.find('#ws-cs-question-text').val();

					if ( title && /\s*$/.test(text) ) {
						mw.chatsabha.addQuestion( title, text );
					}
				})
				.end()
				.find('#ws-cs-question-text')
					.keypress( function(e) {
						var $textbox = $(this);
						setTimeout( function() {
							if ( (/\s*$/).test($textbox.val()) ) {
								$form.find('#ws-cs-question-ask')
									.button( 'option','disabled', false );
							} else {
								$form.find('#ws-cs-question-ask')
									.button( 'option','disabled', true );
							}
						}, 0 );
					} );

			$('.ws-chatsabha-ask').click(function(e) {
				$form.toggle('fast');
				e.cancelBubble = true; // for IE
				if (e.stopPropagation) {
					e.stopPropagation();
					e.preventDefault();
				}
			});

			$(document).click( function(e) {
				var $target = $(e.target);
				if ( ! $target.is('.ws-chatsabha-question-form *') &&
					! $target.is('.ws-chatsabha-ask *')
				) {
					$('.ws-chatsabha-question-form').fadeOut();
				}
			} );

			$(document).keydown( function(e) {
				if ( e.keyCode == 27 ) {// ESC
					$('.ws-chatsabha-question-form').fadeOut();
				}
			});
		} );
	} );
} )(jQuery,mediaWiki);

if ( mw.config.get("wgPageName") == 'ଉଇକିପାଠାଗାର:ଚାଟସଭା/ପ୍ରଶ୍ନ' ) {
(function($,mw) {
 
	$(function() {
		mw.loader.using( ['jquery.ui', 'mediawiki.api'], function() {
 
		function addResponse( section, headline, text ) {
			var wikitext = '\n\n:' + text + '~~~~';
 
			$('.ws-chatsabha-respond-form').hide();
 
			$('.ws-chatsabha-respond')
				.find('.selflink')
				.empty()
				.addClass('mw-ajax-loader');
 
			var api = new mw.Api();
 
			api.get( {
				'action' : 'query',
				'titles' : 'ଉଇକିପାଠାଗାର:ଚାଟସଭା/ପ୍ରଶ୍ନ',
				'prop'   : 'revisions|info',
				'intoken' : 'edit',
				'rvprop' : 'content',
				'indexpageids' : 1
			}).done(
				function(result) {
					result = result.query;
					var page = result.pages[result.pageids[0]];
 
					api.post(
						{
							'action' : 'edit',
							'section' : section,
							'title' : 'ଉଇକିପାଠାଗାର:ଚାଟସଭା/ପ୍ରଶ୍ନ',
							'appendtext' : wikitext,
							'summary' : '/* ' + headline + ' */' + ' response',
							'token' : page.edittoken
						}).done (
							function() {location.reload();}
						);
				});
		}
 
			var headers = $('h2:gt(0)').find('.mw-editsection:first'); 
			var k;
			var header;        
			headers.each(function(k) {
 
				$(this).prepend("<span style='font-size: 2em;color:#3fb6ff;text-shadow: #444 0.1em 0.1em 0.1em;'>«</span>&nbsp;&nbsp;&nbsp;<a style='font-weight:bold;cursor:pointer; color:#7d7b75;' href='#' class='ws-chatsabha-respond' id='ws-chatsabha-respond-" + k + "'>Join this discussion</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
 
				var formCode = 	'<div class="ws-chatsabha-respond-form" id="ws-chatsabha-respond-form-' + k + '"><p>You can type your response below.</p><textarea rows="10" cols="20" id="ws-cs-respond-text-' + k + '"></textarea><p><a href="#" class="ws-cs-respond" id="ws-cs-respond-' + k + '">Add my response</a></p></div>';
 
				var rLink = $('#ws-chatsabha-respond-' + k);
				rLink.after(formCode); 
 
				var rForm = $('#ws-chatsabha-respond-form-' + k);
				var rText = $('#ws-cs-respond-text-' + k);
				var rButton = $('#ws-cs-respond-' + k);
				var headline = $(this).parents('h2').find('span.mw-headline').html();
				headline = headline.replace(/<span class="mw-headline-number">[\d]*<\/span> /, '');
 
				// Prevent flash
				rForm.css( 'left', '-10000px' );
 
				// Set up position
				setTimeout( function() {
					var pos = rLink.position();
					var hCenter = ( $(window).width() / 2 );
					rForm.css( 'top', pos.top + 20 + 'px' );
					rForm.css( 'left', (hCenter - (rForm.width()) /2) + 'px' );
					rForm.hide();
				}, 0);
 
				rButton.button({disabled : true}).click( function(e) {
					e.preventDefault();
 
					var text = rText.val();
						addResponse( k+1, headline, text );
				}).end()
 
				rText.keypress( function(e) {
						var $textbox = $(this);
						setTimeout( function() {
							if ( (/\s*$/).test($textbox.val()) ) {
								rButton.button( 'option','disabled', false );
							} else {
								rButton.button( 'option','disabled', true );
							}
						}, 0 );
					} );
 
				rLink.click(function(e) {
					rForm.toggle('fast');
					e.cancelBubble = true; // for IE
					if (e.stopPropagation) {
						e.stopPropagation();
						e.preventDefault();
					}
				});
 
			$(document).click( function(e) {
				var $target = $(e.target);
				if ( ! $target.is('.ws-chatsabha-respond-form *') &&
					! $target.is('.ws-chatsabha-respond *')
				) {
					$('.ws-chatsabha-respond-form').fadeOut();
				}
			} );
 
				$(document).keydown( function(e) {
					if ( e.keyCode == 27 ) {// ESC
						rForm.fadeOut();
					}
				});   //after loop
			}); 
		});
	} );
} )(jQuery,mediaWiki);
}
//</nowiki>