├── templates ├── footer.php ├── footer-bar.php ├── header.php ├── header-bar.php └── chat.php ├── public ├── inc.php ├── img.php ├── assets │ ├── logo │ │ ├── known.png │ │ ├── w3c.png │ │ ├── bridgy.png │ │ ├── indieweb.png │ │ └── microformats.png │ ├── user-bkg.jpg │ ├── user.svg │ ├── indiewebcamp.svg │ ├── streaming.js │ ├── cookie.js │ ├── styles.css │ ├── pushstream.js │ └── moment.min.js ├── materialize │ ├── fonts │ │ └── roboto │ │ │ ├── Roboto-Bold.eot │ │ │ ├── Roboto-Bold.ttf │ │ │ ├── Roboto-Bold.woff │ │ │ ├── Roboto-Light.eot │ │ │ ├── Roboto-Light.ttf │ │ │ ├── Roboto-Thin.eot │ │ │ ├── Roboto-Thin.ttf │ │ │ ├── Roboto-Thin.woff │ │ │ ├── Roboto-Bold.woff2 │ │ │ ├── Roboto-Light.woff │ │ │ ├── Roboto-Light.woff2 │ │ │ ├── Roboto-Medium.eot │ │ │ ├── Roboto-Medium.ttf │ │ │ ├── Roboto-Medium.woff │ │ │ ├── Roboto-Regular.eot │ │ │ ├── Roboto-Regular.ttf │ │ │ ├── Roboto-Thin.woff2 │ │ │ ├── Roboto-Medium.woff2 │ │ │ ├── Roboto-Regular.woff │ │ │ └── Roboto-Regular.woff2 │ ├── LICENSE │ └── README.md ├── set-timezone.php ├── send.php ├── opensearchdescription.php ├── today.php ├── slack.php ├── permalink.php ├── log.php └── day.php ├── .gitignore ├── maintenance ├── refresh-users.php ├── refresh-first.php └── import-logs.php ├── composer.json ├── README.md ├── nginx.conf ├── lib ├── php_calendar.php ├── config.template.php ├── Regex.php └── format.php ├── inc.php ├── LICENSE.txt └── composer.lock /templates/footer.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /public/inc.php: -------------------------------------------------------------------------------- 1 | 7 | -------------------------------------------------------------------------------- /public/materialize/fonts/roboto/Roboto-Bold.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indieweb/chat.indieweb.org/main/public/materialize/fonts/roboto/Roboto-Bold.eot -------------------------------------------------------------------------------- /public/materialize/fonts/roboto/Roboto-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indieweb/chat.indieweb.org/main/public/materialize/fonts/roboto/Roboto-Bold.ttf -------------------------------------------------------------------------------- /public/materialize/fonts/roboto/Roboto-Bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indieweb/chat.indieweb.org/main/public/materialize/fonts/roboto/Roboto-Bold.woff -------------------------------------------------------------------------------- /public/materialize/fonts/roboto/Roboto-Light.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indieweb/chat.indieweb.org/main/public/materialize/fonts/roboto/Roboto-Light.eot -------------------------------------------------------------------------------- /public/materialize/fonts/roboto/Roboto-Light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indieweb/chat.indieweb.org/main/public/materialize/fonts/roboto/Roboto-Light.ttf -------------------------------------------------------------------------------- /public/materialize/fonts/roboto/Roboto-Thin.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indieweb/chat.indieweb.org/main/public/materialize/fonts/roboto/Roboto-Thin.eot -------------------------------------------------------------------------------- /public/materialize/fonts/roboto/Roboto-Thin.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indieweb/chat.indieweb.org/main/public/materialize/fonts/roboto/Roboto-Thin.ttf -------------------------------------------------------------------------------- /public/materialize/fonts/roboto/Roboto-Thin.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indieweb/chat.indieweb.org/main/public/materialize/fonts/roboto/Roboto-Thin.woff -------------------------------------------------------------------------------- /public/materialize/fonts/roboto/Roboto-Bold.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indieweb/chat.indieweb.org/main/public/materialize/fonts/roboto/Roboto-Bold.woff2 -------------------------------------------------------------------------------- /public/materialize/fonts/roboto/Roboto-Light.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indieweb/chat.indieweb.org/main/public/materialize/fonts/roboto/Roboto-Light.woff -------------------------------------------------------------------------------- /public/materialize/fonts/roboto/Roboto-Light.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indieweb/chat.indieweb.org/main/public/materialize/fonts/roboto/Roboto-Light.woff2 -------------------------------------------------------------------------------- /public/materialize/fonts/roboto/Roboto-Medium.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indieweb/chat.indieweb.org/main/public/materialize/fonts/roboto/Roboto-Medium.eot -------------------------------------------------------------------------------- /public/materialize/fonts/roboto/Roboto-Medium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indieweb/chat.indieweb.org/main/public/materialize/fonts/roboto/Roboto-Medium.ttf -------------------------------------------------------------------------------- /public/materialize/fonts/roboto/Roboto-Medium.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indieweb/chat.indieweb.org/main/public/materialize/fonts/roboto/Roboto-Medium.woff -------------------------------------------------------------------------------- /public/materialize/fonts/roboto/Roboto-Regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indieweb/chat.indieweb.org/main/public/materialize/fonts/roboto/Roboto-Regular.eot -------------------------------------------------------------------------------- /public/materialize/fonts/roboto/Roboto-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indieweb/chat.indieweb.org/main/public/materialize/fonts/roboto/Roboto-Regular.ttf -------------------------------------------------------------------------------- /public/materialize/fonts/roboto/Roboto-Thin.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indieweb/chat.indieweb.org/main/public/materialize/fonts/roboto/Roboto-Thin.woff2 -------------------------------------------------------------------------------- /public/materialize/fonts/roboto/Roboto-Medium.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indieweb/chat.indieweb.org/main/public/materialize/fonts/roboto/Roboto-Medium.woff2 -------------------------------------------------------------------------------- /public/materialize/fonts/roboto/Roboto-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indieweb/chat.indieweb.org/main/public/materialize/fonts/roboto/Roboto-Regular.woff -------------------------------------------------------------------------------- /public/materialize/fonts/roboto/Roboto-Regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indieweb/chat.indieweb.org/main/public/materialize/fonts/roboto/Roboto-Regular.woff2 -------------------------------------------------------------------------------- /public/set-timezone.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |
7 | 8 | -------------------------------------------------------------------------------- /public/send.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /public/opensearchdescription.php: -------------------------------------------------------------------------------- 1 | '."\n"; 4 | ?> 5 | 6 | search chat.indieweb.org 7 | Search 8 | 10 | 12 | 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # chat.indieweb.org 2 | 3 | This is the source code for the chat logs at https://chat.indieweb.org 4 | 5 | Looking for the chat logs themselves? See: https://github.com/indieweb/indieweb-chat-archive 6 | 7 | ## Requirements 8 | 9 | * nginx 10 | * nginx push-stream module 11 | 12 | 13 | 14 | ## License 15 | 16 | Copyright 2016 by Aaron Parecki 17 | 18 | Licensed under the Apache License, Version 2.0 (the "License"); 19 | you may not use this file except in compliance with the License. 20 | You may obtain a copy of the License at 21 | 22 | http://www.apache.org/licenses/LICENSE-2.0 23 | 24 | Unless required by applicable law or agreed to in writing, software 25 | distributed under the License is distributed on an "AS IS" BASIS, 26 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 27 | See the License for the specific language governing permissions and 28 | limitations under the License. 29 | 30 | -------------------------------------------------------------------------------- /public/materialize/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014-2016 Materialize 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /public/today.php: -------------------------------------------------------------------------------- 1 | 10 | 11 | 12 | Click this, then bookmark 13 | 19 | 20 | 21 | #<?= $channel ?> 22 | 23 | 24 | 25 | 26 | 27 |

Bookmark this page or add to your home screen! When you visit it again, it will redirect you to today's logs.

28 | 29 | 30 | ; rel="hub"'); 41 | header('Link: <' . Config::base_url_for_channel($channel) . '>; rel="self"', false); 42 | 43 | header('Location: ' . Config::$base . $destination . $date->format('Y-m-d') . '#bottom'); 44 | -------------------------------------------------------------------------------- /public/assets/indiewebcamp.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /nginx.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 443 ssl http2; 3 | server_name chat.indieweb.org; 4 | 5 | ssl_certificate /path/to/indieweb.org.crt; 6 | ssl_certificate_key /path/to/server.key; 7 | 8 | access_log chat.indieweb.org.access_log main; 9 | error_log chat.indieweb.org.error_log; 10 | 11 | root /path/to/chat.indieweb.org/public; 12 | index index.php; 13 | 14 | location / { 15 | # Today 16 | rewrite ^/today /today.php?channel=indieweb; 17 | rewrite ^/([a-z\-]+)/today /today.php?channel=$1; 18 | 19 | rewrite ^/slack$ /slack.php; 20 | 21 | # Channel name only 22 | rewrite ^/$ /today.php?channel=indieweb; 23 | rewrite ^/([a-z\-]+)/?$ /today.php?channel=$1; 24 | 25 | # Calendar 26 | rewrite ^/calendar /calendar.php?channel=indieweb; 27 | rewrite ^/([a-z\-]+)/calendar /calendar.php?channel=$1; 28 | 29 | # Day pages 30 | rewrite "^/([0-9]{4}-[0-9]{2}-[0-9]{2})$" /day.php?channel=indieweb&date=$1; 31 | rewrite "^/([a-z\-]+)/([0-9]{4}-[0-9]{2}-[0-9]{2})$" /day.php?channel=$1&date=$2; 32 | 33 | # Chat Line Permalinks 34 | rewrite "^/([0-9]{4}-[0-9]{2}-[0-9]{2})/([0-9]+)$" /permalink.php?channel=indieweb&date=$1×tamp=$2; 35 | rewrite "^/([a-z\-]+)/([0-9]{4}-[0-9]{2}-[0-9]{2})/([0-9]+)$" /permalink.php?channel=$1&date=$2×tamp=$3; 36 | } 37 | 38 | location ~* \.php$ { 39 | fastcgi_pass php-pool; 40 | fastcgi_index index.php; 41 | fastcgi_split_path_info ^(.+\.php)(.*)$; 42 | include fastcgi_params; 43 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 44 | } 45 | 46 | location /__/pub { 47 | push_stream_publisher admin; 48 | push_stream_channels_path $arg_id; 49 | } 50 | location /__/sub { 51 | add_header 'Access-Control-Allow-Origin' '*'; 52 | push_stream_subscriber eventsource; 53 | push_stream_channels_path $arg_id; 54 | push_stream_message_template "{\"id\":~id~,\"channel\":\"~channel~\",\"text\":~text~}"; 55 | push_stream_ping_message_interval 10s; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /public/materialize/README.md: -------------------------------------------------------------------------------- 1 | ![alt tag](https://raw.github.com/dogfalo/materialize/master/images/materialize.gif) 2 | =========== 3 | 4 | [![Travis CI](https://travis-ci.org/Dogfalo/materialize.svg?branch=master)](https://travis-ci.org/Dogfalo/materialize)[![devDependency Status](https://david-dm.org/Dogfalo/materialize/dev-status.svg)](https://david-dm.org/Dogfalo/materialize#info=devDependencies)[![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/Dogfalo/materialize?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) 5 | 6 | [Materialize](http://materializecss.com/), a CSS Framework based on material design 7 | 8 | ### Current Version : v0.97.7 9 | 10 | ## Sass Requirements: 11 | - Ruby Sass 3.3+, LibSass 0.6+ 12 | 13 | ## Supported Browsers: 14 | Chrome 35+, Firefox 31+, Safari 7+, IE 10+ 15 | 16 | ## Changelog 17 | - v0.97.7 (July 23rd) 18 | - Basic horizontal cards 19 | - Carousel bug fixes and new features 20 | - Updated sidenav styles and new component 21 | - Meteor package now supports Sass 22 | - Autocomplete form component 23 | - Chips jQuery plugin 24 | - v0.97.6 (April 1st) 25 | - **Removed deprecated material icons from project** 26 | - **Changed /font directory to /fonts** 27 | - Datepicker and ScrollSpy now compatible with jQuery 2.2.x 28 | - Responsive tables now work with empty cells 29 | - Added focus states to checkboxes, switches, and radio buttons 30 | - Sidenav and Modals no longer cause flicker with scrollbar 31 | - Materialbox overflow and z-index issues fixed 32 | - Added new option for Card actions within a Card reveal 33 | - v0.97.5 (Dec 21, 2015) 34 | - Fixed Meteor package crash 35 | - v0.97.4 (Dec 20, 2015) 36 | - Added Jasmine testing with Travis CI 37 | - Select bugfixes 38 | - Grid Offset bugfix 39 | - Dropdown overflow bugfix 40 | - Range slider error bugfix 41 | 42 | 43 | 44 | ## Contributing 45 | [Please read CONTRIBUTING.md for more information](CONTRIBUTING.md) 46 | 47 | ## Testing 48 | We use Jasmine as our testing framework and we're trying to write a robust test suite for our components. If you want to help, [here's a starting guide on how to write tests in Jasmine](https://docs.google.com/document/d/1dVM6qGt_b_y9RRhr9X7oZfFydaJIEqB9CT7yekv-4XE/edit?usp=sharing) 49 | -------------------------------------------------------------------------------- /public/slack.php: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | IndieWebCamp Slack Setup 7 | 33 | 34 | 35 | 36 |
37 | 42 |

Welcome to IndieWebCamp!

43 |

Enter your email address to be invited to the Slack gateway!

44 |

Slack is just one way you can join the IndieWebCamp chat room. You can also join via IRC on freenode.net, as well as from our web interface.

45 |
46 | 47 | 48 |

49 |
50 |

Please note that all our public Slack channels are bridged to IRC and archived permanently on the web at chat.indieweb.org. All contributions to the IndieWeb chat and wiki are made under a CC0 license.

51 | $_POST['email'], 60 | 'token' => Config::$slack_token, 61 | 'set_active' => 'true' 62 | ])); 63 | $result = curl_exec($ch); 64 | 65 | ?> 66 |

Check your email!

67 |

You should have an invitation in your inbox now!

68 |

Check your spam folder if you don't see it at first. The email will come from Slack.

69 | 70 | 73 | 74 |
75 | 76 | 77 | setTimeZone($tz); 35 | 36 | $db = new Quartz\DB('data/'.Config::logpath_for_channel($channel), 'r'); 37 | $line = $db->getByDate($date); 38 | 39 | if(!$line) { 40 | header('HTTP/1.1 404 Not Found'); 41 | die('not found'); 42 | } 43 | 44 | $dateTitle = $date->format('Y-m-d'); 45 | 46 | header('Last-Modified: '.date('r', $timestamp/1000000)); 47 | header('Cache-Control: max-age=2592000'); 48 | 49 | if(isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { 50 | if(strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= floor($timestamp/1000000)) { 51 | header('HTTP/1.1 304 Not Modified'); 52 | die(); 53 | } 54 | } 55 | 56 | if($line->type == 'join') { 57 | $noindex = true; 58 | } 59 | 60 | $current = $line->data; 61 | if($current->author && property_exists($current->author, 'url') && $current->author->url) { 62 | $userUrl = $current->author->url; 63 | } 64 | 65 | if(property_exists($current, 'deleted')) { 66 | header('HTTP/1.1 410 Gone'); 67 | die('deleted'); 68 | } 69 | 70 | include('templates/header.php'); 71 | include('templates/header-bar.php'); 72 | ?> 73 |
74 |
75 | 79 |
80 |
81 | 4 | 5 | 6 | 7 | 8 | <?= $channelName ?> <?= $dateTitle ?> 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /public/assets/streaming.js: -------------------------------------------------------------------------------- 1 | // Streaming logs 2 | var pushstream = new PushStream({ 3 | host: window.location.hostname, 4 | port: 443, 5 | useSSL: true, 6 | modes: "eventsource", 7 | urlPrefixEventsource: "/__/sub", 8 | channelsByArgument: true, 9 | channelsArgument: "id" 10 | }); 11 | pushstream.onmessage = function(data,id,channel) { 12 | // console.log(data); 13 | 14 | // Check that this channel matches the active channel 15 | if(document.getElementById('active-channel') && document.getElementById('active-channel').value == data.channel) { 16 | var html = data.html; 17 | var autoScroll = (window.innerHeight + window.scrollY) >= document.body.offsetHeight; 18 | var line = document.createElement('div'); 19 | line.innerHTML = html; 20 | 21 | // Format the timestamp in the display timezone 22 | var timestamp = line.querySelector("time").attributes['datetime'].value; 23 | var displayTime = moment(timestamp).utcOffset(document.getElementById('tz-offset').value).format("HH:mm"); 24 | if(line.querySelector("time a")) { 25 | line.querySelector("time a").innerText = displayTime; 26 | } 27 | 28 | document.getElementById('log-lines').appendChild(line.childNodes[0]); 29 | // Auto-scroll if the window is already scrolled to the bottom 30 | if(autoScroll) { 31 | window.scrollTo(0,document.body.scrollHeight); 32 | } 33 | if(window.check_alert) { 34 | check_alert(data); 35 | } 36 | } else { 37 | channel_activity(data.channel, data.type); 38 | } 39 | } 40 | pushstream.addChannel('chat'); 41 | pushstream.connect(); 42 | 43 | // Channel unread indicators 44 | function channel_activity(channel, type) { 45 | var tab = document.querySelector('li.channel[data-channel="'+channel+'"]'); 46 | if(tab && type == 'message') { 47 | tab.classList.add('activity'); 48 | } 49 | 50 | var channels = Cookies.getJSON('unread'); 51 | if(channels == "undefined") { 52 | channels = {}; 53 | } 54 | if(typeof channels[channel] == 'undefined' || channels[channel] == 'read') { 55 | channels[channel] = 'unread'; 56 | Cookies.set('unread', channels); 57 | } 58 | } 59 | 60 | function channel_unread(channel) { 61 | var channels = Cookies.getJSON('unread'); 62 | return channels && channels[channel] == 'unread'; 63 | } 64 | 65 | function channel_read(channel) { 66 | var channels = Cookies.getJSON('unread'); 67 | if(channels) { 68 | channels[channel] = 'read'; 69 | } 70 | Cookies.set('unread', channels); 71 | var tab = document.querySelector('li.channel[data-channel="'+channel+'"]'); 72 | if(tab) { 73 | tab.classList.remove('activity'); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /public/log.php: -------------------------------------------------------------------------------- 1 | add($date, $params); 31 | $db->close(); 32 | } 33 | 34 | redis()->incr('indieweb-chat-total-messages'); 35 | 36 | $local_channel = Config::irc_channel_to_local_channel($params['channel']['name']); 37 | 38 | loadUsers($local_channel); 39 | 40 | $tz = new DateTimeZone('UTC'); 41 | $html = format_line($local_channel, $date, $tz, json_decode($input))['html']; 42 | 43 | if($params['channel']['name'] !== '#indieweb-chat') { 44 | 45 | // Publish to the realtime logs 46 | $ch = curl_init(Config::$base.'__/pub?id=chat'); 47 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 48 | curl_setopt($ch, CURLOPT_POST, true); 49 | $data = []; 50 | $data['html'] = $html; 51 | $data['channel'] = $params['channel']['name']; 52 | $data['type'] = $params['type']; 53 | $data['nick'] = $params['author']['nickname']; 54 | curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); 55 | curl_exec($ch); 56 | 57 | } 58 | 59 | 60 | if($params['channel']['name'] != '#indieweb-chat') { 61 | // Notify the WebSub hub that there is new content 62 | $url = Config::base_url_for_channel($params['channel']['name']); 63 | if(!mc()->get('websub-throttle:'.$url)) { 64 | 65 | $debug = date('c')."\nattempting to deliver PuSH"; 66 | 67 | $ch = curl_init(Config::$hub); 68 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 69 | curl_setopt($ch, CURLOPT_POST, true); 70 | curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([ 71 | 'hub.mode' => 'publish', 72 | 'hub.url' => $url 73 | ])); 74 | $response = curl_exec($ch); 75 | 76 | $debug .= "\n\n".$response."\n"; 77 | file_put_contents('/web/sites/chat.indieweb.org/maintenance/logs/push.txt', $debug); 78 | 79 | // throttle notifications to 2 minutes 80 | mc()->set('websub-throttle:'.$url, 1, 120); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /lib/php_calendar.php: -------------------------------------------------------------------------------- 1 | . See http://diveintomark.org/archives/2002/07/03 22 | @list($p, $pl) = each($pn); @list($n, $nl) = each($pn); #previous and next links, if applicable 23 | if($p) $p = ''.($pl ? ''.$p.'' : $p).' '; 24 | if($n) $n = ' '.($nl ? ''.$n.'' : $n).''; 25 | $calendar = ''."\n". 26 | '\n"; 27 | 28 | if($day_name_length){ #if the day names should be shown ($day_name_length > 0) 29 | #if day_name_length is >3, the full name of the day will be printed 30 | foreach($day_names as $d) 31 | $calendar .= ''; 32 | $calendar .= "\n"; 33 | } 34 | 35 | if($weekday > 0) $calendar .= ''; #initial 'empty' days 36 | for($day=1,$days_in_month=gmdate('t',$first_of_month); $day<=$days_in_month; $day++,$weekday++){ 37 | if($weekday == 7){ 38 | $weekday = 0; #start a new week 39 | $calendar .= "\n"; 40 | } 41 | if(isset($days[$day]) and is_array($days[$day])){ 42 | @list($link, $classes, $content) = $days[$day]; 43 | if(is_null($content)) $content = $day; 44 | $calendar .= '' : '>'). 45 | ($link ? ''.$content.'' : $content).''; 46 | } 47 | else $calendar .= ""; 48 | } 49 | if($weekday != 7) $calendar .= ''; #remaining "empty" days 50 | 51 | return $calendar."\n
'.$p.($month_href ? ''.$title.'' : $title).$n."
'.htmlentities($day_name_length < 4 ? substr($d,0,$day_name_length) : $d).'
 
$day 
\n"; 52 | } 53 | -------------------------------------------------------------------------------- /templates/header-bar.php: -------------------------------------------------------------------------------- 1 | 58 | 59 | 84 | 85 | 96 | -------------------------------------------------------------------------------- /maintenance/import-logs.php: -------------------------------------------------------------------------------- 1 | [ 15 | 'path' => 'freenode/#indieweb', 16 | 'server' => 'freenode', 17 | ], 18 | '#indieweb' => [ 19 | 'path' => 'freenode/#indieweb', 20 | 'server' => 'freenode', 21 | ], 22 | '#indieweb-dev' => [ 23 | 'path' => 'freenode/#indieweb-dev', 24 | 'server' => 'freenode', 25 | ], 26 | '#indieweb-wordpress' => [ 27 | 'path' => 'freenode/#indieweb-wordpress', 28 | 'server' => 'freenode', 29 | ], 30 | '#indieweb-meta' => [ 31 | 'path' => 'freenode/#indieweb-meta', 32 | 'server' => 'freenode', 33 | ], 34 | '#bridgy' => [ 35 | 'path' => 'freenode/#bridgy', 36 | 'server' => 'freenode', 37 | ], 38 | '#knownchat' => [ 39 | 'path' => 'freenode/#knownchat', 40 | 'server' => 'freenode', 41 | ], 42 | '#social' => [ 43 | 'path' => 'w3c/#social', 44 | 'server' => 'w3c', 45 | ] 46 | '#microformats' => [ 47 | 'path' => 'freenode/#microformats', 48 | 'server' => 'freenode', 49 | ], 50 | ]; 51 | 52 | foreach($channels as $channel=>$chinfo) { 53 | 54 | echo "=====================\n"; 55 | echo $channel."\n"; 56 | 57 | $batch = 2000; 58 | $continue = true; 59 | $last = false; 60 | 61 | $db = new Quartz\DB('data/'.$chinfo['path'], 'w'); 62 | 63 | while($continue) { 64 | $rows = ORM::for_table('irclog') 65 | ->where_gt('timestamp', $last) 66 | ->where('channel', $channel) 67 | // ->where_gt('timestamp', strtotime('2017-10-10T00:00:00+0000').'000') 68 | // ->where_lt('timestamp', strtotime('2012-01-01T00:00:00+0000').'000') 69 | ->order_by_asc('timestamp') 70 | ->limit($batch) 71 | ->find_many(); 72 | 73 | foreach($rows as $row) { 74 | if($row->spam == 1 || $row->hide == 1) continue; 75 | 76 | switch($row->type) { 77 | case 64: 78 | $type = 'join'; break; 79 | default: 80 | $type = 'message'; 81 | } 82 | 83 | $date = DateTime::createFromFormat('U.u', floor($row->timestamp/1000).'.'.sprintf('%06d',1000*($row->timestamp%1000))); 84 | 85 | $content = $row->line; 86 | 87 | // Replace some common encoding errors 88 | $content = str_replace( 89 | ['€','‚','…','‘','’','“','•','–','—','â„¢','›','â€','£', 90 | '©','µ','ß','ä','ç','Ç','ñ','ö','ø','ü','è','é',json_decode("\"\u00c3\u00a0\""), 91 | 'ò','ó','õ','ù','ú','á','â','ê','ô','ÿ','ý'], 92 | ['€', '‚', '…', '‘', '’', '“', '•', '–', '—', '™', '›', '”', '£', 93 | '©', 'µ', 'ß', 'ä', 'ç', 'Ç', 'ñ', 'ö', 'ø', 'ü', 'è', 'é', 'á', 94 | 'ò', 'ó', 'õ', 'ù', 'ú', 'á', 'â', 'ê', 'ô', 'ÿ', 'ý'], 95 | $content 96 | ); 97 | 98 | 99 | #echo $row->nick . ': ' . $content ."\n"; 100 | $db->add($date, [ 101 | 'type' => $type, 102 | 'timestamp' => $date->format('U.u'), 103 | 'network' => 'irc', 104 | 'server' => $chinfo['server'], 105 | 'channel' => [ 106 | 'id' => $channel, 107 | 'name' => $channel, 108 | ], 109 | 'author' => [ 110 | 'uid' => $row->nick, 111 | 'nickname' => $row->nick, 112 | 'name' => $row->nick, 113 | 'username' => null 114 | ], 115 | 'content' => $content, 116 | ]); 117 | 118 | } 119 | if($row) { 120 | echo $date->format('Y-m-d') . ' ' . $row->timestamp."\n"; 121 | $last = $row->timestamp; 122 | } 123 | 124 | if(!$rows) { 125 | echo "Finished!\n"; 126 | $continue = false; 127 | } 128 | } 129 | 130 | $seconds = time()-$start; 131 | echo "Finished in ".$seconds." seconds\n"; 132 | 133 | } 134 | 135 | -------------------------------------------------------------------------------- /public/assets/cookie.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * JavaScript Cookie v2.1.2 3 | * https://github.com/js-cookie/js-cookie 4 | * 5 | * Copyright 2006, 2015 Klaus Hartl & Fagner Brack 6 | * Released under the MIT license 7 | */ 8 | ;(function (factory) { 9 | if (typeof define === 'function' && define.amd) { 10 | define(factory); 11 | } else if (typeof exports === 'object') { 12 | module.exports = factory(); 13 | } else { 14 | var OldCookies = window.Cookies; 15 | var api = window.Cookies = factory(); 16 | api.noConflict = function () { 17 | window.Cookies = OldCookies; 18 | return api; 19 | }; 20 | } 21 | }(function () { 22 | function extend () { 23 | var i = 0; 24 | var result = {}; 25 | for (; i < arguments.length; i++) { 26 | var attributes = arguments[ i ]; 27 | for (var key in attributes) { 28 | result[key] = attributes[key]; 29 | } 30 | } 31 | return result; 32 | } 33 | 34 | function init (converter) { 35 | function api (key, value, attributes) { 36 | var result; 37 | if (typeof document === 'undefined') { 38 | return; 39 | } 40 | 41 | // Write 42 | 43 | if (arguments.length > 1) { 44 | attributes = extend({ 45 | path: '/' 46 | }, api.defaults, attributes); 47 | 48 | if (typeof attributes.expires === 'number') { 49 | var expires = new Date(); 50 | expires.setMilliseconds(expires.getMilliseconds() + attributes.expires * 864e+5); 51 | attributes.expires = expires; 52 | } 53 | 54 | try { 55 | result = JSON.stringify(value); 56 | if (/^[\{\[]/.test(result)) { 57 | value = result; 58 | } 59 | } catch (e) {} 60 | 61 | if (!converter.write) { 62 | value = encodeURIComponent(String(value)) 63 | .replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent); 64 | } else { 65 | value = converter.write(value, key); 66 | } 67 | 68 | key = encodeURIComponent(String(key)); 69 | key = key.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent); 70 | key = key.replace(/[\(\)]/g, escape); 71 | 72 | return (document.cookie = [ 73 | key, '=', value, 74 | attributes.expires && '; expires=' + attributes.expires.toUTCString(), // use expires attribute, max-age is not supported by IE 75 | attributes.path && '; path=' + attributes.path, 76 | attributes.domain && '; domain=' + attributes.domain, 77 | attributes.secure ? '; secure' : '' 78 | ].join('')); 79 | } 80 | 81 | // Read 82 | 83 | if (!key) { 84 | result = {}; 85 | } 86 | 87 | // To prevent the for loop in the first place assign an empty array 88 | // in case there are no cookies at all. Also prevents odd result when 89 | // calling "get()" 90 | var cookies = document.cookie ? document.cookie.split('; ') : []; 91 | var rdecode = /(%[0-9A-Z]{2})+/g; 92 | var i = 0; 93 | 94 | for (; i < cookies.length; i++) { 95 | var parts = cookies[i].split('='); 96 | var cookie = parts.slice(1).join('='); 97 | 98 | if (cookie.charAt(0) === '"') { 99 | cookie = cookie.slice(1, -1); 100 | } 101 | 102 | try { 103 | var name = parts[0].replace(rdecode, decodeURIComponent); 104 | cookie = converter.read ? 105 | converter.read(cookie, name) : converter(cookie, name) || 106 | cookie.replace(rdecode, decodeURIComponent); 107 | 108 | if (this.json) { 109 | try { 110 | cookie = JSON.parse(cookie); 111 | } catch (e) {} 112 | } 113 | 114 | if (key === name) { 115 | result = cookie; 116 | break; 117 | } 118 | 119 | if (!key) { 120 | result[name] = cookie; 121 | } 122 | } catch (e) {} 123 | } 124 | 125 | return result; 126 | } 127 | 128 | api.set = api; 129 | api.get = function (key) { 130 | return api(key); 131 | }; 132 | api.getJSON = function () { 133 | return api.apply({ 134 | json: true 135 | }, [].slice.call(arguments)); 136 | }; 137 | api.defaults = {}; 138 | 139 | api.remove = function (key, attributes) { 140 | api(key, '', extend(attributes, { 141 | expires: -1 142 | })); 143 | }; 144 | 145 | api.withConverter = init; 146 | 147 | return api; 148 | } 149 | 150 | return init(function () {}); 151 | })); -------------------------------------------------------------------------------- /public/day.php: -------------------------------------------------------------------------------- 1 | setTimeZone($tz); 29 | $date = clone $start; 30 | $end = new DateTime($_GET['date'].' 23:59:59', $utc); 31 | $end->setTimeZone($tz); 32 | 33 | # Return 404 for days in the future 34 | if($start->format('U') > time()) { 35 | header('HTTP/1.1 404 Not Found'); 36 | die(); 37 | } 38 | 39 | 40 | $start_utc = new DateTime($_GET['date'].' 00:00:00', $utc); 41 | $end_utc = new DateTime($_GET['date'].' 23:59:59', $utc); 42 | 43 | $dateTitle = $start_utc->format('Y-m-d'); 44 | 45 | $tmrw = new DateTime($_GET['date'].' 00:00:00', $utc); 46 | $tmrw->add(new DateInterval('P1D')); 47 | $tomorrow = $tmrw->format('Y-m-d'); 48 | $ystr = new DateTime($_GET['date'].' 00:00:00', $utc); 49 | $ystr->sub(new DateInterval('P1D')); 50 | $yesterday = $ystr->format('Y-m-d'); 51 | if($tmrw->format('U') > time()) $tomorrow = false; 52 | 53 | $channel = '#'.$_GET['channel']; 54 | $channel_link = Config::base_url_for_channel($channel); 55 | 56 | if (!isAfterFirst($channel, $yesterday)) { 57 | $yesterday = false; 58 | } 59 | $channelName = $channel; 60 | 61 | // #indiewebcamp channel was renamed to #indieweb on 2016-07-04 62 | if($start->format('U') < 1467615600 && $channelName == '#indieweb') $channelName = '#indiewebcamp'; 63 | 64 | 65 | $db = new Quartz\DB('data/'.Config::logpath_for_channel($channel), 'r'); 66 | $results = $db->queryRange(clone $start_utc, clone $end_utc); 67 | 68 | ob_start(); 69 | $num_lines = 0; 70 | $noindex = true; 71 | include('templates/header.php'); 72 | include('templates/header-bar.php'); 73 | 74 | ?> 75 |
76 | 77 |

78 | 79 |
80 |
81 | format('Y-m-d') != $start_utc->format('Y-m-c')) { 84 | echo '
'.$start->setTimeZone($tz)->format('Y-m-d').' '.$tzname.'
'; 85 | } 86 | $last_line_type = false; 87 | $cluster = []; 88 | foreach($results as $line) { 89 | $num_lines++; 90 | $localdate = clone $line->date; 91 | $localdate->setTimeZone($tz); 92 | if($localdate->format('Y-m-d') != $lastday->format('Y-m-d')) { 93 | if(count($cluster)) { 94 | echo render_cluster($cluster); 95 | $cluster = []; 96 | } 97 | echo '
'.$localdate->format('Y-m-d').' '.$tzname.'
'; 98 | } 99 | $current = format_line($channel, $line->date, $tz, $line->data); 100 | if($current['cluster'] && (!$last_line_type || $current['cluster'] == $last_line_type)) { 101 | $cluster[] = $current; 102 | } else { 103 | if(count($cluster)) { 104 | echo render_cluster($cluster); 105 | $cluster = []; 106 | } 107 | echo $current['html']; 108 | } 109 | $lastday = $localdate; 110 | $last_line_type = $current['cluster']; 111 | } 112 | if(count($cluster)) { 113 | echo render_cluster($cluster); 114 | } 115 | ?> 116 |
117 | 118 |
119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 139 | 140 |
141 | ]+)/i','/\[\[([^\]]+)\]\]/'), 153 | array('$1','[[]]'), $msg); 154 | 155 | // Convert mentions of slack usernames "[aaronpk]" to slack format "@aaronpk" 156 | $msg = preg_replace('/\[([a-zA-Z0-9_-]+)\]/', '@$1', $msg); 157 | // Except a few 158 | $msg = preg_replace('/^@(mention|bridgy|indienews|indieweb)/', '[$1]', $msg); 159 | 160 | return $msg; 161 | } 162 | 163 | public static function wiki_base($channel) { 164 | switch($channel) { 165 | case '#indieweb': 166 | case '#indiewebcamp': 167 | case '#dev': 168 | case '#meta': 169 | case '#wordpress': 170 | return 'https://indieweb.org/'; 171 | case '#microformats': 172 | return 'http://microformats.org/wiki/'; 173 | default: 174 | return false; 175 | } 176 | } 177 | 178 | } 179 | -------------------------------------------------------------------------------- /public/assets/styles.css: -------------------------------------------------------------------------------- 1 | main { 2 | padding-left: 300px; 3 | } 4 | 5 | @media (max-width : 992px) { 6 | main { 7 | padding-left: 0; 8 | } 9 | main h2 .channel-name { 10 | display: none; 11 | } 12 | :target:before { 13 | content: ""; 14 | display: block; 15 | height: 72px; 16 | margin-top: -72px; 17 | } 18 | } 19 | @media (min-width : 992px) { 20 | nav { 21 | display: none; 22 | } 23 | } 24 | 25 | nav abbr[title] { 26 | border: none; 27 | text-decoration: none; 28 | } 29 | 30 | nav a.button-collapse { 31 | font-size: 32px; 32 | padding-left: 13px; 33 | height: 100%; 34 | } 35 | 36 | nav ul.right a { 37 | font-size: 2rem; 38 | padding: 0 7px 0 0; 39 | } 40 | 41 | nav ul.right { 42 | padding-right: 8px; 43 | } 44 | 45 | li.channel.activity { 46 | background-color: rgba(255,177,0,0.25); 47 | } 48 | 49 | li.channel.current { 50 | background-color: rgb(240,240,240); 51 | } 52 | 53 | .side-nav form { 54 | padding: 10px; 55 | } 56 | 57 | h2 { 58 | font-size: 2.5rem; 59 | } 60 | 61 | 62 | a.time { 63 | color: #999; 64 | font-weight: normal; 65 | } 66 | a.hash { 67 | color: #BBB; 68 | font-weight: normal; 69 | text-decoration: none; 70 | } 71 | a.hash-join, a.hash-leave { 72 | opacity: 0; 73 | } 74 | .line { 75 | min-height: 22px; 76 | margin-bottom: 4px; 77 | } 78 | .line .text span { 79 | word-wrap: break-word; 80 | } 81 | .join.cluster { 82 | color: #bbb; 83 | padding-left: 48px; 84 | } 85 | .deleted.cluster { 86 | color: #bbb; 87 | padding-left: 48px; 88 | } 89 | .msg-join, .msg-join .text a, .msg-leave, .msg-leave a { 90 | color: #bbb; 91 | } 92 | .msg-wiki, .msg-wiki .text a, .msg-wiki a.author { 93 | color: #7e3db4; 94 | } 95 | .msg-wiki .text a { 96 | font-weight: bold; 97 | } 98 | .msg-message.emote .text { 99 | font-style: italic; 100 | } 101 | .msg-twitter.retweet { 102 | opacity: 0.5; 103 | } 104 | .msg-twitter, .msg-twitter a { 105 | color: #2087e1; 106 | } 107 | a { 108 | color: #222299; 109 | overflow-wrap: break-word; 110 | word-wrap: break-word; 111 | } 112 | .nick, a.author { 113 | color: #a13d3d; 114 | } 115 | .msg-twitter a.author { 116 | color: #2087e1; 117 | } 118 | .author { 119 | font-weight: bold; 120 | } 121 | .avatar { 122 | margin-right: 3px; 123 | margin-top: 1px; 124 | margin-bottom: 1px; 125 | display: inline-block; 126 | } 127 | .avatar img { 128 | -webkit-border-radius: 3px; 129 | -moz-border-radius: 3px; 130 | border-radius: 3px; 131 | vertical-align: middle; 132 | } 133 | 134 | .clear { 135 | clear: both; 136 | } 137 | 138 | h2.date { 139 | padding: 0 10px; 140 | margin: 0; 141 | margin-top: 6px; 142 | } 143 | 144 | .logs { 145 | padding: 4px 10px 60px 10px; 146 | } 147 | .logs.active-chat { 148 | padding-bottom: 120px; 149 | } 150 | 151 | .hilite { 152 | font-size: 130%; 153 | } 154 | .hilite .in { 155 | background-color: #fffdd0; 156 | } 157 | 158 | .skip { 159 | margin-bottom: 12px; 160 | } 161 | #bottom { 162 | margin-top: 12px; 163 | } 164 | 165 | @media (max-width: 640px) { 166 | body { 167 | width: 100%; 168 | font-size: 12px; 169 | } 170 | .avatar img { 171 | width: 16px; 172 | height: 16px; 173 | } 174 | } 175 | 176 | .line:hover { 177 | background-color: #fffdeb; 178 | } 179 | 180 | .featured { 181 | font-size: 130%; 182 | margin: 20px 0; 183 | } 184 | 185 | .spam { 186 | color:lightgrey; 187 | font-size: x-small; 188 | max-width:100%; 189 | overflow:hidden; 190 | text-overflow:ellipsis; 191 | margin-bottom: 1px; 192 | white-space: nowrap; 193 | min-height: 10px; 194 | opacity: 0.5; 195 | } 196 | .spam .avatar img { 197 | height: 10px; 198 | } 199 | 200 | .daymark { 201 | font-size: 1.2em; 202 | border-top: 2px #ccc solid; 203 | } 204 | .daymark .tz { 205 | color: #888; 206 | } 207 | 208 | #indieweb-header .channels .channel.current { 209 | background: #e5e5e5; 210 | box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.125) 211 | } 212 | #indieweb-header .channels .channel.activity { 213 | background: #ffee88; 214 | box-shadow: inset 0 3px 8px rgba(200, 180, 30, 0.325) 215 | } 216 | 217 | 218 | #indieweb-header ul.right { 219 | float: right; 220 | list-style-type: none; 221 | margin: 0; 222 | padding: 0; 223 | margin-right: 10px; 224 | } 225 | #indieweb-header ul.right li { 226 | display: inline-block; 227 | margin: 0; 228 | padding: 4px 10px; 229 | } 230 | #indieweb-header .disabled, 231 | .side-nav.fixed a.disabled { 232 | color: #ccc; 233 | } 234 | 235 | .side-nav .search button.material-icons { 236 | position: absolute; 237 | top: 8px; 238 | right: 8px; 239 | padding: 2px; 240 | border: none; 241 | background-color: transparent; 242 | } 243 | 244 | .side-nav .search button.material-icons:focus, .side-nav .search button.material-icons:hover { 245 | background-color: rgba(255,177,0,0.25); 246 | } 247 | 248 | 249 | #chat-footer { 250 | border-top: 1px #ddd solid; 251 | 252 | background: #fafafa; /* Old browsers */ 253 | background: -moz-linear-gradient(top, #ffffff, #f2f2f2); /* FF3.6-15 */ 254 | background: -webkit-linear-gradient(top, #ffffff, #f2f2f2); /* Chrome10-25,Safari5.1-6 */ 255 | background: linear-gradient(to bottom, #e9e9e9, #f2f2f2); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */ 256 | 257 | padding-top: 10px; 258 | padding-bottom: 10px; 259 | padding-left: 10px; 260 | position: fixed; 261 | bottom: 0; 262 | width: 100%; 263 | } 264 | -------------------------------------------------------------------------------- /lib/Regex.php: -------------------------------------------------------------------------------- 1 | @$1'; 103 | 104 | /** 105 | * Returns the Twitter username found in $text 106 | * @param string $text 107 | * @return string The matched text 108 | */ 109 | public static function get($text) 110 | { 111 | return self::_get($text); 112 | } 113 | } 114 | 115 | class Regex_URL extends Regex 116 | { 117 | public static $expression = '|(https?:\/\/[^\s]+(?$1'; 119 | 120 | /** 121 | * Returns the raw URL found in $text 122 | * @param string $text 123 | * @return string The matched text 124 | */ 125 | public static function get($text) 126 | { 127 | return self::_get($text); 128 | } 129 | 130 | public static function replace($text) 131 | { 132 | return parent::replace($text); 133 | } 134 | } 135 | 136 | 137 | class Regex_WikiPage extends Regex 138 | { 139 | public static $expression = array('/(^|\s)\/([^ >*]+)/i','/\[\[([^\]]+)\]\]/'); 140 | public static $replacement = array('$1/$2','[[$1]]'); 141 | 142 | /** 143 | * Returns the raw URL found in $text 144 | * @param string $text 145 | * @return string The matched text 146 | */ 147 | public static function get($text) 148 | { 149 | return self::_get($text); 150 | } 151 | 152 | public static function replace($text) 153 | { 154 | return parent::replace($text); 155 | } 156 | } 157 | 158 | 159 | class Regex_Email extends Regex 160 | { 161 | public static $expression = '|([a-z0-9_\.\+\-]+@[a-z0-9_\.\+\-]+\.[a-z0-9\.]{2,4})|i'; 162 | public static $replacement = '$1'; 163 | 164 | /** 165 | * Returns the raw email found in $text 166 | * @param string $text 167 | * @return string The matched text 168 | */ 169 | public static function get($text) 170 | { 171 | return self::_get($text); 172 | } 173 | } 174 | 175 | /** 176 | * Parses the name and email address out of an email recipient line. 177 | * May be formatted like any of the following: 178 | * 179 | * "First Last" 180 | * First Last 181 | * first.last@gmail.com 182 | */ 183 | class Regex_EmailRecipient extends Regex 184 | { 185 | public static $expression = '|([a-z0-9_\.\+\-]+@[a-z0-9_\.\+\-]+\.[a-z0-9\.]{2,4})|i'; 186 | public static $nameExpression = '|([^<>"]+)|'; 187 | public static $replacement = '$2'; 188 | 189 | /** 190 | * Returns the raw email found in $text 191 | * @param string $text 192 | * @return string The matched text 193 | */ 194 | public static function get($text) 195 | { 196 | parent::$expression = self::$expression; 197 | return self::_get($text); 198 | } 199 | 200 | public static function getEmail($text) 201 | { 202 | if(preg_match(self::$expression, $text, $match)) 203 | return $match[1]; 204 | else 205 | return FALSE; 206 | } 207 | 208 | public static function getName($text) 209 | { 210 | $text = preg_replace(self::$expression, '', $text); 211 | if(preg_match(self::$nameExpression, $text, $match)) 212 | return trim($match[1]); 213 | if(preg_match(self::$nameExpression, $text, $match)) 214 | return trim($match[1]); 215 | else 216 | return FALSE; 217 | } 218 | 219 | public static function test() 220 | { 221 | $tests[] = '"First Last" '; 222 | $tests[] = 'First Last '; 223 | $tests[] = 'First Middle Last '; 224 | $tests[] = ''; 225 | $tests[] = 'first.last@gmail.com'; 226 | $tests[] = 'Not an email address'; 227 | 228 | foreach($tests as $test) 229 | { 230 | echo 'Input: ' . htmlspecialchars($test) . '
'; 231 | echo htmlspecialchars('Email: /' . Regex_EmailRecipient::getEmail($test) . '/ Name: /' . Regex_EmailRecipient::getName($test)) . '/
'; 232 | echo '
'; 233 | } 234 | } 235 | } 236 | 237 | -------------------------------------------------------------------------------- /inc.php: -------------------------------------------------------------------------------- 1 | addServer('127.0.0.1', 11211); 16 | } 17 | return $m; 18 | } 19 | 20 | class ImageProxy { 21 | 22 | public static function url($url) { 23 | $signature = hash_hmac('sha256', $url, Config::$secret); 24 | if(preg_match('/^http/', $url)) 25 | $path = '?url=' . urlencode($url) . '&'; 26 | else 27 | $path = '/' . $url . '?'; 28 | return Config::$base.'img.php'.$path.'sig=' . $signature; 29 | } 30 | 31 | public static function image($url, $sig) { 32 | $expectedSignature = hash_hmac('sha256', $url, Config::$secret); 33 | if($sig == $expectedSignature) { 34 | $filename = './public/avatars/'.$sig.'.jpg'; 35 | 36 | if(preg_match('/^https?:\/\//', $url)) { 37 | 38 | if(file_exists($filename)) { 39 | header('Content-type: image/jpeg'); 40 | readfile($filename); 41 | return; 42 | } 43 | 44 | $client = new GuzzleHttp\Client(); 45 | 46 | try { 47 | $img = $client->request('GET', $url); 48 | 49 | // Resize to 64px 50 | $image = ImageResize::createFromString($img->getBody()); 51 | $image->resizeToBestFit(64, 64); 52 | 53 | // Save to disk 54 | $image->save($filename, IMAGETYPE_JPEG, 80); 55 | $image->output(IMAGETYPE_JPEG, 80); 56 | 57 | return; 58 | } catch(GuzzleHttp\Exception\ClientException $e) { 59 | } 60 | } 61 | } 62 | header('Content-type: image/svg+xml'); 63 | readfile('./public/assets/user.svg'); 64 | } 65 | 66 | } 67 | 68 | function getViewerTimezone() { 69 | try { 70 | $tzname = array_key_exists('timezone_view', $_COOKIE) ? $_COOKIE['timezone_view'] : 'UTC'; 71 | $tz = new DateTimeZone($tzname); 72 | } catch(Exception $e) { 73 | $tzname = 'UTC'; 74 | $tz = new DateTimeZone('UTC'); 75 | } 76 | return [$tzname, $tz]; 77 | } 78 | 79 | function filterText($text, $channel) { 80 | /* 81 | for($i=0; $i$1', $text); 94 | 95 | $text = preg_replace(Regex_URL::$expression, Regex_URL::$replacement, $text); 96 | $text = preg_replace(Regex_Twitter::$expression, Regex_Twitter::$replacement, $text); 97 | 98 | if($b=Config::wiki_base($channel)) { 99 | $wikireplace = str_replace('{{wikibase}}', $b, Regex_WikiPage::$replacement); 100 | $text = preg_replace(Regex_WikiPage::$expression, $wikireplace, $text); 101 | } 102 | 103 | // Expand Loqi memes 104 | $text = preg_replace('/(?', $text); 105 | 106 | return $text; 107 | } 108 | 109 | function isMeMessage($text) { 110 | return preg_match('/^\/me /', $text); 111 | } 112 | 113 | function xmlEscapeText($text, $autolink=TRUE) { 114 | # escape the source line of text 115 | $text = str_replace(array('&','<','>','"'), array('&','<','>','"'), $text); 116 | 117 | if($autolink) { 118 | # add links for URLs and twitter names 119 | $text = preg_replace(Regex_URL::$expression, Regex_URL::$replacement, $text); 120 | $text = preg_replace(Regex_Twitter::$expression, Regex_Twitter::$replacement, $text); 121 | } 122 | 123 | return $text; 124 | } 125 | 126 | function stripIRCControlChars($text) { 127 | $text = preg_replace('/\x03\d{1,2}/', '', $text); 128 | $text = preg_replace('/\x03/', '', $text); 129 | return $text; 130 | } 131 | 132 | function trimString($str, $length, $allow_word_break=false) { 133 | // trims $str to $length characters 134 | // if $str is too long, it puts … on the end 135 | // if $allow_word_break is true, doesn't split a word in the middle 136 | 137 | if( strlen($str) <= $length ) { 138 | return $str; 139 | } else { 140 | if( $allow_word_break ) { 141 | return trim(substr($str,0,$length-3))."..."; 142 | } else { 143 | $newstr = substr($str,0,$length-3); 144 | return substr($newstr, 0, strrpos($newstr, " "))."..."; 145 | } 146 | } 147 | } 148 | 149 | 150 | function refreshUsers() { 151 | $collections = [ 152 | ['group'=>'indieweb', 'url'=>'https://indieweb.org/irc-people'], 153 | ['group'=>'w3c', 'url'=>'https://www.w3.org/wiki/IRC-people'] 154 | ]; 155 | 156 | foreach($collections as $c) { 157 | $parsed = file_get_contents('http://pin13.net/mf2/?url='.urlencode($c['url'])); 158 | if(trim($parsed)) { 159 | $data = json_decode($parsed); 160 | if($data && property_exists($data, 'items') && count($data->items) && count($data->items[0])) { 161 | $item = $data->items[0]; 162 | if(isset($item->children)) 163 | $users = $item->children; 164 | else 165 | $users = $data->items; 166 | 167 | $er = fopen('php://stderr', 'w'); 168 | fputs($er, 'found ' . count($users) . ' items'."\n"); 169 | fclose($er); 170 | file_put_contents(dirname(__FILE__).'/data/'.$c['group'].'.json', json_encode($users,JSON_PRETTY_PRINT+JSON_UNESCAPED_SLASHES)); 171 | } 172 | } 173 | } 174 | } 175 | 176 | function join_with_and($array) { 177 | if(count($array) == 0) return ''; 178 | if(count($array) == 1) return $array[0]; 179 | $last = array_pop($array); 180 | return implode(', ', $array).' and '.$last; 181 | } 182 | 183 | /** 184 | * Generate file that contains the date with the first message 185 | * in each channel 186 | */ 187 | /* TODO: update to check files on disk and save as YYYY-MM-DD 188 | function refreshFirst() { 189 | $channels = Config::supported_channels(); 190 | $dates = new stdClass(); 191 | 192 | foreach ($channels as $channel) { 193 | if ($channel == 'indieweb') { 194 | $sqlChannels = '"#indieweb","#indiewebcamp"'; 195 | } else { 196 | $sqlChannels = '"' . Config::irc_channel_for_slug($channel) . '"'; 197 | } 198 | $sql = 'SELECT timestamp FROM irclog' 199 | . ' WHERE channel IN (' . $sqlChannels . ')' 200 | . ' ORDER BY timestamp ASC' 201 | . ' LIMIT 1'; 202 | $stmt = db()->query($sql); 203 | $row = $stmt->fetchObject(); 204 | if (is_object($row)) { 205 | $dates->{'#' . $channel} = strtotime(date('Y-m-d', ((int) $row->timestamp / 1000))) * 1000; 206 | } 207 | } 208 | file_put_contents(__DIR__ . '/data/first.json', json_encode($dates)); 209 | } 210 | */ 211 | 212 | function isAfterFirst($channel, $date) 213 | { 214 | $data = json_decode(file_get_contents(__DIR__ . '/data/first.json')); 215 | if (!isset($data->$channel)) { 216 | return false; 217 | } 218 | 219 | return strtotime($date) >= strtotime($data->$channel); 220 | } 221 | 222 | $users = array(); 223 | 224 | function loadUsers($channel) { 225 | global $users; 226 | 227 | if($group=Config::group_for_channel($channel)) { 228 | $filename = dirname(__FILE__).'/data/'.$group.'.json'; 229 | if(file_exists($filename)){ 230 | $data = json_decode(file_get_contents($filename)); 231 | foreach($data as $item) { 232 | if(in_array('h-card', $item->type)) { 233 | $users[] = $item; 234 | } 235 | } 236 | } 237 | } 238 | } 239 | 240 | function loadTimezones() { 241 | global $users; 242 | 243 | $timezones = []; 244 | foreach($users as $u) { 245 | if(property_exists($u->properties, 'tz')) { 246 | $t = $u->properties->tz[0]; 247 | if(!in_array($t, $timezones)) { 248 | try { 249 | new DateTimeZone($t); 250 | $timezones[] = $t; 251 | } catch(Exception $e) {} 252 | } 253 | } 254 | } 255 | sort($timezones); 256 | return $timezones; 257 | } 258 | 259 | function userForNick($nick) { 260 | global $users; 261 | 262 | $nick = strtolower(trim($nick,'_[]')); 263 | 264 | foreach($users as $u) { 265 | if(@strtolower($u->properties->nickname[0]) == $nick) { 266 | return $u; 267 | } 268 | } 269 | return null; 270 | } 271 | 272 | function userForHost($host) { 273 | global $users; 274 | 275 | foreach($users as $u) { 276 | $userHost = property_exists($u->properties, 'url') ? preg_replace('/https?:\/\//','', strtolower($u->properties->url[0])) : false; 277 | if($userHost && $userHost == strtolower($host)) { 278 | return $u; 279 | } 280 | } 281 | return null; 282 | } 283 | 284 | function debug($thing) { 285 | if($_SERVER['REMOTE_ADDR'] == '24.21.213.88') { 286 | var_dump($thing); 287 | } 288 | } 289 | -------------------------------------------------------------------------------- /templates/chat.php: -------------------------------------------------------------------------------- 1 |
2 | 3 | (or join via Discord, IRC, 4 | or Slack). 5 | Any problems? Please file an 6 | issue on GitHub. 7 |
8 | 9 | 12 | 13 | 16 | 17 | 23 | 24 | 25 | 30 | 31 | 32 | 97 | 98 | 306 | -------------------------------------------------------------------------------- /lib/format.php: -------------------------------------------------------------------------------- 1 | author->nickname; 10 | $user = userForNick($input->author->nickname); 11 | $permalink = false; 12 | 13 | $localdate = clone $date; 14 | $localdate->setTimeZone($tz); 15 | 16 | $blank_avatar = '
'; 17 | $avatar = $blank_avatar; 18 | 19 | if($user) { 20 | if(property_exists($user->properties, 'photo')) { 21 | $img = $user->properties->photo[0]; 22 | if(is_object($img) && property_exists($img, 'value')) 23 | $img = $img->value; 24 | $avatar = '
'; 25 | } 26 | $who = $avatar . '' 27 | . '' . $nick . '' 28 | . ''; 29 | } else { 30 | $who = $avatar . '' 31 | . '' . $nick . '' 32 | . ''; 33 | } 34 | 35 | if(property_exists($input, 'deleted')) { 36 | $line['content'] = ''; 37 | $who = ''; 38 | $deleted = true; 39 | } else { 40 | $line['content'] = stripIRCControlChars($input->content); 41 | $deleted = false; 42 | } 43 | 44 | 45 | $timestamp = DateTime::createFromFormat('U.u', $input->timestamp); 46 | $line['timestamp'] = $timestamp->format('Uu'); 47 | $line['type'] = $input->type; 48 | if(preg_match('/^\[\[(?.+)\]\](?: (?[!NM]*|delete|restore|upload|moved))? (?[^ ]+) +\* (?[^\*]+) \* (?:\((?[+-]\d+)\))?(?:uploaded|deleted|restored|moved)?(?.*)/', $line['content'], $match)) { 49 | $line = format_wiki_line($channel, $line, $match, $mf, $blank_avatar); 50 | if(isset($line['who'])) 51 | $who = $line['who']; 52 | } 53 | 54 | // Old twitter citations 55 | if($timestamp->format('U') < strtotime('2014-01-01') && preg_match('/^https?:\/\/twitter.com\/([^ ]+) /', $line['content'], $match)) { 56 | $line['type'] = 'twitter'; 57 | $line['content'] = str_replace(array($match[0].':: ',$match[0]), '', $line['content']); 58 | $avatar = '
'; 59 | $who = $avatar . '@' . $match[1] . ''; 60 | } 61 | 62 | // New tweets 63 | if(preg_match('/\[@([^\]]+)\] (.+) \((https?:\/\/twtr\.io\/[^ ]+|https?:\/\/twitter\.com\/[^ ]+)\)/ms', $line['content'], $match)) { 64 | $line['type'] = 'twitter'; 65 | $line['content'] = $match[2]; 66 | $permalink = $match[3]; 67 | if(parse_url($permalink, PHP_URL_HOST) == 'twtr.io') { 68 | $id = b60to10(parse_url($permalink, PHP_URL_PATH)); 69 | $permalink = 'https://twitter.com/_/status/'.$id; 70 | } 71 | $avatar = '
'; 72 | $who = $avatar . '@' . $match[1] . ''; 73 | } 74 | 75 | // Ugly hack for old Loqi ACTIONs 76 | if($nick == 'Loqi') { 77 | if(preg_match('/^ACTION (.+)/', $line['content'], $match)) { 78 | $line['content'] = $match[1]; 79 | } 80 | } 81 | 82 | 83 | # localize the timestamp to the person who spoke 84 | // if($user && property_exists($user->properties, 'tz')) { 85 | // $tz = $user->properties->tz[0]; 86 | // } else { 87 | // $tz = 'America/Los_Angeles'; 88 | // } 89 | // $date = new DateTime(); 90 | // $date->setTimestamp(round($line['timestamp']/1000)); 91 | // try { 92 | // $date->setTimezone(new DateTimeZone($tz)); 93 | // } catch(Exception $e) { 94 | // $date->setTimezone(new DateTimeZone('America/Los_Angeles')); 95 | // } 96 | 97 | 98 | $url = Config::base_url_for_channel($channel) . $date->format('Y-m-d') . '/' . $date->format('Uu'); 99 | $urlInContext = Config::base_url_for_channel($channel) . $date->format('Y-m-d') . '#t' . $date->format('Uu'); 100 | 101 | // Different css for retweets 102 | $classes = array(); 103 | if($line['type'] == 'twitter' && preg_match('/^RT /', $line['content'])) 104 | $classes[] = 'retweet'; 105 | 106 | if(isMeMessage($line['content'])) 107 | $classes[] = 'emote'; 108 | 109 | if($deleted) 110 | $classes[] = 'deleted'; 111 | 112 | $mf = $mf && !in_array($line['type'], ['join','leave']); 113 | 114 | echo '
'; 115 | 116 | echo '
'; 117 | if(!in_array($line['type'], ['join','leave'])) 118 | echo '# '; 119 | else 120 | echo '# '; 121 | 122 | echo ' '; 129 | 130 | echo ''; 131 | if(!in_array($line['type'], ['join','leave']) && !$deleted) 132 | echo '' . $who . ' '; 133 | 134 | if(!$deleted) { 135 | echo ''; 136 | if(!in_array($line['type'], ['join','leave'])) { 137 | echo filterText($line['content'], $channel); 138 | } else { 139 | echo $nick . ' ' . ($line['type'] == 'join' ? 'joined' : 'left') . ' the channel'; 140 | } 141 | echo ''; 142 | } 143 | echo ''; 144 | 145 | if($line['type'] == 'twitter' && $permalink) { 146 | echo ' (' . preg_replace('/https?:\/\//', '', $permalink) . ')'; 147 | } elseif($line['type'] == 'wiki' && $line['diff']) { 148 | echo ' (view diff)'; 149 | } 150 | echo '
'; 151 | 152 | if($deleted) { 153 | echo ''; 154 | } 155 | 156 | echo "
\n\n"; 157 | 158 | $cluster = false; 159 | if(in_array($line['type'], ['join','leave'])) $cluster = 'join'; 160 | if($deleted) $cluster = 'deleted'; 161 | 162 | return [ 163 | 'type' => $deleted ? 'deleted' : $line['type'], 164 | 'cluster' => $cluster, 165 | 'html' => ob_get_clean(), 166 | 'nick' => $nick, 167 | 'url' => $url 168 | ]; 169 | } 170 | 171 | function render_cluster($cluster) { 172 | ob_start(); 173 | if($cluster[0]['type'] == 'deleted') { 174 | echo '
['.count($cluster).' line'.(count($cluster)>1?'s':'').' deleted]
'; 175 | } else { 176 | $groups = ['join'=>[], 'leave'=>[]]; 177 | foreach($cluster as $c) { 178 | $groups[$c['type']][] = $c['nick']; 179 | } 180 | echo '
'; 181 | $cluster_line = []; 182 | if(count($groups['join'])) { 183 | $groups['join'] = array_unique($groups['join']); 184 | $cluster_line[] = join_with_and($groups['join']).' joined the channel'; 185 | } 186 | if(count($groups['leave'])) { 187 | $groups['leave'] = array_unique($groups['leave']); 188 | $cluster_line[] = join_with_and($groups['leave']).' left the channel'; 189 | } 190 | echo implode('; ', $cluster_line); 191 | echo '
'; 192 | } 193 | return ob_get_clean(); 194 | } 195 | 196 | function format_wiki_line($channel, $line, $match, $mf, $blank_avatar) { 197 | if(!Config::wiki_base($channel)) 198 | return $line; 199 | 200 | // Wiki edits 201 | $line['type'] = 'wiki'; 202 | $user = userForHost($match['user']); 203 | 204 | if($user) { 205 | if(property_exists($user->properties, 'photo')) { 206 | $img = $user->properties->photo[0]; 207 | if(is_object($img) && property_exists($img, 'value')) 208 | $img = $img->value; 209 | $avatar = '
'; 210 | } else { 211 | $avatar = $blank_avatar; 212 | } 213 | $who = $avatar . '' 214 | . '' . strtolower($match['user']) . '' 215 | . ''; 216 | } else { 217 | $who = $blank_avatar . '' 218 | . '' . strtolower($match['user']) . '' 219 | . ''; 220 | } 221 | 222 | $line['who'] = $who; 223 | 224 | if(trim($match['url']) == 'delete') 225 | $action = 'deleted'; 226 | elseif(trim($match['url']) == 'restore') 227 | $action = 'restored'; 228 | elseif(trim($match['url']) == 'upload') 229 | $action = 'uploaded'; 230 | elseif(trim($match['url']) == 'move') 231 | $action = 'moved'; 232 | elseif(strpos($match['type'], 'N') !== false) 233 | $action = 'created'; 234 | else 235 | $action = 'edited'; 236 | 237 | if(in_array($action, array('deleted','restored','uploaded','moved'))) { 238 | $line['diff'] = false; 239 | if(preg_match('/"\[\[(.+)\]\]": (.+)/', $match['comment'], $dmatch)) { 240 | $match['page'] = str_replace(' ','_',$dmatch[1]); 241 | $match['comment'] = $dmatch[2]; 242 | } 243 | if(preg_match('/moved \[\[([^\]]+)\]\] to \[\[([^\]]+)\]\](?:: (.*))?/', $match['comment'], $dmatch)) { 244 | $match['page'] = str_replace(' ','_',$dmatch[2]); 245 | $match['oldpage'] = str_replace(' ','_',$dmatch[1]); 246 | $match['comment'] = array_key_exists(3, $dmatch) ? $dmatch[3] : ''; 247 | } 248 | } else { 249 | $line['diff'] = $match['url']; 250 | } 251 | 252 | $match['page'] = str_replace(' ', '_', $match['page']); 253 | 254 | $line['content'] = $action 255 | . ($action == 'moved' ? ' /' . $match['oldpage'] . ' to' : '') . ' /' . $match['page'] 256 | . (in_array($action, array('deleted','restored','uploaded','moved')) ? '' : ' (' . ($match['size']) . ')') 257 | . (trim($match['comment']) ? ' "' . trim($match['comment']) . '"' : ''); 258 | 259 | return $line; 260 | } 261 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", 5 | "This file is @generated automatically" 6 | ], 7 | "content-hash": "ccfd2e5086ad004b0047bf95e070565d", 8 | "packages": [ 9 | { 10 | "name": "eventviva/php-image-resize", 11 | "version": "1.5.4", 12 | "source": { 13 | "type": "git", 14 | "url": "https://github.com/eventviva/php-image-resize.git", 15 | "reference": "41e2bbc8dbbf43b9a78bf56095e33d5398eeb056" 16 | }, 17 | "dist": { 18 | "type": "zip", 19 | "url": "https://api.github.com/repos/eventviva/php-image-resize/zipball/41e2bbc8dbbf43b9a78bf56095e33d5398eeb056", 20 | "reference": "41e2bbc8dbbf43b9a78bf56095e33d5398eeb056", 21 | "shasum": "" 22 | }, 23 | "require": { 24 | "ext-gd": "*", 25 | "php": ">=5.3.0" 26 | }, 27 | "type": "library", 28 | "autoload": { 29 | "classmap": [ 30 | "src" 31 | ] 32 | }, 33 | "notification-url": "https://packagist.org/downloads/", 34 | "license": [ 35 | "MIT" 36 | ], 37 | "authors": [ 38 | { 39 | "name": "Aditya Patadia", 40 | "homepage": "http://aditya.patadia.org/" 41 | } 42 | ], 43 | "description": "PHP class to re-size and scale images", 44 | "homepage": "https://github.com/eventviva/php-image-resize", 45 | "keywords": [ 46 | "image", 47 | "php", 48 | "resize", 49 | "scale" 50 | ], 51 | "time": "2016-05-06T08:00:50+00:00" 52 | }, 53 | { 54 | "name": "guzzlehttp/guzzle", 55 | "version": "6.2.0", 56 | "source": { 57 | "type": "git", 58 | "url": "https://github.com/guzzle/guzzle.git", 59 | "reference": "d094e337976dff9d8e2424e8485872194e768662" 60 | }, 61 | "dist": { 62 | "type": "zip", 63 | "url": "https://api.github.com/repos/guzzle/guzzle/zipball/d094e337976dff9d8e2424e8485872194e768662", 64 | "reference": "d094e337976dff9d8e2424e8485872194e768662", 65 | "shasum": "" 66 | }, 67 | "require": { 68 | "guzzlehttp/promises": "~1.0", 69 | "guzzlehttp/psr7": "~1.1", 70 | "php": ">=5.5.0" 71 | }, 72 | "require-dev": { 73 | "ext-curl": "*", 74 | "phpunit/phpunit": "~4.0", 75 | "psr/log": "~1.0" 76 | }, 77 | "type": "library", 78 | "extra": { 79 | "branch-alias": { 80 | "dev-master": "6.2-dev" 81 | } 82 | }, 83 | "autoload": { 84 | "files": [ 85 | "src/functions_include.php" 86 | ], 87 | "psr-4": { 88 | "GuzzleHttp\\": "src/" 89 | } 90 | }, 91 | "notification-url": "https://packagist.org/downloads/", 92 | "license": [ 93 | "MIT" 94 | ], 95 | "authors": [ 96 | { 97 | "name": "Michael Dowling", 98 | "email": "mtdowling@gmail.com", 99 | "homepage": "https://github.com/mtdowling" 100 | } 101 | ], 102 | "description": "Guzzle is a PHP HTTP client library", 103 | "homepage": "http://guzzlephp.org/", 104 | "keywords": [ 105 | "client", 106 | "curl", 107 | "framework", 108 | "http", 109 | "http client", 110 | "rest", 111 | "web service" 112 | ], 113 | "time": "2016-03-21T20:02:09+00:00" 114 | }, 115 | { 116 | "name": "guzzlehttp/promises", 117 | "version": "1.2.0", 118 | "source": { 119 | "type": "git", 120 | "url": "https://github.com/guzzle/promises.git", 121 | "reference": "c10d860e2a9595f8883527fa0021c7da9e65f579" 122 | }, 123 | "dist": { 124 | "type": "zip", 125 | "url": "https://api.github.com/repos/guzzle/promises/zipball/c10d860e2a9595f8883527fa0021c7da9e65f579", 126 | "reference": "c10d860e2a9595f8883527fa0021c7da9e65f579", 127 | "shasum": "" 128 | }, 129 | "require": { 130 | "php": ">=5.5.0" 131 | }, 132 | "require-dev": { 133 | "phpunit/phpunit": "~4.0" 134 | }, 135 | "type": "library", 136 | "extra": { 137 | "branch-alias": { 138 | "dev-master": "1.0-dev" 139 | } 140 | }, 141 | "autoload": { 142 | "psr-4": { 143 | "GuzzleHttp\\Promise\\": "src/" 144 | }, 145 | "files": [ 146 | "src/functions_include.php" 147 | ] 148 | }, 149 | "notification-url": "https://packagist.org/downloads/", 150 | "license": [ 151 | "MIT" 152 | ], 153 | "authors": [ 154 | { 155 | "name": "Michael Dowling", 156 | "email": "mtdowling@gmail.com", 157 | "homepage": "https://github.com/mtdowling" 158 | } 159 | ], 160 | "description": "Guzzle promises library", 161 | "keywords": [ 162 | "promise" 163 | ], 164 | "time": "2016-05-18T16:56:05+00:00" 165 | }, 166 | { 167 | "name": "guzzlehttp/psr7", 168 | "version": "1.3.1", 169 | "source": { 170 | "type": "git", 171 | "url": "https://github.com/guzzle/psr7.git", 172 | "reference": "5c6447c9df362e8f8093bda8f5d8873fe5c7f65b" 173 | }, 174 | "dist": { 175 | "type": "zip", 176 | "url": "https://api.github.com/repos/guzzle/psr7/zipball/5c6447c9df362e8f8093bda8f5d8873fe5c7f65b", 177 | "reference": "5c6447c9df362e8f8093bda8f5d8873fe5c7f65b", 178 | "shasum": "" 179 | }, 180 | "require": { 181 | "php": ">=5.4.0", 182 | "psr/http-message": "~1.0" 183 | }, 184 | "provide": { 185 | "psr/http-message-implementation": "1.0" 186 | }, 187 | "require-dev": { 188 | "phpunit/phpunit": "~4.0" 189 | }, 190 | "type": "library", 191 | "extra": { 192 | "branch-alias": { 193 | "dev-master": "1.4-dev" 194 | } 195 | }, 196 | "autoload": { 197 | "psr-4": { 198 | "GuzzleHttp\\Psr7\\": "src/" 199 | }, 200 | "files": [ 201 | "src/functions_include.php" 202 | ] 203 | }, 204 | "notification-url": "https://packagist.org/downloads/", 205 | "license": [ 206 | "MIT" 207 | ], 208 | "authors": [ 209 | { 210 | "name": "Michael Dowling", 211 | "email": "mtdowling@gmail.com", 212 | "homepage": "https://github.com/mtdowling" 213 | } 214 | ], 215 | "description": "PSR-7 message implementation", 216 | "keywords": [ 217 | "http", 218 | "message", 219 | "stream", 220 | "uri" 221 | ], 222 | "time": "2016-06-24T23:00:38+00:00" 223 | }, 224 | { 225 | "name": "j4mie/idiorm", 226 | "version": "v1.5.1", 227 | "source": { 228 | "type": "git", 229 | "url": "https://github.com/j4mie/idiorm.git", 230 | "reference": "b0922d8719a94e3a0e0e4a0ca3876f4f91475dcf" 231 | }, 232 | "dist": { 233 | "type": "zip", 234 | "url": "https://api.github.com/repos/j4mie/idiorm/zipball/b0922d8719a94e3a0e0e4a0ca3876f4f91475dcf", 235 | "reference": "b0922d8719a94e3a0e0e4a0ca3876f4f91475dcf", 236 | "shasum": "" 237 | }, 238 | "require": { 239 | "php": ">=5.2.0" 240 | }, 241 | "type": "library", 242 | "autoload": { 243 | "classmap": [ 244 | "idiorm.php" 245 | ] 246 | }, 247 | "notification-url": "https://packagist.org/downloads/", 248 | "license": [ 249 | "BSD-2-Clause", 250 | "BSD-3-Clause", 251 | "BSD-4-Clause" 252 | ], 253 | "authors": [ 254 | { 255 | "name": "Simon Holywell", 256 | "email": "treffynnon@php.net", 257 | "homepage": "http://simonholywell.com", 258 | "role": "Maintainer" 259 | }, 260 | { 261 | "name": "Jamie Matthews", 262 | "email": "jamie.matthews@gmail.com", 263 | "homepage": "http://j4mie.org", 264 | "role": "Developer" 265 | }, 266 | { 267 | "name": "Durham Hale", 268 | "email": "me@durhamhale.com", 269 | "homepage": "http://durhamhale.com", 270 | "role": "Maintainer" 271 | } 272 | ], 273 | "description": "A lightweight nearly-zero-configuration object-relational mapper and fluent query builder for PHP5", 274 | "homepage": "http://j4mie.github.com/idiormandparis", 275 | "keywords": [ 276 | "idiorm", 277 | "orm", 278 | "query builder" 279 | ], 280 | "time": "2014-06-23T13:08:57+00:00" 281 | }, 282 | { 283 | "name": "mf2/mf2", 284 | "version": "v0.3.0", 285 | "source": { 286 | "type": "git", 287 | "url": "https://github.com/indieweb/php-mf2.git", 288 | "reference": "4fb2eb5365cbc0fd2e0c26ca748777d6c2539763" 289 | }, 290 | "dist": { 291 | "type": "zip", 292 | "url": "https://api.github.com/repos/indieweb/php-mf2/zipball/4fb2eb5365cbc0fd2e0c26ca748777d6c2539763", 293 | "reference": "4fb2eb5365cbc0fd2e0c26ca748777d6c2539763", 294 | "shasum": "" 295 | }, 296 | "require": { 297 | "php": ">=5.4.0" 298 | }, 299 | "require-dev": { 300 | "phpunit/phpunit": "3.7.*" 301 | }, 302 | "suggest": { 303 | "barnabywalters/mf-cleaner": "To more easily handle the canonical data php-mf2 gives you" 304 | }, 305 | "bin": [ 306 | "bin/fetch-mf2", 307 | "bin/parse-mf2" 308 | ], 309 | "type": "library", 310 | "autoload": { 311 | "files": [ 312 | "Mf2/Parser.php" 313 | ] 314 | }, 315 | "notification-url": "https://packagist.org/downloads/", 316 | "license": [ 317 | "CC0" 318 | ], 319 | "authors": [ 320 | { 321 | "name": "Barnaby Walters", 322 | "homepage": "http://waterpigs.co.uk" 323 | } 324 | ], 325 | "description": "A pure, generic microformats2 parser — makes HTML as easy to consume as a JSON API", 326 | "keywords": [ 327 | "html", 328 | "microformats", 329 | "microformats 2", 330 | "parser", 331 | "semantic" 332 | ], 333 | "time": "2016-03-14T12:13:34+00:00" 334 | }, 335 | { 336 | "name": "p3k/quartz-db", 337 | "version": "0.1.3", 338 | "source": { 339 | "type": "git", 340 | "url": "https://github.com/aaronpk/QuartzDB.git", 341 | "reference": "e103e13f539fed255d841fa321560a8595351426" 342 | }, 343 | "dist": { 344 | "type": "zip", 345 | "url": "https://api.github.com/repos/aaronpk/QuartzDB/zipball/e103e13f539fed255d841fa321560a8595351426", 346 | "reference": "e103e13f539fed255d841fa321560a8595351426", 347 | "shasum": "" 348 | }, 349 | "type": "library", 350 | "autoload": { 351 | "psr-0": { 352 | "Quartz": "src/" 353 | } 354 | }, 355 | "notification-url": "https://packagist.org/downloads/", 356 | "license": [ 357 | "Apache 2.0" 358 | ], 359 | "authors": [ 360 | { 361 | "name": "Aaron Parecki", 362 | "homepage": "http://aaronparecki.com/" 363 | } 364 | ], 365 | "description": "A flat-file database optimized to hold time-series data.", 366 | "time": "2017-12-01T00:39:27+00:00" 367 | }, 368 | { 369 | "name": "predis/predis", 370 | "version": "v1.1.1", 371 | "source": { 372 | "type": "git", 373 | "url": "https://github.com/nrk/predis.git", 374 | "reference": "f0210e38881631afeafb56ab43405a92cafd9fd1" 375 | }, 376 | "dist": { 377 | "type": "zip", 378 | "url": "https://api.github.com/repos/nrk/predis/zipball/f0210e38881631afeafb56ab43405a92cafd9fd1", 379 | "reference": "f0210e38881631afeafb56ab43405a92cafd9fd1", 380 | "shasum": "" 381 | }, 382 | "require": { 383 | "php": ">=5.3.9" 384 | }, 385 | "require-dev": { 386 | "phpunit/phpunit": "~4.8" 387 | }, 388 | "suggest": { 389 | "ext-curl": "Allows access to Webdis when paired with phpiredis", 390 | "ext-phpiredis": "Allows faster serialization and deserialization of the Redis protocol" 391 | }, 392 | "type": "library", 393 | "autoload": { 394 | "psr-4": { 395 | "Predis\\": "src/" 396 | } 397 | }, 398 | "notification-url": "https://packagist.org/downloads/", 399 | "license": [ 400 | "MIT" 401 | ], 402 | "authors": [ 403 | { 404 | "name": "Daniele Alessandri", 405 | "email": "suppakilla@gmail.com", 406 | "homepage": "http://clorophilla.net" 407 | } 408 | ], 409 | "description": "Flexible and feature-complete Redis client for PHP and HHVM", 410 | "homepage": "http://github.com/nrk/predis", 411 | "keywords": [ 412 | "nosql", 413 | "predis", 414 | "redis" 415 | ], 416 | "time": "2016-06-16T16:22:20+00:00" 417 | }, 418 | { 419 | "name": "psr/http-message", 420 | "version": "1.0", 421 | "source": { 422 | "type": "git", 423 | "url": "https://github.com/php-fig/http-message.git", 424 | "reference": "85d63699f0dbedb190bbd4b0d2b9dc707ea4c298" 425 | }, 426 | "dist": { 427 | "type": "zip", 428 | "url": "https://api.github.com/repos/php-fig/http-message/zipball/85d63699f0dbedb190bbd4b0d2b9dc707ea4c298", 429 | "reference": "85d63699f0dbedb190bbd4b0d2b9dc707ea4c298", 430 | "shasum": "" 431 | }, 432 | "require": { 433 | "php": ">=5.3.0" 434 | }, 435 | "type": "library", 436 | "extra": { 437 | "branch-alias": { 438 | "dev-master": "1.0.x-dev" 439 | } 440 | }, 441 | "autoload": { 442 | "psr-4": { 443 | "Psr\\Http\\Message\\": "src/" 444 | } 445 | }, 446 | "notification-url": "https://packagist.org/downloads/", 447 | "license": [ 448 | "MIT" 449 | ], 450 | "authors": [ 451 | { 452 | "name": "PHP-FIG", 453 | "homepage": "http://www.php-fig.org/" 454 | } 455 | ], 456 | "description": "Common interface for HTTP messages", 457 | "keywords": [ 458 | "http", 459 | "http-message", 460 | "psr", 461 | "psr-7", 462 | "request", 463 | "response" 464 | ], 465 | "time": "2015-05-04T20:22:00+00:00" 466 | } 467 | ], 468 | "packages-dev": [], 469 | "aliases": [], 470 | "minimum-stability": "stable", 471 | "stability-flags": [], 472 | "prefer-stable": false, 473 | "prefer-lowest": false, 474 | "platform": [], 475 | "platform-dev": [] 476 | } 477 | -------------------------------------------------------------------------------- /public/assets/pushstream.js: -------------------------------------------------------------------------------- 1 | /*global PushStream WebSocketWrapper EventSourceWrapper EventSource*/ 2 | /*jshint evil: true, plusplus: false, regexp: false */ 3 | /** 4 | The MIT License (MIT) 5 | 6 | Copyright (c) 2010-2014 Wandenberg Peixoto , Rogério Carvalho Schneider 7 | 8 | This file is part of Nginx Push Stream Module. 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | pushstream.js 29 | 30 | Created: Nov 01, 2011 31 | Authors: Wandenberg Peixoto , Rogério Carvalho Schneider 32 | */ 33 | (function (window, document, undefined) { 34 | "use strict"; 35 | 36 | /* prevent duplicate declaration */ 37 | if (window.PushStream) { return; } 38 | 39 | var Utils = {}; 40 | 41 | var days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]; 42 | var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; 43 | 44 | var valueToTwoDigits = function (value) { 45 | return ((value < 10) ? '0' : '') + value; 46 | }; 47 | 48 | Utils.dateToUTCString = function (date) { 49 | var time = valueToTwoDigits(date.getUTCHours()) + ':' + valueToTwoDigits(date.getUTCMinutes()) + ':' + valueToTwoDigits(date.getUTCSeconds()); 50 | return days[date.getUTCDay()] + ', ' + valueToTwoDigits(date.getUTCDate()) + ' ' + months[date.getUTCMonth()] + ' ' + date.getUTCFullYear() + ' ' + time + ' GMT'; 51 | }; 52 | 53 | var extend = function () { 54 | var object = arguments[0] || {}; 55 | for (var i = 0; i < arguments.length; i++) { 56 | var settings = arguments[i]; 57 | for (var attr in settings) { 58 | if (!settings.hasOwnProperty || settings.hasOwnProperty(attr)) { 59 | object[attr] = settings[attr]; 60 | } 61 | } 62 | } 63 | return object; 64 | }; 65 | 66 | var validChars = /^[\],:{}\s]*$/, 67 | validEscape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, 68 | validTokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, 69 | validBraces = /(?:^|:|,)(?:\s*\[)+/g; 70 | 71 | var trim = function(value) { 72 | return value.replace(/^\s*/, "").replace(/\s*$/, ""); 73 | }; 74 | 75 | Utils.parseJSON = function(data) { 76 | if (!data || !isString(data)) { 77 | return null; 78 | } 79 | 80 | // Make sure leading/trailing whitespace is removed (IE can't handle it) 81 | data = trim(data); 82 | 83 | // Attempt to parse using the native JSON parser first 84 | if (window.JSON && window.JSON.parse) { 85 | try { 86 | return window.JSON.parse( data ); 87 | } catch(e) { 88 | throw "Invalid JSON: " + data; 89 | } 90 | } 91 | 92 | // Make sure the incoming data is actual JSON 93 | // Logic borrowed from http://json.org/json2.js 94 | if (validChars.test(data.replace(validEscape, "@").replace( validTokens, "]").replace( validBraces, "")) ) { 95 | return (new Function("return " + data))(); 96 | } 97 | 98 | throw "Invalid JSON: " + data; 99 | }; 100 | 101 | var getControlParams = function(pushstream) { 102 | var data = {}; 103 | data[pushstream.tagArgument] = ""; 104 | data[pushstream.timeArgument] = ""; 105 | data[pushstream.eventIdArgument] = ""; 106 | if (pushstream.messagesControlByArgument) { 107 | data[pushstream.tagArgument] = Number(pushstream._etag); 108 | if (pushstream._lastModified) { 109 | data[pushstream.timeArgument] = pushstream._lastModified; 110 | } else if (pushstream._lastEventId) { 111 | data[pushstream.eventIdArgument] = pushstream._lastEventId; 112 | } 113 | } 114 | return data; 115 | }; 116 | 117 | var getTime = function() { 118 | return (new Date()).getTime(); 119 | }; 120 | 121 | var currentTimestampParam = function() { 122 | return { "_" : getTime() }; 123 | }; 124 | 125 | var objectToUrlParams = function(settings) { 126 | var params = settings; 127 | if (typeof(settings) === 'object') { 128 | params = ''; 129 | for (var attr in settings) { 130 | if (!settings.hasOwnProperty || settings.hasOwnProperty(attr)) { 131 | params += '&' + attr + '=' + window.escape(settings[attr]); 132 | } 133 | } 134 | params = params.substring(1); 135 | } 136 | 137 | return params || ''; 138 | }; 139 | 140 | var addParamsToUrl = function(url, params) { 141 | return url + ((url.indexOf('?') < 0) ? '?' : '&') + objectToUrlParams(params); 142 | }; 143 | 144 | var isArray = Array.isArray || function(obj) { 145 | return Object.prototype.toString.call(obj) === '[object Array]'; 146 | }; 147 | 148 | var isString = function(obj) { 149 | return Object.prototype.toString.call(obj) === '[object String]'; 150 | }; 151 | 152 | var isDate = function(obj) { 153 | return Object.prototype.toString.call(obj) === '[object Date]'; 154 | }; 155 | 156 | var Log4js = { 157 | logger: null, 158 | debug : function() { if (PushStream.LOG_LEVEL === 'debug') { Log4js._log.apply(Log4js._log, arguments); }}, 159 | info : function() { if ((PushStream.LOG_LEVEL === 'info') || (PushStream.LOG_LEVEL === 'debug')) { Log4js._log.apply(Log4js._log, arguments); }}, 160 | error : function() { Log4js._log.apply(Log4js._log, arguments); }, 161 | _initLogger : function() { 162 | var console = window.console; 163 | if (console && console.log) { 164 | if (console.log.apply) { 165 | Log4js.logger = console.log; 166 | } else if ((typeof console.log === "object") && Function.prototype.bind) { 167 | Log4js.logger = Function.prototype.bind.call(console.log, console); 168 | } else if ((typeof console.log === "object") && Function.prototype.call) { 169 | Log4js.logger = function() { 170 | Function.prototype.call.call(console.log, console, Array.prototype.slice.call(arguments)); 171 | }; 172 | } 173 | } 174 | }, 175 | _log : function() { 176 | if (!Log4js.logger) { 177 | Log4js._initLogger(); 178 | } 179 | 180 | if (Log4js.logger) { 181 | try { 182 | Log4js.logger.apply(window.console, arguments); 183 | } catch(e) { 184 | Log4js._initLogger(); 185 | if (Log4js.logger) { 186 | Log4js.logger.apply(window.console, arguments); 187 | } 188 | } 189 | } 190 | 191 | var logElement = document.getElementById(PushStream.LOG_OUTPUT_ELEMENT_ID); 192 | if (logElement) { 193 | var str = ''; 194 | for (var i = 0; i < arguments.length; i++) { 195 | str += arguments[i] + " "; 196 | } 197 | logElement.innerHTML += str + '\n'; 198 | 199 | var lines = logElement.innerHTML.split('\n'); 200 | if (lines.length > 100) { 201 | logElement.innerHTML = lines.slice(-100).join('\n'); 202 | } 203 | } 204 | } 205 | }; 206 | 207 | var Ajax = { 208 | _getXHRObject : function(crossDomain) { 209 | var xhr = false; 210 | if (crossDomain) { 211 | try { xhr = new window.XDomainRequest(); } catch (e) { } 212 | if (xhr) { 213 | return xhr; 214 | } 215 | } 216 | 217 | try { xhr = new window.XMLHttpRequest(); } 218 | catch (e1) { 219 | try { xhr = new window.ActiveXObject("Msxml2.XMLHTTP"); } 220 | catch (e2) { 221 | try { xhr = new window.ActiveXObject("Microsoft.XMLHTTP"); } 222 | catch (e3) { 223 | xhr = false; 224 | } 225 | } 226 | } 227 | return xhr; 228 | }, 229 | 230 | _send : function(settings, post) { 231 | settings = settings || {}; 232 | settings.timeout = settings.timeout || 30000; 233 | var xhr = Ajax._getXHRObject(settings.crossDomain); 234 | if (!xhr||!settings.url) { return; } 235 | 236 | Ajax.clear(settings); 237 | 238 | settings.xhr = xhr; 239 | 240 | if (window.XDomainRequest && (xhr instanceof window.XDomainRequest)) { 241 | xhr.onload = function () { 242 | if (settings.afterReceive) { settings.afterReceive(xhr); } 243 | if (settings.success) { settings.success(xhr.responseText); } 244 | }; 245 | 246 | xhr.onerror = xhr.ontimeout = function () { 247 | if (settings.afterReceive) { settings.afterReceive(xhr); } 248 | if (settings.error) { settings.error(xhr.status); } 249 | }; 250 | } else { 251 | xhr.onreadystatechange = function () { 252 | if (xhr.readyState === 4) { 253 | Ajax.clear(settings); 254 | if (settings.afterReceive) { settings.afterReceive(xhr); } 255 | if(xhr.status === 200) { 256 | if (settings.success) { settings.success(xhr.responseText); } 257 | } else { 258 | if (settings.error) { settings.error(xhr.status); } 259 | } 260 | } 261 | }; 262 | } 263 | 264 | if (settings.beforeOpen) { settings.beforeOpen(xhr); } 265 | 266 | var params = {}; 267 | var body = null; 268 | var method = "GET"; 269 | if (post) { 270 | body = objectToUrlParams(settings.data); 271 | method = "POST"; 272 | } else { 273 | params = settings.data || {}; 274 | } 275 | 276 | xhr.open(method, addParamsToUrl(settings.url, extend({}, params, currentTimestampParam())), true); 277 | 278 | if (settings.beforeSend) { settings.beforeSend(xhr); } 279 | 280 | var onerror = function() { 281 | Ajax.clear(settings); 282 | try { xhr.abort(); } catch (e) { /* ignore error on closing */ } 283 | settings.error(304); 284 | }; 285 | 286 | if (post) { 287 | if (xhr.setRequestHeader) { 288 | xhr.setRequestHeader("Accept", "application/json"); 289 | xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 290 | } 291 | } else { 292 | settings.timeoutId = window.setTimeout(onerror, settings.timeout + 2000); 293 | } 294 | 295 | xhr.send(body); 296 | return xhr; 297 | }, 298 | 299 | _clear_xhr : function(xhr) { 300 | if (xhr) { 301 | xhr.onreadystatechange = null; 302 | } 303 | }, 304 | 305 | _clear_script : function(script) { 306 | // Handling memory leak in IE, removing and dereference the script 307 | if (script) { 308 | script.onerror = script.onload = script.onreadystatechange = null; 309 | if (script.parentNode) { script.parentNode.removeChild(script); } 310 | } 311 | }, 312 | 313 | _clear_timeout : function(settings) { 314 | settings.timeoutId = clearTimer(settings.timeoutId); 315 | }, 316 | 317 | _clear_jsonp : function(settings) { 318 | var callbackFunctionName = settings.data.callback; 319 | if (callbackFunctionName) { 320 | window[callbackFunctionName] = function() { window[callbackFunctionName] = null; }; 321 | } 322 | }, 323 | 324 | clear : function(settings) { 325 | Ajax._clear_timeout(settings); 326 | Ajax._clear_jsonp(settings); 327 | Ajax._clear_script(document.getElementById(settings.scriptId)); 328 | Ajax._clear_xhr(settings.xhr); 329 | }, 330 | 331 | jsonp : function(settings) { 332 | settings.timeout = settings.timeout || 30000; 333 | Ajax.clear(settings); 334 | 335 | var head = document.head || document.getElementsByTagName("head")[0]; 336 | var script = document.createElement("script"); 337 | var startTime = getTime(); 338 | 339 | var onerror = function() { 340 | Ajax.clear(settings); 341 | var endTime = getTime(); 342 | settings.error(((endTime - startTime) > settings.timeout/2) ? 304 : 403); 343 | }; 344 | 345 | var onload = function() { 346 | Ajax.clear(settings); 347 | settings.load(); 348 | }; 349 | 350 | var onsuccess = function() { 351 | settings.afterSuccess = true; 352 | settings.success.apply(null, arguments); 353 | }; 354 | 355 | script.onerror = onerror; 356 | script.onload = script.onreadystatechange = function(eventLoad) { 357 | if (!script.readyState || /loaded|complete/.test(script.readyState)) { 358 | if (settings.afterSuccess) { 359 | onload(); 360 | } else { 361 | onerror(); 362 | } 363 | } 364 | }; 365 | 366 | if (settings.beforeOpen) { settings.beforeOpen({}); } 367 | if (settings.beforeSend) { settings.beforeSend({}); } 368 | 369 | settings.timeoutId = window.setTimeout(onerror, settings.timeout + 2000); 370 | settings.scriptId = settings.scriptId || getTime(); 371 | settings.afterSuccess = null; 372 | 373 | settings.data.callback = settings.scriptId + "_onmessage_" + getTime(); 374 | window[settings.data.callback] = onsuccess; 375 | 376 | script.setAttribute("src", addParamsToUrl(settings.url, extend({}, settings.data, currentTimestampParam()))); 377 | script.setAttribute("async", "async"); 378 | script.setAttribute("id", settings.scriptId); 379 | 380 | // Use insertBefore instead of appendChild to circumvent an IE6 bug. 381 | head.insertBefore(script, head.firstChild); 382 | return settings; 383 | }, 384 | 385 | load : function(settings) { 386 | return Ajax._send(settings, false); 387 | }, 388 | 389 | post : function(settings) { 390 | return Ajax._send(settings, true); 391 | } 392 | }; 393 | 394 | var escapeText = function(text) { 395 | return (text) ? window.escape(text) : ''; 396 | }; 397 | 398 | var unescapeText = function(text) { 399 | return (text) ? window.unescape(text) : ''; 400 | }; 401 | 402 | Utils.parseMessage = function(messageText, keys) { 403 | var msg = messageText; 404 | if (isString(messageText)) { 405 | msg = Utils.parseJSON(messageText); 406 | } 407 | 408 | var message = { 409 | id : msg[keys.jsonIdKey], 410 | channel: msg[keys.jsonChannelKey], 411 | text : isString(msg[keys.jsonTextKey]) ? unescapeText(msg[keys.jsonTextKey]) : msg[keys.jsonTextKey], 412 | tag : msg[keys.jsonTagKey], 413 | time : msg[keys.jsonTimeKey], 414 | eventid: msg[keys.jsonEventIdKey] || "" 415 | }; 416 | 417 | return message; 418 | }; 419 | 420 | var getBacktrack = function(options) { 421 | return (options.backtrack) ? ".b" + Number(options.backtrack) : ""; 422 | }; 423 | 424 | var getChannelsPath = function(channels, withBacktrack) { 425 | var path = ''; 426 | for (var channelName in channels) { 427 | if (!channels.hasOwnProperty || channels.hasOwnProperty(channelName)) { 428 | path += "/" + channelName + (withBacktrack ? getBacktrack(channels[channelName]) : ""); 429 | } 430 | } 431 | return path; 432 | }; 433 | 434 | var getSubscriberUrl = function(pushstream, prefix, extraParams, withBacktrack) { 435 | var websocket = pushstream.wrapper.type === WebSocketWrapper.TYPE; 436 | var useSSL = pushstream.useSSL; 437 | var port = normalizePort(useSSL, pushstream.port); 438 | var url = (websocket) ? ((useSSL) ? "wss://" : "ws://") : ((useSSL) ? "https://" : "http://"); 439 | url += pushstream.host; 440 | url += (port ? (":" + port) : ""); 441 | url += prefix; 442 | 443 | var channels = getChannelsPath(pushstream.channels, withBacktrack); 444 | if (pushstream.channelsByArgument) { 445 | var channelParam = {}; 446 | channelParam[pushstream.channelsArgument] = channels.substring(1); 447 | extraParams = extend({}, extraParams, channelParam); 448 | } else { 449 | url += channels; 450 | } 451 | return addParamsToUrl(url, extraParams); 452 | }; 453 | 454 | var getPublisherUrl = function(pushstream) { 455 | var port = normalizePort(pushstream.useSSL, pushstream.port); 456 | var url = (pushstream.useSSL) ? "https://" : "http://"; 457 | url += pushstream.host; 458 | url += (port ? (":" + port) : ""); 459 | url += pushstream.urlPrefixPublisher; 460 | url += "?id=" + getChannelsPath(pushstream.channels, false); 461 | 462 | return url; 463 | }; 464 | 465 | Utils.extract_xss_domain = function(domain) { 466 | // if domain is an ip address return it, else return ate least the last two parts of it 467 | if (domain.match(/^(\d{1,3}\.){3}\d{1,3}$/)) { 468 | return domain; 469 | } 470 | 471 | var domainParts = domain.split('.'); 472 | // if the domain ends with 3 chars or 2 chars preceded by more than 4 chars, 473 | // we can keep only 2 parts, else we have to keep at least 3 (or all domain name) 474 | var keepNumber = Math.max(domainParts.length - 1, (domain.match(/(\w{4,}\.\w{2}|\.\w{3,})$/) ? 2 : 3)); 475 | 476 | return domainParts.slice(-1 * keepNumber).join('.'); 477 | }; 478 | 479 | var normalizePort = function (useSSL, port) { 480 | port = Number(port || (useSSL ? 443 : 80)); 481 | return ((!useSSL && port === 80) || (useSSL && port === 443)) ? "" : port; 482 | }; 483 | 484 | Utils.isCrossDomainUrl = function(url) { 485 | if (!url) { 486 | return false; 487 | } 488 | 489 | var parser = document.createElement('a'); 490 | parser.href = url; 491 | 492 | var srcPort = normalizePort(window.location.protocol === "https:", window.location.port); 493 | var dstPort = normalizePort(parser.protocol === "https:", parser.port); 494 | 495 | return (window.location.protocol !== parser.protocol) || 496 | (window.location.hostname !== parser.hostname) || 497 | (srcPort !== dstPort); 498 | }; 499 | 500 | var linker = function(method, instance) { 501 | return function() { 502 | return method.apply(instance, arguments); 503 | }; 504 | }; 505 | 506 | var clearTimer = function(timer) { 507 | if (timer) { 508 | window.clearTimeout(timer); 509 | } 510 | return null; 511 | }; 512 | 513 | /* common callbacks */ 514 | var onmessageCallback = function(event) { 515 | Log4js.info("[" + this.type + "] message received", arguments); 516 | var message = Utils.parseMessage(event.data, this.pushstream); 517 | if (message.tag) { this.pushstream._etag = message.tag; } 518 | if (message.time) { this.pushstream._lastModified = message.time; } 519 | if (message.eventid) { this.pushstream._lastEventId = message.eventid; } 520 | this.pushstream._onmessage(message.text, message.id, message.channel, message.eventid, true); 521 | }; 522 | 523 | var onopenCallback = function() { 524 | this.pushstream._onopen(); 525 | Log4js.info("[" + this.type + "] connection opened"); 526 | }; 527 | 528 | var onerrorCallback = function(event) { 529 | Log4js.info("[" + this.type + "] error (disconnected by server):", event); 530 | if ((this.pushstream.readyState === PushStream.OPEN) && 531 | (this.type === EventSourceWrapper.TYPE) && 532 | (event.type === 'error') && 533 | (this.connection.readyState === window.EventSource.CONNECTING)) { 534 | // EventSource already has a reconnection function using the last-event-id header 535 | return; 536 | } 537 | this._closeCurrentConnection(); 538 | this.pushstream._onerror({type: ((event && ((event.type === "load") || (event.type === "close"))) || (this.pushstream.readyState === PushStream.CONNECTING)) ? "load" : "timeout"}); 539 | }; 540 | 541 | /* wrappers */ 542 | 543 | var WebSocketWrapper = function(pushstream) { 544 | if (!window.WebSocket && !window.MozWebSocket) { throw "WebSocket not supported"; } 545 | this.type = WebSocketWrapper.TYPE; 546 | this.pushstream = pushstream; 547 | this.connection = null; 548 | }; 549 | 550 | WebSocketWrapper.TYPE = "WebSocket"; 551 | 552 | WebSocketWrapper.prototype = { 553 | connect: function() { 554 | this._closeCurrentConnection(); 555 | var params = extend({}, this.pushstream.extraParams(), currentTimestampParam(), getControlParams(this.pushstream)); 556 | var url = getSubscriberUrl(this.pushstream, this.pushstream.urlPrefixWebsocket, params, !this.pushstream._useControlArguments()); 557 | this.connection = (window.WebSocket) ? new window.WebSocket(url) : new window.MozWebSocket(url); 558 | this.connection.onerror = linker(onerrorCallback, this); 559 | this.connection.onclose = linker(onerrorCallback, this); 560 | this.connection.onopen = linker(onopenCallback, this); 561 | this.connection.onmessage = linker(onmessageCallback, this); 562 | Log4js.info("[WebSocket] connecting to:", url); 563 | }, 564 | 565 | disconnect: function() { 566 | if (this.connection) { 567 | Log4js.debug("[WebSocket] closing connection to:", this.connection.url); 568 | this.connection.onclose = null; 569 | this._closeCurrentConnection(); 570 | this.pushstream._onclose(); 571 | } 572 | }, 573 | 574 | _closeCurrentConnection: function() { 575 | if (this.connection) { 576 | try { this.connection.close(); } catch (e) { /* ignore error on closing */ } 577 | this.connection = null; 578 | } 579 | }, 580 | 581 | sendMessage: function(message) { 582 | if (this.connection) { this.connection.send(message); } 583 | } 584 | }; 585 | 586 | var EventSourceWrapper = function(pushstream) { 587 | if (!window.EventSource) { throw "EventSource not supported"; } 588 | this.type = EventSourceWrapper.TYPE; 589 | this.pushstream = pushstream; 590 | this.connection = null; 591 | }; 592 | 593 | EventSourceWrapper.TYPE = "EventSource"; 594 | 595 | EventSourceWrapper.prototype = { 596 | connect: function() { 597 | this._closeCurrentConnection(); 598 | var params = extend({}, this.pushstream.extraParams(), currentTimestampParam(), getControlParams(this.pushstream)); 599 | var url = getSubscriberUrl(this.pushstream, this.pushstream.urlPrefixEventsource, params, !this.pushstream._useControlArguments()); 600 | this.connection = new window.EventSource(url); 601 | this.connection.onerror = linker(onerrorCallback, this); 602 | this.connection.onopen = linker(onopenCallback, this); 603 | this.connection.onmessage = linker(onmessageCallback, this); 604 | Log4js.info("[EventSource] connecting to:", url); 605 | }, 606 | 607 | disconnect: function() { 608 | if (this.connection) { 609 | Log4js.debug("[EventSource] closing connection to:", this.connection.url); 610 | this.connection.onclose = null; 611 | this._closeCurrentConnection(); 612 | this.pushstream._onclose(); 613 | } 614 | }, 615 | 616 | _closeCurrentConnection: function() { 617 | if (this.connection) { 618 | try { this.connection.close(); } catch (e) { /* ignore error on closing */ } 619 | this.connection = null; 620 | } 621 | } 622 | }; 623 | 624 | var StreamWrapper = function(pushstream) { 625 | this.type = StreamWrapper.TYPE; 626 | this.pushstream = pushstream; 627 | this.connection = null; 628 | this.url = null; 629 | this.frameloadtimer = null; 630 | this.pingtimer = null; 631 | this.iframeId = "PushStreamManager_" + pushstream.id; 632 | }; 633 | 634 | StreamWrapper.TYPE = "Stream"; 635 | 636 | StreamWrapper.prototype = { 637 | connect: function() { 638 | this._closeCurrentConnection(); 639 | var domain = Utils.extract_xss_domain(this.pushstream.host); 640 | try { 641 | document.domain = domain; 642 | } catch(e) { 643 | Log4js.error("[Stream] (warning) problem setting document.domain = " + domain + " (OBS: IE8 does not support set IP numbers as domain)"); 644 | } 645 | var params = extend({}, this.pushstream.extraParams(), currentTimestampParam(), {"streamid": this.pushstream.id}, getControlParams(this.pushstream)); 646 | this.url = getSubscriberUrl(this.pushstream, this.pushstream.urlPrefixStream, params, !this.pushstream._useControlArguments()); 647 | Log4js.debug("[Stream] connecting to:", this.url); 648 | this.loadFrame(this.url); 649 | }, 650 | 651 | disconnect: function() { 652 | if (this.connection) { 653 | Log4js.debug("[Stream] closing connection to:", this.url); 654 | this._closeCurrentConnection(); 655 | this.pushstream._onclose(); 656 | } 657 | }, 658 | 659 | _clear_iframe: function() { 660 | var oldIframe = document.getElementById(this.iframeId); 661 | if (oldIframe) { 662 | oldIframe.onload = null; 663 | oldIframe.src = "about:blank"; 664 | if (oldIframe.parentNode) { oldIframe.parentNode.removeChild(oldIframe); } 665 | } 666 | }, 667 | 668 | _closeCurrentConnection: function() { 669 | this._clear_iframe(); 670 | if (this.connection) { 671 | this.pingtimer = clearTimer(this.pingtimer); 672 | this.frameloadtimer = clearTimer(this.frameloadtimer); 673 | this.connection = null; 674 | this.transferDoc = null; 675 | if (typeof window.CollectGarbage === 'function') { window.CollectGarbage(); } 676 | } 677 | }, 678 | 679 | loadFrame: function(url) { 680 | this._clear_iframe(); 681 | 682 | var ifr = null; 683 | if ("ActiveXObject" in window) { 684 | var transferDoc = new window.ActiveXObject("htmlfile"); 685 | transferDoc.open(); 686 | transferDoc.write(""); 687 | transferDoc.parentWindow.PushStream = PushStream; 688 | transferDoc.close(); 689 | ifr = transferDoc.getElementById(this.iframeId); 690 | this.transferDoc = transferDoc; 691 | } else { 692 | ifr = document.createElement("IFRAME"); 693 | ifr.style.width = "1px"; 694 | ifr.style.height = "1px"; 695 | ifr.style.border = "none"; 696 | ifr.style.position = "absolute"; 697 | ifr.style.top = "-10px"; 698 | ifr.style.marginTop = "-10px"; 699 | ifr.style.zIndex = "-20"; 700 | ifr.PushStream = PushStream; 701 | document.body.appendChild(ifr); 702 | ifr.setAttribute("src", url); 703 | ifr.setAttribute("id", this.iframeId); 704 | } 705 | 706 | ifr.onload = linker(onerrorCallback, this); 707 | this.connection = ifr; 708 | this.frameloadtimer = window.setTimeout(linker(onerrorCallback, this), this.pushstream.timeout); 709 | }, 710 | 711 | register: function(iframeWindow) { 712 | this.frameloadtimer = clearTimer(this.frameloadtimer); 713 | iframeWindow.p = linker(this.process, this); 714 | this.connection.onload = linker(this._onframeloaded, this); 715 | this.pushstream._onopen(); 716 | this.setPingTimer(); 717 | Log4js.info("[Stream] frame registered"); 718 | }, 719 | 720 | process: function(id, channel, text, eventid, time, tag) { 721 | this.pingtimer = clearTimer(this.pingtimer); 722 | Log4js.info("[Stream] message received", arguments); 723 | if (id !== -1) { 724 | if (tag) { this.pushstream._etag = tag; } 725 | if (time) { this.pushstream._lastModified = time; } 726 | if (eventid) { this.pushstream._lastEventId = eventid; } 727 | } 728 | this.pushstream._onmessage(unescapeText(text), id, channel, eventid || "", true); 729 | this.setPingTimer(); 730 | }, 731 | 732 | _onframeloaded: function() { 733 | Log4js.info("[Stream] frame loaded (disconnected by server)"); 734 | this.connection.onload = null; 735 | this.disconnect(); 736 | }, 737 | 738 | setPingTimer: function() { 739 | if (this.pingtimer) { clearTimer(this.pingtimer); } 740 | this.pingtimer = window.setTimeout(linker(onerrorCallback, this), this.pushstream.pingtimeout); 741 | } 742 | }; 743 | 744 | var LongPollingWrapper = function(pushstream) { 745 | this.type = LongPollingWrapper.TYPE; 746 | this.pushstream = pushstream; 747 | this.connection = null; 748 | this.opentimer = null; 749 | this.messagesQueue = []; 750 | this._linkedInternalListen = linker(this._internalListen, this); 751 | this.xhrSettings = { 752 | timeout: this.pushstream.timeout, 753 | data: {}, 754 | url: null, 755 | success: linker(this.onmessage, this), 756 | error: linker(this.onerror, this), 757 | load: linker(this.onload, this), 758 | beforeSend: linker(this.beforeSend, this), 759 | afterReceive: linker(this.afterReceive, this) 760 | }; 761 | }; 762 | 763 | LongPollingWrapper.TYPE = "LongPolling"; 764 | 765 | LongPollingWrapper.prototype = { 766 | connect: function() { 767 | this.messagesQueue = []; 768 | this._closeCurrentConnection(); 769 | this.urlWithBacktrack = getSubscriberUrl(this.pushstream, this.pushstream.urlPrefixLongpolling, {}, true); 770 | this.urlWithoutBacktrack = getSubscriberUrl(this.pushstream, this.pushstream.urlPrefixLongpolling, {}, false); 771 | this.xhrSettings.url = this.urlWithBacktrack; 772 | this.useJSONP = this.pushstream._crossDomain || this.pushstream.useJSONP; 773 | this.xhrSettings.scriptId = "PushStreamManager_" + this.pushstream.id; 774 | if (this.useJSONP) { 775 | this.pushstream.messagesControlByArgument = true; 776 | } 777 | this._listen(); 778 | this.opentimer = window.setTimeout(linker(onopenCallback, this), 150); 779 | Log4js.info("[LongPolling] connecting to:", this.xhrSettings.url); 780 | }, 781 | 782 | _listen: function() { 783 | if (this._internalListenTimeout) { clearTimer(this._internalListenTimeout); } 784 | this._internalListenTimeout = window.setTimeout(this._linkedInternalListen, 100); 785 | }, 786 | 787 | _internalListen: function() { 788 | if (this.pushstream._keepConnected) { 789 | this.xhrSettings.url = this.pushstream._useControlArguments() ? this.urlWithoutBacktrack : this.urlWithBacktrack; 790 | this.xhrSettings.data = extend({}, this.pushstream.extraParams(), this.xhrSettings.data, getControlParams(this.pushstream)); 791 | if (this.useJSONP) { 792 | this.connection = Ajax.jsonp(this.xhrSettings); 793 | } else if (!this.connection) { 794 | this.connection = Ajax.load(this.xhrSettings); 795 | } 796 | } 797 | }, 798 | 799 | disconnect: function() { 800 | if (this.connection) { 801 | Log4js.debug("[LongPolling] closing connection to:", this.xhrSettings.url); 802 | this._closeCurrentConnection(); 803 | this.pushstream._onclose(); 804 | } 805 | }, 806 | 807 | _closeCurrentConnection: function() { 808 | this.opentimer = clearTimer(this.opentimer); 809 | if (this.connection) { 810 | try { this.connection.abort(); } catch (e) { 811 | try { Ajax.clear(this.connection); } catch (e1) { /* ignore error on closing */ } 812 | } 813 | this.connection = null; 814 | this.xhrSettings.url = null; 815 | } 816 | }, 817 | 818 | beforeSend: function(xhr) { 819 | if (!this.pushstream.messagesControlByArgument) { 820 | xhr.setRequestHeader("If-None-Match", this.pushstream._etag); 821 | xhr.setRequestHeader("If-Modified-Since", this.pushstream._lastModified); 822 | } 823 | }, 824 | 825 | afterReceive: function(xhr) { 826 | if (!this.pushstream.messagesControlByArgument) { 827 | this.pushstream._etag = xhr.getResponseHeader('Etag'); 828 | this.pushstream._lastModified = xhr.getResponseHeader('Last-Modified'); 829 | } 830 | this.connection = null; 831 | }, 832 | 833 | onerror: function(status) { 834 | this._closeCurrentConnection(); 835 | if (this.pushstream._keepConnected) { /* abort(), called by disconnect(), call this callback, but should be ignored */ 836 | if (status === 304) { 837 | this._listen(); 838 | } else { 839 | Log4js.info("[LongPolling] error (disconnected by server):", status); 840 | this.pushstream._onerror({type: ((status === 403) || (this.pushstream.readyState === PushStream.CONNECTING)) ? "load" : "timeout"}); 841 | } 842 | } 843 | }, 844 | 845 | onload: function() { 846 | this._listen(); 847 | }, 848 | 849 | onmessage: function(responseText) { 850 | if (this._internalListenTimeout) { clearTimer(this._internalListenTimeout); } 851 | Log4js.info("[LongPolling] message received", responseText); 852 | var lastMessage = null; 853 | var messages = isArray(responseText) ? responseText : responseText.replace(/\}\{/g, "}\r\n{").split("\r\n"); 854 | for (var i = 0; i < messages.length; i++) { 855 | if (messages[i]) { 856 | lastMessage = Utils.parseMessage(messages[i], this.pushstream); 857 | this.messagesQueue.push(lastMessage); 858 | if (this.pushstream.messagesControlByArgument && lastMessage.time) { 859 | this.pushstream._etag = lastMessage.tag; 860 | this.pushstream._lastModified = lastMessage.time; 861 | } 862 | } 863 | } 864 | 865 | this._listen(); 866 | 867 | while (this.messagesQueue.length > 0) { 868 | var message = this.messagesQueue.shift(); 869 | this.pushstream._onmessage(message.text, message.id, message.channel, message.eventid, (this.messagesQueue.length === 0)); 870 | } 871 | } 872 | }; 873 | 874 | /* mains class */ 875 | 876 | var PushStreamManager = []; 877 | 878 | var PushStream = function(settings) { 879 | settings = settings || {}; 880 | 881 | this.id = PushStreamManager.push(this) - 1; 882 | 883 | this.useSSL = settings.useSSL || false; 884 | this.host = settings.host || window.location.hostname; 885 | this.port = Number(settings.port || (this.useSSL ? 443 : 80)); 886 | 887 | this.timeout = settings.timeout || 30000; 888 | this.pingtimeout = settings.pingtimeout || 30000; 889 | this.reconnectOnTimeoutInterval = settings.reconnectOnTimeoutInterval || 3000; 890 | this.reconnectOnChannelUnavailableInterval = settings.reconnectOnChannelUnavailableInterval || 60000; 891 | 892 | this.lastEventId = settings.lastEventId || null; 893 | this.messagesPublishedAfter = settings.messagesPublishedAfter; 894 | this.messagesControlByArgument = settings.messagesControlByArgument || false; 895 | this.tagArgument = settings.tagArgument || 'tag'; 896 | this.timeArgument = settings.timeArgument || 'time'; 897 | this.eventIdArgument = settings.eventIdArgument || 'eventid'; 898 | this.useJSONP = settings.useJSONP || false; 899 | 900 | this._reconnecttimer = null; 901 | this._etag = 0; 902 | this._lastModified = null; 903 | this._lastEventId = null; 904 | 905 | this.urlPrefixPublisher = settings.urlPrefixPublisher || '/pub'; 906 | this.urlPrefixStream = settings.urlPrefixStream || '/sub'; 907 | this.urlPrefixEventsource = settings.urlPrefixEventsource || '/ev'; 908 | this.urlPrefixLongpolling = settings.urlPrefixLongpolling || '/lp'; 909 | this.urlPrefixWebsocket = settings.urlPrefixWebsocket || '/ws'; 910 | 911 | this.jsonIdKey = settings.jsonIdKey || 'id'; 912 | this.jsonChannelKey = settings.jsonChannelKey || 'channel'; 913 | this.jsonTextKey = settings.jsonTextKey || 'text'; 914 | this.jsonTagKey = settings.jsonTagKey || 'tag'; 915 | this.jsonTimeKey = settings.jsonTimeKey || 'time'; 916 | this.jsonEventIdKey = settings.jsonEventIdKey || 'eventid'; 917 | 918 | this.modes = (settings.modes || 'eventsource|websocket|stream|longpolling').split('|'); 919 | this.wrappers = []; 920 | this.wrapper = null; 921 | 922 | this.onchanneldeleted = settings.onchanneldeleted || null; 923 | this.onmessage = settings.onmessage || null; 924 | this.onerror = settings.onerror || null; 925 | this.onstatuschange = settings.onstatuschange || null; 926 | this.extraParams = settings.extraParams || function() { return {}; }; 927 | 928 | this.channels = {}; 929 | this.channelsCount = 0; 930 | this.channelsByArgument = settings.channelsByArgument || false; 931 | this.channelsArgument = settings.channelsArgument || 'channels'; 932 | 933 | this._crossDomain = Utils.isCrossDomainUrl(getPublisherUrl(this)); 934 | 935 | for (var i = 0; i < this.modes.length; i++) { 936 | try { 937 | var wrapper = null; 938 | switch (this.modes[i]) { 939 | case "websocket" : wrapper = new WebSocketWrapper(this); break; 940 | case "eventsource": wrapper = new EventSourceWrapper(this); break; 941 | case "longpolling": wrapper = new LongPollingWrapper(this); break; 942 | case "stream" : wrapper = new StreamWrapper(this); break; 943 | } 944 | this.wrappers[this.wrappers.length] = wrapper; 945 | } catch(e) { Log4js.info(e); } 946 | } 947 | 948 | this.readyState = 0; 949 | }; 950 | 951 | /* constants */ 952 | PushStream.LOG_LEVEL = 'error'; /* debug, info, error */ 953 | PushStream.LOG_OUTPUT_ELEMENT_ID = 'Log4jsLogOutput'; 954 | 955 | /* status codes */ 956 | PushStream.CLOSED = 0; 957 | PushStream.CONNECTING = 1; 958 | PushStream.OPEN = 2; 959 | 960 | /* main code */ 961 | PushStream.prototype = { 962 | addChannel: function(channel, options) { 963 | if (escapeText(channel) !== channel) { 964 | throw "Invalid channel name! Channel has to be a set of [a-zA-Z0-9]"; 965 | } 966 | Log4js.debug("entering addChannel"); 967 | if (typeof(this.channels[channel]) !== "undefined") { throw "Cannot add channel " + channel + ": already subscribed"; } 968 | options = options || {}; 969 | Log4js.info("adding channel", channel, options); 970 | this.channels[channel] = options; 971 | this.channelsCount++; 972 | if (this.readyState !== PushStream.CLOSED) { this.connect(); } 973 | Log4js.debug("leaving addChannel"); 974 | }, 975 | 976 | removeChannel: function(channel) { 977 | if (this.channels[channel]) { 978 | Log4js.info("removing channel", channel); 979 | delete this.channels[channel]; 980 | this.channelsCount--; 981 | } 982 | }, 983 | 984 | removeAllChannels: function() { 985 | Log4js.info("removing all channels"); 986 | this.channels = {}; 987 | this.channelsCount = 0; 988 | }, 989 | 990 | _setState: function(state) { 991 | if (this.readyState !== state) { 992 | Log4js.info("status changed", state); 993 | this.readyState = state; 994 | if (this.onstatuschange) { 995 | this.onstatuschange(this.readyState); 996 | } 997 | } 998 | }, 999 | 1000 | connect: function() { 1001 | Log4js.debug("entering connect"); 1002 | if (!this.host) { throw "PushStream host not specified"; } 1003 | if (isNaN(this.port)) { throw "PushStream port not specified"; } 1004 | if (!this.channelsCount) { throw "No channels specified"; } 1005 | if (this.wrappers.length === 0) { throw "No available support for this browser"; } 1006 | 1007 | this._keepConnected = true; 1008 | this._lastUsedMode = 0; 1009 | this._connect(); 1010 | 1011 | Log4js.debug("leaving connect"); 1012 | }, 1013 | 1014 | disconnect: function() { 1015 | Log4js.debug("entering disconnect"); 1016 | this._keepConnected = false; 1017 | this._disconnect(); 1018 | this._setState(PushStream.CLOSED); 1019 | Log4js.info("disconnected"); 1020 | Log4js.debug("leaving disconnect"); 1021 | }, 1022 | 1023 | _useControlArguments :function() { 1024 | return this.messagesControlByArgument && ((this._lastModified !== null) || (this._lastEventId !== null)); 1025 | }, 1026 | 1027 | _connect: function() { 1028 | if (this._lastEventId === null) { 1029 | this._lastEventId = this.lastEventId; 1030 | } 1031 | if (this._lastModified === null) { 1032 | var date = this.messagesPublishedAfter; 1033 | if (!isDate(date)) { 1034 | var messagesPublishedAfter = Number(this.messagesPublishedAfter); 1035 | if (messagesPublishedAfter > 0) { 1036 | date = new Date(); 1037 | date.setTime(date.getTime() - (messagesPublishedAfter * 1000)); 1038 | } else if (messagesPublishedAfter < 0) { 1039 | date = new Date(0); 1040 | } 1041 | } 1042 | 1043 | if (isDate(date)) { 1044 | this._lastModified = Utils.dateToUTCString(date); 1045 | } 1046 | } 1047 | 1048 | this._disconnect(); 1049 | this._setState(PushStream.CONNECTING); 1050 | this.wrapper = this.wrappers[this._lastUsedMode++ % this.wrappers.length]; 1051 | 1052 | try { 1053 | this.wrapper.connect(); 1054 | } catch (e) { 1055 | //each wrapper has a cleanup routine at disconnect method 1056 | if (this.wrapper) { 1057 | this.wrapper.disconnect(); 1058 | } 1059 | } 1060 | }, 1061 | 1062 | _disconnect: function() { 1063 | this._reconnecttimer = clearTimer(this._reconnecttimer); 1064 | if (this.wrapper) { 1065 | this.wrapper.disconnect(); 1066 | } 1067 | }, 1068 | 1069 | _onopen: function() { 1070 | this._reconnecttimer = clearTimer(this._reconnecttimer); 1071 | this._setState(PushStream.OPEN); 1072 | if (this._lastUsedMode > 0) { 1073 | this._lastUsedMode--; //use same mode on next connection 1074 | } 1075 | }, 1076 | 1077 | _onclose: function() { 1078 | this._reconnecttimer = clearTimer(this._reconnecttimer); 1079 | this._setState(PushStream.CLOSED); 1080 | this._reconnect(this.reconnectOnTimeoutInterval); 1081 | }, 1082 | 1083 | _onmessage: function(text, id, channel, eventid, isLastMessageFromBatch) { 1084 | Log4js.debug("message", text, id, channel, eventid, isLastMessageFromBatch); 1085 | if (id === -2) { 1086 | if (this.onchanneldeleted) { this.onchanneldeleted(channel); } 1087 | } else if (id > 0) { 1088 | if (this.onmessage) { this.onmessage(text, id, channel, eventid, isLastMessageFromBatch); } 1089 | } 1090 | }, 1091 | 1092 | _onerror: function(error) { 1093 | this._setState(PushStream.CLOSED); 1094 | this._reconnect((error.type === "timeout") ? this.reconnectOnTimeoutInterval : this.reconnectOnChannelUnavailableInterval); 1095 | if (this.onerror) { this.onerror(error); } 1096 | }, 1097 | 1098 | _reconnect: function(timeout) { 1099 | if (this._keepConnected && !this._reconnecttimer && (this.readyState !== PushStream.CONNECTING)) { 1100 | Log4js.info("trying to reconnect in", timeout); 1101 | this._reconnecttimer = window.setTimeout(linker(this._connect, this), timeout); 1102 | } 1103 | }, 1104 | 1105 | sendMessage: function(message, successCallback, errorCallback) { 1106 | message = escapeText(message); 1107 | if (this.wrapper.type === WebSocketWrapper.TYPE) { 1108 | this.wrapper.sendMessage(message); 1109 | if (successCallback) { successCallback(); } 1110 | } else { 1111 | Ajax.post({url: getPublisherUrl(this), data: message, success: successCallback, error: errorCallback, crossDomain: this._crossDomain}); 1112 | } 1113 | } 1114 | }; 1115 | 1116 | PushStream.sendMessage = function(url, message, successCallback, errorCallback) { 1117 | Ajax.post({url: url, data: escapeText(message), success: successCallback, error: errorCallback}); 1118 | }; 1119 | 1120 | // to make server header template more clear, it calls register and 1121 | // by a url parameter we find the stream wrapper instance 1122 | PushStream.register = function(iframe) { 1123 | var matcher = iframe.window.location.href.match(/streamid=([0-9]*)&?/); 1124 | if (matcher[1] && PushStreamManager[matcher[1]]) { 1125 | PushStreamManager[matcher[1]].wrapper.register(iframe); 1126 | } 1127 | }; 1128 | 1129 | PushStream.unload = function() { 1130 | for (var i = 0; i < PushStreamManager.length; i++) { 1131 | try { PushStreamManager[i].disconnect(); } catch(e){} 1132 | } 1133 | }; 1134 | 1135 | /* make class public */ 1136 | window.PushStream = PushStream; 1137 | window.PushStreamManager = PushStreamManager; 1138 | 1139 | if (window.attachEvent) { window.attachEvent("onunload", PushStream.unload); } 1140 | if (window.addEventListener) { window.addEventListener.call(window, "unload", PushStream.unload, false); } 1141 | 1142 | })(window, document); 1143 | -------------------------------------------------------------------------------- /public/assets/moment.min.js: -------------------------------------------------------------------------------- 1 | !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.moment=t()}(this,function(){"use strict";function e(){return Qe.apply(null,arguments)}function t(e){return e instanceof Array||"[object Array]"===Object.prototype.toString.call(e)}function n(e){return null!=e&&"[object Object]"===Object.prototype.toString.call(e)}function s(e){return void 0===e}function i(e){return"number"==typeof e||"[object Number]"===Object.prototype.toString.call(e)}function r(e){return e instanceof Date||"[object Date]"===Object.prototype.toString.call(e)}function a(e,t){var n,s=[];for(n=0;n0)for(n=0;n=0?n?"+":"":"-")+Math.pow(10,Math.max(0,i)).toString().substr(1)+s}function P(e,t,n,s){var i=s;"string"==typeof s&&(i=function(){return this[s]()}),e&&(ut[e]=i),t&&(ut[t[0]]=function(){return b(i.apply(this,arguments),t[1],t[2])}),n&&(ut[n]=function(){return this.localeData().ordinal(i.apply(this,arguments),e)})}function W(e){return e.match(/\[[\s\S]/)?e.replace(/^\[|\]$/g,""):e.replace(/\\/g,"")}function R(e,t){return e.isValid()?(t=C(t,e.localeData()),ot[t]=ot[t]||function(e){var t,n,s=e.match(rt);for(t=0,n=s.length;t=0&&at.test(e);)e=e.replace(at,n),at.lastIndex=0,s-=1;return e}function F(e,t,n){Yt[e]=k(t)?t:function(e,s){return e&&n?n:t}}function U(e,t){return o(Yt,e)?Yt[e](t._strict,t._locale):new RegExp(function(e){return N(e.replace("\\","").replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(e,t,n,s,i){return t||n||s||i}))}(e))}function N(e){return e.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}function H(e,t){var n,s=t;for("string"==typeof e&&(e=[e]),i(t)&&(s=function(e,n){n[t]=g(e)}),n=0;n=0&&isFinite(t.getUTCFullYear())&&t.setUTCFullYear(e),t}function B(e,t,n){var s=7+t-n;return-((7+J(e,0,s).getUTCDay()-t)%7)+s-1}function Q(e,t,n,s,i){var r,a,o=1+7*(t-1)+(7+n-s)%7+B(e,s,i);return o<=0?a=V(r=e-1)+o:o>V(e)?(r=e+1,a=o-V(e)):(r=e,a=o),{year:r,dayOfYear:a}}function X(e,t,n){var s,i,r=B(e.year(),t,n),a=Math.floor((e.dayOfYear()-r-1)/7)+1;return a<1?s=a+K(i=e.year()-1,t,n):a>K(e.year(),t,n)?(s=a-K(e.year(),t,n),i=e.year()+1):(i=e.year(),s=a),{week:s,year:i}}function K(e,t,n){var s=B(e,t,n),i=B(e+1,t,n);return(V(e)-s+i)/7}function ee(){function e(e,t){return t.length-e.length}var t,n,s,i,r,a=[],o=[],u=[],d=[];for(t=0;t<7;t++)n=l([2e3,1]).day(t),s=this.weekdaysMin(n,""),i=this.weekdaysShort(n,""),r=this.weekdays(n,""),a.push(s),o.push(i),u.push(r),d.push(s),d.push(i),d.push(r);for(a.sort(e),o.sort(e),u.sort(e),d.sort(e),t=0;t<7;t++)o[t]=N(o[t]),u[t]=N(u[t]),d[t]=N(d[t]);this._weekdaysRegex=new RegExp("^("+d.join("|")+")","i"),this._weekdaysShortRegex=this._weekdaysRegex,this._weekdaysMinRegex=this._weekdaysRegex,this._weekdaysStrictRegex=new RegExp("^("+u.join("|")+")","i"),this._weekdaysShortStrictRegex=new RegExp("^("+o.join("|")+")","i"),this._weekdaysMinStrictRegex=new RegExp("^("+a.join("|")+")","i")}function te(){return this.hours()%12||12}function ne(e,t){P(e,0,0,function(){return this.localeData().meridiem(this.hours(),this.minutes(),t)})}function se(e,t){return t._meridiemParse}function ie(e){return e?e.toLowerCase().replace("_","-"):e}function re(e){var t=null;if(!Xt[e]&&"undefined"!=typeof module&&module&&module.exports)try{t=Jt._abbr;require("./locale/"+e),ae(t)}catch(e){}return Xt[e]}function ae(e,t){var n;return e&&(n=s(t)?ue(e):oe(e,t))&&(Jt=n),Jt._abbr}function oe(e,t){if(null!==t){var n=Qt;if(t.abbr=e,null!=Xt[e])M("defineLocaleOverride","use moment.updateLocale(localeName, config) to change an existing locale. moment.defineLocale(localeName, config) should only be used for creating a new locale See http://momentjs.com/guides/#/warnings/define-locale/ for more info."),n=Xt[e]._config;else if(null!=t.parentLocale){if(null==Xt[t.parentLocale])return Kt[t.parentLocale]||(Kt[t.parentLocale]=[]),Kt[t.parentLocale].push({name:e,config:t}),null;n=Xt[t.parentLocale]._config}return Xt[e]=new D(S(n,t)),Kt[e]&&Kt[e].forEach(function(e){oe(e.name,e.config)}),ae(e),Xt[e]}return delete Xt[e],null}function ue(e){var n;if(e&&e._locale&&e._locale._abbr&&(e=e._locale._abbr),!e)return Jt;if(!t(e)){if(n=re(e))return n;e=[e]}return function(e){for(var t,n,s,i,r=0;r0;){if(s=re(i.slice(0,t).join("-")))return s;if(n&&n.length>=t&&p(i,n,!0)>=t-1)break;t--}r++}return null}(e)}function le(e){var t,n=e._a;return n&&-2===d(e).overflow&&(t=n[Tt]<0||n[Tt]>11?Tt:n[bt]<1||n[bt]>z(n[xt],n[Tt])?bt:n[Pt]<0||n[Pt]>24||24===n[Pt]&&(0!==n[Wt]||0!==n[Rt]||0!==n[Ct])?Pt:n[Wt]<0||n[Wt]>59?Wt:n[Rt]<0||n[Rt]>59?Rt:n[Ct]<0||n[Ct]>999?Ct:-1,d(e)._overflowDayOfYear&&(tbt)&&(t=bt),d(e)._overflowWeeks&&-1===t&&(t=Ft),d(e)._overflowWeekday&&-1===t&&(t=Ut),d(e).overflow=t),e}function de(e,t,n){return null!=e?e:null!=t?t:n}function he(t){var n,s,i,r,a=[];if(!t._d){for(i=function(t){var n=new Date(e.now());return t._useUTC?[n.getUTCFullYear(),n.getUTCMonth(),n.getUTCDate()]:[n.getFullYear(),n.getMonth(),n.getDate()]}(t),t._w&&null==t._a[bt]&&null==t._a[Tt]&&function(e){var t,n,s,i,r,a,o,u;if(null!=(t=e._w).GG||null!=t.W||null!=t.E)r=1,a=4,n=de(t.GG,e._a[xt],X(pe(),1,4).year),s=de(t.W,1),((i=de(t.E,1))<1||i>7)&&(u=!0);else{r=e._locale._week.dow,a=e._locale._week.doy;var l=X(pe(),r,a);n=de(t.gg,e._a[xt],l.year),s=de(t.w,l.week),null!=t.d?((i=t.d)<0||i>6)&&(u=!0):null!=t.e?(i=t.e+r,(t.e<0||t.e>6)&&(u=!0)):i=r}s<1||s>K(n,r,a)?d(e)._overflowWeeks=!0:null!=u?d(e)._overflowWeekday=!0:(o=Q(n,s,i,r,a),e._a[xt]=o.year,e._dayOfYear=o.dayOfYear)}(t),null!=t._dayOfYear&&(r=de(t._a[xt],i[xt]),(t._dayOfYear>V(r)||0===t._dayOfYear)&&(d(t)._overflowDayOfYear=!0),s=J(r,0,t._dayOfYear),t._a[Tt]=s.getUTCMonth(),t._a[bt]=s.getUTCDate()),n=0;n<3&&null==t._a[n];++n)t._a[n]=a[n]=i[n];for(;n<7;n++)t._a[n]=a[n]=null==t._a[n]?2===n?1:0:t._a[n];24===t._a[Pt]&&0===t._a[Wt]&&0===t._a[Rt]&&0===t._a[Ct]&&(t._nextDay=!0,t._a[Pt]=0),t._d=(t._useUTC?J:function(e,t,n,s,i,r,a){var o=new Date(e,t,n,s,i,r,a);return e<100&&e>=0&&isFinite(o.getFullYear())&&o.setFullYear(e),o}).apply(null,a),null!=t._tzm&&t._d.setUTCMinutes(t._d.getUTCMinutes()-t._tzm),t._nextDay&&(t._a[Pt]=24),t._w&&void 0!==t._w.d&&t._w.d!==t._d.getDay()&&(d(t).weekdayMismatch=!0)}}function ce(e){var t,n,s,i,r,a,o=e._i,u=en.exec(o)||tn.exec(o);if(u){for(d(e).iso=!0,t=0,n=sn.length;t0&&d(t).unusedInput.push(a),o=o.slice(o.indexOf(s)+s.length),l+=s.length),ut[r]?(s?d(t).empty=!1:d(t).unusedTokens.push(r),G(r,s,t)):t._strict&&!s&&d(t).unusedTokens.push(r);d(t).charsLeftOver=u-l,o.length>0&&d(t).unusedInput.push(o),t._a[Pt]<=12&&!0===d(t).bigHour&&t._a[Pt]>0&&(d(t).bigHour=void 0),d(t).parsedDateParts=t._a.slice(0),d(t).meridiem=t._meridiem,t._a[Pt]=function(e,t,n){var s;if(null==n)return t;return null!=e.meridiemHour?e.meridiemHour(t,n):null!=e.isPM?((s=e.isPM(n))&&t<12&&(t+=12),s||12!==t||(t=0),t):t}(t._locale,t._a[Pt],t._meridiem),he(t),le(t)}else me(t);else ce(t)}function ye(o){var l=o._i,y=o._f;return o._locale=o._locale||ue(o._l),null===l||void 0===y&&""===l?c({nullInput:!0}):("string"==typeof l&&(o._i=l=o._locale.preparse(l)),_(l)?new m(le(l)):(r(l)?o._d=l:t(y)?function(e){var t,n,s,i,r;if(0===e._f.length)return d(e).invalidFormat=!0,void(e._d=new Date(NaN));for(i=0;ir&&(t=r),function(e,t,n,s,i){var r=Q(e,t,n,s,i),a=J(r.year,0,r.dayOfYear);return this.year(a.getUTCFullYear()),this.month(a.getUTCMonth()),this.date(a.getUTCDate()),this}.call(this,e,t,n,s,i))}function Le(e,t){t[Ct]=g(1e3*("0."+e))}function Ge(e){return e}function Ve(e,t,n,s){var i=ue(),r=l().set(s,t);return i[n](r,e)}function je(e,t,n){if(i(e)&&(t=e,e=void 0),e=e||"",null!=t)return Ve(e,t,n,"month");var s,r=[];for(s=0;s<12;s++)r[s]=Ve(e,s,n,"month");return r}function Ie(e,t,n,s){"boolean"==typeof e?(i(t)&&(n=t,t=void 0),t=t||""):(n=t=e,e=!1,i(t)&&(n=t,t=void 0),t=t||"");var r=ue(),a=e?r._week.dow:0;if(null!=n)return Ve(t,(n+a)%7,s,"day");var o,u=[];for(o=0;o<7;o++)u[o]=Ve(t,(o+a)%7,s,"day");return u}function Ee(e,t,n,s){var i=Te(t,n);return e._milliseconds+=s*i._milliseconds,e._days+=s*i._days,e._months+=s*i._months,e._bubble()}function Ae(e){return e<0?Math.floor(e):Math.ceil(e)}function ze(e){return 4800*e/146097}function Ze(e){return 146097*e/4800}function $e(e){return function(){return this.as(e)}}function qe(e){return function(){return this.isValid()?this._data[e]:NaN}}function Je(e){return(e>0)-(e<0)||+e}function Be(){if(!this.isValid())return this.localeData().invalidDate();var e,t,n,s=En(this._milliseconds)/1e3,i=En(this._days),r=En(this._months);t=y((e=y(s/60))/60),s%=60,e%=60;var a=n=y(r/12),o=r%=12,u=i,l=t,d=e,h=s?s.toFixed(3).replace(/\.?0+$/,""):"",c=this.asSeconds();if(!c)return"P0D";var f=c<0?"-":"",m=Je(this._months)!==Je(c)?"-":"",_=Je(this._days)!==Je(c)?"-":"",g=Je(this._milliseconds)!==Je(c)?"-":"";return f+"P"+(a?m+a+"Y":"")+(o?m+o+"M":"")+(u?_+u+"D":"")+(l||d||h?"T":"")+(l?g+l+"H":"")+(d?g+d+"M":"")+(h?g+h+"S":"")}var Qe,Xe;Xe=Array.prototype.some?Array.prototype.some:function(e){for(var t=Object(this),n=t.length>>>0,s=0;s68?1900:2e3)};var Nt,Ht=I("FullYear",!0);Nt=Array.prototype.indexOf?Array.prototype.indexOf:function(e){var t;for(t=0;tthis?this:e:c()}),hn=["year","quarter","month","week","day","hour","minute","second","millisecond"];Se("Z",":"),Se("ZZ",""),F("Z",St),F("ZZ",St),H(["Z","ZZ"],function(e,t,n){n._useUTC=!0,n._tzm=De(St,e)});var cn=/([\+\-]|\d\d)/gi;e.updateOffset=function(){};var fn=/^(\-|\+)?(?:(\d*)[. ])?(\d+)\:(\d+)(?:\:(\d+)(\.\d*)?)?$/,mn=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;Te.fn=ve.prototype,Te.invalid=function(){return Te(NaN)};var _n=We(1,"add"),yn=We(-1,"subtract");e.defaultFormat="YYYY-MM-DDTHH:mm:ssZ",e.defaultFormatUtc="YYYY-MM-DDTHH:mm:ss[Z]";var gn=v("moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.",function(e){return void 0===e?this.localeData():this.locale(e)});P(0,["gg",2],0,function(){return this.weekYear()%100}),P(0,["GG",2],0,function(){return this.isoWeekYear()%100}),Ne("gggg","weekYear"),Ne("ggggg","weekYear"),Ne("GGGG","isoWeekYear"),Ne("GGGGG","isoWeekYear"),Y("weekYear","gg"),Y("isoWeekYear","GG"),T("weekYear",1),T("isoWeekYear",1),F("G",Mt),F("g",Mt),F("GG",mt,dt),F("gg",mt,dt),F("GGGG",pt,ct),F("gggg",pt,ct),F("GGGGG",wt,ft),F("ggggg",wt,ft),L(["gggg","ggggg","GGGG","GGGGG"],function(e,t,n,s){t[s.substr(0,2)]=g(e)}),L(["gg","GG"],function(t,n,s,i){n[i]=e.parseTwoDigitYear(t)}),P("Q",0,"Qo","quarter"),Y("quarter","Q"),T("quarter",7),F("Q",lt),H("Q",function(e,t){t[Tt]=3*(g(e)-1)}),P("D",["DD",2],"Do","date"),Y("date","D"),T("date",9),F("D",mt),F("DD",mt,dt),F("Do",function(e,t){return e?t._dayOfMonthOrdinalParse||t._ordinalParse:t._dayOfMonthOrdinalParseLenient}),H(["D","DD"],bt),H("Do",function(e,t){t[bt]=g(e.match(mt)[0])});var pn=I("Date",!0);P("DDD",["DDDD",3],"DDDo","dayOfYear"),Y("dayOfYear","DDD"),T("dayOfYear",4),F("DDD",gt),F("DDDD",ht),H(["DDD","DDDD"],function(e,t,n){n._dayOfYear=g(e)}),P("m",["mm",2],0,"minute"),Y("minute","m"),T("minute",14),F("m",mt),F("mm",mt,dt),H(["m","mm"],Wt);var wn=I("Minutes",!1);P("s",["ss",2],0,"second"),Y("second","s"),T("second",15),F("s",mt),F("ss",mt,dt),H(["s","ss"],Rt);var vn=I("Seconds",!1);P("S",0,0,function(){return~~(this.millisecond()/100)}),P(0,["SS",2],0,function(){return~~(this.millisecond()/10)}),P(0,["SSS",3],0,"millisecond"),P(0,["SSSS",4],0,function(){return 10*this.millisecond()}),P(0,["SSSSS",5],0,function(){return 100*this.millisecond()}),P(0,["SSSSSS",6],0,function(){return 1e3*this.millisecond()}),P(0,["SSSSSSS",7],0,function(){return 1e4*this.millisecond()}),P(0,["SSSSSSSS",8],0,function(){return 1e5*this.millisecond()}),P(0,["SSSSSSSSS",9],0,function(){return 1e6*this.millisecond()}),Y("millisecond","ms"),T("millisecond",16),F("S",gt,lt),F("SS",gt,dt),F("SSS",gt,ht);var Mn;for(Mn="SSSS";Mn.length<=9;Mn+="S")F(Mn,vt);for(Mn="S";Mn.length<=9;Mn+="S")H(Mn,Le);var kn=I("Milliseconds",!1);P("z",0,0,"zoneAbbr"),P("zz",0,0,"zoneName");var Sn=m.prototype;Sn.add=_n,Sn.calendar=function(t,n){var s=t||pe(),i=Ye(s,this).startOf("day"),r=e.calendarFormat(this,i)||"sameElse",a=n&&(k(n[r])?n[r].call(this,s):n[r]);return this.format(a||this.localeData().calendar(r,this,pe(s)))},Sn.clone=function(){return new m(this)},Sn.diff=function(e,t,n){var s,i,r;if(!this.isValid())return NaN;if(!(s=Ye(e,this)).isValid())return NaN;switch(i=6e4*(s.utcOffset()-this.utcOffset()),t=O(t)){case"year":r=Ce(this,s)/12;break;case"month":r=Ce(this,s);break;case"quarter":r=Ce(this,s)/3;break;case"second":r=(this-s)/1e3;break;case"minute":r=(this-s)/6e4;break;case"hour":r=(this-s)/36e5;break;case"day":r=(this-s-i)/864e5;break;case"week":r=(this-s-i)/6048e5;break;default:r=this-s}return n?r:y(r)},Sn.endOf=function(e){return void 0===(e=O(e))||"millisecond"===e?this:("date"===e&&(e="day"),this.startOf(e).add(1,"isoWeek"===e?"week":e).subtract(1,"ms"))},Sn.format=function(t){t||(t=this.isUtc()?e.defaultFormatUtc:e.defaultFormat);var n=R(this,t);return this.localeData().postformat(n)},Sn.from=function(e,t){return this.isValid()&&(_(e)&&e.isValid()||pe(e).isValid())?Te({to:this,from:e}).locale(this.locale()).humanize(!t):this.localeData().invalidDate()},Sn.fromNow=function(e){return this.from(pe(),e)},Sn.to=function(e,t){return this.isValid()&&(_(e)&&e.isValid()||pe(e).isValid())?Te({from:this,to:e}).locale(this.locale()).humanize(!t):this.localeData().invalidDate()},Sn.toNow=function(e){return this.to(pe(),e)},Sn.get=function(e){return e=O(e),k(this[e])?this[e]():this},Sn.invalidAt=function(){return d(this).overflow},Sn.isAfter=function(e,t){var n=_(e)?e:pe(e);return!(!this.isValid()||!n.isValid())&&("millisecond"===(t=O(s(t)?"millisecond":t))?this.valueOf()>n.valueOf():n.valueOf()9999?R(e,"YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]"):k(Date.prototype.toISOString)?this.toDate().toISOString():R(e,"YYYY-MM-DD[T]HH:mm:ss.SSS[Z]")},Sn.inspect=function(){if(!this.isValid())return"moment.invalid(/* "+this._i+" */)";var e="moment",t="";this.isLocal()||(e=0===this.utcOffset()?"moment.utc":"moment.parseZone",t="Z");var n="["+e+'("]',s=0<=this.year()&&this.year()<=9999?"YYYY":"YYYYYY",i=t+'[")]';return this.format(n+s+"-MM-DD[T]HH:mm:ss.SSS"+i)},Sn.toJSON=function(){return this.isValid()?this.toISOString():null},Sn.toString=function(){return this.clone().locale("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")},Sn.unix=function(){return Math.floor(this.valueOf()/1e3)},Sn.valueOf=function(){return this._d.valueOf()-6e4*(this._offset||0)},Sn.creationData=function(){return{input:this._i,format:this._f,locale:this._locale,isUTC:this._isUTC,strict:this._strict}},Sn.year=Ht,Sn.isLeapYear=function(){return j(this.year())},Sn.weekYear=function(e){return He.call(this,e,this.week(),this.weekday(),this.localeData()._week.dow,this.localeData()._week.doy)},Sn.isoWeekYear=function(e){return He.call(this,e,this.isoWeek(),this.isoWeekday(),1,4)},Sn.quarter=Sn.quarters=function(e){return null==e?Math.ceil((this.month()+1)/3):this.month(3*(e-1)+this.month()%3)},Sn.month=$,Sn.daysInMonth=function(){return z(this.year(),this.month())},Sn.week=Sn.weeks=function(e){var t=this.localeData().week(this);return null==e?t:this.add(7*(e-t),"d")},Sn.isoWeek=Sn.isoWeeks=function(e){var t=X(this,1,4).week;return null==e?t:this.add(7*(e-t),"d")},Sn.weeksInYear=function(){var e=this.localeData()._week;return K(this.year(),e.dow,e.doy)},Sn.isoWeeksInYear=function(){return K(this.year(),1,4)},Sn.date=pn,Sn.day=Sn.days=function(e){if(!this.isValid())return null!=e?this:NaN;var t=this._isUTC?this._d.getUTCDay():this._d.getDay();return null!=e?(e=function(e,t){return"string"!=typeof e?e:isNaN(e)?"number"==typeof(e=t.weekdaysParse(e))?e:null:parseInt(e,10)}(e,this.localeData()),this.add(e-t,"d")):t},Sn.weekday=function(e){if(!this.isValid())return null!=e?this:NaN;var t=(this.day()+7-this.localeData()._week.dow)%7;return null==e?t:this.add(e-t,"d")},Sn.isoWeekday=function(e){if(!this.isValid())return null!=e?this:NaN;if(null!=e){var t=function(e,t){return"string"==typeof e?t.weekdaysParse(e)%7||7:isNaN(e)?null:e}(e,this.localeData());return this.day(this.day()%7?t:t-7)}return this.day()||7},Sn.dayOfYear=function(e){var t=Math.round((this.clone().startOf("day")-this.clone().startOf("year"))/864e5)+1;return null==e?t:this.add(e-t,"d")},Sn.hour=Sn.hours=Bt,Sn.minute=Sn.minutes=wn,Sn.second=Sn.seconds=vn,Sn.millisecond=Sn.milliseconds=kn,Sn.utcOffset=function(t,n,s){var i,r=this._offset||0;if(!this.isValid())return null!=t?this:NaN;if(null!=t){if("string"==typeof t){if(null===(t=De(St,t)))return this}else Math.abs(t)<16&&!s&&(t*=60);return!this._isUTC&&n&&(i=Oe(this)),this._offset=t,this._isUTC=!0,null!=i&&this.add(i,"m"),r!==t&&(!n||this._changeInProgress?Re(this,Te(t-r,"m"),1,!1):this._changeInProgress||(this._changeInProgress=!0,e.updateOffset(this,!0),this._changeInProgress=null)),this}return this._isUTC?r:Oe(this)},Sn.utc=function(e){return this.utcOffset(0,e)},Sn.local=function(e){return this._isUTC&&(this.utcOffset(0,e),this._isUTC=!1,e&&this.subtract(Oe(this),"m")),this},Sn.parseZone=function(){if(null!=this._tzm)this.utcOffset(this._tzm,!1,!0);else if("string"==typeof this._i){var e=De(kt,this._i);null!=e?this.utcOffset(e):this.utcOffset(0,!0)}return this},Sn.hasAlignedHourOffset=function(e){return!!this.isValid()&&(e=e?pe(e).utcOffset():0,(this.utcOffset()-e)%60==0)},Sn.isDST=function(){return this.utcOffset()>this.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()},Sn.isLocal=function(){return!!this.isValid()&&!this._isUTC},Sn.isUtcOffset=function(){return!!this.isValid()&&this._isUTC},Sn.isUtc=xe,Sn.isUTC=xe,Sn.zoneAbbr=function(){return this._isUTC?"UTC":""},Sn.zoneName=function(){return this._isUTC?"Coordinated Universal Time":""},Sn.dates=v("dates accessor is deprecated. Use date instead.",pn),Sn.months=v("months accessor is deprecated. Use month instead",$),Sn.years=v("years accessor is deprecated. Use year instead",Ht),Sn.zone=v("moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/",function(e,t){return null!=e?("string"!=typeof e&&(e=-e),this.utcOffset(e,t),this):-this.utcOffset()}),Sn.isDSTShifted=v("isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information",function(){if(!s(this._isDSTShifted))return this._isDSTShifted;var e={};if(f(e,this),(e=ye(e))._a){var t=e._isUTC?l(e._a):pe(e._a);this._isDSTShifted=this.isValid()&&p(e._a,t.toArray())>0}else this._isDSTShifted=!1;return this._isDSTShifted});var Dn=D.prototype;Dn.calendar=function(e,t,n){var s=this._calendar[e]||this._calendar.sameElse;return k(s)?s.call(t,n):s},Dn.longDateFormat=function(e){var t=this._longDateFormat[e],n=this._longDateFormat[e.toUpperCase()];return t||!n?t:(this._longDateFormat[e]=n.replace(/MMMM|MM|DD|dddd/g,function(e){return e.slice(1)}),this._longDateFormat[e])},Dn.invalidDate=function(){return this._invalidDate},Dn.ordinal=function(e){return this._ordinal.replace("%d",e)},Dn.preparse=Ge,Dn.postformat=Ge,Dn.relativeTime=function(e,t,n,s){var i=this._relativeTime[n];return k(i)?i(e,t,n,s):i.replace(/%d/i,e)},Dn.pastFuture=function(e,t){var n=this._relativeTime[e>0?"future":"past"];return k(n)?n(t):n.replace(/%s/i,t)},Dn.set=function(e){var t,n;for(n in e)k(t=e[n])?this[n]=t:this["_"+n]=t;this._config=e,this._dayOfMonthOrdinalParseLenient=new RegExp((this._dayOfMonthOrdinalParse.source||this._ordinalParse.source)+"|"+/\d{1,2}/.source)},Dn.months=function(e,n){return e?t(this._months)?this._months[e.month()]:this._months[(this._months.isFormat||Lt).test(n)?"format":"standalone"][e.month()]:t(this._months)?this._months:this._months.standalone},Dn.monthsShort=function(e,n){return e?t(this._monthsShort)?this._monthsShort[e.month()]:this._monthsShort[Lt.test(n)?"format":"standalone"][e.month()]:t(this._monthsShort)?this._monthsShort:this._monthsShort.standalone},Dn.monthsParse=function(e,t,n){var s,i,r;if(this._monthsParseExact)return function(e,t,n){var s,i,r,a=e.toLocaleLowerCase();if(!this._monthsParse)for(this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[],s=0;s<12;++s)r=l([2e3,s]),this._shortMonthsParse[s]=this.monthsShort(r,"").toLocaleLowerCase(),this._longMonthsParse[s]=this.months(r,"").toLocaleLowerCase();return n?"MMM"===t?-1!==(i=Nt.call(this._shortMonthsParse,a))?i:null:-1!==(i=Nt.call(this._longMonthsParse,a))?i:null:"MMM"===t?-1!==(i=Nt.call(this._shortMonthsParse,a))?i:-1!==(i=Nt.call(this._longMonthsParse,a))?i:null:-1!==(i=Nt.call(this._longMonthsParse,a))?i:-1!==(i=Nt.call(this._shortMonthsParse,a))?i:null}.call(this,e,t,n);for(this._monthsParse||(this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[]),s=0;s<12;s++){if(i=l([2e3,s]),n&&!this._longMonthsParse[s]&&(this._longMonthsParse[s]=new RegExp("^"+this.months(i,"").replace(".","")+"$","i"),this._shortMonthsParse[s]=new RegExp("^"+this.monthsShort(i,"").replace(".","")+"$","i")),n||this._monthsParse[s]||(r="^"+this.months(i,"")+"|^"+this.monthsShort(i,""),this._monthsParse[s]=new RegExp(r.replace(".",""),"i")),n&&"MMMM"===t&&this._longMonthsParse[s].test(e))return s;if(n&&"MMM"===t&&this._shortMonthsParse[s].test(e))return s;if(!n&&this._monthsParse[s].test(e))return s}},Dn.monthsRegex=function(e){return this._monthsParseExact?(o(this,"_monthsRegex")||q.call(this),e?this._monthsStrictRegex:this._monthsRegex):(o(this,"_monthsRegex")||(this._monthsRegex=It),this._monthsStrictRegex&&e?this._monthsStrictRegex:this._monthsRegex)},Dn.monthsShortRegex=function(e){return this._monthsParseExact?(o(this,"_monthsRegex")||q.call(this),e?this._monthsShortStrictRegex:this._monthsShortRegex):(o(this,"_monthsShortRegex")||(this._monthsShortRegex=jt),this._monthsShortStrictRegex&&e?this._monthsShortStrictRegex:this._monthsShortRegex)},Dn.week=function(e){return X(e,this._week.dow,this._week.doy).week},Dn.firstDayOfYear=function(){return this._week.doy},Dn.firstDayOfWeek=function(){return this._week.dow},Dn.weekdays=function(e,n){return e?t(this._weekdays)?this._weekdays[e.day()]:this._weekdays[this._weekdays.isFormat.test(n)?"format":"standalone"][e.day()]:t(this._weekdays)?this._weekdays:this._weekdays.standalone},Dn.weekdaysMin=function(e){return e?this._weekdaysMin[e.day()]:this._weekdaysMin},Dn.weekdaysShort=function(e){return e?this._weekdaysShort[e.day()]:this._weekdaysShort},Dn.weekdaysParse=function(e,t,n){var s,i,r;if(this._weekdaysParseExact)return function(e,t,n){var s,i,r,a=e.toLocaleLowerCase();if(!this._weekdaysParse)for(this._weekdaysParse=[],this._shortWeekdaysParse=[],this._minWeekdaysParse=[],s=0;s<7;++s)r=l([2e3,1]).day(s),this._minWeekdaysParse[s]=this.weekdaysMin(r,"").toLocaleLowerCase(),this._shortWeekdaysParse[s]=this.weekdaysShort(r,"").toLocaleLowerCase(),this._weekdaysParse[s]=this.weekdays(r,"").toLocaleLowerCase();return n?"dddd"===t?-1!==(i=Nt.call(this._weekdaysParse,a))?i:null:"ddd"===t?-1!==(i=Nt.call(this._shortWeekdaysParse,a))?i:null:-1!==(i=Nt.call(this._minWeekdaysParse,a))?i:null:"dddd"===t?-1!==(i=Nt.call(this._weekdaysParse,a))?i:-1!==(i=Nt.call(this._shortWeekdaysParse,a))?i:-1!==(i=Nt.call(this._minWeekdaysParse,a))?i:null:"ddd"===t?-1!==(i=Nt.call(this._shortWeekdaysParse,a))?i:-1!==(i=Nt.call(this._weekdaysParse,a))?i:-1!==(i=Nt.call(this._minWeekdaysParse,a))?i:null:-1!==(i=Nt.call(this._minWeekdaysParse,a))?i:-1!==(i=Nt.call(this._weekdaysParse,a))?i:-1!==(i=Nt.call(this._shortWeekdaysParse,a))?i:null}.call(this,e,t,n);for(this._weekdaysParse||(this._weekdaysParse=[],this._minWeekdaysParse=[],this._shortWeekdaysParse=[],this._fullWeekdaysParse=[]),s=0;s<7;s++){if(i=l([2e3,1]).day(s),n&&!this._fullWeekdaysParse[s]&&(this._fullWeekdaysParse[s]=new RegExp("^"+this.weekdays(i,"").replace(".",".?")+"$","i"),this._shortWeekdaysParse[s]=new RegExp("^"+this.weekdaysShort(i,"").replace(".",".?")+"$","i"),this._minWeekdaysParse[s]=new RegExp("^"+this.weekdaysMin(i,"").replace(".",".?")+"$","i")),this._weekdaysParse[s]||(r="^"+this.weekdays(i,"")+"|^"+this.weekdaysShort(i,"")+"|^"+this.weekdaysMin(i,""),this._weekdaysParse[s]=new RegExp(r.replace(".",""),"i")),n&&"dddd"===t&&this._fullWeekdaysParse[s].test(e))return s;if(n&&"ddd"===t&&this._shortWeekdaysParse[s].test(e))return s;if(n&&"dd"===t&&this._minWeekdaysParse[s].test(e))return s;if(!n&&this._weekdaysParse[s].test(e))return s}},Dn.weekdaysRegex=function(e){return this._weekdaysParseExact?(o(this,"_weekdaysRegex")||ee.call(this),e?this._weekdaysStrictRegex:this._weekdaysRegex):(o(this,"_weekdaysRegex")||(this._weekdaysRegex=Zt),this._weekdaysStrictRegex&&e?this._weekdaysStrictRegex:this._weekdaysRegex)},Dn.weekdaysShortRegex=function(e){return this._weekdaysParseExact?(o(this,"_weekdaysRegex")||ee.call(this),e?this._weekdaysShortStrictRegex:this._weekdaysShortRegex):(o(this,"_weekdaysShortRegex")||(this._weekdaysShortRegex=$t),this._weekdaysShortStrictRegex&&e?this._weekdaysShortStrictRegex:this._weekdaysShortRegex)},Dn.weekdaysMinRegex=function(e){return this._weekdaysParseExact?(o(this,"_weekdaysRegex")||ee.call(this),e?this._weekdaysMinStrictRegex:this._weekdaysMinRegex):(o(this,"_weekdaysMinRegex")||(this._weekdaysMinRegex=qt),this._weekdaysMinStrictRegex&&e?this._weekdaysMinStrictRegex:this._weekdaysMinRegex)},Dn.isPM=function(e){return"p"===(e+"").toLowerCase().charAt(0)},Dn.meridiem=function(e,t,n){return e>11?n?"pm":"PM":n?"am":"AM"},ae("en",{dayOfMonthOrdinalParse:/\d{1,2}(th|st|nd|rd)/,ordinal:function(e){var t=e%10;return e+(1===g(e%100/10)?"th":1===t?"st":2===t?"nd":3===t?"rd":"th")}}),e.lang=v("moment.lang is deprecated. Use moment.locale instead.",ae),e.langData=v("moment.langData is deprecated. Use moment.localeData instead.",ue);var Yn=Math.abs,On=$e("ms"),xn=$e("s"),Tn=$e("m"),bn=$e("h"),Pn=$e("d"),Wn=$e("w"),Rn=$e("M"),Cn=$e("y"),Fn=qe("milliseconds"),Un=qe("seconds"),Nn=qe("minutes"),Hn=qe("hours"),Ln=qe("days"),Gn=qe("months"),Vn=qe("years"),jn=Math.round,In={ss:44,s:45,m:45,h:22,d:26,M:11},En=Math.abs,An=ve.prototype;return An.isValid=function(){return this._isValid},An.abs=function(){var e=this._data;return this._milliseconds=Yn(this._milliseconds),this._days=Yn(this._days),this._months=Yn(this._months),e.milliseconds=Yn(e.milliseconds),e.seconds=Yn(e.seconds),e.minutes=Yn(e.minutes),e.hours=Yn(e.hours),e.months=Yn(e.months),e.years=Yn(e.years),this},An.add=function(e,t){return Ee(this,e,t,1)},An.subtract=function(e,t){return Ee(this,e,t,-1)},An.as=function(e){if(!this.isValid())return NaN;var t,n,s=this._milliseconds;if("month"===(e=O(e))||"year"===e)return t=this._days+s/864e5,n=this._months+ze(t),"month"===e?n:n/12;switch(t=this._days+Math.round(Ze(this._months)),e){case"week":return t/7+s/6048e5;case"day":return t+s/864e5;case"hour":return 24*t+s/36e5;case"minute":return 1440*t+s/6e4;case"second":return 86400*t+s/1e3;case"millisecond":return Math.floor(864e5*t)+s;default:throw new Error("Unknown unit "+e)}},An.asMilliseconds=On,An.asSeconds=xn,An.asMinutes=Tn,An.asHours=bn,An.asDays=Pn,An.asWeeks=Wn,An.asMonths=Rn,An.asYears=Cn,An.valueOf=function(){return this.isValid()?this._milliseconds+864e5*this._days+this._months%12*2592e6+31536e6*g(this._months/12):NaN},An._bubble=function(){var e,t,n,s,i,r=this._milliseconds,a=this._days,o=this._months,u=this._data;return r>=0&&a>=0&&o>=0||r<=0&&a<=0&&o<=0||(r+=864e5*Ae(Ze(o)+a),a=0,o=0),u.milliseconds=r%1e3,e=y(r/1e3),u.seconds=e%60,t=y(e/60),u.minutes=t%60,n=y(t/60),u.hours=n%24,a+=y(n/24),i=y(ze(a)),o+=i,a-=Ae(Ze(i)),s=y(o/12),o%=12,u.days=a,u.months=o,u.years=s,this},An.clone=function(){return Te(this)},An.get=function(e){return e=O(e),this.isValid()?this[e+"s"]():NaN},An.milliseconds=Fn,An.seconds=Un,An.minutes=Nn,An.hours=Hn,An.days=Ln,An.weeks=function(){return y(this.days()/7)},An.months=Gn,An.years=Vn,An.humanize=function(e){if(!this.isValid())return this.localeData().invalidDate();var t=this.localeData(),n=function(e,t,n){var s=Te(e).abs(),i=jn(s.as("s")),r=jn(s.as("m")),a=jn(s.as("h")),o=jn(s.as("d")),u=jn(s.as("M")),l=jn(s.as("y")),d=i<=In.ss&&["s",i]||i0,d[4]=n,function(e,t,n,s,i){return i.relativeTime(t||1,!!n,e,s)}.apply(null,d)}(this,!e,t);return e&&(n=t.pastFuture(+this,n)),t.postformat(n)},An.toISOString=Be,An.toString=Be,An.toJSON=Be,An.locale=Fe,An.localeData=Ue,An.toIsoString=v("toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)",Be),An.lang=gn,P("X",0,0,"unix"),P("x",0,0,"valueOf"),F("x",Mt),F("X",/[+-]?\d+(\.\d{1,3})?/),H("X",function(e,t,n){n._d=new Date(1e3*parseFloat(e,10))}),H("x",function(e,t,n){n._d=new Date(g(e))}),e.version="2.19.3",function(e){Qe=e}(pe),e.fn=Sn,e.min=function(){return we("isBefore",[].slice.call(arguments,0))},e.max=function(){return we("isAfter",[].slice.call(arguments,0))},e.now=function(){return Date.now?Date.now():+new Date},e.utc=l,e.unix=function(e){return pe(1e3*e)},e.months=function(e,t){return je(e,t,"months")},e.isDate=r,e.locale=ae,e.invalid=c,e.duration=Te,e.isMoment=_,e.weekdays=function(e,t,n){return Ie(e,t,n,"weekdays")},e.parseZone=function(){return pe.apply(null,arguments).parseZone()},e.localeData=ue,e.isDuration=Me,e.monthsShort=function(e,t){return je(e,t,"monthsShort")},e.weekdaysMin=function(e,t,n){return Ie(e,t,n,"weekdaysMin")},e.defineLocale=oe,e.updateLocale=function(e,t){if(null!=t){var n,s,i=Qt;null!=(s=re(e))&&(i=s._config),(n=new D(t=S(i,t))).parentLocale=Xt[e],Xt[e]=n,ae(e)}else null!=Xt[e]&&(null!=Xt[e].parentLocale?Xt[e]=Xt[e].parentLocale:null!=Xt[e]&&delete Xt[e]);return Xt[e]},e.locales=function(){return nt(Xt)},e.weekdaysShort=function(e,t,n){return Ie(e,t,n,"weekdaysShort")},e.normalizeUnits=O,e.relativeTimeRounding=function(e){return void 0===e?jn:"function"==typeof e&&(jn=e,!0)},e.relativeTimeThreshold=function(e,t){return void 0!==In[e]&&(void 0===t?In[e]:(In[e]=t,"s"===e&&(In.ss=t-1),!0))},e.calendarFormat=function(e,t){var n=e.diff(t,"days",!0);return n<-6?"sameElse":n<-1?"lastWeek":n<0?"lastDay":n<1?"sameDay":n<2?"nextDay":n<7?"nextWeek":"sameElse"},e.prototype=Sn,e}); --------------------------------------------------------------------------------