This commit is contained in:
@@ -24,6 +24,13 @@ function ayRegisterHelpers() {
|
||||
)}logo/${size}`;
|
||||
return new Handlebars.SafeString("<img src='" + url + "'/>");
|
||||
});
|
||||
|
||||
Handlebars.registerHelper("ayT", function (translationKey) {
|
||||
if (ayTranslationKeyCache[translationKey] == undefined) {
|
||||
return translationKey;
|
||||
}
|
||||
return ayTranslationKeyCache[translationKey];
|
||||
});
|
||||
} //eof
|
||||
|
||||
async function ayPreRender(ayAllData) {
|
||||
@@ -34,10 +41,39 @@ async function ayPreRender(ayAllData) {
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////
|
||||
// cache to hold translations keys
|
||||
//
|
||||
var ayTranslationKeyCache = {};
|
||||
|
||||
///////////////////////////////////
|
||||
// GET TRANSLATIONS FROM API SERVER
|
||||
//
|
||||
async function ayGetTranslations(keys) {
|
||||
try {
|
||||
let r = await fetch(route, {
|
||||
method: "get",
|
||||
mode: "cors",
|
||||
headers: {
|
||||
Accept: "application/json",
|
||||
"Content-Type": "application/json",
|
||||
Authorization: token
|
||||
}
|
||||
});
|
||||
return await r.json();
|
||||
} catch (error) {
|
||||
//fundamental error, can't proceed with this call
|
||||
// handleError("GET", error, route);
|
||||
//todo: deal with this properly
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////
|
||||
// GET DATA FROM API SERVER
|
||||
//
|
||||
async function ayGetFromAPI(route, token) {
|
||||
token = token || AYMETA.ayClientMetaData.Authorization;
|
||||
try {
|
||||
let r = await fetch(route, {
|
||||
method: "get",
|
||||
@@ -60,7 +96,8 @@ async function ayGetFromAPI(route, token) {
|
||||
///////////////////////////////////
|
||||
// POST DATA TO API SERVER
|
||||
//
|
||||
async function ayPostToAPI(route, token, data) {
|
||||
async function ayPostToAPI(route, data, token) {
|
||||
token = token || AYMETA.ayClientMetaData.Authorization;
|
||||
try {
|
||||
fetchOptions = {
|
||||
method: "post",
|
||||
|
||||
Reference in New Issue
Block a user