Sha256: 8078682505e195ba570b6c923395887ec249321d686e71d3b38520b8a7b594e1
Contents?: true
Size: 775 Bytes
Versions: 11
Compression:
Stored size: 775 Bytes
Contents
class ApiFetcher { // eslint-disable-line no-unused-vars constructor(query, variables) { this.query = query; this.variables = variables; } fetch(callback) { $.ajax({ method: "POST", url: "/api", contentType: "application/json", data: JSON.stringify({ query: this.query, variables: this.variables }) }).done(function(data) { callback(data.data); }); } fetchAll (callback) { this.fetch(callback); } static findTranslation(translations) { let text, lang = document.querySelector('html').getAttribute('lang'); translations.forEach((t) => { if(t.text) { if(!text || t.locale == lang) { text = t.text } } }); return text; } }
Version data entries
11 entries across 11 versions & 1 rubygems