Skip to content

Instantly share code, notes, and snippets.

@met
Created September 15, 2024 17:02
Show Gist options
  • Save met/f2546d38d35d792d7ca149eb0cc9c37f to your computer and use it in GitHub Desktop.
Save met/f2546d38d35d792d7ca149eb0cc9c37f to your computer and use it in GitHub Desktop.
Train vocabulary with ZivyObraz.cz
// This work by Martin Hassman is marked with CC0 1.0
// https://creativecommons.org/publicdomain/zero/1.0/?ref=chooser-v1
//
// How to use:
// 1. Upload your vocabulary into 1st column of 1st sheet in Google Tables
// 2. Set apiKey of https://zivyobraz.eu/
// 3. Set time trigger to SetNewVocab() function
// 4. Practice vocabulary
function SetNewVocab() {
let phrase = GetRandomPhrase();
let apiKey = "*** YOUR API KEY TO ZIVYOBRAZ.EU ***";
pushValueToZivyObraz(apiKey, "vocabulary", phrase);
}
// Get content of random cell from 1st column of 1st sheet containing word or phrase
function GetRandomPhrase() {
let sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0];
let lastRow = sheet.getLastRow(); // last row with some content
let randomLineNumber = Math.floor(Math.random()*lastRow);
let phrase = sheet.getRange(randomLineNumber, 1).getValue();
//console.log(phrase);
return phrase;
}
function pushValueToZivyObraz(apiKey, valueName, value) {
let response = UrlFetchApp.fetch(`https://in.zivyobraz.eu/?import_key=${apiKey}&${valueName}=${value}`);
//console.log(response.getResponseCode());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment