Difference between revisions of "MediaWiki:Wiki.js"

From WikiSoft
Jump to: navigation, search
(One intermediate revision by the same user not shown)
Line 616: Line 616:
 
       elem2.innerHTML= "";
 
       elem2.innerHTML= "";
 
   var txtGroupField = document.getElementById("groupfield-txt");
 
   var txtGroupField = document.getElementById("groupfield-txt");
 
+
 
 +
 
  
 
   if(Number(value2) < 0 || parseFloat(value2) ){
 
   if(Number(value2) < 0 || parseFloat(value2) ){
Line 647: Line 648:
 
    
 
    
 
       }
 
       }
  if(Number(value2)<500)
+
  if(Number(value2)==""){
 +
            txtGroupField .value="";
 +
        $("#no_of_shareserr").html("Number of share value required");
 +
    }
 +
  else if(Number(value2)<500)
 
   {
 
   {
 
     $("#no_of_shareserr").html("minimum 500 share value required ");  
 
     $("#no_of_shareserr").html("minimum 500 share value required ");  

Revision as of 08:54, 4 December 2019

var respon_chptcha1="";

$(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(mw.config.get('wgPageName') != "WikiProfile"){ 
if(mw.config.get('wgNamespaceNumber')  == 0 || mw.config.get('wgNamespaceNumber')  == 777 || mw.config.get('wgNamespaceNumber')  == 100){

var wikiHTML;
var page = $("#cname").html();  
//var page = wgPageName;
//var page = "Viewsonic";
	if(mw.config.get('wgNamespaceNumber')  == 777){
                var page = mw.config.get('wgPageName');
		page = page.replace("Wiki:","");
	}
        if(mw.config.get('wgNamespaceNumber')  == 100){
                var page = mw.config.get('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="https://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:mw.config.get('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:mw.config.get('wgPageName'),page_content: data.parse.text["*"]},
										 type: 'POST',
										 success:function(data){
											 alert("ok");
											}
										});
									}	
											}else{
												$("#cse").html('');}
										});
												
								}
								}
									
								else{
									$("#cse").html('');}
                                                             

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

}
if(mw.config.get('wgNamespaceNumber')  == 777 || mw.config.get('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);	   
	}
	}
}
});

function getmarketdata()
{
if(mw.config.get('wgPageName')=="Wikisoft_Investor_relations")
{
   $.get("/w/data/get_market_data.php",function(response) {
      $('#current_val').html(response.regularMarketPrice);
var share_price= parseFloat(response.regularMarketPrice);
var share_price=(share_price-((share_price*35)/100));
 if(response.regularMarketPrice!=0.000)
  {
     /*$('#share_price').css('display','block');*/
   
     $('#share_price').html(share_price.toFixed(2));
      if(response.regularMarketChange>0)
       {
      $('#updownvalue').html('+'+response.regularMarketChange);
      $('#updownvalue').css('color','#009933');
       }
       else
       {
         $('#updownvalue').html(response.regularMarketChange);
         $('#updownvalue').css('color','#ff333a');
       }
       if(response.regularMarketChangePercent>0)
       {
     $('#percentage').html('(+'+response.regularMarketChangePercent+'%)');
    $('#percentage').css('color','#009933');
       }
       else
       {
          $('#percentage').html('('+response.regularMarketChangePercent+'%)');
         $('#percentage').css('color','#ff333a');
       }
      $('#lasttime').html(response.regularMarketTime);
   }

});
}
}
getmarketdata();
setInterval(getmarketdata, 30000)


$(window).on('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});
}
});

var respon="";


function captcha_validate(response)
{
   if (response.length > 0) {

     respon=response;
    return true;
    }
    else
    {
       return false;
    }
}
/*
$("#no_of_shares").on("change keyup blur",function(){

  var share = $("#no_of_shares").val();
   var share = parseInt(share);
if(isNaN(share)) {
var share = 0;
}
share=Math.abs(share);
$("#no_of_shares").val(share);


 var value = (share*4.25);
 value = Math.round(value);

value = commaSeparateNumber(value);

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

});


$("#no_of_shares2").on("change keyup blur",function(){
  var share = $("#no_of_shares2").val();
if(isNaN(share)) {
var share = 0;
}
share=Math.abs(share);
$("#no_of_shares2").val(share);
  share = (share*1.65);
 share = math.round(share);
   $("#groupfield-txt").val(share);  

});
*/



$("#full_name").blur(function(){
if($("#full_name").val() == ""){
$("#full_nameerr").html("Name required"); $("#full_name").focus();return false;
}
else if(!isstring($("#full_name").val()))
{
$("#full_nameerr").html("Enter name in  Alphabetic Chracter "); $("#full_name").focus();return false;
}
else{
$("#full_nameerr").html("");
}
});

$("#email").blur(function(){
if($("#email").val() == "" || !isEmail($("#email ").val())){
$("#emailerr").html("Valid email required");  return false;
}
else{
$("#emailerr").html("");
}
});
$("#no_of_shares").blur(function(){
if($("#no_of_shares ").val() == ""){
$("#no_of_shareserr").html("Number of share value required"); return false;
}
else if($("#no_of_shares ").val() <500){
$("#no_of_shareserr").html("minimum 500 share value required "); return false;
}
else{
$("#no_of_shareserr").html("");
}
});
$("#no_of_shares2").blur(function(){
if($("#no_of_shares2").val() == ""){
$("#no_of_shareserr").html("Number of share value required"); return false;
}
else if($("#no_of_shares2").val() <500){
$("#no_of_shareserr").html("minimum 500 share value required "); 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="";
var share_price="";
var share_price= parseFloat(document.getElementById("current_val").innerHTML);
if(isNaN(share_price) || share_price==0)
{
  share_price=1.75;
}
else
{
  share_price=$('#share_price').html();
}


 if($("#no_of_shares").length!=0)
{
  no_of_shares = $("#no_of_shares").val();
}else if($("#no_of_shares2").length!=0)
{
    no_of_shares = $("#no_of_shares2").val();
}
else{
    no_of_shares = $("#no_of_shares3").val();
}
 var groupfieldtxt = $("#groupfield-txt").val();

if(full_name=="" && email=="" && (no_of_shares==""  ) && no_of_shares>0 && !isstring(full_name) )
{

$('#ermessage').html('<span style="color:red">Please Fill Up all The Required Field</span>');return false;

}
else if(!isEmail(email))
{
$("#emailerr").html("Valid email required");  return false;
}
else if(respon_chptcha1.length<=0)
{
 $('#ermessage').html('<span style="color:red">please  verify the Captcha</span>'); return false;
}
else if(no_of_shares<500)
{
$("#no_of_shareserr").html("minimum 500 share value required "); return false;
}
else
{
$('#loader').css('display','block');
$('#ermessage').html("");
respon_chptcha1="";
var data=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
grecaptcha.reset();
						var dateObj = new Date();
						var month = dateObj.getUTCMonth() + 1; //months from 1-12
						var day = dateObj.getUTCDate();
						var year = dateObj.getUTCFullYear();

						var newdate =day+ " " + data[month-1] +" " + year  
						var newdate2=year+'-'+month+'-'+day;
						var certno="";

var senddata;
if($("#no_of_shares").length!=0)
{
       
     senddata={full_name:full_name,email:email,share_price:share_price,no_of_shares:no_of_shares,source:'Wikisoft Investor Relation -Wikisoft.com','groupfieldtxt':groupfieldtxt };
      
}
else if($("#no_of_shares2").length!=0)
{
     senddata={full_name:full_name,email:email,no_of_shares:no_of_shares,share_price:4.25,source:'Wikisoft Private Placement - Wikisoft.com',type:"Private Placement",'groupfieldtxt':groupfieldtxt};
       share_price=4.25;
}


$.ajax({
    type: "POST",
    url: "/w/mail.php",
    data: senddata,
datatype:'json',
    success: function(response) {

     var captcha = true;

 $('#loader').css('display','none');
    if(response.status=="success")
    { 
var certno=response.certno;
var row="";
if($("#no_of_shares").length!=0)
{
row='"'+full_name+'","'+email+'",'+no_of_shares+','+groupfieldtxt+','+share_price+','+certno+',"","'+newdate +'",';
}
else if($("#no_of_shares2").length!=0)
{
row='"'+full_name+'","'+email+'",'+no_of_shares+','+groupfieldtxt+',4.25,'+certno+',"","'+newdate +'",';
}
		 // calling function   for the add the data in  google sheet  
			add_sheet(row);



        $("#mw-navigation").css('opacity', '0.2');
        $("#popup_display").css('display','block');
        $("#deartitle").html("Dear "+ full_name);
	
        if($("#no_of_shares").length!=0)
         {
 
           $("#deartitle_belowtext").html("We have made a reservation of "+ no_of_shares +" shares in WikiSoft Corp.<br>at US$ "+share_price+" per share including discount<br>according to your request.");  
         }
          else if($("#no_of_shares2").length!=0){
           $("#deartitle_belowtext").html("We have made a reservation of "+ no_of_shares +" shares in WikiSoft Corp.<br>at US$ 4.25 per share including discount<br>according to your request.");  

            }
   
     
           $('#ermessage').html("Order placed successfully").hide().fadeIn(1500, function() {
        
              document.getElementById("sendemail_form").reset();
                 /*grecaptcha.reset(); */
                 full_name = "";
                 no_of_shares = "";
                 email = "";
                 groupfieldtxt = "";
              });
          }
          else
          {
$('#loader').css('display','none');

              $('#ermessage').html("<span style='color:red'>"+response.message+"</span>").hide().fadeIn( 1500, function() {
    
  });
           }

          
   
   
    },
  error: function(){
$('#loader').css('display','none');
   $('#ermessage').html("<span style='color:red'>Please Try again</span>");
 /* var captcha = false; */
   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 isstring(str)
{
   var regex = /^[A-Za-z \s]*$/;
  return regex.test(str);
}
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();
            }
 });*/




function clac(value2)
{
 
   var num=Math.abs(Number(value2));
   num=Math.round(num)
   var elem2 = document.getElementById("no_of_shareserr");
      elem2.innerHTML= "";
   var txtGroupField = document.getElementById("groupfield-txt");
  
  

   if(Number(value2) < 0 || parseFloat(value2) ){

           if(document.getElementById("no_of_shares"))
            {
              var elem = document.getElementById("no_of_shares");
              var share_price= parseFloat(document.getElementById("current_val").innerHTML);
if(isNaN(share_price) || share_price==0)
{
  share_price=1.75;
}
else
{
  share_price=(share_price-((share_price*35)/100).toFixed(2));
}
    var c = (num * share_price);
   txtGroupField.value =Math.round(c);
              elem.value = num;
            }
           else if(document.getElementById("no_of_shares2"))
           {
              var elem = document.getElementById("no_of_shares2");
                  
            
                var c = (num * 4.25);
                txtGroupField.value =Math.round(c);
               elem.value = num;
           }
   
      }
   if(Number(value2)==""){
            txtGroupField .value="";
        $("#no_of_shareserr").html("Number of share value required");
    }
   else if(Number(value2)<500)
  {
    $("#no_of_shareserr").html("minimum 500 share value required "); 
  }
  
}


function  add_sheet(row)
	{
   
    // Submission
    	
		// Clean Row
		row = row.slice(0, -1);		
        // Config
        var gs_sid = '1o05GWGEVtubqOmJXL6vofqEEPt8jntRghYocLpicuWk'; // Enter your Google Sheet ID here
        var gs_clid = '976352680249-ijeue9v33god66ipd4dl7fbre3hguegj.apps.googleusercontent.com'; // Enter your API Client ID here
        var gs_clis = '_7NxHaygC7Lid6O1HmGY8KyC'; // Enter your API Client Secret here
        var gs_rtok = '1/J4Of2tWc51cRl85NwtU0Va0wEjraV7EejDTMOCkrQSk'; // Enter your OAuth Refresh Token here
        var gs_atok = false;
        var gs_url = 'https://sheets.googleapis.com/v4/spreadsheets/'+gs_sid+'/values/A1:append?includeValuesInResponse=false&insertDataOption=INSERT_ROWS&responseDateTimeRenderOption=SERIAL_NUMBER&responseValueRenderOption=FORMATTED_VALUE&valueInputOption=USER_ENTERED';
        var gs_body = '{"majorDimension":"ROWS", "values":[['+row+']]}';     

console.log(gs_body);

		
         // HTTP Request Token Refresh
        var xhr = new XMLHttpRequest();
        xhr.open('POST', 'https://www.googleapis.com/oauth2/v4/token?client_id='+gs_clid+'&client_secret='+gs_clis+'&refresh_token='+gs_rtok+'&grant_type=refresh_token');
        xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
        xhr.onload = function() {            
            var response = JSON.parse(xhr.responseText);
            var gs_atok = response.access_token;            
			// HTTP Request Append Data
            if(gs_atok) {
                var xxhr = new XMLHttpRequest();
                xxhr.open('POST', gs_url);
                xxhr.setRequestHeader('Content-length', gs_body.length);
                xxhr.setRequestHeader('Content-type', 'application/json');
                xxhr.setRequestHeader('Authorization', 'OAuth ' + gs_atok );
                xxhr.onload = function() {
					if(xxhr.status == 200) {
						// Success
						console.log(xxhr.responseText)
						} else {
						// Fail
						console.log('<p>Row Not Added</p><p>Response:<br/>'+xxhr.responseText+'</p>');
					}
                };
                xxhr.send(gs_body);
            }            
        };
        xhr.send();
    	
}


function captchavalidate2(response) {
    if (response.length > 0) {
        respon_chptcha1= response;
        return true;
    } else {
        return false;
    }
}