Skip to content

Instantly share code, notes, and snippets.

@edi9999
Last active November 15, 2015 17:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edi9999/7a043c860002f354fce4 to your computer and use it in GitHub Desktop.
Save edi9999/7a043c860002f354fce4 to your computer and use it in GitHub Desktop.
Yogamoves
doc = $('frame[name="mainFrame"]', top.document)[0].contentDocument;
$(doc).find("tr.scheduleRow").each(function(el){
obj = $(this).find("td").map(function(){return this.innerText});
teacher = encodeURIComponent(obj[4].replace("\n",""));
course = encodeURIComponent(obj[3].replace("\n",""));
date = obj[0].replace(/.* ([0-9]+)\/([0-9]+)\/([0-9]+)/,"$3$2$1");
time = parseInt(obj[1].replace(/([0-9]+):([0-9]+)/,"0$1$2"),10)
console.log(obj)
startT = date+"T"+pad(time,4) + "00"
endT = date + "T" + pad((time+100),4) +"00"
console.log(obj);
console.log(date);
url = "http://www.google.com/calendar/event?action=TEMPLATE&text=Yoga"+teacher+"|"+course+"&dates="+startT+"/"+endT+""
window.open(url)
console.log(url)
})
function pad(number, length) {
var str = '' + number;
while (str.length < length) {
str = '0' + str;
}
return str;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment