starting to move code server side
This commit is contained in:
parent
58b3bfa487
commit
e4ca4b5e3d
88
ics.php
88
ics.php
|
@ -12,6 +12,51 @@
|
|||
die('<p>Access denied.</p></body></html>');
|
||||
}
|
||||
|
||||
/*function ics2json($input)
|
||||
{
|
||||
$id = 0;
|
||||
$root = array();
|
||||
$curr = root;
|
||||
input.split("\r\n").forEach(l =>
|
||||
{
|
||||
var key = l.split(":")[0].split(";")[0];
|
||||
var val = l.split(":")[1];
|
||||
if (key == "BEGIN")
|
||||
{
|
||||
if (curr[val])
|
||||
{
|
||||
val += "_" + (id++);
|
||||
}
|
||||
curr[val] = {
|
||||
parent: curr
|
||||
};
|
||||
curr = curr[val];
|
||||
}
|
||||
else if (key == "END")
|
||||
{
|
||||
var parent = curr.parent;
|
||||
delete curr.parent;
|
||||
curr = parent;
|
||||
}
|
||||
else
|
||||
{
|
||||
curr[key] = key.startsWith("DT") ? dt(val) : val;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
root.VCALENDAR.VEVENTS = [];
|
||||
Object.keys(root.VCALENDAR)
|
||||
.filter(k => (k == "VEVENT" || k.startsWith("VEVENT_")))
|
||||
.forEach(k =>
|
||||
{
|
||||
root.VCALENDAR.VEVENTS.push(root.VCALENDAR[k]);
|
||||
delete root.VCALENDAR[k];
|
||||
});
|
||||
|
||||
return root.VCALENDAR;
|
||||
}*/
|
||||
|
||||
// Get ics file
|
||||
$curl = curl_init();
|
||||
curl_setopt($curl, CURLOPT_URL, $url);
|
||||
|
@ -43,50 +88,7 @@
|
|||
<!-- old -->
|
||||
<div id="content">Récupération du calendrier...</div>
|
||||
<script type="text/javascript">
|
||||
function ics2json(input)
|
||||
{
|
||||
var id = 0;
|
||||
var root = {};
|
||||
var curr = root;
|
||||
input.split("\r\n").forEach(l =>
|
||||
{
|
||||
var key = l.split(":")[0].split(";")[0];
|
||||
var val = l.split(":")[1];
|
||||
if (key == "BEGIN")
|
||||
{
|
||||
if (curr[val])
|
||||
{
|
||||
val += "_" + (id++);
|
||||
}
|
||||
curr[val] = {
|
||||
parent: curr
|
||||
};
|
||||
curr = curr[val];
|
||||
}
|
||||
else if (key == "END")
|
||||
{
|
||||
var parent = curr.parent;
|
||||
delete curr.parent;
|
||||
curr = parent;
|
||||
}
|
||||
else
|
||||
{
|
||||
curr[key] = key.startsWith("DT") ? dt(val) : val;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
root.VCALENDAR.VEVENTS = [];
|
||||
Object.keys(root.VCALENDAR)
|
||||
.filter(k => (k == "VEVENT" || k.startsWith("VEVENT_")))
|
||||
.forEach(k =>
|
||||
{
|
||||
root.VCALENDAR.VEVENTS.push(root.VCALENDAR[k]);
|
||||
delete root.VCALENDAR[k];
|
||||
});
|
||||
|
||||
return root.VCALENDAR;
|
||||
}
|
||||
|
||||
function dt(s)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue