Instantly share code, notes, and snippets.

Embed
What would you like to do?
A scheduler for studying tractate Nazir
function onEdit(e) {
// Interact with Sheets App
var app = SpreadsheetApp;
// get current active sheet
var activeSheet = app.getActiveSpreadsheet().getActiveSheet();
// gets the amount of blatt in Nazir
var blattInNazir = activeSheet.getRange("B2").getValue();
// Log blattInNazir
Logger.log("There are " + blattInNazir + " blatt in Nazir");
// The gemara starts on daf 2
var start = activeSheet.getRange("D2").getValue();
var learnt = activeSheet.getRange("E2").getValue();
// Ends on daf 66 (there are 65 blatt)
var end = blattInNazir + 1;
var todaysBlatt = start;
var blattRow = 5 + learnt;
var today = new Date().getTime();
if(learnt !== 0){
today = new Date(today + 86400000).getTime();
}
for(start; start <= end; start++){
var todaysBlattCell = activeSheet.getRange(blattRow, 2);
var dateCell = activeSheet.getRange(blattRow, 1);
var theDate = new Date(today);
var learntCell = activeSheet.getRange(blattRow,3).getValue();
if(!learntCell){
today = today + 86400000;
todaysBlattCell.setValue("Nazir " + start);
dateCell.setValue(theDate);
}
blattRow++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment