-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rebuild, update docs with new MkDocs release (v1.0.4)
- Loading branch information
1 parent
d26adf9
commit cdd554c
Showing
11 changed files
with
241 additions
and
238 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,94 +1,96 @@ | ||
function getSearchTermFromLocation() { | ||
var sPageURL = window.location.search.substring(1); | ||
var sURLVariables = sPageURL.split('&'); | ||
for (var i = 0; i < sURLVariables.length; i++) { | ||
var sParameterName = sURLVariables[i].split('='); | ||
if (sParameterName[0] == 'q') { | ||
return decodeURIComponent(sParameterName[1].replace(/\+/g, '%20')); | ||
} | ||
} | ||
} | ||
|
||
function formatResult (location, title, summary) { | ||
return '<article><h3><a href="' + base_url + '/' + location + '">'+ title + '</a></h3><p>' + summary +'</p></article>'; | ||
} | ||
|
||
function displayResults (results) { | ||
var search_results = document.getElementById("mkdocs-search-results"); | ||
while (search_results.firstChild) { | ||
search_results.removeChild(search_results.firstChild); | ||
} | ||
if (results.length > 0){ | ||
for (var i=0; i < results.length; i++){ | ||
var result = results[i]; | ||
var html = formatResult(result.location, result.title, result.summary); | ||
search_results.insertAdjacentHTML('beforeend', html); | ||
} | ||
} else { | ||
search_results.insertAdjacentHTML('beforeend', "<p>No results found</p>"); | ||
} | ||
} | ||
|
||
function doSearch () { | ||
var query = document.getElementById('mkdocs-search-query').value; | ||
if (query.length > 2) { | ||
console.log('Searching with query: ' + query); | ||
if (!window.Worker) { | ||
displayResults(search(query)); | ||
} else { | ||
searchWorker.postMessage({query: query}); | ||
} | ||
} else { | ||
// Clear results for short queries | ||
displayResults([]); | ||
} | ||
} | ||
|
||
function initSearch () { | ||
var search_input = document.getElementById('mkdocs-search-query'); | ||
if (search_input) { | ||
search_input.addEventListener("keyup", doSearch); | ||
} | ||
|
||
var term = getSearchTermFromLocation(); | ||
if (term) { | ||
search_input.value = term; | ||
doSearch(); | ||
} | ||
} | ||
|
||
function onWorkerMessage (e) { | ||
if (e.data.results) { | ||
var results = e.data.results; | ||
displayResults(results); | ||
} | ||
} | ||
|
||
if (!window.Worker) { | ||
console.log('Web Worker API not supported'); | ||
// load index in main thread | ||
$.getScript(base_url + "/search/worker.js").done(function () { | ||
console.log('Loaded worker'); | ||
init(); | ||
}).fail(function (jqxhr, settings, exception) { | ||
console.error('Could not load worker.js'); | ||
}); | ||
} else { | ||
// Wrap search in a web worker | ||
var searchWorker = new Worker(base_url + "/search/worker.js"); | ||
searchWorker.postMessage({init: true}); | ||
searchWorker.onmessage = onWorkerMessage; | ||
} | ||
|
||
$(function() { | ||
var search_input = document.getElementById('mkdocs-search-query'); | ||
if (search_input) { | ||
search_input.addEventListener("keyup", doSearch); | ||
} | ||
|
||
var term = getSearchTermFromLocation(); | ||
if (term) { | ||
search_input.value = term; | ||
doSearch(); | ||
} | ||
}); | ||
function getSearchTermFromLocation() { | ||
var sPageURL = window.location.search.substring(1); | ||
var sURLVariables = sPageURL.split('&'); | ||
for (var i = 0; i < sURLVariables.length; i++) { | ||
var sParameterName = sURLVariables[i].split('='); | ||
if (sParameterName[0] == 'q') { | ||
return decodeURIComponent(sParameterName[1].replace(/\+/g, '%20')); | ||
} | ||
} | ||
} | ||
|
||
function joinUrl (base, path) { | ||
if (path.substring(0, 1) === "/") { | ||
// path starts with `/`. Thus it is absolute. | ||
return path; | ||
} | ||
if (base.substring(base.length-1) === "/") { | ||
// base ends with `/` | ||
return base + path; | ||
} | ||
return base + "/" + path; | ||
} | ||
|
||
function formatResult (location, title, summary) { | ||
return '<article><h3><a href="' + joinUrl(base_url, location) + '">'+ title + '</a></h3><p>' + summary +'</p></article>'; | ||
} | ||
|
||
function displayResults (results) { | ||
var search_results = document.getElementById("mkdocs-search-results"); | ||
while (search_results.firstChild) { | ||
search_results.removeChild(search_results.firstChild); | ||
} | ||
if (results.length > 0){ | ||
for (var i=0; i < results.length; i++){ | ||
var result = results[i]; | ||
var html = formatResult(result.location, result.title, result.summary); | ||
search_results.insertAdjacentHTML('beforeend', html); | ||
} | ||
} else { | ||
search_results.insertAdjacentHTML('beforeend', "<p>No results found</p>"); | ||
} | ||
} | ||
|
||
function doSearch () { | ||
var query = document.getElementById('mkdocs-search-query').value; | ||
if (query.length > 2) { | ||
if (!window.Worker) { | ||
displayResults(search(query)); | ||
} else { | ||
searchWorker.postMessage({query: query}); | ||
} | ||
} else { | ||
// Clear results for short queries | ||
displayResults([]); | ||
} | ||
} | ||
|
||
function initSearch () { | ||
var search_input = document.getElementById('mkdocs-search-query'); | ||
if (search_input) { | ||
search_input.addEventListener("keyup", doSearch); | ||
} | ||
var term = getSearchTermFromLocation(); | ||
if (term) { | ||
search_input.value = term; | ||
doSearch(); | ||
} | ||
} | ||
|
||
function onWorkerMessage (e) { | ||
if (e.data.allowSearch) { | ||
initSearch(); | ||
} else if (e.data.results) { | ||
var results = e.data.results; | ||
displayResults(results); | ||
} | ||
} | ||
|
||
if (!window.Worker) { | ||
console.log('Web Worker API not supported'); | ||
// load index in main thread | ||
$.getScript(joinUrl(base_url, "search/worker.js")).done(function () { | ||
console.log('Loaded worker'); | ||
init(); | ||
window.postMessage = function (msg) { | ||
onWorkerMessage({data: msg}); | ||
}; | ||
}).fail(function (jqxhr, settings, exception) { | ||
console.error('Could not load worker.js'); | ||
}); | ||
} else { | ||
// Wrap search in a web worker | ||
var searchWorker = new Worker(joinUrl(base_url, "search/worker.js")); | ||
searchWorker.postMessage({init: true}); | ||
searchWorker.onmessage = onWorkerMessage; | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.