MediaWiki:Wiki.js

From WikiSoft
Revision as of 14:57, 19 October 2018 by Admin (talk | contribs)
Jump to: navigation, search

Note: After saving, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.


$(document).ready(function() {
  
  $(".external.text").removeClass('external');
  $('a[target="_blank"]').removeAttr('target');
  $('.infoheader a').attr('target', '_blank'); 
 $('.readfull_artical').attr('target', '_blank');


   var keyname = $("#keywordcustomer").text();
   if(keyname != '')
   {
     var keyname = keyname.split(',').join(', ');
     var keyname = keyname.split('  ').join(' ');   
       
      $("#mw-normal-catlinks").append("<div id='keywordLink' class='mw-normal-catlinks'>Keyword: "+keyname+"</div>");
   }

$("#close_btn").click(function () 
{
    $("#popup_display").css('display','none');
     $("#mw-navigation").css('opacity', 'unset');
});

$('#n-Wikiprofile a').attr('target', '_blank'); 
$('#n-Wikipedia a').attr('target', '_blank'); 
$('#n-Mediawiki a').attr('target', '_blank'); 
$('#n-Wikicareer a').attr('target', '_blank'); 

if(wgPageName != "WikiProfile"){ 
if(wgNamespaceNumber  == 0 || wgNamespaceNumber  == 777 || wgNamespaceNumber  == 100){

var wikiHTML;
var page = $("#cname").html();  
//var page = wgPageName;
//var page = "Viewsonic";
	if(wgNamespaceNumber  == 777){
                var page = wgPageName;
		page = page.replace("Wiki:","");
	}
        if(wgNamespaceNumber  == 100){
                var page = wgPageName;
		page = $("#wikipCname").html();
	}
 
	//check for content exist in database or not
	$.ajax({
		url: '/w/check_wikidata.php',
		data:{pagename:page},
		type: 'GET',
		success:function(data){
			var response = data;
			if(data || data.error){ 
                                $("#cse").html(data); 
			 
setTimeout(function(){
        $(".image img").fadeIn("fast");
                             var info=$("table.infobox.vcard").height();
                             var box=$("table.infobox.biota").height();
                              var c_Rocky=$("table.infobox.vevent").height();
                            var c_samsung=$("table.vertical-navbox.nowraplinks.hlist").height();
                            var c_pepsi = $("table.infobox.hrecipe.hproduct").height();

                            if($("table.collapsible.collapsed").height() != null)
                            {
                                $(".infobox").addClass('comp_tab_second');
                               var c_asus=$("table.collapsible.collapsed").height() + 520;
                              /* var c_asus=$("table.infobox.comp_tab_second").height();*/
                                 var tab_second_css = info + 20; 
                                 var totinfo = info + c_asus - 220;
                                 $("#desc").css({'min-height':totinfo + 'px'});
                                 $(".infobox.comp_tab_second").css({'margin-top':tab_second_css + 'px'});
                             }
                             else{
                              
                              var totinfo = info + c_samsung + c_pepsi + c_Rocky - 220;
                              
                               var box = box - 220;

  			       $("#desc").css({'min-height':totinfo + 'px'});
                              $("#desc").css({'min-height':box + 'px'});
                             $("#mw-content-text").css({'min-height':info + 'px'});
                           }
    }, 2000);
             
			 }else{


page = encodeURIComponent(page );
				name = page;
				if(name != ""){
				name = name.replace(/ /g,"_");
				var v1="http://en.wikipedia.org/w/api.php?section=0&action=parse&page=";
				var v2="&format=json&redirects=content|format=Wiki|data=wikitext=text&prop=text&callback=?";
				var url=v1+page+v2;

							$.getJSON(url,function(data){
                                                         
                                                         if(data.parse){
                                                       
							 wikiHTML = data.parse.text["*"];
							
                                                      	wikiHTML =wikiHTML.replace(/wiki\//g,  "wiki/Wiki:");
                                                         }
                                                             else{
                                                                  wikiHTML = data.error;
                                                                   
                                                              }
							 					
							  $wikiDOM = $("<document>"+wikiHTML+"</document>");
							  
							  if(wikiHTML != ''){
								
								$("#cse").html(wikiHTML);
								
								if($("table.infobox.geography.vcard").height() == null){
								 
var box=$("table.infobox.vcard").height();
                                                         
								}else{

								if($("table.infobox.geography.vcard").height() !== null && $("table.infobox.geography.vcard").height() != box){
								 box=$("table.infobox.geography.vcard").height() + 370; 

								}
								}
				                var info=box+10;

				                $("#desc").css({"min-height":info + "px"} );
								WikiContent = wikiHTML;
								var cnamewbt = $("#cnamewbt").html();
								if(WikiContent != ''){
					
									$.ajax({
															
										url: '/w/insertWikidata.php',
										data:{pagename:wgPageName,page_content: WikiContent},
										type: 'POST',
										success:function(data){
                                                                                        setTimeout(function(){
                                                                                               $(".image img").fadeIn("fast");
                                                                                 var wikiheight=$("table.infobox.vcard").height();
                                                                                  var c_pepsi = $("table.infobox.hrecipe.hproduct").height();
                                                                                  
                                                                                 var main = wikiheight + c_pepsi - 220;
                                                                                 $("#mw-content-text").css({'min-height':wikiheight + 'px'});
                                                                                  $("#desc").css({'min-height':main + 'px'});

                                                                                       }, 2000);
										 
										}
									
									});
								}
								if(WikiContent == '' && cnamewbt != undefined){
									//alert(cnamewbt);
									name = cnamewbt.replace(/ /g,"_");
									url=v1+name+v2;
									$.getJSON(url,function(data){
											 wikiHTML = data.parse.text["*"];
											
										  $wikiDOM = $("<document>"+wikiHTML+"</document>");
										  if(wikiHTML != '' && WikiContent == ''){
											
											$("#cse").html(wikiHTML);
										
											if(wikiHTML != ''){
								
										$.ajax({
										
										url: '/insertWikidata.php',
										 data:{pagename:wgPageName,page_content: data.parse.text["*"]},
										 type: 'POST',
										 success:function(data){
											 alert("ok");
											}
										});
									}	
											}else{
												$("#cse").html('');}
										});
												
								}
								}
									
								else{
									$("#cse").html('');}
                                                             

							});
							
					var WikiContent = wikiHTML; 
					
				}	
				
			}
	
	}
});

}
if(wgNamespaceNumber  == 777 || wgNamespaceNumber  == 100){
wikipCname = $("#wikipCname").html(); 
	if(wikipCname != "" && wikipCname != undefined){
	wikipCname = wikipCname.replace(/ /g,"_");
	var v1="/w/wikipediaSearch.php?key=";
	
	var wikiSearchurl=v1+wikipCname; 
	 var response = '';
          $.ajax({
			   type: "GET",
			   url:wikiSearchurl,
			   async: false,
			   success: function(text)
			   {				     
				    response = text; 	
				    		       
		        }
		       
			   });

		$("#wikipDiv").html(response);	   
	}
	
	wikibCname = $("#wikibCname").html(); 
	if(wikibCname != "" &&  wikibCname != undefined){
	wikibCname = wikibCname.replace(/ /g,"_");
	var v1="wiki/Search.php?key=";
	//var v2="&no_category=business&list=search&format=json&prop=text&section=0&ellimit=5";
	var wikiSearchurl=v1+wikibCname;
	var response = '';
          $.ajax({
			   type: "GET",
			   url:wikiSearchurl,
			   async: false,
			   success: function(text)
			   {				     
				    response = text;	
				     	
		        }
		       
			   });
		$("#wikiBDiv").html(response);	   
	}
	}
}
});

$( window ).load(function() {
	
if($("table.infobox.vevent").html()!=null){
    var box1=$("table.infobox.vevent").height();
	//alert(box1);
	var info1=box1+240;
	
    $(".right_box").css({"margin-top":info1});
}
else if($("table.infobox.vcard").html() != null){
	var box=$("table.infobox.vcard").height();
	//alert(box);
	var info=box+10;
	
    $(".right_box").css({"margin-top":info});
}
else if($("table.infobox").html()!=null){

var box1=$("table.infobox").height();
	//alert(box1);
	var info1=box1+10;
	//alert(info);
    $(".right_box").css({"margin-top":info1});
}
else if($("table.geography.vcard").html()!=null){ 
var box1=$("table.infobox").height();
	//alert(box1);
	var info1=box1+10;
	//alert(info);
    $(".right_box").css({"margin-top":info1});
}
});


$("#no_of_shares").keyup(function(){

  var share = $("#no_of_shares").val();
   var share = parseInt(share);
if(isNaN(share)) {
var share = 0;
}
//var value = commaSeparateNumber((share * (1.85)).toFixed(2));
 var value = (share*1.85);
 value = value.toFixed(2);

value = commaSeparateNumber(value);

   $("#groupfield-txt").val(value);  

});


$("#full_name").blur(function(){
if($("#full_name").val() == ""){
$("#full_nameerr").html("Name required"); $("#full_name").focus();return false;
}
else{
$("#full_nameerr").html("");
}
})

$("#email").blur(function(){
if($("#email").val() == "" || !isEmail($("#email ").val())){
$("#emailerr").html("Valid email required");  $("#email").focus();return false;
}
else{
$("#emailerr").html("");
}
})
$("#no_of_shares").blur(function(){
if($("#no_of_shares ").val() == ""){
$("#no_of_shareserr").html("Number of share value required");$("#no_of_shares").focus(); return false;
}
else{
$("#no_of_shareserr").html("");
}
})


$("#sendemail_form").on('submit', function(){

   if($("#g-recaptcha-response").val() == "" ){
  $('#ermessage').html('Please verify captcha');return false;

}
  var full_name = $("#full_name").val();
  var email = $("#email").val();
  var no_of_shares = $("#no_of_shares").val();
 var groupfieldtxt = $("#groupfield-txt").val();

$.ajax({
    type: "POST",
    url: "/w/mail.php",
    data: {full_name:full_name,email:email,no_of_shares:no_of_shares,groupfieldtxt:groupfieldtxt,captcha:grecaptcha.getResponse()},
    success: function() {
     var captcha = true;

   /*  $("#full_name").val("");
     $("#no_of_shares").val("");
     $("#email").val("");
     $("#groupfield-txt").val("");

     $("#mw-navigation").css('opacity', '0.2');
      $("#popup_display").css('display','block');
      $("#deartitle").append("Dear "+ full_name);	
      $("#deartitle_belowtext").append("We have made a reservation of "+ no_of_shares +" shares in WikiSoft Corp.<br>in the Pre-IPO at US$ 1.85 per share including discount<br>according to your request."); 
$('#ermessage').html("Order placed successfully").hide().fadeIn(1500, function() {
      // $("#ermessage").html().show.fadeOut(1000);
   
      });*/
   
    },
  error: function(){
   $('#ermessage').html("Please verify captcha");
  var captcha = false; 
   return false;
}
  });

  
 $.ajax({
    type: "POST",
    url: "http://email.wikiprofile.org/emailsendingservices.asmx/emailsending",
    data: {name:full_name,email:email,noofshares:no_of_shares,price:groupfieldtxt},
    success: function() {

     $("#full_name").val("");
 $("#no_of_shares").val("");
$("#email").val("");
$("#groupfield-txt").val("");
$("#full_nameerr").hide();
$("#emailerr").hide();
$("#no_of_shareserr").hide();

 $('#ermessage').html("Order placed successfully").hide().fadeIn(1500, function() {
      // $("#ermessage").html().show.fadeOut(1000);
      
      });
    
     $("#mw-navigation").css('opacity', '0.2');
      $("#popup_display").css('display','block');
      $("#deartitle").append("Dear "+ full_name);	
      $("#deartitle_belowtext").append("We have made a reservation of "+ no_of_shares +" shares in WikiSoft Corp.<br>in the Pre-IPO at US$ 1.85 per share including discount<br>according to your request."); 

    }, error: function(){
  alert("email sending error");
   return false;
}
  });

return false;
});

function isEmail(email) {
  var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
  return regex.test(email);
}

function commaSeparateNumber(val) {
    while (/(\d+)(\d{3})/.test(val.toString())) {
        val = val.toString().replace(/(\d+)(\d{3})/, '$1' + ',' + '$2');
    }
    return val;
}
 /*$("#no_of_shares").on("keypress keyup blur",function (event) {    
           $(this).val($(this).val().replace(/[^\d].+/, ""));
            if ((event.which < 48 || event.which > 57)) {
                event.preventDefault();
            }
 });*/