china verification at search improve (#10166)

pull/10171/head
Diego Fagundes 2018-08-31 16:08:34 -03:00 committed by k8s-ci-robot
parent 2bb5538bdf
commit 88a76d7632
4 changed files with 70 additions and 17 deletions

View File

@ -1 +1 @@
{"Target":"css/styles.min.c3dac3efbe182866a2a6b370e5218510dc34634d47746426b4590cbbe7138d62.css","MediaType":"text/css","Data":{"Integrity":"sha256-w9rD774YKGaiprNw5SGFENw0Y01HdGQmtFkMu+cTjWI="}}
{"Target":"css/styles.min.55d1e72cc5418eace24df1a4450abe45a6ee9111f9814269bc6540e8c49d2399.css","MediaType":"text/css","Data":{"Integrity":"sha256-VdHnLMVBjqziTfGkRQq+RabukRH5gUJpvGVA6MSdI5k="}}

View File

@ -1531,6 +1531,36 @@ html.search #docsContent {
.gsc-above-wrapper-area {
border-bottom: 0; }
/* Bing Search */
#bing-results-container {
margin-top: 30px;
margin-left: 20px; }
.bing-result {
margin-bottom: 20px; }
.bing-result-name a {
font-size: 16px;
color: #0000CC; }
.bing-result-url {
color: #008000;
font-size: 13px; }
.bing-result-snippet {
color: #000;
font-size: 11px; }
#bing-pagination-container {
margin: 10px;
margin-left: 20px; }
.bing-page-anchor {
text-decoration: none !important;
cursor: pointer;
color: #0000CC;
margin-right: 8px; }
@media screen and (min-width: 750px) {
h1 {
font-size: 32px;

View File

@ -1,3 +1,5 @@
document.querySelector('html').classList.add('search');
window.renderGoogleSearchResults = () => {
var cx = '013288817511911618469:elfqqbqldzg';
var gcse = document.createElement('script');
@ -6,7 +8,6 @@
gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//cse.google.com/cse.js?cx=' + cx;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(gcse, s);
// document.querySelector('html').classList.add('search');
}
window.getPaginationAnchors = (pages) => {
@ -52,22 +53,44 @@
if($('#bing-results-container').length > 0) $('#bing-results-container').html(results);
if($('#bing-pagination-container').length > 0) $('#bing-pagination-container').html(paginationAnchors);
});
document.querySelector('html').classList.add('search');
}
window.renderBingSearchResults();
$.ajax({
url: "https://ipinfo.io",
dataType: "jsonp",
success: function (response) {
if (response.country != 'CN') window.renderGoogleSearchResults();
},
error: function () {
console.log('sorry...')
},
timeout: 5000
});
//China Verification
var path = "path=/;"
d = new Date()
d.setTime(d.getTime() + (7 * 24 * 60 * 60 * 1000))
expires = "expires=" + d.toUTCString()
function getCookie(name) {
var value = "; " + document.cookie;
var parts = value.split("; " + name + "=");
if (parts.length == 2) return parts.pop().split(";").shift();
else return "";
}
if (getCookie("is_china") === "") {
$.ajax({
url: "https://ipinfo.io?token=796e43f4f146b1",
dataType: "jsonp",
success: function (response) {
if (response.country == 'CN') {
window.renderBingSearchResults()
document.cookie = "is_china=true;" + path + expires
} else {
window.renderGoogleSearchResults()
document.cookie = "is_china=false;" + path + expires;
}
},
error: function () {
window.renderBingSearchResults()
document.cookie = "is_china=true;" + path + expires;
},
timeout: 3000
});
} else if (getCookie("is_china") === "true") {
window.renderBingSearchResults()
} else {
window.renderGoogleSearchResults()
}