aboutsummaryrefslogtreecommitdiffstats
path: root/jm2l/static/js
diff options
context:
space:
mode:
authortr4ck3ur <tr4ck3ur@style-python.fr>2015-02-14 03:35:21 +0100
committertr4ck3ur <tr4ck3ur@style-python.fr>2015-02-14 03:35:21 +0100
commit114d2d92147f53a1ed1d0090feedb3fb0b50d064 (patch)
treed8b9c71567b5b0fcd84f6285c669fc754fbde26f /jm2l/static/js
parentfa4a9859c57de6b7894ff4b84b75d242f2b796f5 (diff)
downloadjm2l-114d2d92147f53a1ed1d0090feedb3fb0b50d064.tar.gz
jm2l-114d2d92147f53a1ed1d0090feedb3fb0b50d064.tar.bz2
jm2l-114d2d92147f53a1ed1d0090feedb3fb0b50d064.tar.xz
jm2l-114d2d92147f53a1ed1d0090feedb3fb0b50d064.zip
harmonize file structure for third party plugins
Diffstat (limited to 'jm2l/static/js')
-rw-r--r--jm2l/static/js/Schedule.js437
-rw-r--r--jm2l/static/js/jm2l.js202
-rw-r--r--jm2l/static/js/programme.js111
3 files changed, 750 insertions, 0 deletions
diff --git a/jm2l/static/js/Schedule.js b/jm2l/static/js/Schedule.js
new file mode 100644
index 0000000..f017240
--- /dev/null
+++ b/jm2l/static/js/Schedule.js
@@ -0,0 +1,437 @@
+/**
+ * inspired from @author Dimitry Kudrayvtsev
+ * @author tr4ck3ur
+ */
+
+d3.sched = function(EventType) {
+ var FIT_TIME_DOMAIN_MODE = "fit";
+ var FIXED_TIME_DOMAIN_MODE = "fixed";
+ var myname = EventType;
+ var margin = {
+ top : 15,
+ right : 10,
+ bottom : 10,
+ left : 50
+ };
+ var timeDomainStart = d3.time.hour.offset(new Date(),-2);
+ var timeDomainEnd = d3.time.hour.offset(new Date(),+2);
+ var timeDomainMode = FIT_TIME_DOMAIN_MODE;// fixed or fit
+ var taskTypes = [];
+ var taskStatus = [];
+ //var height = document.body.clientHeight - margin.top - margin.bottom-5;
+ height = 700;
+ //var width = document.body.clientWidth - margin.right - margin.left-5;
+ var width = 700;// - margin.right - margin.left;
+ var tickFormat = "%H:%M";
+ var lastscale = -1;
+
+ var xScale = d3.scale.ordinal()
+ .domain(taskTypes)
+ .rangeRoundBands([ 0, width - margin.left], .1);
+
+ var yScale = d3.time.scale()
+ .domain([ timeDomainStart, timeDomainEnd ])
+ .range([ 0, height - margin.top ]) //- margin.bottom ]);
+ .clamp(true);
+
+ var xAxis = d3.svg.axis()
+ .scale(xScale)
+ .orient("left")
+ .tickSize(1);
+
+ var yAxis = d3.svg.axis()
+ .scale(yScale)
+ .orient("bottom")
+ .tickFormat(d3.time.format(tickFormat))
+ .tickSubdivide(true)
+ .tickSize(8).tickPadding(8);
+
+ var keyFunction = function(d) {
+ return d.startDate + d.placeName + d.endDate;
+ };
+
+ var rectTransform = function(d) {
+ return "translate(" + xScale(d.placeName) + "," + yScale(d.startDate) + ")";
+ };
+
+ var initTimeDomain = function(tasks) {
+ if (timeDomainMode === FIT_TIME_DOMAIN_MODE) {
+ if (tasks === undefined || tasks.length < 1) {
+ timeDomainStart = d3.time.day.offset(new Date(), -3);
+ timeDomainEnd = d3.time.hour.offset(new Date(), +3);
+ return;
+ }
+ tasks.sort(function(a, b) {
+ return a.endDate - b.endDate;
+ });
+ timeDomainEnd = tasks[tasks.length - 1].endDate;
+ tasks.sort(function(a, b) {
+ return a.startDate - b.startDate;
+ });
+ timeDomainStart = tasks[0].startDate;
+ }
+ };
+
+ var initAxis = function() {
+
+ xScale = d3.scale.ordinal()
+ .domain(taskTypes)
+ .rangeRoundBands([ 0, width ], .1);
+
+ yScale = d3.time.scale()
+ .domain([ timeDomainStart, timeDomainEnd ])
+ .range([ 0, height - margin.top - margin.bottom ])
+ .clamp(true);
+
+ xAxis = d3.svg.axis()
+ .scale(xScale)
+ .orient("top")
+ .tickSize(1);
+
+ yAxis = d3.svg.axis()
+ .scale(yScale)
+ .orient("left")
+ .tickFormat(d3.time.format(tickFormat))
+ .tickSubdivide(true)
+ .tickSize(8)
+ .tickPadding(8);
+ };
+
+ function sched(tasks) {
+
+ initTimeDomain(tasks);
+ initAxis();
+
+ function zoomed() {
+ var px = d3.event.translate[0];
+ var py = d3.event.translate[1];
+ var dx = 0;
+ timeDomainStart = d3.time.hour.offset( timeDomainStart, 0)
+ if (py>0) {
+ dx = timeDomainStart.getTime()-yScale.invert(py).getTime()
+ } else {
+ dx = -timeDomainStart.getTime()+yScale.invert(-py).getTime()
+ }
+ NewStart = d3.time.hour.offset( timeDomainStart.getTime()+dx, 0)
+ //NewEnd = d3.time.hour.offset( timeDomainStart.getTime()+dx, 0) //.3*d3.event.scale)
+ //yScale.domain([ NewStart , NewEnd ])
+
+ sched.timeDomainMode("fit")
+ //sched.timeDomain([ NewStart , NewEnd ]);
+ //timeDomainStart = NewStart
+ //timeDomainEnd = NewEnd
+
+ var dy = py;
+ var dz = timeDomainEnd-timeDomainStart
+ if (py>0)
+ var dx = timeDomainStart-yScale.invert(py).getTime()
+ else
+ var dx = -timeDomainStart+yScale.invert(-py).getTime()
+
+ //yScale.domain([ timeDomainStart, d3.time.hour.offset(timeDomainStart, d3.event.scale*4) ])
+ // .range([ 0, height - margin.top - margin.bottom ])
+ // .clamp(true);
+
+ //yScale2.domain([ NewStart, d3.time.hour.offset(NewStart, d3.event.scale*4) ])
+ // .range([ 0, height - margin.top - margin.bottom ])
+ // .clamp(true);
+
+ //
+ if (0 && lastscale!=d3.event.scale) {
+ lastscale = d3.event.scale;
+ yScale.domain([ timeDomainStart, d3.time.hour.offset(timeDomainStart, d3.event.scale*4) ])
+ .range([ 0, height - margin.top - margin.bottom ])
+ .clamp(true);
+ //Saved = chart.attr("transform");
+ //coords = Saved.slice(Saved.search(/([0-9]+)/g),Saved.length-1).split(',');
+ //chart.attr("transform", "translate(" + px + "," + py + ")");
+ //zoom.translate((80,120))
+ //zoom.center([121, 21])
+ //sched.redraw(this.id, tasks);
+ //zoom.translate()
+
+ //chart.attr("transform", "translate(" + parseInt(coords[0])+px + "," + parseInt(coords[1])+py + ")");
+ //chart.attr("transform", "translate(" + 121 + "," + 21 + ")");
+ chart.attr("transform", "translate(" + px + "," + py + ")");
+ }
+ // else {
+ // chart.attr("transform", "translate(" + px + "," + py + ")");
+ //}
+
+ var dxr = d3.time.hour.offset( timeDomainStart+dx, 0)
+ //ind.text( py +" "+ dz +" => "+ d3.event.scale )
+ //if ( DragLimit.xmin < (-px) && (-px) < DragLimit.xmax ) {
+ // } else {
+ // d3.event.sourceEvent.stopPropagation();
+ // }
+
+ //sched.redraw(tasks);
+
+
+ //sched.timeDomain([ d3.time.hour.offset(mystart,0), d3.time.hour.offset(mystart, d3.event.scale) ]);
+ if (1) {
+ svg.select(".yAxis")
+ .attr("transform", "translate("+ margin.left +","+ margin.top +")")// + py + ")")
+ .transition()
+ .call(yAxis);
+
+ //svg.select(".yAxis2")
+ // .attr("transform", "translate(80,0)")
+ // .call(yAxis2);
+
+ svg.select(".xAxis")
+ .attr("transform", "translate("+ margin.left +","+ margin.top +")")
+ .transition()
+ .call(xAxis);
+
+ chart.attr("transform", "translate("+ margin.left +","+ margin.top +")");
+ }
+
+ }
+
+ var zoom = d3.behavior.zoom()
+ .scaleExtent([1, 4])
+ .on("zoom", zoomed);
+
+ var svg = d3.select("#Schedule_"+EventType)
+ .append("svg")
+ .attr("id", EventType)
+ .attr("class", "chart")
+ .attr("width", width + margin.left + margin.right)
+ .attr("height", height + margin.top + margin.bottom)
+ .call(zoom);
+
+ var chart = svg.append("g")
+ .attr("class", "sched-chart");
+
+ chart.selectAll(".sched-chart")
+ .data(tasks, keyFunction).enter()
+ .append("rect")
+ .attr("class", function(d){
+ if(taskStatus[d.status] == null)
+ { return "bar";}
+ return taskStatus[d.status];
+ });
+
+
+if (0) {
+ chart.selectAll('.foreignObject')
+ .data(tasks, keyFunction).enter()
+ .append('foreignObject')
+ .attr("x", function(d){
+ return xScale(d.placeName || "unk");
+ })
+ .attr("y", function(d){
+ return yScale(d.startDate);
+ })
+ //.attr("y", 0)
+ //.attr("x", 2)
+ //.attr("transform", rectTransform)
+ .attr("width", function(d) {
+ return xScale.rangeBand();
+ })
+ .attr("height", function(d) {
+ return (yScale(d.endDate) - yScale(d.startDate));
+ })
+ .append("xhtml:div")
+ .html(function(d) {
+ return '<div style="padding:2px;height:100%"><a href="/event/'+ d.uid +
+ '">' + d.desc + '</a></div>'
+ });
+}
+/* svg.selectAll("text")
+ .data(tasks, keyFunction).enter()
+ .append("text")
+ .text(function(d) { return d.desc; })
+ .attr("x", 2)
+ .attr("y", 16)
+ .attr("transform", rectTransform)
+ .attr("width", function(d) {
+ return x.rangeBand();
+ })
+ .fill('blue');
+*/
+
+ svg.append("g")
+ .attr("class", "xAxis axis");
+
+ svg.append("g")
+ .attr("class", "yAxis axis");
+
+ //zoomed();
+ //sched.redraw(tasks);
+ return sched;
+
+ };
+
+ sched.redraw = function(who, tasks) {
+
+ //initTimeDomain(tasks);
+ //initAxis();
+ var svg = d3.select("#"+who);
+
+ var schedChartGroup = svg.select(".sched-chart");
+
+ var rect = schedChartGroup.selectAll("rect")
+ .data(tasks, keyFunction);
+
+ rect.enter()
+ .insert("rect",":first-child")
+ .attr("rx", 5)
+ .attr("ry", 5)
+ .attr("class", function(d){
+ if(taskStatus[d.status] == null)
+ { return "bar";}
+ return taskStatus[d.status];
+ })
+ //.transition()
+ .attr("x", function(d){
+ return xScale(d.placeName || "unk");
+ })
+ .attr("y", function(d){
+ return yScale(d.startDate);
+ })
+ //.attr("transform", rectTransform)
+ .attr("width", function(d) {
+ return xScale.rangeBand();
+ })
+ .attr("height", function(d) {
+ return (yScale(d.endDate) - yScale(d.startDate));
+ });
+
+ rect.transition()
+ //.attr("transform", rectTransform)
+ .attr("x", function(d){
+ return xScale(d.placeName || "unk");
+ })
+ .attr("y", function(d){
+ return yScale(d.startDate);
+ })
+ .attr("width", function(d) {
+ return xScale.rangeBand();
+ })
+ .attr("height", function(d) {
+ return (yScale(d.endDate) - yScale(d.startDate));
+ });
+
+ rect.exit()
+ .remove();
+
+ var content = schedChartGroup.selectAll("foreignObject")
+ .data(tasks, keyFunction);
+
+ content.enter()
+ .insert("foreignObject",":first-child")
+ //.transition()
+ .attr("x", function(d){
+ return xScale(d.placeName || "unk");
+ })
+ .attr("y", function(d){
+ return yScale(d.startDate);
+ })
+ //.attr("transform", rectTransform)
+ .attr("width", function(d) {
+ return xScale.rangeBand();
+ })
+ .attr("height", function(d) {
+ return (yScale(d.endDate) - yScale(d.startDate));
+ })
+ .append("xhtml:div")
+ .html(function(d) {
+ return '<div style="padding:2px;height:100%"><a href="/event/'+ d.uid +
+ '">' + d.desc + '</a></div>'
+ });
+
+ content.transition()
+ //.attr("transform", rectTransform)
+ .attr("x", function(d){
+ return xScale(d.placeName || "unk");
+ })
+ .attr("y", function(d){
+ return yScale(d.startDate);
+ })
+ .attr("width", function(d) {
+ return xScale.rangeBand();
+ })
+ .attr("height", function(d) {
+ return (yScale(d.endDate) - yScale(d.startDate));
+ });
+
+ content.exit()
+ .remove();
+
+
+
+ return sched;
+ };
+
+ sched.margin = function(value) {
+ if (!arguments.length)
+ return margin;
+ margin = value;
+ return sched;
+ };
+
+ sched.timeDomain = function(value) {
+ if (!arguments.length)
+ return [ timeDomainStart, timeDomainEnd ];
+ timeDomainStart = +value[0], timeDomainEnd = +value[1];
+ return sched;
+ };
+
+ /**
+ * @param {string}
+ * vale The value can be "fit" - the domain fits the data or
+ * "fixed" - fixed domain.
+ */
+ sched.timeDomainMode = function(value) {
+ if (!arguments.length)
+ return timeDomainMode;
+ timeDomainMode = value;
+ return sched;
+ };
+
+ sched.taskTypes = function(value) {
+ if (!arguments.length)
+ return taskTypes;
+ taskTypes = value;
+ return sched;
+ };
+
+ sched.taskStatus = function(value) {
+ if (!arguments.length)
+ return taskStatus;
+ taskStatus = value;
+ return sched;
+ };
+
+ sched.width = function(value) {
+ if (!arguments.length)
+ return width;
+ width = +value;
+ return sched;
+ };
+
+ sched.height = function(value) {
+ if (!arguments.length)
+ return height;
+ height = +value;
+ return sched;
+ };
+
+ sched.tickFormat = function(value) {
+ if (!arguments.length)
+ return tickFormat;
+ tickFormat = value;
+ return sched;
+ };
+
+ sched.name = function(value) {
+ if (!arguments.length)
+ return myname;
+ myname = value;
+ return sched;
+ };
+
+ return sched;
+};
diff --git a/jm2l/static/js/jm2l.js b/jm2l/static/js/jm2l.js
new file mode 100644
index 0000000..e24c7d0
--- /dev/null
+++ b/jm2l/static/js/jm2l.js
@@ -0,0 +1,202 @@
+
+function DoPost(TargetURL) {
+ var Datas=$('#ModalForm').serialize();
+ $.ajax({
+ type:'post',
+ url:TargetURL,
+ data:Datas,
+ success:function(result, status, jqXHR){
+ var regexp = /(javascript)/gi;
+ if (!jqXHR.getResponseHeader('content-type').match(regexp))
+ $("#AjaxModal").html(result);
+ },
+ error:function(result, error){
+ alert(error);
+ },
+ });
+}
+
+function DoPostLieu(TargetURL) {
+ var Datas=$('#ModalPlaceForm').serialize();
+ $.ajax({
+ type:'post',
+ url:TargetURL,
+ data:Datas,
+ success:function(result, status, jqXHR){
+ var regexp = /(javascript)/gi;
+ if (!jqXHR.getResponseHeader('content-type').match(regexp))
+ $("#AjaxPlaceModal").html(result);
+ },
+ error:function(result, error){
+ alert(error);
+ },
+ });
+}
+
+function DoGet(TargetURL) {
+ $.ajax({
+ url:TargetURL,
+ success:function(result, status, jqXHR){
+ var regexp = /(javascript)/gi;
+ if (!jqXHR.getResponseHeader('content-type').match(regexp)) {
+ $("#AjaxModal").html(result);
+ $("#AjaxModal").modal('show');
+ }
+ },
+ error:function(result, error){
+ alert(error);
+ },
+ });
+}
+
+function DoGetLieu(TargetURL) {
+ $('#AjaxModal').modal("hide");
+ $.ajax({
+ url:TargetURL,
+ success:function(result, status, jqXHR){
+ var regexp = /(javascript)/gi;
+ if (!jqXHR.getResponseHeader('content-type').match(regexp)) {
+ $("#AjaxPlaceModal").html(result);
+ $("#AjaxPlaceModal").modal('show');
+ }
+ },
+ error:function(result, error){
+ alert(error);
+ },
+ });
+}
+
+$(document).ready(function() {
+ $.fn.modal.Constructor.prototype.enforceFocus = function() {};
+
+ $('[handle="modal"]').click(function(e) {
+ e.preventDefault();
+ var url = $(this).attr('Myhref');
+ var target = $(this).attr('data-target');
+ $(target).html('');
+ $(target).addClass("Loading");
+ $(target).modal("show");
+ $(target).load(url, function() {
+ $(target).removeClass("Loading");
+ });
+ return false;
+ });
+
+ $('#AjaxModal').on('hidden', function(bla){
+ //$(this).data('modal', null);
+ if (bla.target.id.endsWith('-help'))
+ return;
+ if (bla.target.id=='AjaxModal') {
+ if ($(this).children().length)
+ $(this).children()[0].remove();
+ if (typeof map === "undefined")
+ return;
+ if (map)
+ map.remove();
+ }
+ });
+
+ $('#AjaxPlaceModal').on('hidden', function(bla){
+ $("#place_type").select2("destroy");
+ //$(this).data('modal', null);
+ if (bla.target.id.endsWith('-help'))
+ return;
+ if ($(this).children().length)
+ $(this).children()[0].remove();
+ $("#place_type");
+ });
+
+ $('#AjaxPlaceModal').on('shown', function(bla){
+ if (map)
+ setTimeout(function() {
+ map.invalidateSize();
+ }, 10);
+ });
+
+ $('#AjaxModal').on('shown', function(bla){
+ if (bla.target.id=="ItinMap")
+ setTimeout(function() {
+ map.invalidateSize();
+ toast.route();
+ $('#map_Itineraire').eq(0).html( $('.leaflet-routing-alt').eq(0).html() );
+ $('.leaflet-routing-container').eq(0).attr("style","display:none;")
+ $('#map_Itineraire > table').eq(0).attr("style","width:100%;");
+ }, 10);
+ });
+
+ $('[data-toggle="modal"]').click(function(e) {
+ e.preventDefault();
+ var url = $(this).attr('href');
+ //var modal_id = $(this).attr('data-target');
+ $.get(url, function(data) {
+ $(data).modal();
+ });
+ });
+
+ if (location.hash !== '') {
+ var SavHash = location.hash;
+ if (Array('#Miam','#Covoiturage','#Hebergement',
+ '#Materiel','#ResumeInt').indexOf(location.hash)>=0)
+ $('a[href="#Logistique"]').tab('show')
+ .on('shown', function(e) {
+ $('a[href="' + SavHash + '"]').tab('show');
+ });
+ else {
+ if (Array('#ResumePart','#Conference','#Stand','#Atelier',
+ '#TableRonde','#Organisation').indexOf(location.hash)>=0)
+ $('a[href="#Interventions"]').tab('show')
+ .on('shown', function(e) {
+ $('a[href="' + SavHash + '"]').tab('show');
+ });
+ else
+ $('a[href="' + SavHash + '"]').tab('show');
+ }
+ }
+
+
+ if (0) {
+ var editor = CKEDITOR.replace( 'bio', {
+ saveSubmitURL:'/SaveFrontPage/?part=bio',
+ on : { blur: function( event ) { event.editor.getCommand( 'save' ).enable(); }
+ }
+ } );
+ } else {
+ //CKEDITOR.disableAutoInline = true;
+ //var editor = CKEDITOR.inline( 'bio' );
+ //var editor = CKEDITOR.replace( 'bio' );
+ //var editor = CKEDITOR.replace( 'bio' );
+ };
+
+ jQuery(function() {
+ jQuery('.repeat').each(function() {
+ jQuery(this).repeatable_fields(
+ {
+ is_ready: function(container, therow) {
+ var numrow=$(container).attr('data-rf-row-count');
+ $("#tiersship-"+ (numrow-1) +"-tiers_uid").select2(
+ {
+ placeholder: 'Entrez ici votre entité',
+ minimumInputLength: 2, allowClear: true,
+ ajax: {
+ quietMillis: 250, url: "/json-tiers", dataType: 'json',
+ data: function (term, page) {
+ return { pageSize: 8, pageNum: page, searchTerm: term };
+ },
+ results: function (data, page) {
+ var more = (page * 8) < data.Total;
+ return { results: data.Results, more: more };
+ }
+ }
+ });
+ }
+ });
+ });
+ });
+
+ $('a[data-toggle="tab"]')
+ .on('shown', function(e) {
+ stateObj = { tab: $(e.target).attr('href').substr(1) };
+ history.replaceState(stateObj, "", "/MesJM2L" + $(e.target).attr('href') );
+ });
+
+ });
diff --git a/jm2l/static/js/programme.js b/jm2l/static/js/programme.js
new file mode 100644
index 0000000..407a2b9
--- /dev/null
+++ b/jm2l/static/js/programme.js
@@ -0,0 +1,111 @@
+var scheds = {};
+
+function example() {
+
+ var taskStatus = {'Stand':'Stand',
+ 'Table ronde':'Table-ronde',
+ 'Atelier':'Atelier',
+ 'Concert':'Concert',
+ 'Conference':'Conference',
+ 'Repas':'Repas'}
+
+ d3.json("le-prog-json", function(error, JsonContent) {
+ if (error)
+ return console.warn(error);
+ $.each( JsonContent,
+ function( EventType, ListEvType ) {
+ $.each( ListEvType,
+ function( Day, ListEvent ) {
+ var placeNames = [];
+ for ( var i = 0; i < ListEvent.length; i++) {
+ placeNames.push(ListEvent[i]["placeName"]);
+ // convert json text to js Date
+ ListEvent[i]["startDate"] = new Date(ListEvent[i]["startDate"]);
+ ListEvent[i]["endDate"] = new Date(ListEvent[i]["endDate"]);
+ }
+ //placeNames.push("unk")
+ scheds[EventType+"_"+Day] = new d3.sched("SVG_"+Day)
+ .taskTypes(placeNames)
+ .taskStatus(taskStatus)
+ .tickFormat("%H:%M");
+ //scheds[EventType+"_"+Day].timeDomainMode("fit");
+ //scheds[EventType+"_"+Day].margin(margin);
+ scheds[EventType+"_"+Day](ListEvent);
+ //scheds[EventType+"_"+Day].zoomed();
+ scheds[EventType+"_"+Day].redraw("SVG_"+Day, ListEvent)
+ });
+ });
+ });
+
+};
+
+// Query Programme
+example();
+
+function changeTimeDomain(timeDomainString) {
+ this.timeDomainString = timeDomainString;
+ switch (timeDomainString) {
+ case "1hr":
+ format = "%H:%M:%S";
+ sched.timeDomain([ d3.time.hour.offset(getEndDate(), -1), getEndDate() ]);
+ break;
+ case "3hr":
+ format = "%H:%M";
+ sched.timeDomain([ d3.time.hour.offset(getEndDate(), -3), getEndDate() ]);
+ break;
+
+ case "6hr":
+ format = "%H:%M";
+ sched.timeDomain([ d3.time.hour.offset(getEndDate(), -6), getEndDate() ]);
+ break;
+
+ case "1day":
+ format = "%H:%M";
+ sched.timeDomain([ d3.time.day.offset(getEndDate(), -1), getEndDate() ]);
+ break;
+
+ case "1week":
+ format = "%a %H:%M";
+ sched.timeDomain([ d3.time.day.offset(getEndDate(), -7), getEndDate() ]);
+ break;
+ default:
+ format = "%H:%M"
+
+ }
+ sched.tickFormat(format);
+ sched.redraw(tasks);
+}
+
+function getEndDate() {
+ var lastEndDate = Date.now();
+ if (tasks.length > 0) {
+ lastEndDate = tasks[tasks.length - 1].endDate;
+ }
+
+ return lastEndDate;
+}
+
+function addTask() {
+
+ var lastEndDate = getEndDate();
+ var taskStatusKeys = Object.keys(taskStatus);
+ var taskStatusName = taskStatusKeys[Math.floor(Math.random() * taskStatusKeys.length)];
+ var taskName = taskNames[Math.floor(Math.random() * taskNames.length)];
+
+ tasks.push({
+ "startDate" : d3.time.hour.offset(lastEndDate, Math.ceil(1 * Math.random())),
+ "endDate" : d3.time.hour.offset(lastEndDate, (Math.ceil(Math.random() * 3)) + 1),
+ "taskName" : taskName,
+ "status" : taskStatusName
+ });
+
+ changeTimeDomain(timeDomainString);
+
+ sched.redraw(tasks);
+};
+
+function removeTask() {
+ tasks.pop();
+ changeTimeDomain(timeDomainString);
+ sched.redraw(tasks);
+};