diff --git a/README.md b/README.md index f9c01f3..aa35d52 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Just copy the files into your php capable webserver directory. Be sure, that the Just call the url. You can filter by categories by adding /?filter=category to the request. You can expand the period of the events by adding /?period= to the request. The number represents the amount of future months as an integer between 1..12. -## Example integration using vanilla ja +## Example integration using vanilla js You will need to include a ``
`` placeholder in your html page. @@ -29,9 +29,10 @@ document.addEventListener("DOMContentLoaded", function () { items.push("
" + day.toLocaleDateString(true, {weekday:'short', day:'numeric', month:'long', year: 'numeric'}) + "
"); Object.keys(data[date]).forEach(function (uid) { var event = data[date][uid]; - if(event.location) event.location = event.location.replace(/\n/g,"
").replace(uri_regex, "$1"); - if(event.description) event.description = event.description.replace(/\n/g,"
").replace(uri_regex, (url) => {event.summary = `${event.summary}`; return "";}); - items.push("
" + event.datestr + "" + event.summary + " | " + ((event.location)?event.location:'') + "
" + ((event.description)?event.description:'') + "
"); + var location = (event.location)?event.location.replace(/\n/g,"
").replace(uri_regex, "$1"):''; + var description = (event.description)?event.description.replace(/\n/g,"
").replace(uri_regex, (url) => {event.summary = `${event.summary}`; return "";}):''; + var categories = (event.categories)?"" + event.categories.replace(",", " ") + "":''; + items.push("
" + event.datestr + "" + event.summary + " | " + location + "
" + description + categories + "
"); }); }); document.querySelector('#hackcal').innerHTML = items.join( "" ); @@ -41,3 +42,12 @@ document.addEventListener("DOMContentLoaded", function () { ``` +## Sample CSS +``` +#hackcal {border: 1px solid #CCC} +#hackcal div {display: flex; padding: 8px 14px} +#hackcal [data-date] {background: #CCC; font-weight: bold} +#hackcal [data-uid] {font-size: .9em; gap: .5em; line-height: 1.5em} +#hackcal [data-uid] span:first-child {flex: 0 0 3em; font-weight: bold} +``` +