Commit 6d5f44b3 authored by Craig Watson's avatar Craig Watson

Search language matches OpenBoard's language

parent 88782ef9
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
</head> </head>
<body> <body>
<!--<p id="lang"></p>-->
</body> </body>
<script type="text/javascript"> <script type="text/javascript">
...@@ -32,18 +33,23 @@ ...@@ -32,18 +33,23 @@
// Image type to retrieve. Can be "photo", "illustration", "vector" or "all". // Image type to retrieve. Can be "photo", "illustration", "vector" or "all".
var imageType = "all"; var imageType = "all";
// Language code to search in // Default language to search in, if the application can't return a suitable one
var searchLanguage = "en"; var searchLanguage = "en";
// Fetch 960px images instead of the default 640px. However the API doesn't // Fetch 960px images instead of the default 640px. However the API doesn't
// provide size information in this case, so it is disabled by default. // provide size information in this case, so it is disabled by default.
var fetchMediumResImages = false; var fetchMediumResImages = false;
// --------------------- // ---------------------
// Globals // Globals
// ---------------------
var currentIndex = 0; var currentIndex = 0;
var currentTerm = ""; var currentTerm = "";
// Pixabay's supported search languages
var availableLanguages = ['cs', 'da', 'de', 'en', 'es', 'fr', 'id', 'it', 'hu', 'nl', 'no',
'pl', 'pt', 'ro', 'sk', 'fi', 'sv', 'tr', 'vi', 'th', 'bg', 'ru', 'el', 'ja', 'ko', 'zh'];
// --------------------- // ---------------------
$(document).ready(loadPage) $(document).ready(loadPage)
...@@ -51,6 +57,12 @@ ...@@ -51,6 +57,12 @@
/* Initialize the page layout */ /* Initialize the page layout */
function loadPage() { function loadPage() {
// Get OpenBoard's current language
var appLanguage = window.sankore ? sankore.locale().substr(0,2) : searchLanguage;
if (availableLanguages.indexOf(appLanguage) > -1)
searchLanguage = appLanguage
var mode = false; //search or view mode var mode = false; //search or view mode
var hide = false; //hide or no main panel var hide = false; //hide or no main panel
...@@ -106,6 +118,7 @@ ...@@ -106,6 +118,7 @@
+"&safesearch=true"; +"&safesearch=true";
//console.log(url); //console.log(url);
//document.getElementById("lang").innerHTML = "Language: " + searchLanguage;
$.ajax({ $.ajax({
url: url, url: url,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment