Skip to content

Instantly share code, notes, and snippets.

@ezp-matt
Created March 5, 2012 20:57
Show Gist options
  • Save ezp-matt/1981034 to your computer and use it in GitHub Desktop.
Save ezp-matt/1981034 to your computer and use it in GitHub Desktop.
dojo calendar internal/external data tests
{
"identifier":"event_id",
"numRows":1,
"items":[
{"event_id":"1","title":"Test Event","start":"2012-03-05 10:00:00","end":"2012-03-05 14:00:00"}
]
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Calendar Loader</title>
<link rel="stylesheet" type="text/css" href="dijit/themes/claro/document.css" />
<link rel="stylesheet" type="text/css" href="dijit/themes/claro/claro.css" />
<link rel="stylesheet" type="text/css" href="dojox/calendar/themes/claro/Calendar.css" />
<script src="dojo/dojo.js" type="text/javascript" data-dojo-config="parseOnLoad: true"></script>
<script type="text/javascript">
require([
"dojo/ready",
"dojo/data/ItemFileWriteStore",
"dojo/store/DataStore",
"dojox/calendar/Calendar"
]);
</script>
<style>
html, body {
width: 100%;
height: 100%;
}
</style>
</head>
<body class="claro">
<div data-dojo-type="dojo.data.ItemFileWriteStore"
data-dojo-id="calendar_store"
data-dojo-props="url:'calendar_data.json'">
<script type="dojo/connect" data-dojo-event="startup">
this._saveEverything = function(saveCompleteCallback, saveFailedCallback, newFileContentString) {
console.log('saveEverything');
console.log(newFileContentString);
saveCompleteCallback();
}
</script>
</div>
<div data-dojo-type="dojo.store.DataStore" data-dojo-id="calendar_dataStore" store="calendar_store">
</div>
<div data-dojo-id="calendar_calendar" data-dojo-type="dojox.calendar.Calendar" store="calendar_dataStore" startTimeAttr="start" endTimeAttr="end" summaryAttr="title" style="background-color:white">
<script type="dojo/method" data-dojo-event="mysqlToDate" data-dojo-args="datetime">
var regex=/^([0-9]{2,4})-([0-1][0-9])-([0-3][0-9]) (?:([0-2][0-9]):([0-5][0-9]):([0-5][0-9]))?$/;
var parts=datetime.replace(regex,"$1 $2 $3 $4 $5 $6").split(' ');
return new Date(parts[0],parts[1]-1,parts[2],parts[3],parts[4],parts[5]);
</script>
<script type="dojo/method" data-dojo-event="decodeDate" data-dojo-args="d">
return this.mysqlToDate(d);
</script>
</div>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Calendar Loader</title>
<link rel="stylesheet" type="text/css" href="dijit/themes/claro/document.css" />
<link rel="stylesheet" type="text/css" href="dijit/themes/claro/claro.css" />
<link rel="stylesheet" type="text/css" href="dojox/calendar/themes/claro/Calendar.css" />
<script src="dojo/dojo.js" type="text/javascript" data-dojo-config="parseOnLoad: true"></script>
<script type="text/javascript">
require([
"dojo/ready",
"dojo/data/ItemFileWriteStore",
"dojo/store/DataStore",
"dojox/calendar/Calendar"
]);
var calendarData = {
'identifier':'event_id',
'numRows':1,
'items':[
{'event_id':'1','title':'Test Event','start':'2012-03-05 10:00:00','end':'2012-03-05 14:00:00'}
]
};
</script>
<style>
html, body {
width: 100%;
height: 100%;
}
</style>
</head>
<body class="claro">
<div data-dojo-type="dojo.data.ItemFileWriteStore"
data-dojo-id="calendar_store"
data-dojo-props="data:calendarData">
<script type="dojo/connect" data-dojo-event="startup">
this._saveEverything = function(saveCompleteCallback, saveFailedCallback, newFileContentString) {
console.log('saveEverything');
console.log(newFileContentString);
saveCompleteCallback();
}
</script>
</div>
<div data-dojo-type="dojo.store.DataStore" data-dojo-id="calendar_dataStore" store="calendar_store">
</div>
<div data-dojo-id="calendar_calendar" data-dojo-type="dojox.calendar.Calendar" store="calendar_dataStore" startTimeAttr="start" endTimeAttr="end" summaryAttr="title" style="background-color:white">
<script type="dojo/method" data-dojo-event="mysqlToDate" data-dojo-args="datetime">
var regex=/^([0-9]{2,4})-([0-1][0-9])-([0-3][0-9]) (?:([0-2][0-9]):([0-5][0-9]):([0-5][0-9]))?$/;
var parts=datetime.replace(regex,"$1 $2 $3 $4 $5 $6").split(' ');
return new Date(parts[0],parts[1]-1,parts[2],parts[3],parts[4],parts[5]);
</script>
<script type="dojo/method" data-dojo-event="decodeDate" data-dojo-args="d">
return this.mysqlToDate(d);
</script>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment