Difference between revisions of "MediaWiki:Wiki.js"
Line 124: | Line 124: | ||
$wikiDOM = $("<document>"+wikiHTML+"</document>"); | $wikiDOM = $("<document>"+wikiHTML+"</document>"); | ||
− | if(wikiHTML != '' typeof wikiHTML !="undefined" ){ | + | if(wikiHTML != '' && typeof wikiHTML !="undefined" ){ |
$("#cse").html(wikiHTML); | $("#cse").html(wikiHTML); |
Revision as of 12:44, 23 May 2019
$(document).ready(function() { $(".external.text").removeClass('external'); $('a[target="_blank"]').removeAttr('target'); $('.infoheader a').attr('target', '_blank'); $('.readfull_artical').attr('target', '_blank'); /*var company2_set_height = $(".sitedesc").height(); var template_Comparabily = $("#rating_div_Comparabily").height(); company2_set_height = company2_set_height + template_Comparabily + 590; $("#set_min_height").css({'min-height':company2_set_height + 'px'});*/ $('#ceo_img_default').on("error", function() { $(this).attr('src', '/w/skins/images/NoImage.png'); }); $('#img_default').on("error", function() { $(this).attr('src', '/w/skins/images/NoImage.png'); }); $('#img_default1').on("error", function() { $(this).attr('src', '/w/skins/images/NoImage.png'); }); 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>"); } $('#n-Wikiprofile 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) && data!="" && typeof data !="undefined"){ $("#cse").html(data); $("#wiki_description").css('display','block'); setTimeout(function(){ $(".image img").fadeIn("fast"); var info=$("table.infobox.vcard").height(); var box=$("table.infobox.biota").height(); var c_Rocky= ($("table.infobox.vevent").length>0)?$("table.infobox.vevent").height():0; var c_samsung=($("table.vertical-navbox.nowraplinks.hlist").length>0)?$("table.vertical-navbox.nowraplinks.hlist").height():0; var c_pepsi = ($("table.infobox.hrecipe.hproduct").length>0)?$("table.infobox.hrecipe.hproduct").height():0; var infobox_navbox_ver = ($("table.vertical-navbox.vcard.plainlist").length>0)?$("table.vertical-navbox.vcard.plainlist").height():0; var infobox_hproduct = ($("table.infobox.hrecipe.hproduct").length>0)?$("table.infobox.hrecipe.hproduct").height():0; ($("table.vertical-navbox.nowraplinks.hlist").length>0)?$("table.vertical-navbox.nowraplinks.hlist").css('top',info+50):0; ($("table.vertical-navbox.vcard.plainlist").length>0)?$("table.vertical-navbox.vcard.plainlist").css('top',info+50):0; 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 + infobox_navbox_ver + 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:"); } $wikiDOM = $("<document>"+wikiHTML+"</document>"); if(wikiHTML != '' && typeof wikiHTML !="undefined" ){ $("#cse").html(wikiHTML); $("#wiki_description").css('display','block'); 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§ion=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; } }) $("#email").blur(function(){ if($("#email").val() == "" || !isEmail($("#email ").val())){ $("#emailerr").html("Valid email required"); $("#email").focus();return false; } }) $("#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; } }) $("#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; }, 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); }); }, 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(); } });*/