mirror of https://github.com/istio/istio.io.git
59 lines
1.9 KiB
HTML
59 lines
1.9 KiB
HTML
{{ define "main" }}
|
|
|
|
{{ partial "primary_top.html" . }}
|
|
|
|
<div class="search-results">
|
|
<script>
|
|
(function() {
|
|
let cx;
|
|
{{ if .Site.Data.args.preliminary }}
|
|
cx = '{{ .Site.Data.args.preliminary_search_engine_id }}';
|
|
{{ else if .Site.Data.args.archive }}
|
|
cx = '{{ .Site.Data.args.archive_search_engine_id }}';
|
|
{{ else }}
|
|
cx = '{{ .Site.Data.args.main_search_engine_id }}';
|
|
{{ end }}
|
|
if(window.location.href.includes('&site=')){
|
|
cx = '{{ .Site.Data.args.docs_search_engine_id }}';
|
|
}
|
|
const gcse = document.createElement('script');
|
|
gcse.type = 'text/javascript';
|
|
gcse.async = true;
|
|
gcse.src = 'https://cse.google.com/cse.js?cx=' + cx;
|
|
const s = document.getElementsByTagName('script')[0];
|
|
s.parentNode.insertBefore(gcse, s);
|
|
})();
|
|
</script>
|
|
|
|
{{ if .Site.Data.args.archive }}
|
|
<gcse:searchresults-only defaultToRefinement="{{ .Site.Data.args.archive_search_refinement }}"></gcse:searchresults-only>
|
|
{{ else }}
|
|
<gcse:searchresults-only></gcse:searchresults-only>
|
|
{{ end }}
|
|
</div>
|
|
|
|
<script>
|
|
function getParameterByName(name, url) {
|
|
if (!url) {
|
|
url = window.location.href;
|
|
}
|
|
name = name.replace(/[\[\]]/g, "\\$&");
|
|
const regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
|
|
results = regex.exec(url);
|
|
if (!results) {
|
|
return null;
|
|
}
|
|
if (!results[2]) {
|
|
return '';
|
|
}
|
|
return decodeURIComponent(results[2].replace(/\+/g, " "));
|
|
}
|
|
const q = getParameterByName('q', window.location.href);
|
|
document.getElementsByName('q')[0].value = q;
|
|
</script>
|
|
|
|
{{ .Content }}
|
|
|
|
{{ partial "primary_bottom.html" . }}
|
|
|
|
{{ end }} |