Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit 61929046aad216d821596ea4d1cafe713f30e6ae Eliseo Soto committed Aug 9, 2012
@@ -0,0 +1,4 @@
+.idea/
+.tm_properties
+builds/
+release/
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Calendar</title>
+ <link rel="stylesheet" href="style.css">
+ </head>
+ <body>
+ <div id="calendarContainer" class="calendarContainer"></div>
+
+ <script src="js/calendar.js"></script>
+ </body>
+</html>
@@ -0,0 +1,78 @@
+var Calendar = {
+ DAY_WIDTH: 600,
+
+ /**
+ * Compares two events and the event that starts first is place before the other.
+ * If the two events start at the same time then the shortest event wins.
+ * @param evtA
+ * @param evtB
+ * @return {*}
+ */
+ eventCompareFunction: function(evtA, evtB) {
+ if (evtA.start < evtB.start) {
+ return -1;
+ } else if (evtA.start === evtB.start) {
+ return (evtA.end - evtA.start) - (evtB.end - evtB.start);
+ } else {
+ return 1;
+ }
+ },
+
+ /**
+ Lays out events for a single day
+
+ @param array events
+ An array of event objects. Each event object consists of a start time, end
+ Time (measured in minutes) from 9am, as well as a unique id. The
+ Start and end time of each event will be [0, 720]. The start time will
+ Be less than the end time. The array is not sorted.
+
+ @return array
+ An array of event objects that has the width, the left and top positions set,
+ In addition to start time, end time, and id.
+
+ **/
+ layOutDay: function(events) {
+ if (!Array.isArray(events)) {
+ throw new Error("events must be an Array!");
+ }
+ var evts = events.slice(0); // clone the original array
+
+ var result = [];
+
+ // Sort the events
+ evts.sort(this.eventCompareFunction);
+
+ // See what are the events that collide
+ if(evts.length > 1) {
+ var event = evts[0];
+
+ // Create collision groups
+
+ // Count how many collision an event has
+
+ for(var i = 1; i < evts.length; i++) {
+ var ev = evts[i];
+
+ if(ev.start < event.end && ev.start > event.start) {
+
+ }
+ }
+
+ } else {
+ if(evts.length === 1) {
+ var event = evts[0];
+ event['width'] = this.DAY_WIDTH;
+ event['left'] = 0;
+ event['top'] = event.start;
+ result.push(event);
+ }
+ }
+
+ return result;
+ }
+};
+
+(function() {
+
+})();
@@ -0,0 +1,6 @@
+.calendarContainer {
+ border: black;
+ border-width: 1px;
+ width: 620px;
+ height: 720px;
+}
@@ -0,0 +1,51 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+ <title>Jasmine Spec Runner</title>
+
+ <link rel="shortcut icon" type="image/png" href="lib/jasmine-1.2.0/jasmine_favicon.png">
+ <link rel="stylesheet" type="text/css" href="lib/jasmine-1.2.0/jasmine.css">
+ <script type="text/javascript" src="lib/jasmine-1.2.0/jasmine.js"></script>
+ <script type="text/javascript" src="lib/jasmine-1.2.0/jasmine-html.js"></script>
+
+ <!-- include source files here... -->
+ <script type="text/javascript" src="../js/calendar.js"></script>
+
+ <!-- include spec files here... -->
+ <script type="text/javascript" src="spec/CalendarSpec.js"></script>
+
+ <script type="text/javascript">
+ (function() {
+ var jasmineEnv = jasmine.getEnv();
+ jasmineEnv.updateInterval = 1000;
+
+ var htmlReporter = new jasmine.HtmlReporter();
+
+ jasmineEnv.addReporter(htmlReporter);
+
+ jasmineEnv.specFilter = function(spec) {
+ return htmlReporter.specFilter(spec);
+ };
+
+ var currentWindowOnload = window.onload;
+
+ window.onload = function() {
+ if (currentWindowOnload) {
+ currentWindowOnload();
+ }
+ execJasmine();
+ };
+
+ function execJasmine() {
+ jasmineEnv.execute();
+ }
+
+ })();
+ </script>
+
+</head>
+
+<body>
+</body>
+</html>
@@ -0,0 +1,20 @@
+Copyright (c) 2008-2011 Pivotal Labs
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Oops, something went wrong.

0 comments on commit 6192904

Please sign in to comment.