mirror of
https://github.com/hanzoai/jube-fork.git
synced 2026-11-02 14:29:36 +00:00
144 lines
5.1 KiB
HTML
Executable File
144 lines
5.1 KiB
HTML
Executable File
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Binding to Kinvey Backend Services</title>
|
|
<meta charset="utf-8">
|
|
<link href="../content/shared/styles/examples-offline.css" rel="stylesheet">
|
|
<link href="../../styles/kendo.common.min.css" rel="stylesheet">
|
|
<link href="../../styles/kendo.rtl.min.css" rel="stylesheet">
|
|
<link href="../../styles/kendo.default.min.css" rel="stylesheet">
|
|
<link href="../../styles/kendo.default.mobile.min.css" rel="stylesheet">
|
|
<script src="../../js/jquery.min.js"></script>
|
|
<script src="../../js/jszip.min.js"></script>
|
|
<script src="../../js/kendo.all.min.js"></script>
|
|
<script src="../content/shared/js/console.js"></script>
|
|
<script>
|
|
|
|
</script>
|
|
|
|
|
|
</head>
|
|
<body>
|
|
|
|
<a class="offline-button" href="../index.html">Back</a>
|
|
|
|
<div id="example">
|
|
<!--[if gte IE 11]>-->
|
|
<div id="scheduler"></div>
|
|
|
|
<!-- Kinvey JS SDK (HTML, PhoneGap, etc.) -->
|
|
<script src="../content/shared/js/kinvey-html5-sdk.min.js"></script>
|
|
|
|
<!-- Kinvey Kendo UI Data Source -->
|
|
<script src="../content/shared/js/kendo.data.kinvey.min.js"></script>
|
|
|
|
<script>
|
|
// initialize Kinvey application with application API key
|
|
Kinvey.init({
|
|
appKey: 'kid_SJyRpx96G',
|
|
appSecret: 'a88466f87e434ca4a1a0194e33d3168d'
|
|
});
|
|
|
|
function createScheduler() {
|
|
var collectionName = "tasks";
|
|
|
|
var dataSource = new kendo.data.SchedulerDataSource({
|
|
type: "kinvey",
|
|
transport: {
|
|
// binding to the Tasks type in Kinvey
|
|
typeName: collectionName
|
|
},
|
|
schema: {
|
|
model: {
|
|
id: "id",
|
|
fields: {
|
|
// type fields, projected to the scheduler format
|
|
id: { from: "_id", type: "string" },
|
|
title: { from: "Title", defaultValue: "No title", validation: { required: true } },
|
|
start: { type: "date", from: "Start" },
|
|
end: { type: "date", from: "End" },
|
|
startTimezone: { from: "StartTimezone" },
|
|
endTimezone: { from: "EndTimezone" },
|
|
description: { from: "Description" },
|
|
recurrenceId: { from: "RecurrenceID" },
|
|
recurrenceRule: { from: "RecurrenceRule" },
|
|
recurrenceException: { from: "RecurrenceException" },
|
|
ownerId: { from: "OwnerID", defaultValue: 1 },
|
|
isAllDay: { type: "boolean", from: "IsAllDay" }
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
$("#scheduler").kendoScheduler({
|
|
date: new Date("2013/6/13"),
|
|
startTime: new Date("2013/6/13 07:00 AM"),
|
|
height: 600,
|
|
editable: false,
|
|
views: [
|
|
"day",
|
|
{ type: "workWeek", selected: true },
|
|
"week",
|
|
"month",
|
|
"agenda",
|
|
"timeline"
|
|
],
|
|
dataSource: dataSource,
|
|
timezone: "Etc/UTC",
|
|
resources: [
|
|
{
|
|
field: "ownerId",
|
|
title: "Owner",
|
|
dataSource: [
|
|
{ text: "Alex", value: 1, color: "#f8a398" },
|
|
{ text: "Bob", value: 2, color: "#51a0ed" },
|
|
{ text: "Charlie", value: 3, color: "#56ca85" }
|
|
]
|
|
}
|
|
]
|
|
});
|
|
}
|
|
|
|
$(document).ready(function () {
|
|
// Get the locally stored activeUser
|
|
var activeUser = Kinvey.User.getActiveUser();
|
|
var userPromise;
|
|
|
|
if (activeUser === null) {
|
|
userPromise = Kinvey.User.signup();
|
|
|
|
} else {
|
|
userPromise = activeUser.me();
|
|
}
|
|
|
|
userPromise
|
|
// skipped if no error
|
|
.catch(function (userError) {
|
|
if (userError.name === 'InvalidCredentialsError') {
|
|
// clear the activeUser using logout and then initiate login and return login response
|
|
return Kinvey.User.logout()
|
|
.then(function () {
|
|
return Kinvey.User.signup();
|
|
});
|
|
}
|
|
else {
|
|
// if the error is different from InvalidCredentialsError, forward it down the chain
|
|
return Promise.reject(userError);
|
|
}
|
|
})
|
|
.then(function () {
|
|
createScheduler();
|
|
})
|
|
.catch(function (error) {
|
|
alert(error.message);
|
|
});
|
|
});
|
|
</script>
|
|
<!--<![endif]-->
|
|
</div>
|
|
|
|
|
|
|
|
</body>
|
|
</html>
|