-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathidbtest.php
118 lines (96 loc) · 3.75 KB
/
idbtest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
function base_url() {
return 'http://devoffcalendar.pl/';
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<base href="<?= base_url() ?>" />
<title>IndexedDB TODO List</title>
<script type="text/javascript" src="static/js/jquery.js"></script>
<script type="text/javascript" src="static/js/IndexedDB.js"></script>
<script type="text/javascript" src="static/js/OffCalendar.js"></script>
<script type="text/javascript" src="static/js/OffCalendarHelper.js"></script>
<script type="text/javascript">
IndexedDB.open(function() {
var userId = 1;
var userEmail = '[email protected]';
var userPassword = 'lorem123';
var eventsSyncApiUrl = '<?= base_url() ?>apis/events_api/synchronize';
<?php if(isset($_GET['sync'])) : ?>
IndexedDB.synchronize(userId, userEmail, userPassword, eventsSyncApiUrl, function(){
console.log('Synchronization finished.');
});
<?php else : ?>
// EVENT DIRECT ADD TEST
var start = OffCalendarHelper.currentTimestamp();
var end = start + 3600;
var description = "This is cool event";
var sendNotification = 0;
var currTimestamp = OffCalendarHelper.currentTimestamp();
var Event = {
id: 5,
user_id: userId,
start_timestamp: start,
end_timestamp: end,
description: description,
send_notification: sendNotification,
voided: 0,
created_timestamp: currTimestamp,
remote_timestamp: currTimestamp,
last_update_timestamp: 0,
};
IndexedDB.addEvent(Event, function(remoteEventId) {
console.log('Event added');
// var Event = {
// id: 14,
// user_id: userId,
// start_timestamp: start,
// end_timestamp: end,
// description: "newest description",
// send_notification: sendNotification,
// voided: 0,
// created_timestamp: currTimestamp,
// remote_timestamp: currTimestamp,
// last_update_timestamp: 0,
// };
//
// IndexedDB.updateEventById(Event.id, Event, function(){
// });
});
// // GET EVENTS TEST
//
// IndexedDB.getUserEvents(userId, function(events) {
//
// if (events === null) {
//
// // TODO KO: ERROR
//
// } else {
//
// // TODO KO: SUCCESS
//
// }
//
// });
//
//
// // UPDATE EVENT TEST
//
// var remoteEventId = 1;
//
// var toUpdate = {
// description: "This is not so cool event!"
// };
//
// OffCalendar.updateEvent(remoteEventId, toUpdate);
<?php endif; ?>
});
</script>
</head>
<body>
IndexedDB Test. Open console for output.
</body>
</html>