From: Alex Sadleir Date: Sat, 19 Jan 2013 13:22:22 +0000 Subject: Merge branch 'master' of ssh://apples.lambdacomplex.org/git/scannr X-Git-Url: http://maxious.lambdacomplex.org/git/?p=scannr.git&a=commitdiff&h=e2a40f793bb5cc73cc423d9abd00fa43566174c7 --- Merge branch 'master' of ssh://apples.lambdacomplex.org/git/scannr Conflicts: .idea/workspace.xml generateHourlys.php --- --- /dev/null +++ b/.idea/sqldialects.xml @@ -1,1 +1,8 @@ + + + + + + + --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -2,7 +2,6 @@ - --- a/.idea/workspace.xml +++ /dev/null @@ -1,497 +1,1 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1350026709905 - 1350026709905 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --- a/README.md +++ /dev/null @@ -1,64 +1,1 @@ -# [HTML5 Boilerplate](http://html5boilerplate.com) -HTML5 Boilerplate is a professional front-end template for building fast, -robust, and adaptable web apps or sites. - -This project is the product of many years of iterative development and combined -community knowledge. It does not impose a specific development philosophy or -framework, so you're free to architect your code in the way that you want. - -* Source: [https://github.com/h5bp/html5-boilerplate](https://github.com/h5bp/html5-boilerplate) -* Homepage: [http://html5boilerplate.com](http://html5boilerplate.com) -* Twitter: [@h5bp](http://twitter.com/h5bp) - - -## Quick start - -Choose one of the following options: - -1. Download the latest stable release from - [html5boilerplate.com](http://html5boilerplate.com/) or a custom build from - [Initializr](http://www.initializr.com). -2. Clone the git repo — `git clone - https://github.com/h5bp/html5-boilerplate.git` - and checkout the tagged - release you'd like to use. - - -## Features - -* HTML5 ready. Use the new elements with confidence. -* Cross-browser compatible (Chrome, Opera, Safari, Firefox 3.6+, IE6+). -* Designed with progressive enhancement in mind. -* Includes [Normalize.css](http://necolas.github.com/normalize.css/) for CSS - normalizations and common bug fixes. -* The latest [jQuery](http://jquery.com/) via CDN, with a local fallback. -* The latest [Modernizr](http://modernizr.com/) build for feature detection. -* IE-specific classes for easier cross-browser control. -* Placeholder CSS Media Queries. -* Useful CSS helpers. -* Default print CSS, performance optimized. -* Protection against any stray `console.log` causing JavaScript errors in - IE6/7. -* An optimized Google Analytics snippet. -* Apache server caching, compression, and other configuration defaults for - Grade-A performance. -* Cross-domain Ajax and Flash. -* "Delete-key friendly." Easy to strip out parts you don't need. -* Extensive inline and accompanying documentation. - - -## Documentation - -Take a look at the [documentation table of -contents](/h5bp/html5-boilerplate/blob/master/doc/README.md). This -documentation is bundled with the project, which makes it readily available for -offline reading and provides a useful starting point for any documentation -you want to write about your project. - - -## Contributing - -Anyone and everyone is welcome to -[contribute](/h5bp/html5-boilerplate/blob/master/doc/contribute.md). Hundreds -of developers have helped make the HTML5 Boilerplate what it is today. - --- a/README.txt +++ /dev/null @@ -1,1 +1,1 @@ -ffmpeg from http://ffmpeg.zeranoe.com/builds/ + --- a/common.inc.php +++ b/common.inc.php @@ -57,12 +57,20 @@ + + + + + + + + + + + + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+ + + + + + + + + + + + + + + + + --- a/db.sql +++ b/db.sql @@ -92,4 +92,22 @@ -- PostgreSQL database dump complete -- +CREATE TABLE "compilation" ( + "filename" text NOT NULL, + "files" text ARRAY NOT NULL, + "datetime" timestamp NOT NULL +); +CREATE TABLE "trunk_log" ( + "id" text NOT NULL, + "datetime" integer NOT NULL, + "site" integer NOT NULL, + "action" text NOT NULL, + "sourcetype" character(1) NOT NULL, + "sourceid" smallint NOT NULL, + "targettype" character(1) NOT NULL, + "targetid" smallint NOT NULL, + "channel" smallint NOT NULL, + "calltype" text NOT NULL +); + --- a/generateConvos.php +++ /dev/null @@ -1,36 +1,1 @@ -prepare('select * from recordings limit 100;'); -$sth->execute(); -$recordings = $sth->fetchAll(); -$convos = Array(); -$convo = Array(); -foreach ($recordings as $i => $recording) { - - if (count($convo) > 0) { - echo "
" . strcasecmp($convos[count($convos) - 1][0]['call_timestamp'], $recording['call_timestamp']); - if (abs(strcasecmp($convos[count($convos) - 1][0]['call_timestamp'], $recording['call_timestamp'])) > 2) { - echo " " . $convos[count($convos) - 1][0]['call_timestamp'] . " " . $recording['call_timestamp']; - } - if (strcasecmp($convos[count($convos) - 1][0]['tgid'], $recording['tgid']) != 0) { - $convos[] = $convo; - $convo = Array(); - } - } - ; - //print_r($recording); - $convo[] = $recording; - //print_r($convo); - //echo "
\n"; -} -foreach ($convos as $i => $convo) { - foreach ($convo as $recording) { - echo $recording['filename'] . " , "; - } - echo "

\n"; -} -?> - - --- a/generateHourlys.php +++ b/generateHourlys.php @@ -3,25 +3,36 @@ function processHourly($hourly) { $filename = str_replace(' ',"_",$hourly['tgid']).'-'.str_replace(' 00:00:00+1','',$hourly['aday']).'-'.$hourly['ahour'].'.3gp'; - if(!file_exists("hourly/".$filename)) { + $hfilename = $hourly['tgid'] . '-' . str_replace(' 00:00:00+10', '', $hourly['aday']) . '-' . $hourly['ahour'] . '.3gp'; - $filenames = explode(",",$hourly['filenames']); - $cmd = "/usr/local/bin/ffmpeg -filter_complex concat=n=".count($filenames).":v=0:a=1 -i data/".implode(" -i data/",$filenames)." -ar 8000 -ab 4.75k -ac 1 hourly/".$filename . ' 2>&1'; + if (!file_exists("hourly/" . $hfilename)) { + + $filenames = explode(",", $hourly['filenames']); + $cmd = "/usr/local/bin/ffmpeg -filter_complex concat=n=" . count($filenames) . ":v=0:a=1 -i data/" . implode(" -i data/", $filenames) . " -ar 8000 -ab 4.75k -ac 1 hourly/" . $hfilename . ' 2>&1'; //print_r($hourly); - exec ( $cmd,$output,$returncode ); - echo $cmd."
\n"; + exec($cmd, $output, $returncode); + echo $cmd . "
\n"; if ($returncode != 10) { - //print_r($output); + print_r($output); //die(); + } else { + $q = " insert into compilations (filename files datetime) ('" . $hfilename . "',{'" . implode("', '", $filenames) . "'},'" . strtottime($hourly['aday'] . ' +' . $hourly['ahour'] . " hours')") . "' "; + + foreach ($filenames as $filename) { + $q = "UPDATE recordings SET archived = '$hfilename' WHERE filename = '$filename' "; + } } + } } /*$sth = $conn->prepare("select tgid, extract(hour from call_timestamp) ahour, date_trunc('day', call_timestamp) aday, count(filename), array_to_string(array_agg(filename order by call_timestamp), ',') filenames from recordings group by tgid, ahour, aday order by aday DESC, ahour, tgid;"); +$sth = $conn->prepare("SELECT tgid, EXTRACT(HOUR FROM call_timestamp) ahour, date_trunc('day', call_timestamp) aday, COUNT(filename), array_to_string(array_agg(filename ORDER BY call_timestamp), ',') filenames FROM recordings GROUP BY tgid, ahour, aday ORDER BY aday DESC, ahour, tgid;"); +// TODO use tgid categories instead, tgid too specific $sth->execute(); $hourlies = $sth->fetchAll(PDO::FETCH_ASSOC); -foreach($hourlies as $hourly) { +foreach ($hourlies as $hourly) { processHourly($hourly); } $sth = $conn->prepare("select 'hour' as tgid, extract(hour from call_timestamp) ahour, date_trunc('day', call_timestamp) aday, @@ -29,10 +40,9 @@ $sth->execute(); $hourlies = $sth->fetchAll(PDO::FETCH_ASSOC); -foreach($hourlies as $hourly) { +foreach ($hourlies as $hourly) { processHourly($hourly); } -*/ $sth = $conn->prepare("select coalesce(category,'unknown') as tgid, extract(hour from call_timestamp) ahour, date_trunc('day', call_timestamp) aday, count(filename), array_to_string(array_agg(filename order by call_timestamp), ',') filenames from recordings inner join tgids on recordings.tgid = tgids.tgid group by category, ahour, aday order by aday DESC, ahour, category;"); --- /dev/null +++ b/js/daterangepicker.js @@ -1,1 +1,609 @@ - +/** +* @version: 1.0.1 +* @author: Dan Grossman http://www.dangrossman.info/ +* @date: 2012-08-20 +* @copyright: Copyright (c) 2012 Dan Grossman. All rights reserved. +* @license: Licensed under Apache License v2.0. See http://www.apache.org/licenses/LICENSE-2.0 +* @website: http://www.improvely.com/ +*/ +!function ($) { + + var DateRangePicker = function (element, options, cb) { + var hasOptions = typeof options == 'object' + var localeObject; + + //state + this.startDate = Date.create('today'); + this.endDate = Date.create('today'); + this.minDate = false; + this.maxDate = false; + this.changed = false; + this.cleared = false; + this.ranges = {}; + this.opens = 'right'; + this.cb = function () { }; + this.format = '{MM}/{dd}/{yyyy}'; + this.separator = ' - '; + this.showWeekNumbers = false; + this.buttonClasses = ['btn-success']; + this.locale = { + applyLabel: 'Apply', + clearLabel:"Clear", + fromLabel: 'From', + toLabel: 'To', + weekLabel: 'W', + customRangeLabel: 'Custom Range', + daysOfWeek: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr','Sa'], + monthNames: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], + firstDay: 0 + }; + + localeObject = this.locale; + + this.leftCalendar = { + month: Date.create('today').set({ day: 1, month: this.startDate.getMonth(), year: this.startDate.getFullYear() }), + calendar: Array() + }; + + this.rightCalendar = { + month: Date.create('today').set({ day: 1, month: this.endDate.getMonth(), year: this.endDate.getFullYear() }), + calendar: Array() + }; + + //element that triggered the date range picker + this.element = $(element); + + if (this.element.hasClass('pull-right')) + this.opens = 'left'; + + if (this.element.is('input')) { + this.element.on({ + click: $.proxy(this.show, this), + focus: $.proxy(this.show, this) + }); + } else { + this.element.on('click', $.proxy(this.show, this)); + } + + if (hasOptions) { + if(typeof options.locale == 'object') { + $.each(localeObject, function (property, value) { + localeObject[property] = options.locale[property] || value; + }); + } + } + + var DRPTemplate = ''; + + this.container = $(DRPTemplate).appendTo('body'); + + if (hasOptions) { + + if (typeof options.format == 'string') + this.format = options.format; + + if (typeof options.separator == 'string') + this.separator = options.separator; + + if (typeof options.startDate == 'string') + this.startDate = Date.create(options.startDate); + + if (typeof options.endDate == 'string') + this.endDate = Date.create(options.endDate); + + if (typeof options.minDate == 'string') + this.minDate = Date.create(options.minDate); + + if (typeof options.maxDate == 'string') + this.maxDate = Date.create(options.maxDate); + + + if (typeof options.startDate == 'object') + this.startDate = options.startDate; + + if (typeof options.endDate == 'object') + this.endDate = options.endDate; + + if (typeof options.minDate == 'object') + this.minDate = options.minDate; + + if (typeof options.maxDate == 'object') + this.maxDate = options.maxDate; + + if (typeof options.ranges == 'object') { + for (var range in options.ranges) { + + var start = options.ranges[range][0]; + var end = options.ranges[range][1]; + + if (typeof start == 'string') + start = Date.create(start); + + if (typeof end == 'string') + end = Date.create(end); + + // If we have a min/max date set, bound this range + // to it, but only if it would otherwise fall + // outside of the min/max. + if (this.minDate && start < this.minDate) + start = this.minDate; + + if (this.maxDate && end > this.maxDate) + end = this.maxDate; + + // If the end of the range is before the minimum (if min is set) OR + // the start of the range is after the max (also if set) don't display this + // range option. + if ((this.minDate && end < this.minDate) || (this.maxDate && start > this.maxDate)) + { + continue; + } + + this.ranges[range] = [start, end]; + } + + var list = ''; + this.container.find('.ranges').prepend(list); + } + + // update day names order to firstDay + if (typeof options.locale == 'object') { + if (typeof options.locale.firstDay == 'number') { + this.locale.firstDay = options.locale.firstDay; + var iterator = options.locale.firstDay; + while (iterator > 0) { + this.locale.daysOfWeek.push(this.locale.daysOfWeek.shift()); + iterator--; + } + } + } + + if (typeof options.opens == 'string') + this.opens = options.opens; + + if (typeof options.showWeekNumbers == 'boolean') { + this.showWeekNumbers = options.showWeekNumbers; + } + + if (typeof options.buttonClasses == 'string') { + this.buttonClasses = [options.buttonClasses]; + } + + if (typeof options.buttonClasses == 'object') { + this.buttonClasses = options.buttonClasses; + } + + } + + //apply CSS classes to buttons + var c = this.container; + $.each(this.buttonClasses, function (idx, val) { + c.find('button').addClass(val); + }); + + if (this.opens == 'right') { + //swap calendar positions + var left = this.container.find('.calendar.left'); + var right = this.container.find('.calendar.right'); + left.removeClass('left').addClass('right'); + right.removeClass('right').addClass('left'); + } + + if (typeof options == 'undefined' || typeof options.ranges == 'undefined') + this.container.find('.calendar').show(); + + if (typeof cb == 'function') + this.cb = cb; + + this.container.addClass('opens' + this.opens); + + //event listeners + this.container.on('mousedown', $.proxy(this.mousedown, this)); + this.container.find('.calendar').on('click', '.prev', $.proxy(this.clickPrev, this)); + this.container.find('.calendar').on('click', '.next', $.proxy(this.clickNext, this)); + this.container.find('.ranges').on('click', 'button.applyBtn', $.proxy(this.clickApply, this)); + this.container.find('.ranges').on('click', 'button.clearBtn', $.proxy(this.clickClear, this)); + + this.container.find('.calendar').on('click', 'td.available', $.proxy(this.clickDate, this)); + this.container.find('.calendar').on('mouseenter', 'td.available', $.proxy(this.enterDate, this)); + this.container.find('.calendar').on('mouseleave', 'td.available', $.proxy(this.updateView, this)); + + this.container.find('.ranges').on('click', 'li', $.proxy(this.clickRange, this)); + this.container.find('.ranges').on('mouseenter', 'li', $.proxy(this.enterRange, this)); + this.container.find('.ranges').on('mouseleave', 'li', $.proxy(this.updateView, this)); + + this.element.on('keyup', $.proxy(this.updateFromControl, this)); + + this.updateView(); + this.updateCalendars(); + + }; + + DateRangePicker.prototype = { + + constructor: DateRangePicker, + + mousedown: function (e) { + e.stopPropagation(); + e.preventDefault(); + }, + + updateView: function () { + this.leftCalendar.month.set({ month: this.startDate.getMonth(), year: this.startDate.getFullYear() }); + this.rightCalendar.month.set({ month: this.endDate.getMonth(), year: this.endDate.getFullYear() }); + + this.container.find('input[name=daterangepicker_start]').val(this.startDate.format(this.format)); + this.container.find('input[name=daterangepicker_end]').val(this.endDate.format(this.format)); + + if (this.startDate.is(this.endDate) || this.startDate.isBefore(this.endDate)) { + this.container.find('button.applyBtn').removeAttr('disabled'); + } else { + this.container.find('button.applyBtn').attr('disabled', 'disabled'); + } + }, + + updateFromControl: function () { + if (!this.element.is('input')) return; + + var dateString = this.element.val().split(this.separator); + var start = Date.create(dateString[0]); + var end = Date.create(dateString[1]); + + if (start == null || end == null) return; + if (end.isBefore(start)) return; + + this.startDate = start; + this.endDate = end; + + this.updateView(); + this.cb(this.startDate, this.endDate); + this.updateCalendars(); + }, + + notify: function () { + if (!this.cleared) { + this.updateView(); + } + + if (this.element.is('input')) { + this.element.val(this.cleared ? '' : this.startDate.format(this.format) + this.separator + this.endDate.format(this.format)); + } + var arg1 = (this.cleared ? null : this.startDate), + arg2 = (this.cleared ? null : this.endDate); + this.cleared = false; + this.cb(arg1,arg2); + }, + + move: function () { + if (this.opens == 'left') { + this.container.css({ + top: this.element.offset().top + this.element.outerHeight(), + right: $(window).width() - this.element.offset().left - this.element.outerWidth(), + left: 'auto' + }); + } else { + this.container.css({ + top: this.element.offset().top + this.element.outerHeight(), + left: this.element.offset().left, + right: 'auto' + }); + } + }, + + show: function (e) { + this.container.show(); + this.move(); + + if (e) { + e.stopPropagation(); + e.preventDefault(); + } + + this.changed = false; + + this.element.trigger('shown',{target:e.target,picker:this}); + + $(document).on('mousedown', $.proxy(this.hide, this)); + }, + + hide: function (e) { + this.container.hide(); + $(document).off('mousedown', this.hide); + + if (this.changed) { + this.changed = false; + this.notify(); + } + }, + + enterRange: function (e) { + var label = e.target.innerHTML; + if (label == this.locale.customRangeLabel) { + this.updateView(); + } else { + var dates = this.ranges[label]; + this.container.find('input[name=daterangepicker_start]').val(dates[0].format(this.format)); + this.container.find('input[name=daterangepicker_end]').val(dates[1].format(this.format)); + } + }, + + clickRange: function (e) { + var label = e.target.innerHTML; + if (label == this.locale.customRangeLabel) { + this.container.find('.calendar').show(); + } else { + var dates = this.ranges[label]; + + this.startDate = dates[0]; + this.endDate = dates[1]; + + this.leftCalendar.month.set({ month: this.startDate.getMonth(), year: this.startDate.getFullYear() }); + this.rightCalendar.month.set({ month: this.endDate.getMonth(), year: this.endDate.getFullYear() }); + this.updateCalendars(); + + this.changed = true; + + this.container.find('.calendar').hide(); + this.hide(); + } + }, + + clickPrev: function (e) { + var cal = $(e.target).parents('.calendar'); + if (cal.hasClass('left')) { + this.leftCalendar.month.addMonths(-1); + } else { + this.rightCalendar.month.addMonths(-1); + } + this.updateCalendars(); + }, + + clickNext: function (e) { + var cal = $(e.target).parents('.calendar'); + if (cal.hasClass('left')) { + this.leftCalendar.month.addMonths(1); + } else { + this.rightCalendar.month.addMonths(1); + } + this.updateCalendars(); + }, + + enterDate: function (e) { + + var title = $(e.target).attr('title'); + var row = title.substr(1, 1); + var col = title.substr(3, 1); + var cal = $(e.target).parents('.calendar'); + + if (cal.hasClass('left')) { + this.container.find('input[name=daterangepicker_start]').val(this.leftCalendar.calendar[row][col].format(this.format)); + } else { + this.container.find('input[name=daterangepicker_end]').val(this.rightCalendar.calendar[row][col].format(this.format)); + } + + }, + + clickDate: function (e) { + var title = $(e.target).attr('title'); + var row = title.substr(1, 1); + var col = title.substr(3, 1); + var cal = $(e.target).parents('.calendar'); + + if (cal.hasClass('left')) { + startDate = this.leftCalendar.calendar[row][col]; + endDate = this.endDate; + this.element.trigger('clicked',{ + dir: 'left', + picker: this + }); + } else { + startDate = this.startDate; + endDate = this.rightCalendar.calendar[row][col]; + this.element.trigger('clicked',{ + dir: 'right', + picker: this + }); + } + + cal.find('td').removeClass('active'); + + if (startDate.is(endDate) || startDate.isBefore(endDate)) { + $(e.target).addClass('active'); + if (!startDate.is(this.startDate) || !endDate.is(this.endDate)) + this.changed = true; + this.startDate = startDate; + this.endDate = endDate; + } + else if (startDate.isAfter(endDate)) { + $(e.target).addClass('active'); + this.changed = true; + this.startDate = startDate; + this.endDate = startDate.clone().addDays(1); + } + + this.leftCalendar.month.set({ month: this.startDate.getMonth(), year: this.startDate.getFullYear() }); + this.rightCalendar.month.set({ month: this.endDate.getMonth(), year: this.endDate.getFullYear() }); + this.updateCalendars(); + }, + + clickApply: function (e) { + this.hide(); + }, + + clickClear: function (e) { + this.changed = true; + this.cleared = true; + this.hide(); + }, + + updateCalendars: function () { + this.leftCalendar.calendar = this.buildCalendar(this.leftCalendar.month.getMonth(), this.leftCalendar.month.getFullYear()); + this.rightCalendar.calendar = this.buildCalendar(this.rightCalendar.month.getMonth(), this.rightCalendar.month.getFullYear()); + this.container.find('.calendar.left').html(this.renderCalendar(this.leftCalendar.calendar, this.startDate, this.minDate, this.maxDate)); + this.container.find('.calendar.right').html(this.renderCalendar(this.rightCalendar.calendar, this.endDate, this.startDate, this.maxDate)); + this.element.trigger('updated',this); + }, + + buildCalendar: function (month, year) { + + var firstDay = Date.create('today').set({ day: 1, month: month, year: year }); + var lastMonth = firstDay.clone().addDays(-1).getMonth(); + var lastYear = firstDay.clone().addDays(-1).getFullYear(); + + var daysInMonth = this.getDaysInMonth(year, month); + var daysInLastMonth = this.getDaysInMonth(lastYear, lastMonth); + + var dayOfWeek = firstDay.getDay(); + + //initialize a 6 rows x 7 columns array for the calendar + var calendar = Array(); + for (var i = 0; i < 6; i++) { + calendar[i] = Array(); + } + + //populate the calendar with date objects + var startDay = daysInLastMonth - dayOfWeek + this.locale.firstDay + 1; + if (startDay > daysInLastMonth) + startDay -= 7; + + if (dayOfWeek == this.locale.firstDay) + startDay = daysInLastMonth - 6; + + var curDate = Date.create('today').set({ day: startDay, month: lastMonth, year: lastYear }); + for (var i = 0, col = 0, row = 0; i < 42; i++, col++, curDate = curDate.clone().addDays(1)) { + if (i > 0 && col % 7 == 0) { + col = 0; + row++; + } + calendar[row][col] = curDate; + } + + return calendar; + + }, + + renderCalendar: function (calendar, selected, minDate, maxDate) { + var html = ''; + html += ''; + html += ''; + + // add empty cell for week number + if (this.showWeekNumbers) + html += ''; + + if (!minDate || minDate < calendar[1][1]) + { + html += ''; + } + else + { + html += ''; + } + html += ''; + if (!maxDate || maxDate > calendar[1][1]) + { + html += ''; + } + else + { + html += ''; + } + + html += ''; + html += ''; + + // add week number label + if (this.showWeekNumbers) + html += ''; + + $.each(this.locale.daysOfWeek, function (index, dayOfWeek) { + html += ''; + }); + + html += ''; + html += ''; + html += ''; + + for (var row = 0; row < 6; row++) { + html += ''; + + // add week number + if (this.showWeekNumbers) + html += ''; + + for (var col = 0; col < 7; col++) { + var cname = 'available '; + cname += (calendar[row][col].getMonth() == calendar[1][1].getMonth()) ? '' : 'off'; + + // Normalise the time so the comparison won't fail + selected.setHours(0,0,0,0); + + if ( (minDate && calendar[row][col] < minDate) || (maxDate && calendar[row][col] > maxDate)) + { + cname = ' off disabled '; + } + else if (calendar[row][col].is(selected)) + { + cname += ' active '; + if (calendar[row][col].is(this.startDate)) { cname += ' start-date '; } + if (calendar[row][col].is(this.endDate)) { cname += ' end-date '; } + } + else if (calendar[row][col] >= this.startDate && calendar[row][col] <= this.endDate) + { + cname += ' in-range '; + if (calendar[row][col].is(this.startDate)) { cname += ' start-date '; } + if (calendar[row][col].is(this.endDate)) { cname += ' end-date '; } + } + + var title = 'r' + row + 'c' + col; + html += ''; + } + html += ''; + } + + html += ''; + html += '
' + this.locale.monthNames[calendar[1][1].getMonth()] + calendar[1][1].format(' {yyyy}') + '
' + this.locale.weekLabel + '' + dayOfWeek + '
' + calendar[row][0].getWeek() + '' + calendar[row][col].getDate() + '
'; + + return html; + + }, + + getDaysInMonth: function (y, m) { + return /8|3|5|10/.test(--m)?30:m==1?(!(y%4)&&y%100)||!(y%400)?29:28:31; + } + + }; + + $.fn.daterangepicker = function (options, cb) { + this.each(function() { + var el = $(this); + if (!el.data('daterangepicker')) + el.data('daterangepicker', new DateRangePicker(el, options, cb)); + }); + return this; + }; + +} (window.jQuery); + --- /dev/null +++ b/js/script.js~ @@ -1,1 +1,136 @@ +$(function() { + // Set the default dates + var startDate = Date.create().addDays(-6), // 7 days ago + endDate = Date.create(); // today + + var range = $('#range'); + + // Show the dates in the range input + range.val(startDate.format('{MM}/{dd}/{yyyy}') + ' - ' + endDate.format('{MM}/{dd}/{yyyy}')); + + // Load chart + ajaxLoadChart(startDate,endDate); + + range.daterangepicker({ + + startDate: startDate, + endDate: endDate, + + ranges: { + 'Today': ['today', 'today'], + 'Yesterday': ['yesterday', 'yesterday'], + 'Last 7 Days': [Date.create().addDays(-6), 'today'], + 'Last 30 Days': [Date.create().addDays(-29), 'today'] + } + },function(start, end){ + + ajaxLoadChart(start, end); + + }); + + // The tooltip shown over the chart + var tt = $('
').appendTo('body'), + topOffset = -32; + + var data = { + "xScale" : "time", + "yScale" : "linear", + "main" : [{ + className : ".stats", + "data" : [] + }] + }; + + var opts = { + paddingLeft : 50, + paddingTop : 20, + paddingRight : 10, + axisPaddingLeft : 25, + tickHintX: 9, // How many ticks to show horizontally + + dataFormatX : function(x) { + + // This turns converts the timestamps coming from + // ajax.php into a proper JavaScript Date object + + return Date.create(x); + }, + + tickFormatX : function(x) { + + // Provide formatting for the x-axis tick labels. + // This uses sugar's format method of the date object. + + return x.format('{MM}/{dd}'); + }, + + "mouseover": function (d, i) { + var pos = $(this).offset(); + + tt.text(d.x.format('{Month} {ord}') + ': ' + d.y).css({ + + top: topOffset + pos.top, + left: pos.left + + }).show(); + }, + + "mouseout": function (x) { + tt.hide(); + } + }; + + // Create a new xChart instance, passing the type + // of chart a data set and the options object + + var chart = new xChart('line-dotted', data, '#chart' , opts); + + // Function for loading data via AJAX and showing it on the chart + function ajaxLoadChart(startDate,endDate) { + + // If no data is passed (the chart was cleared) + + if(!startDate || !endDate){ + chart.setData({ + "xScale" : "time", + "yScale" : "linear", + "main" : [{ + className : ".stats", + data : [] + }] + }); + + return; + } + + // Otherwise, issue an AJAX request + + $.getJSON('ajax.php', { + + start: startDate.format('{yyyy}-{MM}-{dd}'), + end: endDate.format('{yyyy}-{MM}-{dd}') + + }, function(data) { + + var set = []; + $.each(data, function() { + set.push({ + x : this.label, + y : parseInt(this.value, 10) + }); + }); + + chart.setData({ + "xScale" : "time", + "yScale" : "linear", + "main" : [{ + className : ".stats", + data : set + }] + }); + + }); + } +}); + --- /dev/null +++ b/js/sugar.min.js @@ -1,1 +1,120 @@ - +/* + * Sugar Library v1.3.7 + * + * Freely distributable and licensed under the MIT-style license. + * Copyright (c) 2012 Andrew Plummer + * http://sugarjs.com/ + * + * ---------------------------- */ +(function(){var k=true,l=null,n=false;function aa(a){return function(){return a}}var p=Object,q=Array,r=RegExp,s=Date,t=String,u=Number,v=Math,ba=typeof global!=="undefined"?global:this,ca=p.defineProperty&&p.defineProperties,x="Array,Boolean,Date,Function,Number,String,RegExp".split(","),da=y(x[0]),ea=y(x[1]),fa=y(x[2]),A=y(x[3]),B=y(x[4]),C=y(x[5]),D=y(x[6]);function y(a){return function(b){return p.prototype.toString.call(b)==="[object "+a+"]"}} +function ga(a){if(!a.SugarMethods){ha(a,"SugarMethods",{});E(a,n,n,{restore:function(){var b=arguments.length===0,c=F(arguments);G(a.SugarMethods,function(d,e){if(b||c.indexOf(d)>-1)ha(e.wa?a.prototype:a,d,e.method)})},extend:function(b,c,d){E(a,d!==n,c,b)}})}}function E(a,b,c,d){var e=b?a.prototype:a,f;ga(a);G(d,function(h,i){f=e[h];if(typeof c==="function")i=ia(e[h],i,c);if(c!==n||!e[h])ha(e,h,i);a.SugarMethods[h]={wa:b,method:i,Da:f}})} +function H(a,b,c,d,e){var f={};d=C(d)?d.split(","):d;d.forEach(function(h,i){e(f,h,i)});E(a,b,c,f)}function ia(a,b,c){return function(){return a&&(c===k||!c.apply(this,arguments))?a.apply(this,arguments):b.apply(this,arguments)}}function ha(a,b,c){if(ca)p.defineProperty(a,b,{value:c,configurable:k,enumerable:n,writable:k});else a[b]=c}function F(a,b){var c=[],d;for(d=0;d=b;){e.push(a);c&&c.call(this,a);a+=d||1}return e}function N(a,b,c){c=v[c||"round"];var d=v.pow(10,v.abs(b||0));if(b<0)d=1/d;return c(a*d)/d}function qa(a,b){return N(a,b,"floor")}function O(a,b,c,d){d=v.abs(a).toString(d||10);d=ra(b-d.replace(/\.\d+/,"").length,"0")+d;if(c||a<0)d=(a<0?"-":"+")+d;return d} +function sa(a){if(a>=11&&a<=13)return"th";else switch(a%10){case 1:return"st";case 2:return"nd";case 3:return"rd";default:return"th"}}function ta(){return"\t\n\u000b\u000c\r \u00a0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u2028\u2029\u3000\ufeff"}function ra(a,b){return q(v.max(0,I(a)?a:1)+1).join(b||"")}function ua(a,b){var c=a.toString().match(/[^/]*$/)[0];if(b)c=(c+b).split("").sort().join("").replace(/([gimy])\1+/g,"$1");return c} +function P(a){C(a)||(a=t(a));return a.replace(/([\\/'*+?|()\[\]{}.^$])/g,"\\$1")}function va(a,b){var c=typeof a,d,e,f,h,i,j;if(c==="string")return a;f=p.prototype.toString.call(a);d=ma(a);e=f==="[object Array]";if(a!=l&&d||e){b||(b=[]);if(b.length>1)for(j=b.length;j--;)if(b[j]===a)return"CYC";b.push(a);d=t(a.constructor);h=e?a:p.keys(a).sort();for(j=0;j>0);if(c<0)c=e+c;if(!f&&c<0||f&&c>=e)c=h;for(;f&&c>=0||!f&&c>>0==e&&e!=4294967295&&e>=c&&d.push(parseInt(e));d.sort().each(function(f){return b.call(a,a[f],f,a)});return a}function Fa(a,b,c,d,e){var f,h;S(a,function(i,j,g){if(Ca(i,b,g,[i,j,g])){f=i;h=j;return n}},c,d);return e?h:f} +function Ga(a,b){var c=[],d={},e;S(a,function(f,h){e=b?R(f,b,a,[f,h,a]):f;Ha(d,e)||c.push(f)});return c}function Ia(a,b,c){var d=[],e={};b.each(function(f){Ha(e,f)});a.each(function(f){var h=va(f),i=!wa(f);if(Ja(e,h,f,i)!=c){var j=0;if(i)for(h=e[h];je||i&&g0)c=b}catch(d){}a=a.concat(c)});return a}}); +E(q,k,n,{find:function(a,b,c){return Fa(this,a,b,c)},findAll:function(a,b,c){var d=[];S(this,function(e,f,h){Ca(e,a,h,[e,f,h])&&d.push(e)},b,c);return d},findIndex:function(a,b,c){a=Fa(this,a,b,c,k);return K(a)?-1:a},count:function(a){if(K(a))return this.length;return this.findAll(a).length},removeAt:function(a,b){if(K(a))return this;if(K(b))b=a;for(var c=0;c<=b-a;c++)this.splice(a,1);return this},include:function(a,b){return this.clone().add(a,b)},exclude:function(){return q.prototype.remove.apply(this.clone(), +arguments)},clone:function(){return na([],this)},unique:function(a){return Ga(this,a)},flatten:function(a){return Ka(this,a)},union:function(){return Ga(this.concat(La(arguments)))},intersect:function(){return Ia(this,La(arguments),n)},subtract:function(){return Ia(this,La(arguments),k)},at:function(){return xa(this,arguments)},first:function(a){if(K(a))return this[0];if(a<0)a=0;return this.slice(0,a)},last:function(a){if(K(a))return this[this.length-1];return this.slice(this.length-a<0?0:this.length- +a)},from:function(a){return this.slice(a)},to:function(a){if(K(a))a=this.length;return this.slice(0,a)},min:function(a,b){return Ma(this,a,"min",b)},max:function(a,b){return Ma(this,a,"max",b)},least:function(a,b){return Ma(this.groupBy.apply(this,[a]),"length","min",b)},most:function(a,b){return Ma(this.groupBy.apply(this,[a]),"length","max",b)},sum:function(a){a=a?this.map(a):this;return a.length>0?a.reduce(function(b,c){return b+c}):0},average:function(a){a=a?this.map(a):this;return a.length>0? +a.sum()/a.length:0},inGroups:function(a,b){var c=arguments.length>1,d=this,e=[],f=N(this.length/a,void 0,"ceil");pa(0,a-1,function(h){h=h*f;var i=d.slice(h,h+f);c&&i.lengthh?1:0;return f*(b?-1:1)});return c},randomize:function(){for(var a=this.concat(),b,c,d=a.length;d;b=parseInt(v.random()* +d),c=a[--d],a[d]=a[b],a[b]=c);return a},zip:function(){var a=F(arguments);return this.map(function(b,c){return[b].concat(a.map(function(d){return c in d?d[c]:l}))})},sample:function(a){var b=this.randomize();return arguments.length>0?b.slice(0,a):b[0]},each:function(a,b,c){S(this,a,b,c);return this},add:function(a,b){if(!B(u(b))||isNaN(b))b=this.length;q.prototype.splice.apply(this,[b,0].concat(a));return this},remove:function(){var a,b=this;F(arguments,function(c){for(a=0;a0&&!A(a[0])},"map,every,all,some,any,none,filter",function(a,b){a[b]=function(c){return this[b](function(d,e){return b==="map"?R(d,c,this,[d,e,this]):Ca(d,c,this,[d,e,this])})}})})(); +(function(){q[Ta]="A\u00c1\u00c0\u00c2\u00c3\u0104BC\u0106\u010c\u00c7D\u010e\u00d0E\u00c9\u00c8\u011a\u00ca\u00cb\u0118FG\u011eH\u0131I\u00cd\u00cc\u0130\u00ce\u00cfJKL\u0141MN\u0143\u0147\u00d1O\u00d3\u00d2\u00d4PQR\u0158S\u015a\u0160\u015eT\u0164U\u00da\u00d9\u016e\u00db\u00dcVWXY\u00ddZ\u0179\u017b\u017d\u00de\u00c6\u0152\u00d8\u00d5\u00c5\u00c4\u00d6".split("").map(function(b){return b+b.toLowerCase()}).join("");var a={};S("A\u00c1\u00c0\u00c2\u00c3\u00c4,C\u00c7,E\u00c9\u00c8\u00ca\u00cb,I\u00cd\u00cc\u0130\u00ce\u00cf,O\u00d3\u00d2\u00d4\u00d5\u00d6,S\u00df,U\u00da\u00d9\u00db\u00dc".split(","), +function(b){var c=b.charAt(0);S(b.slice(1).split(""),function(d){a[d]=c;a[d.toLowerCase()]=c.toLowerCase()})});q[Oa]=k;q[Ra]=a})();Va(Wa);Va(Xa,k);ya(Ya,oa); +var T,$a,ab=["ampm","hour","minute","second","ampm","utc","offset_sign","offset_hours","offset_minutes","ampm"],bb="({t})?\\s*(\\d{1,2}(?:[,.]\\d+)?)(?:{h}([0-5]\\d(?:[,.]\\d+)?)?{m}(?::?([0-5]\\d(?:[,.]\\d+)?){s})?\\s*(?:({t})|(Z)|(?:([+-])(\\d{2,2})(?::?(\\d{2,2}))?)?)?|\\s*({t}))",cb={},db,eb,fb,gb=[],hb=[{ba:"f{1,4}|ms|milliseconds",format:function(a){return V(a,"Milliseconds")}},{ba:"ss?|seconds",format:function(a){return V(a,"Seconds")}},{ba:"mm?|minutes",format:function(a){return V(a,"Minutes")}}, +{ba:"hh?|hours|12hr",format:function(a){a=V(a,"Hours");return a===0?12:a-qa(a/13)*12}},{ba:"HH?|24hr",format:function(a){return V(a,"Hours")}},{ba:"dd?|date|day",format:function(a){return V(a,"Date")}},{ba:"dow|weekday",la:k,format:function(a,b,c){a=V(a,"Day");return b.weekdays[a+(c-1)*7]}},{ba:"MM?",format:function(a){return V(a,"Month")+1}},{ba:"mon|month",la:k,format:function(a,b,c){a=V(a,"Month");return b.months[a+(c-1)*12]}},{ba:"y{2,4}|year",format:function(a){return V(a,"FullYear")}},{ba:"[Tt]{1,2}", +format:function(a,b,c,d){if(b.ampm.length==0)return"";a=V(a,"Hours");b=b.ampm[qa(a/12)];if(d.length===1)b=b.slice(0,1);if(d.slice(0,1)==="T")b=b.toUpperCase();return b}},{ba:"z{1,4}|tz|timezone",text:k,format:function(a,b,c,d){a=a.getUTCOffset();if(d=="z"||d=="zz")a=a.replace(/(\d{2})(\d{2})/,function(e,f){return O(f,d.length)});return a}},{ba:"iso(tz|timezone)",format:function(a){return a.getUTCOffset(k)}},{ba:"ord",format:function(a){a=V(a,"Date");return a+sa(a)}}],ib=[{$:"year",method:"FullYear", +ja:k,da:function(a){return(365+(a?a.isLeapYear()?1:0:0.25))*24*60*60*1E3}},{$:"month",method:"Month",ja:k,da:function(a,b){var c=30.4375,d;if(a){d=a.daysInMonth();if(b<=d.days())c=d}return c*24*60*60*1E3},error:0.919},{$:"week",method:"Week",da:aa(6048E5)},{$:"day",method:"Date",ja:k,da:aa(864E5)},{$:"hour",method:"Hours",da:aa(36E5)},{$:"minute",method:"Minutes",da:aa(6E4)},{$:"second",method:"Seconds",da:aa(1E3)},{$:"millisecond",method:"Milliseconds",da:aa(1)}],jb={}; +function kb(a){na(this,a);this.ga=gb.concat()} +kb.prototype={getMonth:function(a){return B(a)?a-1:this.months.indexOf(a)%12},getWeekday:function(a){return this.weekdays.indexOf(a)%7},oa:function(a){var b;return B(a)?a:a&&(b=this.numbers.indexOf(a))!==-1?(b+1)%10:1},ta:function(a){var b=this;return a.replace(r(this.num,"g"),function(c){return b.oa(c)||""})},ra:function(a){return T.units[this.units.indexOf(a)%8]},ua:function(a){return this.na(a,a[2]>0?"future":"past")},qa:function(a){return this.na(lb(a),"duration")},va:function(a){a=a||this.code; +return a==="en"||a==="en-US"?k:this.variant},ya:function(a){return a===this.ampm[0]},za:function(a){return a&&a===this.ampm[1]},na:function(a,b){var c,d,e=a[0],f=a[1],h=a[2],i=this[b]||this.relative;if(A(i))return i.call(this,e,f,h,b);d=this.units[(this.plural&&e>1?1:0)*8+f]||this.units[f];if(this.capitalizeUnit)d=mb(d);c=this.modifiers.filter(function(j){return j.name=="sign"&&j.value==(h>0?1:-1)})[0];return i.replace(/\{(.*?)\}/g,function(j,g){switch(g){case "num":return e;case "unit":return d; +case "sign":return c.src}})},sa:function(){return this.ma?[this.ma].concat(this.ga):this.ga},addFormat:function(a,b,c,d,e){var f=c||[],h=this,i;a=a.replace(/\s+/g,"[-,. ]*");a=a.replace(/\{([^,]+?)\}/g,function(j,g){var m,o,w,z=g.match(/\?$/);w=g.match(/^(\d+)\??$/);var J=g.match(/(\d)(?:-(\d))?/),M=g.replace(/[^a-z]+$/,"");if(w)m=h.tokens[w[1]];else if(h[M])m=h[M];else if(h[M+"s"]){m=h[M+"s"];if(J){o=[];m.forEach(function(Q,Da){var U=Da%(h.units?8:m.length);if(U>=J[1]&&U<=(J[2]||J[1]))o.push(Q)}); +m=o}m=nb(m)}if(w)w="(?:"+m+")";else{c||f.push(M);w="("+m+")"}if(z)w+="?";return w});if(b){b=ob(bb,h,e);e=["t","[\\s\\u3000]"].concat(h.timeMarker);i=a.match(/\\d\{\d,\d\}\)+\??$/);pb(h,"(?:"+b+")[,\\s\\u3000]+?"+a,ab.concat(f),d);pb(h,a+"(?:[,\\s]*(?:"+e.join("|")+(i?"+":"*")+")"+b+")?",f.concat(ab),d)}else pb(h,a,f,d)}};function qb(a,b){var c;C(a)||(a="");c=jb[a]||jb[a.slice(0,2)];if(b===n&&!c)throw Error("Invalid locale.");return c||$a} +function rb(a,b){function c(g){var m=i[g];if(C(m))i[g]=m.split(",");else m||(i[g]=[])}function d(g,m){g=g.split("+").map(function(o){return o.replace(/(.+):(.+)$/,function(w,z,J){return J.split("|").map(function(M){return z+M}).join("|")})}).join("|");return g.split("|").forEach(m)}function e(g,m,o){var w=[];i[g].forEach(function(z,J){if(m)z+="+"+z.slice(0,3);d(z,function(M,Q){w[Q*o+J]=M.toLowerCase()})});i[g]=w}function f(g,m,o){g="\\d{"+g+","+m+"}";if(o)g+="|(?:"+nb(i.numbers)+")+";return g}function h(g, +m){i[g]=i[g]||m}var i,j;i=new kb(b);c("modifiers");"months,weekdays,units,numbers,articles,tokens,timeMarker,ampm,timeSuffixes,dateParse,timeParse".split(",").forEach(c);j=!i.monthSuffix;e("months",j,12);e("weekdays",j,7);e("units",n,8);e("numbers",n,10);h("code",a);h("date",f(1,2,i.digitDate));h("year","'\\d{2}|"+f(4,4));h("num",function(){var g=["\\d+"].concat(i.articles);if(i.numbers)g=g.concat(i.numbers);return nb(g)}());(function(){var g=[];i.ha={};i.modifiers.forEach(function(m){var o=m.name; +d(m.src,function(w){var z=i[o];i.ha[w]=m;g.push({name:o,src:w,value:m.value});i[o]=z?z+"|"+w:w})});i.day+="|"+nb(i.weekdays);i.modifiers=g})();if(i.monthSuffix){i.month=f(1,2);i.months=pa(1,12).map(function(g){return g+i.monthSuffix})}i.full_month=f(1,2)+"|"+nb(i.months);i.timeSuffixes.length>0&&i.addFormat(ob(bb,i),n,ab);i.addFormat("{day}",k);i.addFormat("{month}"+(i.monthSuffix||""));i.addFormat("{year}"+(i.yearSuffix||""));i.timeParse.forEach(function(g){i.addFormat(g,k)});i.dateParse.forEach(function(g){i.addFormat(g)}); +return jb[a]=i}function pb(a,b,c,d){a.ga.unshift({Ba:d,xa:a,Aa:r("^"+b+"$","i"),to:c})}function mb(a){return a.slice(0,1).toUpperCase()+a.slice(1)}function nb(a){return a.filter(function(b){return!!b}).join("|")}function sb(a,b){var c;if(ma(a[0]))return a;else if(B(a[0])&&!B(a[1]))return[a[0]];else if(C(a[0])&&b)return[tb(a[0]),a[1]];c={};eb.forEach(function(d,e){c[d.$]=a[e]});return[c]} +function tb(a,b){var c={};if(match=a.match(/^(\d+)?\s?(\w+?)s?$/i)){if(K(b))b=parseInt(match[1])||1;c[match[2].toLowerCase()]=b}return c}function ub(a,b){var c={},d,e;b.forEach(function(f,h){d=a[h+1];if(!(K(d)||d==="")){if(f==="year")c.Ca=d.replace(/'/,"");e=parseFloat(d.replace(/'/,"").replace(/,/,"."));c[f]=!isNaN(e)?e:d.toLowerCase()}});return c}function vb(a){a=a.trim().replace(/^(just )?now|\.+$/i,"");return wb(a)} +function wb(a){return a.replace(db,function(b,c,d){var e=0,f=1,h,i;if(c)return b;d.split("").reverse().forEach(function(j){j=cb[j];var g=j>9;if(g){if(h)e+=f;f*=j/(i||1);i=j}else{if(h===n)f*=10;e+=f*j}h=g});if(h)e+=f;return e})} +function xb(a,b,c,d){var e=new s,f=n,h,i,j,g,m,o,w,z,J;e.utc(d);if(fa(a))e.utc(a.isUTC()).setTime(a.getTime());else if(B(a))e.setTime(a);else if(ma(a)){e.set(a,k);g=a}else if(C(a)){h=qb(b);a=vb(a);h&&G(h.sa(),function(M,Q){var Da=a.match(Q.Aa);if(Da){j=Q;i=j.xa;g=ub(Da,j.to,i);g.utc&&e.utc();i.ma=j;if(g.timestamp){g=g.timestamp;return n}if(j.Ba&&!C(g.month)&&(C(g.date)||h.va(b))){z=g.month;g.month=g.date;g.date=z}if(g.year&&g.Ca.length===2)g.year=N(V(new s,"FullYear")/100)*100-N(g.year/100)*100+g.year; +if(g.month){g.month=i.getMonth(g.month);if(g.shift&&!g.unit)g.unit=i.units[7]}if(g.weekday&&g.date)delete g.weekday;else if(g.weekday){g.weekday=i.getWeekday(g.weekday);if(g.shift&&!g.unit)g.unit=i.units[5]}if(g.day&&(z=i.ha[g.day])){g.day=z.value;e.reset();f=k}else if(g.day&&(o=i.getWeekday(g.day))>-1){delete g.day;if(g.num&&g.month){J=function(){var U=e.getWeekday();e.setWeekday(7*(g.num-1)+(U>o?o+7:o))};g.day=1}else g.weekday=o}if(g.date&&!B(g.date))g.date=i.ta(g.date);if(i.za(g.ampm)&&g.hour< +12)g.hour+=12;else if(i.ya(g.ampm)&&g.hour===12)g.hour=0;if("offset_hours"in g||"offset_minutes"in g){e.utc();g.offset_minutes=g.offset_minutes||0;g.offset_minutes+=g.offset_hours*60;if(g.offset_sign==="-")g.offset_minutes*=-1;g.minute-=g.offset_minutes}if(g.unit){f=k;w=i.oa(g.num);m=i.ra(g.unit);if(g.shift||g.edge){w*=(z=i.ha[g.shift])?z.value:0;if(m==="month"&&I(g.date)){e.set({day:g.date},k);delete g.date}if(m==="year"&&I(g.month)){e.set({month:g.month,day:g.date},k);delete g.month;delete g.date}}if(g.sign&& +(z=i.ha[g.sign]))w*=z.value;if(I(g.weekday)){e.set({weekday:g.weekday},k);delete g.weekday}g[m]=(g[m]||0)+w}if(g.year_sign==="-")g.year*=-1;fb.slice(1,4).forEach(function(U,$b){var Eb=g[U.$],Fb=Eb%1;if(Fb){g[fb[$b].$]=N(Fb*(U.$==="second"?1E3:60));g[U.$]=qa(Eb)}});return n}});if(j)if(f)e.advance(g);else{e._utc&&e.reset();yb(e,g,k,n,c)}else{e=a?new s(a):new s;d&&e.addMinutes(e.getTimezoneOffset())}if(g&&g.edge){z=i.ha[g.edge];G(fb.slice(4),function(M,Q){if(I(g[Q.$])){m=Q.$;return n}});if(m==="year")g.fa= +"month";else if(m==="month"||m==="week")g.fa="day";e[(z.value<0?"endOf":"beginningOf")+mb(m)]();z.value===-2&&e.reset()}J&&J();e.utc(n)}return{ea:e,set:g}}function lb(a){var b,c=v.abs(a),d=c,e=0;fb.slice(1).forEach(function(f,h){b=qa(N(c/f.da()*10)/10);if(b>=1){d=b;e=h+1}});return[d,e,a]} +function zb(a,b,c,d){var e,f=qb(d),h=r(/^[A-Z]/);if(a.isValid())if(Date[b])b=Date[b];else{if(A(b)){e=lb(a.millisecondsFromNow());b=b.apply(a,e.concat(f))}}else return"Invalid Date";if(!b&&c){e=e||lb(a.millisecondsFromNow());if(e[1]===0){e[1]=1;e[0]=1}return f.ua(e)}b=b||"long";b=f[b]||b;hb.forEach(function(i){b=b.replace(r("\\{("+i.ba+")(\\d)?\\}",i.la?"i":""),function(j,g,m){j=i.format(a,f,m||1,g);m=g.length;var o=g.match(/^(.)\1+$/);if(i.la){if(m===3)j=j.slice(0,3);if(o||g.match(h))j=mb(j)}else if(o&& +!i.text)j=(B(j)?O(j,m):j.toString()).slice(-m);return j})});return b} +function Ab(a,b,c,d){var e,f,h,i=0,j=0,g=0;e=xb(b,l,l,d);if(c>0){j=g=c;f=k}if(!e.ea.isValid())return n;if(e.set&&e.set.fa){ib.forEach(function(m){if(m.$===e.set.fa)i=m.da(e.ea,a-e.ea)-1});b=mb(e.set.fa);if(e.set.edge||e.set.shift)e.ea["beginningOf"+b]();if(e.set.fa==="month")h=e.ea.clone()["endOf"+b]().getTime();if(!f&&e.set.sign&&e.set.fa!="millisecond"){j=50;g=-50}}f=a.getTime();b=e.ea.getTime();h=h||b+i;h=Bb(a,b,h);return f>=b-j&&f<=h+g} +function Bb(a,b,c){b=new Date(b);a=(new Date(c)).utc(a.isUTC());if(V(a,"Hours")!==23){b=b.getTimezoneOffset();a=a.getTimezoneOffset();if(b!==a)c+=(a-b).minutes()}return c} +function yb(a,b,c,d,e){function f(g){return I(b[g])?b[g]:b[g+"s"]}function h(g){return I(f(g))}var i,j;if(B(b)&&d)b={milliseconds:b};else if(B(b)){a.setTime(b);return a}if(I(b.date))b.day=b.date;G(fb,function(g,m){var o=m.$==="day";if(h(m.$)||o&&h("weekday")){b.fa=m.$;j=+g;return n}else if(c&&m.$!=="week"&&(!o||!h("week")))W(a,m.method,o?1:0)});ib.forEach(function(g){var m=g.$;g=g.method;var o;o=f(m);if(!K(o)){if(d){if(m==="week"){o=(b.day||0)+o*7;g="Date"}o=o*d+V(a,g)}else m==="month"&&h("day")&& +W(a,"Date",15);W(a,g,o);if(d&&m==="month"){m=o;if(m<0)m=m%12+12;m%12!=V(a,"Month")&&W(a,"Date",0)}}});if(!d&&!h("day")&&h("weekday")){i=f("weekday");a.setWeekday(i)}(function(){var g=new s;return e===-1&&a>g||e===1&&as.create(a).getTime()-(b||0)},isBefore:function(a,b){return this.getTime()d},isLeapYear:function(){var a=V(this,"FullYear");return a%4===0&&a%100!==0||a%400===0},daysInMonth:function(){return 32-V(new s(V(this,"FullYear"),V(this,"Month"),32),"Date")},format:function(a,b){return zb(this,a,n,b)},relative:function(a,b){if(C(a)){b=a;a=l}return zb(this,a,k,b)},is:function(a,b,c){var d,e;if(this.isValid()){if(C(a)){a=a.trim().toLowerCase(); +e=this.clone().utc(c);switch(k){case a==="future":return this.getTime()>(new s).getTime();case a==="past":return this.getTime()<(new s).getTime();case a==="weekday":return V(e,"Day")>0&&V(e,"Day")<6;case a==="weekend":return V(e,"Day")===0||V(e,"Day")===6;case (d=T.weekdays.indexOf(a)%7)>-1:return V(e,"Day")===d;case (d=T.months.indexOf(a)%12)>-1:return V(e,"Month")===d}}return Ab(this,a,b,c)}},reset:function(a){var b={},c;a=a||"hours";if(a==="date")a="days";c=ib.some(function(d){return a===d.$|| +a===d.$+"s"});b[a]=a.match(/^days?/)?1:0;return c?this.set(b,k):this},clone:function(){var a=new s(this.getTime());a.utc(this.isUTC());return a}});s.extend({iso:function(){return this.toISOString()},getWeekday:s.prototype.getDay,getUTCWeekday:s.prototype.getUTCDay}); +function Cb(a,b){function c(){return N(this*b)}function d(){return X(arguments)[a.ia](this)}function e(){return X(arguments)[a.ia](-this)}var f=a.$,h={};h[f]=c;h[f+"s"]=c;h[f+"Before"]=e;h[f+"sBefore"]=e;h[f+"Ago"]=e;h[f+"sAgo"]=e;h[f+"After"]=d;h[f+"sAfter"]=d;h[f+"FromNow"]=d;h[f+"sFromNow"]=d;u.extend(h)}u.extend({duration:function(a){return qb(a).qa(this)}}); +T=$a=s.addLocale("en",{plural:k,timeMarker:"at",ampm:"am,pm",months:"January,February,March,April,May,June,July,August,September,October,November,December",weekdays:"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday",units:"millisecond:|s,second:|s,minute:|s,hour:|s,day:|s,week:|s,month:|s,year:|s",numbers:"one,two,three,four,five,six,seven,eight,nine,ten",articles:"a,an,the",tokens:"the,st|nd|rd|th,of","short":"{Month} {d}, {yyyy}","long":"{Month} {d}, {yyyy} {h}:{mm}{tt}",full:"{Weekday} {Month} {d}, {yyyy} {h}:{mm}:{ss}{tt}", +past:"{num} {unit} {sign}",future:"{num} {unit} {sign}",duration:"{num} {unit}",modifiers:[{name:"day",src:"yesterday",value:-1},{name:"day",src:"today",value:0},{name:"day",src:"tomorrow",value:1},{name:"sign",src:"ago|before",value:-1},{name:"sign",src:"from now|after|from|in|later",value:1},{name:"edge",src:"last day",value:-2},{name:"edge",src:"end",value:-1},{name:"edge",src:"first day|beginning",value:1},{name:"shift",src:"last",value:-1},{name:"shift",src:"the|this",value:0},{name:"shift", +src:"next",value:1}],dateParse:["{num} {unit} {sign}","{sign} {num} {unit}","{month} {year}","{shift} {unit=5-7}","{0?} {date}{1}","{0?} {edge} of {shift?} {unit=4-7?}{month?}{year?}"],timeParse:["{0} {num}{1} {day} of {month} {year?}","{weekday?} {month} {date}{1?} {year?}","{date} {month} {year}","{date} {month}","{shift} {weekday}","{shift} week {weekday}","{weekday} {2?} {shift} week","{num} {unit=4-5} {sign} {day}","{0?} {date}{1} of {month}","{0?}{month?} {date?}{1?} of {shift} {unit=6-7}"]}); +fb=ib.concat().reverse();eb=ib.concat();eb.splice(2,1); +H(s,k,n,ib,function(a,b,c){function d(g){g=g/h;var m=g%1,o=b.error||0.999;if(m&&v.abs(m%1)>o)g=N(g);return parseInt(g)}var e=b.$,f=mb(e),h=b.da(),i,j;b.ia="add"+f+"s";i=function(g,m){return d(this.getTime()-s.create(g,m).getTime())};j=function(g,m){return d(s.create(g,m).getTime()-this.getTime())};a[e+"sAgo"]=j;a[e+"sUntil"]=j;a[e+"sSince"]=i;a[e+"sFromNow"]=i;a[b.ia]=function(g,m){var o={};o[e]=g;return this.advance(o,m)};Cb(b,h);c<3&&["Last","This","Next"].forEach(function(g){a["is"+g+f]=function(){return this.is(g+ +" "+e)}});if(c<4){a["beginningOf"+f]=function(){var g={};switch(e){case "year":g.year=V(this,"FullYear");break;case "month":g.month=V(this,"Month");break;case "day":g.day=V(this,"Date");break;case "week":g.weekday=0}return this.set(g,k)};a["endOf"+f]=function(){var g={hours:23,minutes:59,seconds:59,milliseconds:999};switch(e){case "year":g.month=11;g.day=31;break;case "month":g.day=this.daysInMonth();break;case "week":g.weekday=6}return this.set(g,k)}}}); +T.addFormat("([+-])?(\\d{4,4})[-.]?{full_month}[-.]?(\\d{1,2})?",k,["year_sign","year","month","date"],n,k);T.addFormat("(\\d{1,2})[-.\\/]{full_month}(?:[-.\\/](\\d{2,4}))?",k,["date","month","year"],k);T.addFormat("{full_month}[-.](\\d{4,4})",n,["month","year"]);T.addFormat("\\/Date\\((\\d+(?:\\+\\d{4,4})?)\\)\\/",n,["timestamp"]);T.addFormat(ob(bb,T),n,ab);gb=T.ga.slice(0,7).reverse();T.ga=T.ga.slice(7).concat(gb);H(s,k,n,"short,long,full",function(a,b){a[b]=function(c){return zb(this,b,n,c)}}); +"\u3007\u4e00\u4e8c\u4e09\u56db\u4e94\u516d\u4e03\u516b\u4e5d\u5341\u767e\u5343\u4e07".split("").forEach(function(a,b){if(b>9)b=v.pow(10,b-9);cb[a]=b});"\uff10\uff11\uff12\uff13\uff14\uff15\uff16\uff17\uff18\uff19".split("").forEach(function(a,b){cb[a]=b});db=r("([\u671f\u9031\u5468])?([\u3007\u4e00\u4e8c\u4e09\u56db\u4e94\u516d\u4e03\u516b\u4e5d\u5341\u767e\u5343\u4e07\uff10\uff11\uff12\uff13\uff14\uff15\uff16\uff17\uff18\uff19]+)(?!\u6628)","g"); +(function(){var a="today,yesterday,tomorrow,weekday,weekend,future,past".split(","),b=T.weekdays.slice(0,7),c=T.months.slice(0,12);H(s,k,n,a.concat(b).concat(c),function(d,e){d["is"+mb(e)]=function(f){return this.is(e,0,f)}})})();(function(){s.extend({utc:{create:function(){return X(arguments,0,k)},past:function(){return X(arguments,-1,k)},future:function(){return X(arguments,1,k)}}},n,n)})(); +s.extend({RFC1123:"{Dow}, {dd} {Mon} {yyyy} {HH}:{mm}:{ss} {tz}",RFC1036:"{Weekday}, {dd}-{Mon}-{yy} {HH}:{mm}:{ss} {tz}",ISO8601_DATE:"{yyyy}-{MM}-{dd}",ISO8601_DATETIME:"{yyyy}-{MM}-{dd}T{HH}:{mm}:{ss}.{fff}{isotz}"},n,n); +DateRange=function(a,b){this.start=s.create(a);this.end=s.create(b)};DateRange.prototype.toString=function(){return this.isValid()?this.start.full()+".."+this.end.full():"Invalid DateRange"}; +E(DateRange,k,n,{isValid:function(){return this.start=b.start&&c<=b.end})},every:function(a,b){var c=this.start.clone(),d=[],e=0,f,h;if(C(a)){c.advance(tb(a,0),k);f=tb(a);h=a.toLowerCase()==="day"}else f={milliseconds:a};for(;c<=this.end;){d.push(c);b&&b(c,e);if(h&&V(c,"Hours")===23){c=c.clone();W(c, +"Hours",48)}else c=c.clone().advance(f,k);e++}return d},union:function(a){return new DateRange(this.starta.end?this.end:a.end)},intersect:function(a){return new DateRange(this.start>a.start?this.start:a.start,this.endb-2)){e.push([this,arguments]);h()}}var d=this,e=[],f=n,h,i,j;a=a||1;b=b||Infinity;i=N(a,void 0,"ceil");j=N(i/a);h=function(){if(!(f||e.length==0)){for(var g=v.max(e.length-j,0);e.length>g;)Function.prototype.apply.apply(d,e.shift());Db(c,i,function(){f=n;h()});f=k}};return c},delay:function(a){var b=F(arguments).slice(1);Db(this,a,this,this,b);return this},throttle:function(a){return this.lazy(a,1)},debounce:function(a){function b(){b.cancel(); +Db(b,a,c,this,arguments)}var c=this;return b},cancel:function(){if(da(this.timers))for(;this.timers.length>0;)clearTimeout(this.timers.shift());return this},after:function(a){var b=this,c=0,d=[];if(B(a)){if(a===0){b.call();return b}}else a=1;return function(){var e;d.push(F(arguments));c++;if(c==a){e=b.call(this,d);c=0;d=[];return e}}},once:function(){var a=this;return function(){return L(a,"memo")?a.memo:a.memo=a.apply(this,arguments)}},fill:function(){var a=this,b=F(arguments);return function(){var c= +F(arguments);b.forEach(function(d,e){if(d!=l||e>=c.length)c.splice(e,0,d)});return a.apply(this,c)}}}); +function Gb(a,b,c,d,e,f){var h=a.toFixed(20),i=h.search(/\./);h=h.search(/[1-9]/);i=i-h;if(i>0)i-=1;e=v.max(v.min((i/3).floor(),e===n?c.length:e),-d);d=c.charAt(e+d-1);if(i<-9){e=-3;b=i.abs()-9;d=c.slice(0,1)}return(a/(f?(2).pow(10*e):(10).pow(e*3))).round(b||0).format()+d.trim()} +E(u,n,n,{random:function(a,b){var c,d;if(arguments.length==1){b=a;a=0}c=v.min(a||0,K(b)?1:b);d=v.max(a||0,K(b)?1:b)+1;return qa(v.random()*(d-c)+c)}}); +E(u,k,n,{log:function(a){return v.log(this)/(a?v.log(a):1)},abbr:function(a){return Gb(this,a,"kmbt",0,4)},metric:function(a,b){return Gb(this,a,"n\u03bcm kMGTPE",4,K(b)?1:b)},bytes:function(a,b){return Gb(this,a,"kMGTPE",0,K(b)?4:b,k)+"B"},isInteger:function(){return this%1==0},isOdd:function(){return!isNaN(this)&&!this.isMultipleOf(2)},isEven:function(){return this.isMultipleOf(2)},isMultipleOf:function(a){return this%a===0},format:function(a,b,c){var d,e,f,h="";if(K(b))b=",";if(K(c))c=".";d=(B(a)? +N(this,a||0).toFixed(v.max(a,0)):this.toString()).replace(/^-/,"").split(".");e=d[0];f=d[1];for(d=e.length;d>0;d-=3){if(d2},{startsWith:function(a,b,c){var d=this;if(b)d=d.slice(b);if(K(c))c=k;a=D(a)?a.source.replace("^",""):P(a);return r("^"+a,c?"":"i").test(d)},endsWith:function(a,b,c){var d=this;if(I(b))d=d.slice(0,b);if(K(c))c=k;a=D(a)?a.source.replace("$",""):P(a);return r(a+"$",c?"":"i").test(d)}}); +E(t,k,n,{escapeRegExp:function(){return P(this)},escapeURL:function(a){return a?encodeURIComponent(this):encodeURI(this)},unescapeURL:function(a){return a?decodeURI(this):decodeURIComponent(this)},escapeHTML:function(){return this.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/")},unescapeHTML:function(){return this.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g, +"'").replace(///g,"/")},encodeBase64:function(){return Lb(this)},decodeBase64:function(){return Mb(this)},each:function(a,b){var c,d;if(A(a)){b=a;a=/[\s\S]/g}else if(a)if(C(a))a=r(P(a),"gi");else{if(D(a))a=r(a.source,ua(a,"g"))}else a=/[\s\S]/g;c=this.match(a)||[];if(b)for(d=0;d +0?"_":"")+a.toLowerCase()}).replace(/([A-Z\d]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").toLowerCase()},camelize:function(a){return this.underscore().replace(/(^|_)([^_]+)/g,function(b,c,d,e){b=d;b=(c=t.Inflector)&&c.acronyms[b];b=C(b)?b:void 0;e=a!==n||e>0;if(b)return e?b:b.toLowerCase();return e?d.capitalize():d})},spacify:function(){return this.underscore().replace(/_/g," ")},stripTags:function(){var a=this;ja(arguments.length>0?arguments:[""],function(b){a=a.replace(r("]*>","gi"),"")});return a},removeTags:function(){var a=this;ja(arguments.length>0?arguments:["\\S+"],function(b){b=r("<("+b+")[^<>]*(?:\\/>|>.*?<\\/\\1>)","gi");a=a.replace(b,"")});return a},truncate:function(a,b,c,d){var e="",f="",h=this.toString(),i="["+ta()+"]+",j="[^"+ta()+"]*",g=r(i+j+"$");d=K(d)?"...":t(d);if(h.length<=a)return h;switch(c){case "left":a=h.length-a;e=d;h=h.slice(a);g=r("^"+j+i);break;case "middle":a=qa(a/2);f=d+h.slice(h.length-a).trimLeft();h=h.slice(0,a);break;default:a= +a;f=d;h=h.slice(0,a)}if(b===n&&this.slice(a,a+1).match(/\S/))h=h.remove(g);return e+h+f},pad:function(a,b){return ra(b,a)+this+ra(b,a)},padLeft:function(a,b){return ra(b,a)+this},padRight:function(a,b){return this+ra(b,a)},first:function(a){if(K(a))a=1;return this.substr(0,a)},last:function(a){if(K(a))a=1;return this.substr(this.length-a<0?0:this.length-a)},repeat:function(a){var b="",c=this;if(!B(a)||a<1)return"";for(;a;){if(a&1)b+=c;if(a>>=1)c+=c}return b},toNumber:function(a){var b=this.replace(/,/g, +"");return b.match(/\./)?parseFloat(b):parseInt(b,a||10)},capitalize:function(a){var b;return this.toLowerCase().replace(a?/[\s\S]/g:/^\S/,function(c){var d=c.toUpperCase(),e;e=b?c:d;b=d!==c;return e})},assign:function(){var a={};F(arguments,function(b,c){if(ma(b))na(a,b);else a[c+1]=b});return this.replace(/\{([^{]+?)\}/g,function(b,c){return L(a,c)?a[c]:b})},namespace:function(a){a=a||ba;G(this.split("."),function(b,c){return!!(a=a[c])});return a}});E(t,k,n,{insert:t.prototype.add}); +(function(a){if(this.btoa){Lb=this.btoa;Mb=this.atob}else{var b=/[^A-Za-z0-9\+\/\=]/g;Lb=function(c){var d="",e,f,h,i,j,g,m=0;do{e=c.charCodeAt(m++);f=c.charCodeAt(m++);h=c.charCodeAt(m++);i=e>>2;e=(e&3)<<4|f>>4;j=(f&15)<<2|h>>6;g=h&63;if(isNaN(f))j=g=64;else if(isNaN(h))g=64;d=d+a.charAt(i)+a.charAt(e)+a.charAt(j)+a.charAt(g)}while(m>4;f=(f&15)<<4|i>>2;h=(i&3)<<6|j;d+=t.fromCharCode(e);if(i!=64)d+=t.fromCharCode(f);if(j!=64)d+=t.fromCharCode(h)}while(gprepare("select tgid, extract(hour from call_timestamp) ahour, date_trunc('day', call_timestamp) aday, count(filename), array_to_string(array_agg(filename order by call_timestamp), ',') filenames from recordings group by tgid, ahour, aday order by aday DESC, ahour, tgid;"); +// TODO use tgid categories instead, tgid too specific +$sth->execute(); +$hourlies = $sth->fetchAll(PDO::FETCH_ASSOC); +foreach($hourlies as $hourly) { + processHourly($hourly); +} +// delete uninteresting compilations + --- a/run.bat +++ /dev/null @@ -1,2 +1,1 @@ -python scannr.py > output.txt -pause + --- a/viewcalls.php +++ b/viewcalls.php @@ -12,6 +12,13 @@ } ?> +
+
+
+ +
+
+
@@ -67,6 +74,76 @@ }); + // Set the default dates + var startDate = Date.create().addDays(-6), // 7 days ago + endDate = Date.create(); // today + + var range = $('#range'); + + // Show the dates in the range input + range.val(startDate.format('{MM}/{dd}/{yyyy}') + ' - ' + endDate.format('{MM}/{dd}/{yyyy}')); + + range.daterangepicker({ + + startDate: startDate, + endDate: endDate, + + ranges: { + 'Today': ['today', 'today'], + 'Yesterday': ['yesterday', 'yesterday'], + 'Last 7 Days': [Date.create().addDays(-6), 'today'], + 'Last 30 Days': [Date.create().addDays(-29), 'today'] + } + },function(start, end){ + + ajaxLoadChart(start, end); + + }); + function ajaxLoadChart(startDate,endDate) { + + // If no data is passed (the chart was cleared) + + if(!startDate || !endDate){ + chart.setData({ + "xScale" : "time", + "yScale" : "linear", + "main" : [{ + className : ".stats", + data : [] + }] + }); + + return; + } + + // Otherwise, issue an AJAX request + + $.getJSON('ajax.php', { + + start: startDate.format('{yyyy}-{MM}-{dd}'), + end: endDate.format('{yyyy}-{MM}-{dd}') + + }, function(data) { + + var set = []; + $.each(data, function() { + set.push({ + x : this.label, + y : parseInt(this.value, 10) + }); + }); + + chart.setData({ + "xScale" : "time", + "yScale" : "linear", + "main" : [{ + className : ".stats", + data : set + }] + }); + + }); + } getData('', '', ''); });