├── .gitignore ├── screenshot.jpg ├── public ├── img │ └── sheet_64.png ├── lib │ └── fancybox │ │ ├── blank.gif │ │ ├── fancybox_loading.gif │ │ ├── fancybox_overlay.png │ │ ├── fancybox_sprite.png │ │ ├── fancybox_sprite@2x.png │ │ ├── fancybox_loading@2x.gif │ │ ├── helpers │ │ ├── fancybox_buttons.png │ │ ├── jquery.fancybox-thumbs.css │ │ ├── jquery.fancybox-buttons.css │ │ ├── jquery.fancybox-buttons.js │ │ ├── jquery.fancybox-thumbs.js │ │ └── jquery.fancybox-media.js │ │ ├── jquery.fancybox.css │ │ └── jquery.fancybox.pack.js ├── font │ └── vendor │ │ ├── sourcesanspro-light-webfont.eot │ │ ├── sourcesanspro-light-webfont.ttf │ │ ├── sourcecodepro-regular-webfont.eot │ │ ├── sourcecodepro-regular-webfont.ttf │ │ ├── sourcesanspro-light-webfont.woff │ │ ├── sourcesanspro-regular-webfont.eot │ │ ├── sourcesanspro-regular-webfont.ttf │ │ ├── sourcecodepro-regular-webfont.woff │ │ ├── sourcesanspro-regular-webfont.woff │ │ ├── sourcesanspro-semibold-webfont.eot │ │ ├── sourcesanspro-semibold-webfont.ttf │ │ ├── sourcesanspro-semibold-webfont.woff │ │ └── stylesheet.css ├── js │ ├── jquery.emoji.js │ ├── mutate.min.js │ ├── events.min.js │ ├── jquery.linkify.min.js │ ├── main.js │ ├── underscore.min.js │ ├── typeahead.bundle.min.js │ └── moment.min.js ├── css │ ├── emoji.css │ ├── typeahead.css │ ├── spinner.css │ ├── dashboard.css │ └── main.css └── index.html ├── tools ├── send_message.applescript ├── address_export.py └── address_reader.py ├── chatSender.js ├── package.json ├── queries.js ├── app.js ├── addressbook.js ├── README.md ├── chatReader.js └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | address_book.js 2 | address_book_raw.js 3 | *.pyc 4 | node_modules -------------------------------------------------------------------------------- /screenshot.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bsharper/MessageBridge/HEAD/screenshot.jpg -------------------------------------------------------------------------------- /public/img/sheet_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bsharper/MessageBridge/HEAD/public/img/sheet_64.png -------------------------------------------------------------------------------- /public/lib/fancybox/blank.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bsharper/MessageBridge/HEAD/public/lib/fancybox/blank.gif -------------------------------------------------------------------------------- /public/lib/fancybox/fancybox_loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bsharper/MessageBridge/HEAD/public/lib/fancybox/fancybox_loading.gif -------------------------------------------------------------------------------- /public/lib/fancybox/fancybox_overlay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bsharper/MessageBridge/HEAD/public/lib/fancybox/fancybox_overlay.png -------------------------------------------------------------------------------- /public/lib/fancybox/fancybox_sprite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bsharper/MessageBridge/HEAD/public/lib/fancybox/fancybox_sprite.png -------------------------------------------------------------------------------- /public/lib/fancybox/fancybox_sprite@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bsharper/MessageBridge/HEAD/public/lib/fancybox/fancybox_sprite@2x.png -------------------------------------------------------------------------------- /public/lib/fancybox/fancybox_loading@2x.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bsharper/MessageBridge/HEAD/public/lib/fancybox/fancybox_loading@2x.gif -------------------------------------------------------------------------------- /public/font/vendor/sourcesanspro-light-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bsharper/MessageBridge/HEAD/public/font/vendor/sourcesanspro-light-webfont.eot -------------------------------------------------------------------------------- /public/font/vendor/sourcesanspro-light-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bsharper/MessageBridge/HEAD/public/font/vendor/sourcesanspro-light-webfont.ttf -------------------------------------------------------------------------------- /public/lib/fancybox/helpers/fancybox_buttons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bsharper/MessageBridge/HEAD/public/lib/fancybox/helpers/fancybox_buttons.png -------------------------------------------------------------------------------- /public/font/vendor/sourcecodepro-regular-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bsharper/MessageBridge/HEAD/public/font/vendor/sourcecodepro-regular-webfont.eot -------------------------------------------------------------------------------- /public/font/vendor/sourcecodepro-regular-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bsharper/MessageBridge/HEAD/public/font/vendor/sourcecodepro-regular-webfont.ttf -------------------------------------------------------------------------------- /public/font/vendor/sourcesanspro-light-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bsharper/MessageBridge/HEAD/public/font/vendor/sourcesanspro-light-webfont.woff -------------------------------------------------------------------------------- /public/font/vendor/sourcesanspro-regular-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bsharper/MessageBridge/HEAD/public/font/vendor/sourcesanspro-regular-webfont.eot -------------------------------------------------------------------------------- /public/font/vendor/sourcesanspro-regular-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bsharper/MessageBridge/HEAD/public/font/vendor/sourcesanspro-regular-webfont.ttf -------------------------------------------------------------------------------- /public/font/vendor/sourcecodepro-regular-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bsharper/MessageBridge/HEAD/public/font/vendor/sourcecodepro-regular-webfont.woff -------------------------------------------------------------------------------- /public/font/vendor/sourcesanspro-regular-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bsharper/MessageBridge/HEAD/public/font/vendor/sourcesanspro-regular-webfont.woff -------------------------------------------------------------------------------- /public/font/vendor/sourcesanspro-semibold-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bsharper/MessageBridge/HEAD/public/font/vendor/sourcesanspro-semibold-webfont.eot -------------------------------------------------------------------------------- /public/font/vendor/sourcesanspro-semibold-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bsharper/MessageBridge/HEAD/public/font/vendor/sourcesanspro-semibold-webfont.ttf -------------------------------------------------------------------------------- /public/font/vendor/sourcesanspro-semibold-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bsharper/MessageBridge/HEAD/public/font/vendor/sourcesanspro-semibold-webfont.woff -------------------------------------------------------------------------------- /public/js/jquery.emoji.js: -------------------------------------------------------------------------------- 1 | // A very simple jQuery wrapper for js-emoji 2 | $.fn.emoji = function(){ 3 | return this.each(function(){ 4 | $(this).html(function (i, oldHtml){ 5 | return emoji.replace_colons(oldHtml); 6 | }); 7 | }); 8 | }; 9 | -------------------------------------------------------------------------------- /tools/send_message.applescript: -------------------------------------------------------------------------------- 1 | #! /usr/bin/osascript 2 | 3 | 4 | on run(arguments) 5 | set recipient to (first item of arguments) as text 6 | set msg to (second item of arguments) as text 7 | tell application "Messages" 8 | set theChat to chat id recipient 9 | send msg to theChat 10 | end tell 11 | end run -------------------------------------------------------------------------------- /chatSender.js: -------------------------------------------------------------------------------- 1 | var sys = require('sys') 2 | var exec = require('child_process').exec; 3 | function puts(error, stdout, stderr) { sys.puts(stderr); sys.puts(stdout); } 4 | 5 | function sendMessage(txt, guid) { 6 | var cmd = 'osascript tools/send_message.applescript "'+guid+'" "'+txt+'"'; 7 | console.log(cmd); 8 | exec(cmd, puts); 9 | } 10 | 11 | 12 | exports.sendMessage = sendMessage; 13 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "MessageBridge", 3 | "version": "0.0.1", 4 | "description": "Web interface for the Messages app in OS X", 5 | "main": "app.js", 6 | "dependencies": { 7 | "expand-home-dir": "^0.0.2", 8 | "express": "^4.9.7", 9 | "socket.io": "^1.1.0", 10 | "sqlite3": "^3.0.2", 11 | "underscore":"^1.7.0" 12 | }, 13 | "devDependencies": {}, 14 | "scripts": { 15 | "test": "echo \"Error: no test specified\" && exit 1" 16 | }, 17 | "author": "Brian Harper (https://github.com/bsharper)", 18 | "license": "GPLv3" 19 | } 20 | -------------------------------------------------------------------------------- /public/css/emoji.css: -------------------------------------------------------------------------------- 1 | span.emoji { 2 | display: -moz-inline-box; 3 | -moz-box-orient: vertical; 4 | display: inline-block; 5 | vertical-align: baseline; 6 | *vertical-align: auto; 7 | *zoom: 1; 8 | *display: inline; 9 | width: 1em; 10 | height: 1em; 11 | background-size: 1em; 12 | background-repeat: no-repeat; 13 | text-indent: -9999px; 14 | } 15 | 16 | span.emoji-sizer { 17 | line-height: 0.81em; 18 | font-size: 1em; 19 | margin: -2px 0; 20 | } 21 | 22 | span.emoji-outer { 23 | display: -moz-inline-box; 24 | display: inline-block; 25 | *display: inline; 26 | height: 1em; 27 | width: 1em; 28 | } 29 | 30 | span.emoji-inner { 31 | display: -moz-inline-box; 32 | display: inline-block; 33 | text-indent: -9999px; 34 | width: 100%; 35 | height: 100%; 36 | vertical-align: baseline; 37 | *vertical-align: auto; 38 | *zoom: 1; 39 | } 40 | 41 | img.emoji { 42 | width: 1em; 43 | height: 1em; 44 | } 45 | -------------------------------------------------------------------------------- /public/css/typeahead.css: -------------------------------------------------------------------------------- 1 | .tt-query { 2 | -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); 3 | -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); 4 | box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); 5 | } 6 | 7 | .tt-hint { 8 | color: #999 9 | } 10 | 11 | .tt-dropdown-menu { 12 | width: 422px; 13 | margin-top: 12px; 14 | padding: 8px 0; 15 | background-color: #fff; 16 | border: 1px solid #ccc; 17 | border: 1px solid rgba(0, 0, 0, 0.2); 18 | -webkit-border-radius: 8px; 19 | -moz-border-radius: 8px; 20 | border-radius: 8px; 21 | -webkit-box-shadow: 0 5px 10px rgba(0,0,0,.2); 22 | -moz-box-shadow: 0 5px 10px rgba(0,0,0,.2); 23 | box-shadow: 0 5px 10px rgba(0,0,0,.2); 24 | } 25 | 26 | .tt-suggestion { 27 | padding: 3px 20px; 28 | font-size: 18px; 29 | line-height: 24px; 30 | } 31 | 32 | .tt-suggestion.tt-cursor { 33 | color: #fff; 34 | background-color: #0097cf; 35 | 36 | } 37 | 38 | .tt-suggestion p { 39 | margin: 0; 40 | } -------------------------------------------------------------------------------- /public/js/mutate.min.js: -------------------------------------------------------------------------------- 1 | /* @license ! jQuery-mutate - v0.0.1 - 2 | * Licensed under the MIT license 3 | * http://www.opensource.org/licenses/mit-license.php 4 | * Date: 2014-05-19 */ 5 | 6 | !function(a){function b(){var c=mutate;"undefined"!=c.event_stack&&c.event_stack.length&&a.each(c.event_stack,function(a,b){mutate.add_event(b)}),c.event_stack=[],a.each(c.stack,function(b,d){a(d.selector).each(function(a,b){c.events[d.event_name](b)===!0?d.callback&&d.callback(b,d):d.false_callback&&d.false_callback(b,d)})}),setTimeout(b,mutate.speed)}mutate={speed:1,event_stack:mutate_event_stack,stack:[],events:{},add_event:function(a){mutate.events[a.name]=a.handler},add:function(a,b,c,d){mutate.stack[mutate.stack.length]={event_name:a,selector:b,callback:c,false_callback:d}}},b(),a.fn.extend({mutate:function(){var b=!1,c=arguments[1],d=this,e=arguments[2]?arguments[2]:function(){};return"extend"==arguments[0].toLowerCase()?(mutate.add_event(c),this):(a.each(a.trim(arguments[0]).split(" "),function(a,f){b=f,mutate.add(b,d,c,e)}),this)}})}(jQuery); -------------------------------------------------------------------------------- /public/lib/fancybox/helpers/jquery.fancybox-thumbs.css: -------------------------------------------------------------------------------- 1 | #fancybox-thumbs { 2 | position: fixed; 3 | left: 0; 4 | width: 100%; 5 | overflow: hidden; 6 | z-index: 8050; 7 | } 8 | 9 | #fancybox-thumbs.bottom { 10 | bottom: 2px; 11 | } 12 | 13 | #fancybox-thumbs.top { 14 | top: 2px; 15 | } 16 | 17 | #fancybox-thumbs ul { 18 | position: relative; 19 | list-style: none; 20 | margin: 0; 21 | padding: 0; 22 | } 23 | 24 | #fancybox-thumbs ul li { 25 | float: left; 26 | padding: 1px; 27 | opacity: 0.5; 28 | } 29 | 30 | #fancybox-thumbs ul li.active { 31 | opacity: 0.75; 32 | padding: 0; 33 | border: 1px solid #fff; 34 | } 35 | 36 | #fancybox-thumbs ul li:hover { 37 | opacity: 1; 38 | } 39 | 40 | #fancybox-thumbs ul li a { 41 | display: block; 42 | position: relative; 43 | overflow: hidden; 44 | border: 1px solid #222; 45 | background: #111; 46 | outline: none; 47 | } 48 | 49 | #fancybox-thumbs ul li img { 50 | display: block; 51 | position: relative; 52 | border: 0; 53 | padding: 0; 54 | max-width: none; 55 | } -------------------------------------------------------------------------------- /public/css/spinner.css: -------------------------------------------------------------------------------- 1 | .spinner { 2 | margin: 100px auto 0; 3 | width: 70px; 4 | text-align: center; 5 | } 6 | 7 | .spinner > div { 8 | width: 18px; 9 | height: 18px; 10 | background-color: #333; 11 | 12 | border-radius: 100%; 13 | display: inline-block; 14 | -webkit-animation: bouncedelay 1.4s infinite ease-in-out; 15 | animation: bouncedelay 1.4s infinite ease-in-out; 16 | /* Prevent first frame from flickering when animation starts */ 17 | -webkit-animation-fill-mode: both; 18 | animation-fill-mode: both; 19 | } 20 | 21 | .spinner .bounce1 { 22 | -webkit-animation-delay: -0.32s; 23 | animation-delay: -0.32s; 24 | } 25 | 26 | .spinner .bounce2 { 27 | -webkit-animation-delay: -0.16s; 28 | animation-delay: -0.16s; 29 | } 30 | 31 | @-webkit-keyframes bouncedelay { 32 | 0%, 80%, 100% { -webkit-transform: scale(0.0) } 33 | 40% { -webkit-transform: scale(1.0) } 34 | } 35 | 36 | @keyframes bouncedelay { 37 | 0%, 80%, 100% { 38 | transform: scale(0.0); 39 | -webkit-transform: scale(0.0); 40 | } 40% { 41 | transform: scale(1.0); 42 | -webkit-transform: scale(1.0); 43 | } 44 | } -------------------------------------------------------------------------------- /tools/address_export.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | import json, sys 4 | debug = False 5 | 6 | def sanitizeTypes(type, val): 7 | val = val.strip() 8 | if type=='email': 9 | return val.lower() 10 | elif type=='phone': 11 | if val[0:2] == "+1": 12 | val = val[2:] 13 | val = val.replace('(', '').replace(')', '').replace(' ', '').replace('.', '').replace('-', '') 14 | return val 15 | 16 | def exportAddressBook(): 17 | print "Reading address book...", 18 | sys.stdout.flush() 19 | import address_reader 20 | ab = address_reader.addressBookToList() 21 | print "done" 22 | sys.stdout.flush() 23 | gv = ['email', 'phone'] 24 | ar={} 25 | sar = {} 26 | ln = len(ab) 27 | lb = 0 28 | for n, a in enumerate(ab): 29 | msg = "Exporting address book: %d/%d" % (n, ln) 30 | lb = len(msg) 31 | if not debug: 32 | print '\b'*(lb+2), 33 | sys.stdout.flush() 34 | print msg, 35 | sys.stdout.flush() 36 | if 'last' not in a.keys() or 'first' not in a.keys(): 37 | continue 38 | gk = filter(lambda x: x in a.keys(), gv) 39 | nm = "%s %s" % (a['first'], a['last']) 40 | il = [] 41 | sil = [] 42 | for k in gk: 43 | if isinstance(a[k], list): 44 | for z in a[k]: 45 | sil.append(z) 46 | il.append(sanitizeTypes(k, z)) 47 | else: 48 | sil.append(a[k]) 49 | il.append(sanitizeTypes(k, a[k])) 50 | il = list(set(il)) 51 | sil = list(set(sil)) 52 | ar[nm] = il 53 | sar[nm] = sil 54 | print '\b'*(lb+2), 55 | msg = "Exporting address book: %d/%d" % (ln, ln) 56 | print msg 57 | print "Writing json file...", 58 | json.dump(ar, open('address_book.js', 'w')) 59 | json.dump(sar, open('address_book_raw.js', 'w')) 60 | print "done" 61 | 62 | if __name__=="__main__": 63 | exportAddressBook() 64 | -------------------------------------------------------------------------------- /queries.js: -------------------------------------------------------------------------------- 1 | var allChatQuery = (function () {/* 2 | select 3 | chat_id, 4 | guid, 5 | room_name, 6 | people, 7 | most_recent_msg, 8 | account_id 9 | from (select 10 | chj.chat_id, 11 | c.guid, 12 | room_name, 13 | group_concat(distinct h.id) people, 14 | (max(m.date) + 978328800) most_recent_msg, 15 | c.account_id 16 | from 17 | handle h 18 | join chat_handle_join chj on (h.rowid = chj.handle_id) 19 | join chat c on (c.rowid = chj.chat_id) 20 | join chat_message_join cmj on (c.rowid = cmj.chat_id) 21 | join message m on (m.rowid = cmj.message_id) 22 | left join message_attachment_join maj on (maj.message_id = m.rowid) 23 | group by chj.chat_id, room_name) order by most_recent_msg desc 24 | */}).toString().match(/[^]*\/\*([^]*)\*\/\}$/)[1]; 25 | 26 | var chatQuery = (function () {/* 27 | select cmj.message_id, 28 | (select id from handle hi where hi.rowid = m.handle_id) who_from, 29 | is_from_me, cmj.chat_id, m.text, maj.attachment_id, a.mime_type, 30 | (m.date + 978328800) date, c.guid, a.filename, a.uti, a.mime_type 31 | from chat c 32 | join chat_message_join cmj on (c.rowid = cmj.chat_id) 33 | join message m on (m.rowid=cmj.message_id) 34 | left join handle h on (m.handle_id = h.rowid) 35 | left join message_attachment_join maj on (maj.message_id = m.rowid) 36 | left join attachment a on (maj.attachment_id = a.rowid) 37 | where cmj.chat_id = [CHAT_ID] [OTHER_CONST] 38 | order by cmj.chat_id, m.date 39 | */}).toString().match(/[^]*\/\*([^]*)\*\/\}$/)[1]; 40 | 41 | var chatMessageCountsQuery = (function () {/* 42 | select count(1) message_count, cmj.chat_id 43 | from message m 44 | join chat_message_join cmj on (m.rowid = cmj.message_id) 45 | group by chat_id 46 | order by cmj.chat_id 47 | */}).toString().match(/[^]*\/\*([^]*)\*\/\}$/)[1]; 48 | 49 | 50 | exports.allChatQuery = allChatQuery; 51 | exports.chatQuery = chatQuery; 52 | exports.chatMessageCountsQuery = chatMessageCountsQuery; -------------------------------------------------------------------------------- /public/font/vendor/stylesheet.css: -------------------------------------------------------------------------------- 1 | 2 | @font-face { 3 | font-family: 'source-sans-pro'; 4 | src: url('sourcesanspro-light-webfont.eot'); 5 | src: url('sourcesanspro-light-webfont.eot?#iefix') format('embedded-opentype'), 6 | url('sourcesanspro-light-webfont.woff') format('woff'), 7 | url('sourcesanspro-light-webfont.ttf') format('truetype'), 8 | url('sourcesanspro-light-webfont.svg#source_sans_prolight') format('svg'); 9 | font-weight: 300; 10 | font-style: normal; 11 | 12 | } 13 | 14 | 15 | 16 | 17 | @font-face { 18 | font-family: 'source-sans-pro'; 19 | src: url('sourcesanspro-regular-webfont.eot'); 20 | src: url('sourcesanspro-regular-webfont.eot?#iefix') format('embedded-opentype'), 21 | url('sourcesanspro-regular-webfont.woff') format('woff'), 22 | url('sourcesanspro-regular-webfont.ttf') format('truetype'), 23 | url('sourcesanspro-regular-webfont.svg#source_sans_proregular') format('svg'); 24 | font-weight: 400; 25 | font-style: normal; 26 | 27 | } 28 | 29 | 30 | 31 | 32 | @font-face { 33 | font-family: 'source-sans-pro'; 34 | src: url('sourcesanspro-semibold-webfont.eot'); 35 | src: url('sourcesanspro-semibold-webfont.eot?#iefix') format('embedded-opentype'), 36 | url('sourcesanspro-semibold-webfont.woff') format('woff'), 37 | url('sourcesanspro-semibold-webfont.ttf') format('truetype'), 38 | url('sourcesanspro-semibold-webfont.svg#source_sans_prosemibold') format('svg'); 39 | font-weight: 600; 40 | font-style: normal; 41 | 42 | } 43 | 44 | 45 | 46 | 47 | @font-face { 48 | font-family: 'source-code-pro'; 49 | src: url('sourcecodepro-regular-webfont.eot'); 50 | src: url('sourcecodepro-regular-webfont.eot?#iefix') format('embedded-opentype'), 51 | url('sourcecodepro-regular-webfont.woff') format('woff'), 52 | url('sourcecodepro-regular-webfont.ttf') format('truetype'), 53 | url('sourcecodepro-regular-webfont.svg#source_code_proregular') format('svg'); 54 | font-weight: normal; 55 | font-style: normal; 56 | 57 | } -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var app = express(); 3 | var port = 3000; 4 | var io = require('socket.io').listen(app.listen(port)); 5 | var chat = require('./chatReader').chat; 6 | var sendMessage = require('./chatSender').sendMessage; 7 | 8 | app.use(express.static(__dirname + '/public')); 9 | 10 | app.get('/', function (req, res) { 11 | res.sendFile(__dirname + '/public/index.html'); 12 | }); 13 | 14 | app.get('/attachment/:id', function (req, res) { 15 | chat.getAttachmentPath(req.params.id, function (dt) { 16 | res.sendFile(dt.path); 17 | }); 18 | }); 19 | 20 | function chatUpdateTrigger(chat_ids) { 21 | var chats = {}; 22 | console.log('chatUpdate'); 23 | for (var i=0; i li > a { 59 | padding-right: 20px; 60 | padding-left: 20px; 61 | } 62 | .nav-sidebar > .active > a, 63 | .nav-sidebar > .active > a:hover, 64 | .nav-sidebar > .active > a:focus { 65 | color: #fff; 66 | background-color: #428bca; 67 | } 68 | 69 | 70 | /* 71 | * Main content 72 | */ 73 | 74 | .main { 75 | padding: 20px; 76 | } 77 | @media (min-width: 768px) { 78 | .main { 79 | padding-right: 40px; 80 | padding-left: 40px; 81 | } 82 | } 83 | .main .page-header { 84 | margin-top: 0; 85 | } 86 | 87 | 88 | /* 89 | * Placeholder dashboard ideas 90 | */ 91 | 92 | .placeholders { 93 | margin-bottom: 30px; 94 | text-align: center; 95 | } 96 | .placeholders h4 { 97 | margin-bottom: 0; 98 | } 99 | .placeholder { 100 | margin-bottom: 20px; 101 | } 102 | .placeholder img { 103 | display: inline-block; 104 | border-radius: 50%; 105 | } 106 | -------------------------------------------------------------------------------- /public/js/events.min.js: -------------------------------------------------------------------------------- 1 | /* @license ! jQuery-mutate - v0.0.1 - 2 | * Licensed under the MIT license 3 | * http://www.opensource.org/licenses/mit-license.php 4 | * Date: 2014-05-19 */ 5 | 6 | !function(a){mutate_event_stack=[{name:"width",handler:function(b){return n={el:b},a(n.el).data("mutate-width")||a(n.el).data("mutate-width",a(n.el).width()),a(n.el).data("mutate-width")&&a(n.el).width()!=a(n.el).data("mutate-width")?(a(n.el).data("mutate-width",a(n.el).width()),!0):!1}},{name:"height",handler:function(b){return element=b,a(element).data("mutate-height")||a(element).data("mutate-height",a(element).height()),a(element).data("mutate-height")&&a(element).height()!=a(element).data("mutate-height")?(a(element).data("mutate-height",a(element).height()),!0):void 0}},{name:"top",handler:function(b){return a(b).data("mutate-top")||a(b).data("mutate-top",a(b).css("top")),a(b).data("mutate-top")&&a(b).css("top")!=a(b).data("mutate-top")?(a(b).data("mutate-top",a(b).css("top")),!0):void 0}},{name:"bottom",handler:function(b){return a(b).data("mutate-bottom")||a(b).data("mutate-bottom",a(b).css("bottom")),a(b).data("mutate-bottom")&&a(b).css("bottom")!=a(b).data("mutate-bottom")?(a(b).data("mutate-bottom",a(b).css("bottom")),!0):void 0}},{name:"right",handler:function(b){return a(b).data("mutate-right")||a(b).data("mutate-right",a(b).css("right")),a(b).data("mutate-right")&&a(b).css("right")!=a(b).data("mutate-right")?(a(b).data("mutate-right",a(b).css("right")),!0):void 0}},{name:"left",handler:function(b){return a(b).data("mutate-left")||a(b).data("mutate-left",a(b).css("left")),a(b).data("mutate-left")&&a(b).css("left")!=a(b).data("mutate-left")?(a(b).data("mutate-left",a(b).css("left")),!0):void 0}},{name:"hide",handler:function(b){return a(b).is(":hidden")?!0:void 0}},{name:"show",handler:function(b){return a(b).is(":visible")?!0:void 0}},{name:"scrollHeight",handler:function(b){return a(b).data("prev-scrollHeight")||a(b).data("prev-scrollHeight",a(b)[0].scrollHeight),a(b).data("prev-scrollHeight")&&a(b)[0].scrollHeight!=a(b).data("prev-scrollHeight")?(a(b).data("prev-scrollHeight",a(b)[0].scrollHeight),!0):void 0}},{name:"scrollWidth",handler:function(b){return a(b).data("prev-scrollWidth")||a(b).data("prev-scrollWidth",a(b)[0].scrollWidth),a(b).data("prev-scrollWidth")&&a(b)[0].scrollWidth!=a(b).data("prev-scrollWidth")?(a(b).data("prev-scrollWidth",a(b)[0].scrollWidth),!0):void 0}},{name:"scrollTop",handler:function(b){return a(b).data("prev-scrollTop")||a(b).data("prev-scrollTop",a(b)[0].scrollTop()),a(b).data("prev-scrollTop")&&a(b)[0].scrollTop()!=a(b).data("prev-scrollTop")?(a(b).data("prev-scrollTop",a(b)[0].scrollTop()),!0):void 0}},{name:"scrollLeft",handler:function(b){return a(b).data("prev-scrollLeft")||a(b).data("prev-scrollLeft",a(b)[0].scrollLeft()),a(b).data("prev-scrollLeft")&&a(b)[0].scrollLeft()!=a(b).data("prev-scrollLeft")?(a(b).data("prev-scrollLeft",a(b)[0].scrollLeft()),!0):void 0}}]}(jQuery); -------------------------------------------------------------------------------- /public/lib/fancybox/helpers/jquery.fancybox-buttons.css: -------------------------------------------------------------------------------- 1 | #fancybox-buttons { 2 | position: fixed; 3 | left: 0; 4 | width: 100%; 5 | z-index: 8050; 6 | } 7 | 8 | #fancybox-buttons.top { 9 | top: 10px; 10 | } 11 | 12 | #fancybox-buttons.bottom { 13 | bottom: 10px; 14 | } 15 | 16 | #fancybox-buttons ul { 17 | display: block; 18 | width: 166px; 19 | height: 30px; 20 | margin: 0 auto; 21 | padding: 0; 22 | list-style: none; 23 | border: 1px solid #111; 24 | border-radius: 3px; 25 | -webkit-box-shadow: inset 0 0 0 1px rgba(255,255,255,.05); 26 | -moz-box-shadow: inset 0 0 0 1px rgba(255,255,255,.05); 27 | box-shadow: inset 0 0 0 1px rgba(255,255,255,.05); 28 | background: rgb(50,50,50); 29 | background: -moz-linear-gradient(top, rgb(68,68,68) 0%, rgb(52,52,52) 50%, rgb(41,41,41) 50%, rgb(51,51,51) 100%); 30 | background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgb(68,68,68)), color-stop(50%,rgb(52,52,52)), color-stop(50%,rgb(41,41,41)), color-stop(100%,rgb(51,51,51))); 31 | background: -webkit-linear-gradient(top, rgb(68,68,68) 0%,rgb(52,52,52) 50%,rgb(41,41,41) 50%,rgb(51,51,51) 100%); 32 | background: -o-linear-gradient(top, rgb(68,68,68) 0%,rgb(52,52,52) 50%,rgb(41,41,41) 50%,rgb(51,51,51) 100%); 33 | background: -ms-linear-gradient(top, rgb(68,68,68) 0%,rgb(52,52,52) 50%,rgb(41,41,41) 50%,rgb(51,51,51) 100%); 34 | background: linear-gradient(top, rgb(68,68,68) 0%,rgb(52,52,52) 50%,rgb(41,41,41) 50%,rgb(51,51,51) 100%); 35 | filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#444444', endColorstr='#222222',GradientType=0 ); 36 | } 37 | 38 | #fancybox-buttons ul li { 39 | float: left; 40 | margin: 0; 41 | padding: 0; 42 | } 43 | 44 | #fancybox-buttons a { 45 | display: block; 46 | width: 30px; 47 | height: 30px; 48 | text-indent: -9999px; 49 | background-color: transparent; 50 | background-image: url('fancybox_buttons.png'); 51 | background-repeat: no-repeat; 52 | outline: none; 53 | opacity: 0.8; 54 | } 55 | 56 | #fancybox-buttons a:hover { 57 | opacity: 1; 58 | } 59 | 60 | #fancybox-buttons a.btnPrev { 61 | background-position: 5px 0; 62 | } 63 | 64 | #fancybox-buttons a.btnNext { 65 | background-position: -33px 0; 66 | border-right: 1px solid #3e3e3e; 67 | } 68 | 69 | #fancybox-buttons a.btnPlay { 70 | background-position: 0 -30px; 71 | } 72 | 73 | #fancybox-buttons a.btnPlayOn { 74 | background-position: -30px -30px; 75 | } 76 | 77 | #fancybox-buttons a.btnToggle { 78 | background-position: 3px -60px; 79 | border-left: 1px solid #111; 80 | border-right: 1px solid #3e3e3e; 81 | width: 35px 82 | } 83 | 84 | #fancybox-buttons a.btnToggleOn { 85 | background-position: -27px -60px; 86 | } 87 | 88 | #fancybox-buttons a.btnClose { 89 | border-left: 1px solid #111; 90 | width: 35px; 91 | background-position: -56px 0px; 92 | } 93 | 94 | #fancybox-buttons a.btnDisabled { 95 | opacity : 0.4; 96 | cursor: default; 97 | } -------------------------------------------------------------------------------- /addressbook.js: -------------------------------------------------------------------------------- 1 | var _ = require('underscore')._; 2 | var fs = require('fs'); 3 | var ab = {}; 4 | var addressbookData = {}; 5 | var me = "Me"; 6 | var useFakeNames = true; 7 | var fakeNames = ['Aaron Johnson','Alan Wiley','Alfred Rowe','Anastasia Mitchell','Andrea Leon','Andrew Mastrangelo','Andrew Moyer','Antonietta McDonnell','Betty Jackson','Brian Walker','Calvin Thorpe','Caryn Cooper','Charlene Melanson','Colleen Jenkins','Cynthia Ackman','Dalia Drye','Dana Meeks','Darrin Cochran','Darrin Phillips','Dawn Branham','Della Solomon','Dennis Smith','Don Richter','Donald Howard','Dustin Denton','Dwayne Edmiston','Edith Harper','Elizabeth Ballard','Elizabeth Jarrett','Elizabeth Pouncy','Eric Carson','Forest Wilson','Francisco Cisneros','Gerard Turner','Gertrude Foust','Graciela Kash','Harley Garay','Harold Moore','Hugo Kiser','Ian Chaffee','Ira Laguna','Janet Arrington','Jeffery Kim','Jenna Godwin','Jennifer Hughes','Jesus Ward','Jill White','Jimmy Bryant','John Henry','John Noland','Joseph Barrera','Joyce Wright','Karen Taylor','Kevin Rich','Kimberly Deltoro','Lamar Hurtado','Larry Rayes','Leona Herrington','Lloyd Williams','Lynn Bullock','Mark Scott','Marshall Miller','Martha Jacobs','Mary Palmer','Mary Valenzuela','Maude Campo','Michael Lunsford','Molly Flores','Monica Farrell','Morgan Skidmore','Nicholas Dixon','Oliva Johnston','Peggy Kastner','Peggy Schoen','Phillip Rosas','Ray Takacs','Raymon Ferris','Rebecca Adams','Richard Lundy','Richard Smith','Richard Vargas','Robin Connelly','Ruben Anderson','Russell Lafleur','Samuel Monroe','Sandra Wright','Santiago Cash','Shawna Veliz','Suzanne Burleson','Teresa Charles','Tessa Bobbitt','Thomas Lutz','Thomas Murillo','Tina Moyer','Valerie Hamilton','Veronica Hill','Warren Thomas','Wesley Harris','William Levin','Young Fox']; 8 | 9 | function cleanText(txt) { 10 | if ((txt||"").length == 0) return ""; 11 | return txt.replace(/\(/g, '').replace(/\)/g, '').replace(/ /g, '').replace(/\./g, '').replace(/-/g, '').replace('+1',''); 12 | } 13 | 14 | function getSanitizedData() { 15 | var abook = {}; 16 | try { 17 | var ab = JSON.parse(fs.readFileSync('tools/address_book.js').toString()); 18 | } catch (e) { 19 | console.log('Could not open address_book.js'); 20 | return {}; 21 | } 22 | addressbookData = ab; 23 | Object.keys(ab).forEach(function (k) { 24 | var ar = ab[k]; 25 | var items = []; 26 | for (var i=0; i -1) { 43 | return k; 44 | } 45 | } 46 | return val; 47 | } 48 | function _lookupName(val) { 49 | if ((val||"").length == 0) return {value:"Me", lookupValue:"Me"}; 50 | var nm = findName(val); 51 | return {value:val, lookupValue:nm}; 52 | } 53 | function _fakeNameLookup(val) { 54 | if ((val||"").length == 0) return {value:"Me", lookupValue:"Me"}; 55 | var nm = _.sample(fakeNames); 56 | return {value:val, lookupValue:nm}; 57 | } 58 | var lookupName = _.memoize(_lookupName); 59 | if (useFakeNames) lookupName = _.memoize(_fakeNameLookup); 60 | ab = getSanitizedData(); 61 | 62 | exports.lookupName = lookupName; 63 | exports.addressbookData = addressbookData; 64 | -------------------------------------------------------------------------------- /tools/address_reader.py: -------------------------------------------------------------------------------- 1 | from AddressBook import * 2 | import pprint 3 | 4 | def addressBookToList(): 5 | """ 6 | Read the current user's AddressBook database, converting each person 7 | in the address book into a Dictionary of values. Some values (addresses, 8 | phone numbers, email, etc) can have multiple values, in which case a 9 | list of all of those values is stored. The result of this method is 10 | a List of Dictionaries, with each person represented by a single record 11 | in the list. 12 | """ 13 | # get the shared addressbook and the list of 14 | # people from the book. 15 | ab = ABAddressBook.sharedAddressBook() 16 | people = ab.people() 17 | 18 | peopleList = [] 19 | 20 | # convert the ABPerson to a hash 21 | for person in people: 22 | thisPerson = {} 23 | props = person.allProperties() 24 | for prop in props: 25 | 26 | # skip some properties 27 | if prop == "com.apple.ABPersonMeProperty": 28 | continue 29 | elif prop == "com.apple.ABImageData": 30 | continue 31 | 32 | # How we convert the value depends on the ObjC 33 | # class used to represent it 34 | val = person.valueForProperty_(prop) 35 | if type(val) == objc.pyobjc_unicode: 36 | # Unicode String 37 | thisPerson[prop.lower()] = val 38 | elif issubclass(val.__class__, NSDate): 39 | # NSDate 40 | thisPerson[prop.lower()] = val.description() 41 | elif type(val) == ABMultiValueCoreDataWrapper: 42 | # List -- convert each item in the list 43 | # into the proper format 44 | thisPerson[prop.lower()] = [] 45 | for valIndex in range(0, val.count()): 46 | indexedValue = val.valueAtIndex_(valIndex) 47 | if type(indexedValue) == objc.pyobjc_unicode: 48 | # Unicode string 49 | thisPerson[prop.lower()].append(indexedValue) 50 | elif issubclass(indexedValue.__class__, NSDate): 51 | # Date 52 | thisPerson[prop.lower()].append(indexedValue.description()) 53 | elif type(indexedValue) == NSCFDictionary: 54 | # NSDictionary -- convert to a Python Dictionary 55 | propDict = {} 56 | for propKey in indexedValue.keys(): 57 | propValue = indexedValue[propKey] 58 | propDict[propKey.lower()] = propValue 59 | thisPerson[prop.lower()].append(propDict) 60 | peopleList.append(thisPerson) 61 | return peopleList 62 | -------------------------------------------------------------------------------- /public/js/jquery.linkify.min.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Linkify - v1.1.6 3 | * Find URLs in plain text and return HTML for discovered links. 4 | * https://github.com/HitSend/jQuery-linkify/ 5 | * 6 | * Made by SoapBox Innovations, Inc. 7 | * Under MIT License 8 | */ 9 | !function(a,b,c){"use strict";function d(a,b){this._defaults=e,this.element=a,this.setOptions(b),this.init()}var e={tagName:"a",newLine:"\n",target:"_blank",linkClass:null,linkClasses:[],linkAttributes:null};d.prototype={constructor:d,init:function(){1===this.element.nodeType?d.linkifyNode.call(this,this.element):this.element=d.linkify.call(this,this.element.toString())},setOptions:function(a){this.settings=d.extendSettings(a,this.settings)},toString:function(){return this.element.toString()}},d.extendSettings=function(a,b){var c;b=b||{};for(c in e)b[c]||(b[c]=e[c]);for(c in a)b[c]=a[c];return b},d.linkMatch=new RegExp(["(",'\\s|[^a-zA-Z0-9.\\+_\\/"\\>\\-]|^',")(?:","(","[a-zA-Z0-9\\+_\\-]+","(?:","\\.[a-zA-Z0-9\\+_\\-]+",")*@",")?(","http:\\/\\/|https:\\/\\/|ftp:\\/\\/",")?(","(?:(?:[a-z0-9][a-z0-9_%\\-_+]*\\.)+)",")(","(?:com|ca|co|edu|gov|net|org|dev|biz|cat|int|pro|tel|mil|aero|asia|coop|info|jobs|mobi|museum|name|post|travel|local|[a-z]{2})",")(","(?::\\d{1,5})",")?(","(?:","[\\/|\\?]","(?:","[\\-a-zA-Z0-9_%#*&+=~!?,;:.\\/]*",")*",")","[\\-\\/a-zA-Z0-9_%#*&+=~]","|","\\/?",")?",")(",'[^a-zA-Z0-9\\+_\\/"\\<\\-]|$',")"].join(""),"g"),d.emailLinkMatch=/(<[a-z]+ href=\")(http:\/\/)([a-zA-Z0-9\+_\-]+(?:\.[a-zA-Z0-9\+_\-]+)*@)/g,d.linkify=function(a,b){var c,e,f,g=[];this.constructor===d&&this.settings?(e=this.settings,b&&(e=d.extendSettings(b,e))):e=d.extendSettings(b),f=e.linkClass?e.linkClass.split(/\s+/):[],f.push.apply(f,e.linkClasses),a=a.replace(/$2$3$4$5$6$7$8"),a=a.replace(d.linkMatch,g.join(" ")),a=a.replace(d.emailLinkMatch,"$1mailto:$3"),a=a.replace(/(\s){2}/g,"$1"),a=a.replace(/\n/g,e.newLine)},d.linkifyNode=function(a){var b,e,f,g,h;if(a&&"object"==typeof a&&1===a.nodeType&&"a"!==a.tagName.toLowerCase()&&!/[^\s]linkified[\s$]/.test(a.className)){for(b=[],g=d._dummyElement||c.createElement("div"),e=a.firstChild,f=a.childElementCount;e;){if(3===e.nodeType){for(;g.firstChild;)g.removeChild(g.firstChild);for(g.innerHTML=d.linkify.call(this,e.textContent||e.innerText||e.nodeValue),b.push.apply(b,g.childNodes);g.firstChild;)g.removeChild(g.firstChild)}else 1===e.nodeType?b.push(d.linkifyNode(e)):b.push(e);e=e.nextSibling}for(;a.firstChild;)a.removeChild(a.firstChild);for(h=0;h
' 26 | }, 27 | 28 | list : null, 29 | buttons: null, 30 | 31 | beforeLoad: function (opts, obj) { 32 | //Remove self if gallery do not have at least two items 33 | 34 | if (opts.skipSingle && obj.group.length < 2) { 35 | obj.helpers.buttons = false; 36 | obj.closeBtn = true; 37 | 38 | return; 39 | } 40 | 41 | //Increase top margin to give space for buttons 42 | obj.margin[ opts.position === 'bottom' ? 2 : 0 ] += 30; 43 | }, 44 | 45 | onPlayStart: function () { 46 | if (this.buttons) { 47 | this.buttons.play.attr('title', 'Pause slideshow').addClass('btnPlayOn'); 48 | } 49 | }, 50 | 51 | onPlayEnd: function () { 52 | if (this.buttons) { 53 | this.buttons.play.attr('title', 'Start slideshow').removeClass('btnPlayOn'); 54 | } 55 | }, 56 | 57 | afterShow: function (opts, obj) { 58 | var buttons = this.buttons; 59 | 60 | if (!buttons) { 61 | this.list = $(opts.tpl).addClass(opts.position).appendTo('body'); 62 | 63 | buttons = { 64 | prev : this.list.find('.btnPrev').click( F.prev ), 65 | next : this.list.find('.btnNext').click( F.next ), 66 | play : this.list.find('.btnPlay').click( F.play ), 67 | toggle : this.list.find('.btnToggle').click( F.toggle ), 68 | close : this.list.find('.btnClose').click( F.close ) 69 | } 70 | } 71 | 72 | //Prev 73 | if (obj.index > 0 || obj.loop) { 74 | buttons.prev.removeClass('btnDisabled'); 75 | } else { 76 | buttons.prev.addClass('btnDisabled'); 77 | } 78 | 79 | //Next / Play 80 | if (obj.loop || obj.index < obj.group.length - 1) { 81 | buttons.next.removeClass('btnDisabled'); 82 | buttons.play.removeClass('btnDisabled'); 83 | 84 | } else { 85 | buttons.next.addClass('btnDisabled'); 86 | buttons.play.addClass('btnDisabled'); 87 | } 88 | 89 | this.buttons = buttons; 90 | 91 | this.onUpdate(opts, obj); 92 | }, 93 | 94 | onUpdate: function (opts, obj) { 95 | var toggle; 96 | 97 | if (!this.buttons) { 98 | return; 99 | } 100 | 101 | toggle = this.buttons.toggle.removeClass('btnDisabled btnToggleOn'); 102 | 103 | //Size toggle button 104 | if (obj.canShrink) { 105 | toggle.addClass('btnToggleOn'); 106 | 107 | } else if (!obj.canExpand) { 108 | toggle.addClass('btnDisabled'); 109 | } 110 | }, 111 | 112 | beforeClose: function () { 113 | if (this.list) { 114 | this.list.remove(); 115 | } 116 | 117 | this.list = null; 118 | this.buttons = null; 119 | } 120 | }; 121 | 122 | }(jQuery)); 123 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | MessageBridge 2 | ============= 3 | 4 | ![Alt text](https://raw.githubusercontent.com/bsharper/MessageBridge/master/screenshot.jpg "MessageBridge in action") 5 | MessageBridge is a web-based front-end for Messages. It correctly renders most pictures and video attachments and auto-updates when new message is received. 6 | 7 | # Quickstart 8 | 9 | This is if you already have Xcode installed. 10 | 11 | You should just be able to run 12 | ``` 13 | npm install 14 | ``` 15 | And then 16 | ``` 17 | node app.js 18 | ``` 19 | Then go to localhost:3000 in your browser. To add contact lookup, go to the tools directory and run 20 | ``` 21 | python address_export.py 22 | ``` 23 | This will create two files address_book.js and address_book_raw.js. Run node app.js again and it will use the contacts from those two files when it renders the conversations. 24 | 25 | # Installation 26 | You'll need to install Node (http://nodejs.org/download/) and Xcode (https://itunes.apple.com/us/app/xcode/id497799835?mt=12). Once those are both installed go through the steps below. 27 | 28 | 1. Open Terminal (Spotlight search for it or look under Applications/Utilities) 29 | 2. Type "xcode-select --install" and press enter. It may ask you to agree to something, I can't remember. Complete the Xcode command-line installation. 30 | 3. Change to the directory where you want these files to be. If you don't know/care, just type "cd Desktop" and press enter. 31 | 4. Type "git clone https://github.com/bsharper/MessageBridge.git" and press enter. 32 | 5. Type "cd MessageBridge" and press enter. 33 | 6. Type "npm install" and press enter. 34 | 7. Type "cd tools" and press enter. 35 | 8. Type "python address_export.py" and press enter. Type "ls" and enter and make sure "address_book.js" and "address_book_raw.js" have been generated (if you see an errors or they aren't there, let me know) 36 | 9. Type "cd .." and press enter. 37 | 10. Type "node app.js" and press enter. The application should now be running (it should print "Database opened...") 38 | 11. Go to a browser (Chrome, Safari or Firefox should work). In the address bar type "localhost:3000" and press enter. 39 | 12. 40 | To start the program again, you just need steps 1, 3, 5 and 10. If you updated your address book rerun 7, 8 and 9. 41 | 42 | 43 | # Behind the scenes 44 | The messages are retrieved from the '~/Library/Messages/chat.db' sqlite database that Messages uses to store the messages. The queries that retrieve this information are (hackishly) stored in queries.js. When you send a message, send_message.applescript is called to actually send the message. 45 | 46 | # What doesn't work 47 | ### Starting a new chat 48 | Starting a new chat currently isn't implemented. When you click on the New button, the dialog that will eventually be used to send messages is shown. I still have to get typeahead.js fully working with the address book data. 49 | 50 | ### Probably lots of other stuff 51 | The majority of the code was written on one very long night, so lots of things could break on other browsers or systems. This has been tested on the latest version of Yosemite and mostly with Chrome. Currently, there is no image manipulation to create thumbnails, so very large images are loaded in place. Also on chats with a lot of attachments, it's very difficult to determine when everything has stopped rendering so you may see the chat jump around a little bit. 52 | 53 | # Why? 54 | I use this to remote in to my Mac over SSH and forward port 3000 to my local machine so I can type text messages. Eventually it would be great if this could evolve to easily access Messages remotely, since iCloud doesn't have a Messages interface. 55 | 56 | # What's next? 57 | Starting new chats, handling location attachment, possibly sending pictures or videos through the interface. 58 | -------------------------------------------------------------------------------- /public/css/main.css: -------------------------------------------------------------------------------- 1 | html, body { 2 | margin: 0; 3 | -webkit-font-smoothing: antialiased; 4 | } 5 | .uChatList { 6 | border-right: 1px solid black; 7 | } 8 | .uChatList li { 9 | padding-left: 10px; 10 | padding-right: 10px; 11 | width: 100%; 12 | font-size: 1.1em; 13 | border-bottom: 1px solid #D0D0D0; 14 | background-color: rgb(246,246,246); 15 | -webkit-transition: all 300ms ease-out; 16 | -moz-transition: all 300ms ease-out; 17 | -ms-transition: all 300ms ease-out; 18 | -o-transition: all 300ms ease-out; 19 | transition: all 300ms ease-out; 20 | cursor: pointer; 21 | float:left; 22 | } 23 | .contact-list-button { 24 | 25 | } 26 | .contact-list-button-span { 27 | color:white; 28 | } 29 | .uChatList li:hover { 30 | background-color: #ACBDDA; 31 | color: black; 32 | } 33 | .uChatList li.active { 34 | background-color:rgb(17,96,206); 35 | color:white; 36 | } 37 | .chat-person { 38 | font-weight:400; 39 | } 40 | .chat-timestamp { 41 | float:right; 42 | } 43 | 44 | .msg-left { 45 | float: left; 46 | clear: both; 47 | margin-right: 75px; 48 | background-color: #e5e5ea; 49 | } 50 | .msg-right { 51 | float: right; 52 | clear: both; 53 | margin-left: 75px; 54 | background-color: #4787f8; 55 | color:white; 56 | } 57 | .msg-sms { 58 | background-color: rgb(28,187,72); 59 | color:white; 60 | } 61 | .msg { 62 | display: inline-block; 63 | 64 | margin-top: 5px; 65 | font-size: 1.1em; 66 | border: 0.5px solid rgba(71, 71, 71, 0.5); 67 | -webkit-border-radius: 20px 20px 20px 20px; 68 | border-radius: 20px 20px 20px 20px; 69 | padding: 10px; 70 | -webkit-box-shadow: 0px 0px 2px 1px rgba(71, 71, 71, 0.37); 71 | box-shadow: 0px 0px 2px 1px rgba(71, 71, 71, 0.37); 72 | } 73 | .new-message-button { 74 | /* 75 | margin: 15px; 76 | */ 77 | } 78 | 79 | .msg-left a:link { 80 | color: rgb(58,33,234); 81 | text-decoration: underline; 82 | } 83 | .msg-left a:visited { 84 | color: rgb(58,33,234); 85 | text-decoration: underline; 86 | } 87 | .msg-left a:hover { 88 | color: rgb(58,33,234); 89 | text-decoration: underline; 90 | } 91 | .msg-left a:active { 92 | color: rgb(58,33,234); 93 | text-decoration: underline; 94 | } 95 | .msg-right a:link { 96 | color: white; 97 | text-decoration: underline; 98 | } 99 | .msg-right a:visited { 100 | color: white; 101 | text-decoration: underline; 102 | } 103 | .msg-right a:hover { 104 | color: white; 105 | text-decoration: underline; 106 | } 107 | .msg-right a:active { 108 | color: white; 109 | text-decoration: underline; 110 | } 111 | .msg:last-of-type { 112 | margin-bottom: 50px; 113 | } 114 | .msg-sender { 115 | font-weight: bold; 116 | } 117 | .msg-media { 118 | text-align: center; 119 | } 120 | .msg-timestamp { 121 | font-style: italic; 122 | font-size: 0.8em; 123 | } 124 | .msg-bottom { 125 | background-color: white; 126 | color:white; 127 | border: 0; 128 | border-radius: 0; 129 | -webkit-box-shadow: none; 130 | box-shadow: none; 131 | } 132 | .msg-pending { 133 | opacity: 0.8; 134 | } 135 | .contactSearch { 136 | min-width: 200px; 137 | } 138 | /* 139 | .attachment-image-wrapper { 140 | width: 400px; 141 | height: 200px; 142 | } 143 | */ 144 | .attachment-image { 145 | max-width: 400px; 146 | max-height: 200px; 147 | } 148 | video { 149 | width:100%; 150 | max-width:300px; 151 | height:auto; 152 | } 153 | 154 | #messageHeaderWrapper { 155 | background-color: white; 156 | width:100%; 157 | margin-top:-20px; 158 | margin-left:-20px; 159 | margin-right:-20px; 160 | margin-bottom:40px; 161 | } 162 | 163 | .chatInput { 164 | bottom: 0px; 165 | position: absolute; 166 | width: 100%; 167 | left: 0; 168 | margin-top: -50px; 169 | z-index: 100; 170 | } 171 | .chatInput input { 172 | width: 100%; 173 | font-size: 1.2em; 174 | } 175 | #chatView { 176 | margin-bottom: 50px; 177 | } 178 | .bottom-anchor { 179 | position:absolute; 180 | bottom:0; 181 | } 182 | 183 | @media (max-width: 767px) { 184 | .row { 185 | margin-top:6px; 186 | } 187 | .uChatList li { 188 | font-size:1.5em; 189 | padding-top: 5px; 190 | padding-bottom: 5px; 191 | } 192 | .chat-timestamp { 193 | font-weight: lighter; 194 | } 195 | #messageHeader { 196 | margin-left: 5px; 197 | } 198 | } -------------------------------------------------------------------------------- /public/lib/fancybox/helpers/jquery.fancybox-thumbs.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * Thumbnail helper for fancyBox 3 | * version: 1.0.7 (Mon, 01 Oct 2012) 4 | * @requires fancyBox v2.0 or later 5 | * 6 | * Usage: 7 | * $(".fancybox").fancybox({ 8 | * helpers : { 9 | * thumbs: { 10 | * width : 50, 11 | * height : 50 12 | * } 13 | * } 14 | * }); 15 | * 16 | */ 17 | (function ($) { 18 | //Shortcut for fancyBox object 19 | var F = $.fancybox; 20 | 21 | //Add helper object 22 | F.helpers.thumbs = { 23 | defaults : { 24 | width : 50, // thumbnail width 25 | height : 50, // thumbnail height 26 | position : 'bottom', // 'top' or 'bottom' 27 | source : function ( item ) { // function to obtain the URL of the thumbnail image 28 | var href; 29 | 30 | if (item.element) { 31 | href = $(item.element).find('img').attr('src'); 32 | } 33 | 34 | if (!href && item.type === 'image' && item.href) { 35 | href = item.href; 36 | } 37 | 38 | return href; 39 | } 40 | }, 41 | 42 | wrap : null, 43 | list : null, 44 | width : 0, 45 | 46 | init: function (opts, obj) { 47 | var that = this, 48 | list, 49 | thumbWidth = opts.width, 50 | thumbHeight = opts.height, 51 | thumbSource = opts.source; 52 | 53 | //Build list structure 54 | list = ''; 55 | 56 | for (var n = 0; n < obj.group.length; n++) { 57 | list += '
  • '; 58 | } 59 | 60 | this.wrap = $('
    ').addClass(opts.position).appendTo('body'); 61 | this.list = $('
      ' + list + '
    ').appendTo(this.wrap); 62 | 63 | //Load each thumbnail 64 | $.each(obj.group, function (i) { 65 | var href = thumbSource( obj.group[ i ] ); 66 | 67 | if (!href) { 68 | return; 69 | } 70 | 71 | $("").load(function () { 72 | var width = this.width, 73 | height = this.height, 74 | widthRatio, heightRatio, parent; 75 | 76 | if (!that.list || !width || !height) { 77 | return; 78 | } 79 | 80 | //Calculate thumbnail width/height and center it 81 | widthRatio = width / thumbWidth; 82 | heightRatio = height / thumbHeight; 83 | 84 | parent = that.list.children().eq(i).find('a'); 85 | 86 | if (widthRatio >= 1 && heightRatio >= 1) { 87 | if (widthRatio > heightRatio) { 88 | width = Math.floor(width / heightRatio); 89 | height = thumbHeight; 90 | 91 | } else { 92 | width = thumbWidth; 93 | height = Math.floor(height / widthRatio); 94 | } 95 | } 96 | 97 | $(this).css({ 98 | width : width, 99 | height : height, 100 | top : Math.floor(thumbHeight / 2 - height / 2), 101 | left : Math.floor(thumbWidth / 2 - width / 2) 102 | }); 103 | 104 | parent.width(thumbWidth).height(thumbHeight); 105 | 106 | $(this).hide().appendTo(parent).fadeIn(300); 107 | 108 | }).attr('src', href); 109 | }); 110 | 111 | //Set initial width 112 | this.width = this.list.children().eq(0).outerWidth(true); 113 | 114 | this.list.width(this.width * (obj.group.length + 1)).css('left', Math.floor($(window).width() * 0.5 - (obj.index * this.width + this.width * 0.5))); 115 | }, 116 | 117 | beforeLoad: function (opts, obj) { 118 | //Remove self if gallery do not have at least two items 119 | if (obj.group.length < 2) { 120 | obj.helpers.thumbs = false; 121 | 122 | return; 123 | } 124 | 125 | //Increase bottom margin to give space for thumbs 126 | obj.margin[ opts.position === 'top' ? 0 : 2 ] += ((opts.height) + 15); 127 | }, 128 | 129 | afterShow: function (opts, obj) { 130 | //Check if exists and create or update list 131 | if (this.list) { 132 | this.onUpdate(opts, obj); 133 | 134 | } else { 135 | this.init(opts, obj); 136 | } 137 | 138 | //Set active element 139 | this.list.children().removeClass('active').eq(obj.index).addClass('active'); 140 | }, 141 | 142 | //Center list 143 | onUpdate: function (opts, obj) { 144 | if (this.list) { 145 | this.list.stop(true).animate({ 146 | 'left': Math.floor($(window).width() * 0.5 - (obj.index * this.width + this.width * 0.5)) 147 | }, 150); 148 | } 149 | }, 150 | 151 | beforeClose: function () { 152 | if (this.wrap) { 153 | this.wrap.remove(); 154 | } 155 | 156 | this.wrap = null; 157 | this.list = null; 158 | this.width = 0; 159 | } 160 | } 161 | 162 | }(jQuery)); -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Message Bridge 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 46 |
    47 |
    48 | 51 |
    52 |
    53 |

    54 |
    55 |
    56 |
    57 |
    58 |
    59 |
    60 |
    61 | 62 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /public/lib/fancybox/helpers/jquery.fancybox-media.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * Media helper for fancyBox 3 | * version: 1.0.6 (Fri, 14 Jun 2013) 4 | * @requires fancyBox v2.0 or later 5 | * 6 | * Usage: 7 | * $(".fancybox").fancybox({ 8 | * helpers : { 9 | * media: true 10 | * } 11 | * }); 12 | * 13 | * Set custom URL parameters: 14 | * $(".fancybox").fancybox({ 15 | * helpers : { 16 | * media: { 17 | * youtube : { 18 | * params : { 19 | * autoplay : 0 20 | * } 21 | * } 22 | * } 23 | * } 24 | * }); 25 | * 26 | * Or: 27 | * $(".fancybox").fancybox({, 28 | * helpers : { 29 | * media: true 30 | * }, 31 | * youtube : { 32 | * autoplay: 0 33 | * } 34 | * }); 35 | * 36 | * Supports: 37 | * 38 | * Youtube 39 | * http://www.youtube.com/watch?v=opj24KnzrWo 40 | * http://www.youtube.com/embed/opj24KnzrWo 41 | * http://youtu.be/opj24KnzrWo 42 | * http://www.youtube-nocookie.com/embed/opj24KnzrWo 43 | * Vimeo 44 | * http://vimeo.com/40648169 45 | * http://vimeo.com/channels/staffpicks/38843628 46 | * http://vimeo.com/groups/surrealism/videos/36516384 47 | * http://player.vimeo.com/video/45074303 48 | * Metacafe 49 | * http://www.metacafe.com/watch/7635964/dr_seuss_the_lorax_movie_trailer/ 50 | * http://www.metacafe.com/watch/7635964/ 51 | * Dailymotion 52 | * http://www.dailymotion.com/video/xoytqh_dr-seuss-the-lorax-premiere_people 53 | * Twitvid 54 | * http://twitvid.com/QY7MD 55 | * Twitpic 56 | * http://twitpic.com/7p93st 57 | * Instagram 58 | * http://instagr.am/p/IejkuUGxQn/ 59 | * http://instagram.com/p/IejkuUGxQn/ 60 | * Google maps 61 | * http://maps.google.com/maps?q=Eiffel+Tower,+Avenue+Gustave+Eiffel,+Paris,+France&t=h&z=17 62 | * http://maps.google.com/?ll=48.857995,2.294297&spn=0.007666,0.021136&t=m&z=16 63 | * http://maps.google.com/?ll=48.859463,2.292626&spn=0.000965,0.002642&t=m&z=19&layer=c&cbll=48.859524,2.292532&panoid=YJ0lq28OOy3VT2IqIuVY0g&cbp=12,151.58,,0,-15.56 64 | */ 65 | (function ($) { 66 | "use strict"; 67 | 68 | //Shortcut for fancyBox object 69 | var F = $.fancybox, 70 | format = function( url, rez, params ) { 71 | params = params || ''; 72 | 73 | if ( $.type( params ) === "object" ) { 74 | params = $.param(params, true); 75 | } 76 | 77 | $.each(rez, function(key, value) { 78 | url = url.replace( '$' + key, value || '' ); 79 | }); 80 | 81 | if (params.length) { 82 | url += ( url.indexOf('?') > 0 ? '&' : '?' ) + params; 83 | } 84 | 85 | return url; 86 | }; 87 | 88 | //Add helper object 89 | F.helpers.media = { 90 | defaults : { 91 | youtube : { 92 | matcher : /(youtube\.com|youtu\.be|youtube-nocookie\.com)\/(watch\?v=|v\/|u\/|embed\/?)?(videoseries\?list=(.*)|[\w-]{11}|\?listType=(.*)&list=(.*)).*/i, 93 | params : { 94 | autoplay : 1, 95 | autohide : 1, 96 | fs : 1, 97 | rel : 0, 98 | hd : 1, 99 | wmode : 'opaque', 100 | enablejsapi : 1 101 | }, 102 | type : 'iframe', 103 | url : '//www.youtube.com/embed/$3' 104 | }, 105 | vimeo : { 106 | matcher : /(?:vimeo(?:pro)?.com)\/(?:[^\d]+)?(\d+)(?:.*)/, 107 | params : { 108 | autoplay : 1, 109 | hd : 1, 110 | show_title : 1, 111 | show_byline : 1, 112 | show_portrait : 0, 113 | fullscreen : 1 114 | }, 115 | type : 'iframe', 116 | url : '//player.vimeo.com/video/$1' 117 | }, 118 | metacafe : { 119 | matcher : /metacafe.com\/(?:watch|fplayer)\/([\w\-]{1,10})/, 120 | params : { 121 | autoPlay : 'yes' 122 | }, 123 | type : 'swf', 124 | url : function( rez, params, obj ) { 125 | obj.swf.flashVars = 'playerVars=' + $.param( params, true ); 126 | 127 | return '//www.metacafe.com/fplayer/' + rez[1] + '/.swf'; 128 | } 129 | }, 130 | dailymotion : { 131 | matcher : /dailymotion.com\/video\/(.*)\/?(.*)/, 132 | params : { 133 | additionalInfos : 0, 134 | autoStart : 1 135 | }, 136 | type : 'swf', 137 | url : '//www.dailymotion.com/swf/video/$1' 138 | }, 139 | twitvid : { 140 | matcher : /twitvid\.com\/([a-zA-Z0-9_\-\?\=]+)/i, 141 | params : { 142 | autoplay : 0 143 | }, 144 | type : 'iframe', 145 | url : '//www.twitvid.com/embed.php?guid=$1' 146 | }, 147 | twitpic : { 148 | matcher : /twitpic\.com\/(?!(?:place|photos|events)\/)([a-zA-Z0-9\?\=\-]+)/i, 149 | type : 'image', 150 | url : '//twitpic.com/show/full/$1/' 151 | }, 152 | instagram : { 153 | matcher : /(instagr\.am|instagram\.com)\/p\/([a-zA-Z0-9_\-]+)\/?/i, 154 | type : 'image', 155 | url : '//$1/p/$2/media/?size=l' 156 | }, 157 | google_maps : { 158 | matcher : /maps\.google\.([a-z]{2,3}(\.[a-z]{2})?)\/(\?ll=|maps\?)(.*)/i, 159 | type : 'iframe', 160 | url : function( rez ) { 161 | return '//maps.google.' + rez[1] + '/' + rez[3] + '' + rez[4] + '&output=' + (rez[4].indexOf('layer=c') > 0 ? 'svembed' : 'embed'); 162 | } 163 | } 164 | }, 165 | 166 | beforeLoad : function(opts, obj) { 167 | var url = obj.href || '', 168 | type = false, 169 | what, 170 | item, 171 | rez, 172 | params; 173 | 174 | for (what in opts) { 175 | if (opts.hasOwnProperty(what)) { 176 | item = opts[ what ]; 177 | rez = url.match( item.matcher ); 178 | 179 | if (rez) { 180 | type = item.type; 181 | params = $.extend(true, {}, item.params, obj[ what ] || ($.isPlainObject(opts[ what ]) ? opts[ what ].params : null)); 182 | 183 | url = $.type( item.url ) === "function" ? item.url.call( this, rez, params, obj ) : format( item.url, rez, params ); 184 | 185 | break; 186 | } 187 | } 188 | } 189 | 190 | if (type) { 191 | obj.href = url; 192 | obj.type = type; 193 | 194 | obj.autoHeight = false; 195 | } 196 | } 197 | }; 198 | 199 | }(jQuery)); -------------------------------------------------------------------------------- /public/lib/fancybox/jquery.fancybox.css: -------------------------------------------------------------------------------- 1 | /*! fancyBox v2.1.5 fancyapps.com | fancyapps.com/fancybox/#license */ 2 | .fancybox-wrap, 3 | .fancybox-skin, 4 | .fancybox-outer, 5 | .fancybox-inner, 6 | .fancybox-image, 7 | .fancybox-wrap iframe, 8 | .fancybox-wrap object, 9 | .fancybox-nav, 10 | .fancybox-nav span, 11 | .fancybox-tmp 12 | { 13 | padding: 0; 14 | margin: 0; 15 | border: 0; 16 | outline: none; 17 | vertical-align: top; 18 | } 19 | 20 | .fancybox-wrap { 21 | position: absolute; 22 | top: 0; 23 | left: 0; 24 | z-index: 8020; 25 | } 26 | 27 | .fancybox-skin { 28 | position: relative; 29 | background: #f9f9f9; 30 | color: #444; 31 | text-shadow: none; 32 | -webkit-border-radius: 4px; 33 | -moz-border-radius: 4px; 34 | border-radius: 4px; 35 | } 36 | 37 | .fancybox-opened { 38 | z-index: 8030; 39 | } 40 | 41 | .fancybox-opened .fancybox-skin { 42 | -webkit-box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5); 43 | -moz-box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5); 44 | box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5); 45 | } 46 | 47 | .fancybox-outer, .fancybox-inner { 48 | position: relative; 49 | } 50 | 51 | .fancybox-inner { 52 | overflow: hidden; 53 | } 54 | 55 | .fancybox-type-iframe .fancybox-inner { 56 | -webkit-overflow-scrolling: touch; 57 | } 58 | 59 | .fancybox-error { 60 | color: #444; 61 | font: 14px/20px "Helvetica Neue",Helvetica,Arial,sans-serif; 62 | margin: 0; 63 | padding: 15px; 64 | white-space: nowrap; 65 | } 66 | 67 | .fancybox-image, .fancybox-iframe { 68 | display: block; 69 | width: 100%; 70 | height: 100%; 71 | } 72 | 73 | .fancybox-image { 74 | max-width: 100%; 75 | max-height: 100%; 76 | } 77 | 78 | #fancybox-loading, .fancybox-close, .fancybox-prev span, .fancybox-next span { 79 | background-image: url('fancybox_sprite.png'); 80 | } 81 | 82 | #fancybox-loading { 83 | position: fixed; 84 | top: 50%; 85 | left: 50%; 86 | margin-top: -22px; 87 | margin-left: -22px; 88 | background-position: 0 -108px; 89 | opacity: 0.8; 90 | cursor: pointer; 91 | z-index: 8060; 92 | } 93 | 94 | #fancybox-loading div { 95 | width: 44px; 96 | height: 44px; 97 | background: url('fancybox_loading.gif') center center no-repeat; 98 | } 99 | 100 | .fancybox-close { 101 | position: absolute; 102 | top: -18px; 103 | right: -18px; 104 | width: 36px; 105 | height: 36px; 106 | cursor: pointer; 107 | z-index: 8040; 108 | } 109 | 110 | .fancybox-nav { 111 | position: absolute; 112 | top: 0; 113 | width: 40%; 114 | height: 100%; 115 | cursor: pointer; 116 | text-decoration: none; 117 | background: transparent url('blank.gif'); /* helps IE */ 118 | -webkit-tap-highlight-color: rgba(0,0,0,0); 119 | z-index: 8040; 120 | } 121 | 122 | .fancybox-prev { 123 | left: 0; 124 | } 125 | 126 | .fancybox-next { 127 | right: 0; 128 | } 129 | 130 | .fancybox-nav span { 131 | position: absolute; 132 | top: 50%; 133 | width: 36px; 134 | height: 34px; 135 | margin-top: -18px; 136 | cursor: pointer; 137 | z-index: 8040; 138 | visibility: hidden; 139 | } 140 | 141 | .fancybox-prev span { 142 | left: 10px; 143 | background-position: 0 -36px; 144 | } 145 | 146 | .fancybox-next span { 147 | right: 10px; 148 | background-position: 0 -72px; 149 | } 150 | 151 | .fancybox-nav:hover span { 152 | visibility: visible; 153 | } 154 | 155 | .fancybox-tmp { 156 | position: absolute; 157 | top: -99999px; 158 | left: -99999px; 159 | visibility: hidden; 160 | max-width: 99999px; 161 | max-height: 99999px; 162 | overflow: visible !important; 163 | } 164 | 165 | /* Overlay helper */ 166 | 167 | .fancybox-lock { 168 | overflow: hidden !important; 169 | width: auto; 170 | } 171 | 172 | .fancybox-lock body { 173 | overflow: hidden !important; 174 | } 175 | 176 | .fancybox-lock-test { 177 | overflow-y: hidden !important; 178 | } 179 | 180 | .fancybox-overlay { 181 | position: absolute; 182 | top: 0; 183 | left: 0; 184 | overflow: hidden; 185 | display: none; 186 | z-index: 8010; 187 | background: url('fancybox_overlay.png'); 188 | } 189 | 190 | .fancybox-overlay-fixed { 191 | position: fixed; 192 | bottom: 0; 193 | right: 0; 194 | } 195 | 196 | .fancybox-lock .fancybox-overlay { 197 | overflow: auto; 198 | overflow-y: scroll; 199 | } 200 | 201 | /* Title helper */ 202 | 203 | .fancybox-title { 204 | visibility: hidden; 205 | font: normal 13px/20px "Helvetica Neue",Helvetica,Arial,sans-serif; 206 | position: relative; 207 | text-shadow: none; 208 | z-index: 8050; 209 | } 210 | 211 | .fancybox-opened .fancybox-title { 212 | visibility: visible; 213 | } 214 | 215 | .fancybox-title-float-wrap { 216 | position: absolute; 217 | bottom: 0; 218 | right: 50%; 219 | margin-bottom: -35px; 220 | z-index: 8050; 221 | text-align: center; 222 | } 223 | 224 | .fancybox-title-float-wrap .child { 225 | display: inline-block; 226 | margin-right: -100%; 227 | padding: 2px 20px; 228 | background: transparent; /* Fallback for web browsers that doesn't support RGBa */ 229 | background: rgba(0, 0, 0, 0.8); 230 | -webkit-border-radius: 15px; 231 | -moz-border-radius: 15px; 232 | border-radius: 15px; 233 | text-shadow: 0 1px 2px #222; 234 | color: #FFF; 235 | font-weight: bold; 236 | line-height: 24px; 237 | white-space: nowrap; 238 | } 239 | 240 | .fancybox-title-outside-wrap { 241 | position: relative; 242 | margin-top: 10px; 243 | color: #fff; 244 | } 245 | 246 | .fancybox-title-inside-wrap { 247 | padding-top: 10px; 248 | } 249 | 250 | .fancybox-title-over-wrap { 251 | position: absolute; 252 | bottom: 0; 253 | left: 0; 254 | color: #fff; 255 | padding: 10px; 256 | background: #000; 257 | background: rgba(0, 0, 0, .8); 258 | } 259 | 260 | /*Retina graphics!*/ 261 | @media only screen and (-webkit-min-device-pixel-ratio: 1.5), 262 | only screen and (min--moz-device-pixel-ratio: 1.5), 263 | only screen and (min-device-pixel-ratio: 1.5){ 264 | 265 | #fancybox-loading, .fancybox-close, .fancybox-prev span, .fancybox-next span { 266 | background-image: url('fancybox_sprite@2x.png'); 267 | background-size: 44px 152px; /*The size of the normal image, half the size of the hi-res image*/ 268 | } 269 | 270 | #fancybox-loading div { 271 | background-image: url('fancybox_loading@2x.gif'); 272 | background-size: 24px 24px; /*The size of the normal image, half the size of the hi-res image*/ 273 | } 274 | } -------------------------------------------------------------------------------- /chatReader.js: -------------------------------------------------------------------------------- 1 | var expandHomeDir = require('expand-home-dir'); 2 | var sqlite3 = require('sqlite3'); 3 | var fs = require('fs'); 4 | var _ = require('underscore')._; 5 | var queries = require('./queries'); 6 | var addressbook = require('./addressbook'); 7 | var lookupName = addressbook.lookupName; 8 | 9 | var chat = new function () { 10 | this.messageCount = 0; 11 | this.chatMessageCounts = {}; 12 | this.attachmentInfo = {}; 13 | this.chatMessageIds = {}; 14 | this.dbPath = expandHomeDir('~/Library/Messages/chat.db'); 15 | this.lookupName = lookupName; 16 | this.debug = false; 17 | this.testChatUpdate = true; 18 | this.testMessageCounts = true; 19 | this.pollMessageCounts = true; 20 | this.pollInterval = 2000; 21 | this.pollCountInterval = null; 22 | this.addressbookData = addressbook.addressbookData; 23 | this.contactValues = []; 24 | 25 | this.chatUpdateTrigger = function (chat_ids) {} 26 | 27 | this.getContactValues = function () { 28 | var self = this; 29 | 30 | if (self.contactValues.length > 0) return self.contactValues; 31 | var ar =[]; 32 | Object.keys(self.addressbookData).forEach(function (k) { 33 | ar = ar.concat(self.addressbookData[k]); 34 | }); 35 | self.contactValues = ar; 36 | return ar; 37 | } 38 | this.getAttachmentPath = function (attachment_id, cb) { 39 | var self = this; 40 | var fl = self.attachmentInfo[attachment_id]; 41 | 42 | fl.path = expandHomeDir(fl.filename); 43 | cb(_.pick(fl, "path", "filename", "uti", "mime_type")); 44 | 45 | } 46 | this.parseMessageRow = function (row) { 47 | var self = this; 48 | var rr = _.pick(row, "message_id", "who_from", "is_from_me", "chat_id", "text", "attachment_id", "date", "guid", "lookupValue", "mime_type"); 49 | var fi = _.pick(row, "attachment_id", "filename", "chat_id", "mime_type", "uti"); 50 | self.attachmentInfo[fi.attachment_id] = _.pick(fi, "filename", "chat_id", "mime_type", "uti"); 51 | 52 | return rr; 53 | } 54 | 55 | this.getChat = function (chat_id, cb) { 56 | var self = this; 57 | var ar = []; 58 | var mids = []; 59 | var query = queries.chatQuery.replace('[CHAT_ID]', chat_id).replace('[OTHER_CONST]', ''); 60 | this.db.each(query, function(err, row) { 61 | row.lookupValue = self.lookupName(row.who_from).lookupValue; 62 | var rr = self.parseMessageRow.apply(self, [row]); 63 | mids.push(row.message_id); 64 | ar.push(rr); 65 | }, function (e) { 66 | if (self.testChatUpdate) { 67 | self.testChatUpdate = false; 68 | mids.pop(); 69 | ar.pop(); 70 | } 71 | self.chatMessageIds[chat_id] = mids; 72 | if (cb) cb.apply(self, [ar]); 73 | }); 74 | } 75 | this.checkChatUpdates = function (chat_id, cb) { 76 | var self = this; 77 | var ar = []; 78 | if (! _.has(self.chatMessageIds, chat_id)) return; 79 | var mids = self.chatMessageIds[chat_id]; 80 | var query = queries.chatQuery.replace('[CHAT_ID]', chat_id).replace('[OTHER_CONST]', 'and cmj.message_id not in (' + mids.join(', ') + ')'); 81 | this.db.each(query, function(err, row) { 82 | row.who_from = self.lookupName(row.who_from); 83 | var rr = self.parseMessageRow.apply(self, [row]); 84 | mids.push(row.message_id); 85 | ar.push(row); 86 | }, function (err) { 87 | self.chatMessageIds[chat_id] = mids; 88 | if (cb) cb.apply(self, [chat_id, ar]); 89 | }); 90 | } 91 | this.getAllChats = function (cb) { 92 | var self = this; 93 | 94 | var ar = []; 95 | var allData = []; 96 | 97 | this.db.each(queries.allChatQuery, function(err, row) { 98 | if (row.people.indexOf(',') > -1) { 99 | var els = row.people.split(','); 100 | var na = []; 101 | for (var i=0; i 0) self.chatUpdateTrigger(diffs); 141 | }); 142 | } 143 | 144 | this.getMessageCount = function (cb) { 145 | var self = this; 146 | var oldCount = self.messageCount; 147 | var msgCount = 0; 148 | this.db.each("select count(1) c from message", function (err, row) { 149 | msgCount = row.c; 150 | self.messageCount = msgCount; 151 | }, function (err) { 152 | if (err) console.log(err); 153 | else if (cb) cb.apply(self, [oldCount, msgCount]); 154 | }); 155 | } 156 | this.enableMessageCountPoll = function (cb) { 157 | var self = this; 158 | self.pollCountInterval = setInterval(function () { self.checkUpdated.apply(self) }, self.pollInterval); 159 | } 160 | this.openChatDatabase = function (cb) { 161 | var self = this; 162 | //fs.watch(this.dbPath, function(a,b) { self.watchTrigger(a,b,self) }); 163 | this.db = new sqlite3.Database(this.dbPath, sqlite3.OPEN_READONLY, function (e) { 164 | if (self.pollMessageCounts) self.enableMessageCountPoll(); 165 | if (self.debug) self.db.on('profile', function (e, t) { console.log(e, t) }); 166 | if (cb) cb.apply(self, [self.dbPath, e] ); 167 | }); 168 | } 169 | } 170 | exports.chat = chat; -------------------------------------------------------------------------------- /public/js/main.js: -------------------------------------------------------------------------------- 1 | var timezoneOffset = 6; 2 | var whoami = "Me"; 3 | var contacts =[]; 4 | 5 | moment.locale('en', { 6 | calendar : { 7 | lastDay : '[Yesterday]', 8 | sameDay : 'LT', 9 | nextDay : '[Tomorrow] [at] LT', 10 | lastWeek : 'L', 11 | nextWeek : 'dddd [at] LT', 12 | sameElse : 'L' 13 | } 14 | }); 15 | emoji.use_sheet = true; 16 | emoji.sheet_path = "/img/sheet_64.png"; 17 | 18 | 19 | var spinner = '
    '; 20 | 21 | var messageList = new function () { 22 | var self = this; 23 | this.currentChat = []; 24 | this.chat_id = null; 25 | this.messageTemplate = "
    [INFO]
    [MESSAGE]
    "; 26 | this.imageObjectCount = 0; 27 | this.imagesLoadedNum = 0; 28 | this.updateChatData = function (dt) { 29 | var self = this; 30 | var cid = dt.chat_id; 31 | var msg = dt.data; 32 | 33 | console.log(cid, this.chat_id); 34 | if (self.chat_id != cid) return; 35 | var txt = ""; 36 | for (var i=0; i -1) mt = "video/mp4"; 65 | return ""; 66 | } 67 | function renderImage() { 68 | //return ""; 69 | var imgPath = "/attachment/" + m.attachment_id; 70 | self.imageObjectCount++; 71 | return "
    "; 72 | } 73 | 74 | if (mt.indexOf("video") >-1) msg = renderVideo(); 75 | else if (mt.indexOf("image") > -1) msg = renderImage(); 76 | 77 | msg = "
    " + msg + "
    "; 78 | if (m.text != null) msg += "
    " + m.text + ""; 79 | 80 | return msg; 81 | } 82 | 83 | this.renderMessage = function(m, style) { 84 | style = style ||""; 85 | var cls = ""; 86 | var hasImage = false; 87 | 88 | if (m.is_from_me == 1) cls = 'msg-right'; 89 | else cls = 'msg-left'; 90 | 91 | if (m.service_name == "SMS") cls += " msg-sms"; 92 | 93 | var msg = m.text.replace(/(\n|\r)/g, '
    \n').replace(/ /g, ''); 94 | msg = emoji.replace_unified(msg); 95 | 96 | var ts = new Date(m.date*1000); 97 | var mmt = moment(ts).subtract(timezoneOffset, 'hours').format('MMMM Do YYYY, h:mm:ss a'); 98 | var who_from = (m.is_from_me == 0 ? m.lookupValue : whoami); 99 | var info = ""+ who_from + " " + mmt+ ""; 100 | 101 | if (m.attachment_id != null) msg = self.renderAttachment(m); 102 | var fullMsg = self.messageTemplate.replace('[STYLE]', style).replace('[CLASS]', cls).replace('[INFO]', info).replace('[MESSAGE]', msg).replace('[MESSAGE_ID]', m.message_id); 103 | return fullMsg; 104 | } 105 | this.renderDone = function () {} 106 | 107 | this._renderDone = function () { 108 | setTimeout(function () { 109 | $("#loading").velocity({ opacity: 0 }, { 110 | duration:100, 111 | complete: function () { 112 | $("#loading").hide(); 113 | $("#chatView").velocity({ opacity: 1 }, {duration:200}); 114 | } 115 | }); 116 | 117 | }, 200); 118 | 119 | setTimeout(function () { 120 | location.hash = "#bottom"; 121 | $(".msg").linkify({target:"_blank"}); 122 | }, 300); 123 | 124 | //$(".msg").last().velocity('scroll', {duration:100}).velocity('scroll', {duration:100}); 125 | self.addLightbox(); 126 | 127 | } 128 | this.renderMessages = function (msgs) { 129 | self.currentChat = msgs; 130 | self.imageObjectCount = 0; 131 | self.imagesLoadedNum = 0; 132 | location.hash =""; 133 | var hdr = $(".uChatList li.active div").html(); 134 | $("#messageHeader").html(hdr); 135 | $("#loading").html(spinner).show().velocity({ opacity: 1 }, {duration:0}); 136 | $("#chatView").html("").velocity({ opacity: 0 }, {duration:0}); 137 | var txt = ""; 138 | for (var i=0; i 2 && obj.lookupValue.indexOf(" ") > -1) obj.lookupValue = obj.lookupValue.split(' ')[0]; 158 | var people = ""+obj.lookupValue+""; 159 | return people; 160 | } 161 | this.renderTimestamp = function (m) { 162 | var ts = new Date(m.lastUpdate*1000); 163 | var mmt = moment(ts).subtract(timezoneOffset, 'hours').calendar(); 164 | var timestamp = "" + mmt + ""; 165 | return timestamp; 166 | } 167 | this.addChatListHanders = function () { 168 | var lis = $(".uChatList li"); 169 | lis.click(function () { 170 | $(".uChatList li.active").removeClass('active'); 171 | $(this).addClass('active'); 172 | var chat_id = $(this).find('[data-chat-id]').data('chat-id'); 173 | messageList.chat_id = chat_id; 174 | socket.emit('getChat', chat_id, messageList.renderMessages); 175 | $(".sidebar.in").collapse('hide'); 176 | $(".main").show(); 177 | }) 178 | } 179 | this.renderChatList = function (ar) { 180 | $(".uChatList").html(""); 181 | var chats = []; 182 | for (var i=0;i" + chat + self.renderTimestamp(m) + ""; 190 | 191 | chats.push(txt); 192 | } 193 | var txt = "
  • " + chats.join("
  • \n
  • ") + "
  • "; 194 | $(".uChatList").html(txt); 195 | self.addChatListHanders(); 196 | $("#uChatList li:first").click(); 197 | } 198 | this.update = function () { 199 | messenger.getAllChat(self.renderChatList); 200 | } 201 | } 202 | 203 | 204 | var messenger = new function () { 205 | var self = this; 206 | this.allChatDataFull = []; 207 | this.allChatData = []; 208 | this.messageCount = 0; 209 | this.getMessageCount = function () { 210 | socket.emit('getMessageCount', function (o, n) { self.messageCount = n; }); 211 | } 212 | this.getAllChat = function (cb) { 213 | var self = this; 214 | socket.emit('getAllChat', function (ar, all) { 215 | self.allChatData = ar; 216 | self.allChatDataFull = all; 217 | if (cb) cb.apply(self, [ar, all]); 218 | }); 219 | } 220 | this.sendMessage = function (txt, guid) { 221 | console.log(txt, guid); 222 | socket.emit('sendMessage', {text: txt, guid: guid}); 223 | 224 | $(".msg").last().after('
    '+whoami+' Pending...
    '+txt+'
    '); 225 | $(".msg").last().velocity('scroll', {duration:100}).velocity('scroll', {duration:100}); 226 | } 227 | this.inputWatch = function (e) { 228 | if (e.which==13) { 229 | self.sendMessage($(this).val(), $(".active div").data('guid')); 230 | $(this).val('') 231 | return false; 232 | } 233 | return true; 234 | } 235 | } 236 | 237 | function windowResize() { 238 | $(".chatInput").css({'position':'absolute', 'left':0}); 239 | var l = $(".chatInput").offset().left; 240 | $(".chatInput").css({'position':'fixed', 'left':l}); 241 | $(".contact-list-button").unbind('click'); 242 | $(".contact-list-button:visible").click(function () { 243 | $(".main").toggle(); 244 | }); 245 | } 246 | function addTypeahead() { 247 | $('.contactSearch').typeahead({ 248 | minLength: 3, 249 | highlight: true, 250 | }, 251 | { 252 | name: 'contacts', 253 | source: simpleSearch 254 | }); 255 | } 256 | function loadContactValues() { 257 | socket.emit('getContactValues', function (dt) { contacts = dt; addTypeahead(); }) 258 | } 259 | function simpleSearch(query, cb) { 260 | 261 | var search = contacts.filter(function (item) { return item.toLowerCase().indexOf(query) > -1 }); 262 | var results = search.map(function (item) { return {value: item} }); 263 | cb(results); 264 | } 265 | 266 | var socket = io.connect(); 267 | socket.on('updateChatData', function (dt) { messageList.updateChatData.apply(messageList, [dt])}); 268 | 269 | $(window).resize(windowResize); 270 | 271 | $(function () { 272 | loadContactValues(); 273 | $("#myMessage").keypress(messenger.inputWatch); 274 | windowResize(); 275 | chatList.update(); 276 | }); 277 | -------------------------------------------------------------------------------- /public/js/underscore.min.js: -------------------------------------------------------------------------------- 1 | // Underscore.js 1.7.0 2 | // http://underscorejs.org 3 | // (c) 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors 4 | // Underscore may be freely distributed under the MIT license. 5 | (function(){var n=this,t=n._,r=Array.prototype,e=Object.prototype,u=Function.prototype,i=r.push,a=r.slice,o=r.concat,l=e.toString,c=e.hasOwnProperty,f=Array.isArray,s=Object.keys,p=u.bind,h=function(n){return n instanceof h?n:this instanceof h?void(this._wrapped=n):new h(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=h),exports._=h):n._=h,h.VERSION="1.7.0";var g=function(n,t,r){if(t===void 0)return n;switch(null==r?3:r){case 1:return function(r){return n.call(t,r)};case 2:return function(r,e){return n.call(t,r,e)};case 3:return function(r,e,u){return n.call(t,r,e,u)};case 4:return function(r,e,u,i){return n.call(t,r,e,u,i)}}return function(){return n.apply(t,arguments)}};h.iteratee=function(n,t,r){return null==n?h.identity:h.isFunction(n)?g(n,t,r):h.isObject(n)?h.matches(n):h.property(n)},h.each=h.forEach=function(n,t,r){if(null==n)return n;t=g(t,r);var e,u=n.length;if(u===+u)for(e=0;u>e;e++)t(n[e],e,n);else{var i=h.keys(n);for(e=0,u=i.length;u>e;e++)t(n[i[e]],i[e],n)}return n},h.map=h.collect=function(n,t,r){if(null==n)return[];t=h.iteratee(t,r);for(var e,u=n.length!==+n.length&&h.keys(n),i=(u||n).length,a=Array(i),o=0;i>o;o++)e=u?u[o]:o,a[o]=t(n[e],e,n);return a};var v="Reduce of empty array with no initial value";h.reduce=h.foldl=h.inject=function(n,t,r,e){null==n&&(n=[]),t=g(t,e,4);var u,i=n.length!==+n.length&&h.keys(n),a=(i||n).length,o=0;if(arguments.length<3){if(!a)throw new TypeError(v);r=n[i?i[o++]:o++]}for(;a>o;o++)u=i?i[o]:o,r=t(r,n[u],u,n);return r},h.reduceRight=h.foldr=function(n,t,r,e){null==n&&(n=[]),t=g(t,e,4);var u,i=n.length!==+n.length&&h.keys(n),a=(i||n).length;if(arguments.length<3){if(!a)throw new TypeError(v);r=n[i?i[--a]:--a]}for(;a--;)u=i?i[a]:a,r=t(r,n[u],u,n);return r},h.find=h.detect=function(n,t,r){var e;return t=h.iteratee(t,r),h.some(n,function(n,r,u){return t(n,r,u)?(e=n,!0):void 0}),e},h.filter=h.select=function(n,t,r){var e=[];return null==n?e:(t=h.iteratee(t,r),h.each(n,function(n,r,u){t(n,r,u)&&e.push(n)}),e)},h.reject=function(n,t,r){return h.filter(n,h.negate(h.iteratee(t)),r)},h.every=h.all=function(n,t,r){if(null==n)return!0;t=h.iteratee(t,r);var e,u,i=n.length!==+n.length&&h.keys(n),a=(i||n).length;for(e=0;a>e;e++)if(u=i?i[e]:e,!t(n[u],u,n))return!1;return!0},h.some=h.any=function(n,t,r){if(null==n)return!1;t=h.iteratee(t,r);var e,u,i=n.length!==+n.length&&h.keys(n),a=(i||n).length;for(e=0;a>e;e++)if(u=i?i[e]:e,t(n[u],u,n))return!0;return!1},h.contains=h.include=function(n,t){return null==n?!1:(n.length!==+n.length&&(n=h.values(n)),h.indexOf(n,t)>=0)},h.invoke=function(n,t){var r=a.call(arguments,2),e=h.isFunction(t);return h.map(n,function(n){return(e?t:n[t]).apply(n,r)})},h.pluck=function(n,t){return h.map(n,h.property(t))},h.where=function(n,t){return h.filter(n,h.matches(t))},h.findWhere=function(n,t){return h.find(n,h.matches(t))},h.max=function(n,t,r){var e,u,i=-1/0,a=-1/0;if(null==t&&null!=n){n=n.length===+n.length?n:h.values(n);for(var o=0,l=n.length;l>o;o++)e=n[o],e>i&&(i=e)}else t=h.iteratee(t,r),h.each(n,function(n,r,e){u=t(n,r,e),(u>a||u===-1/0&&i===-1/0)&&(i=n,a=u)});return i},h.min=function(n,t,r){var e,u,i=1/0,a=1/0;if(null==t&&null!=n){n=n.length===+n.length?n:h.values(n);for(var o=0,l=n.length;l>o;o++)e=n[o],i>e&&(i=e)}else t=h.iteratee(t,r),h.each(n,function(n,r,e){u=t(n,r,e),(a>u||1/0===u&&1/0===i)&&(i=n,a=u)});return i},h.shuffle=function(n){for(var t,r=n&&n.length===+n.length?n:h.values(n),e=r.length,u=Array(e),i=0;e>i;i++)t=h.random(0,i),t!==i&&(u[i]=u[t]),u[t]=r[i];return u},h.sample=function(n,t,r){return null==t||r?(n.length!==+n.length&&(n=h.values(n)),n[h.random(n.length-1)]):h.shuffle(n).slice(0,Math.max(0,t))},h.sortBy=function(n,t,r){return t=h.iteratee(t,r),h.pluck(h.map(n,function(n,r,e){return{value:n,index:r,criteria:t(n,r,e)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||r===void 0)return 1;if(e>r||e===void 0)return-1}return n.index-t.index}),"value")};var m=function(n){return function(t,r,e){var u={};return r=h.iteratee(r,e),h.each(t,function(e,i){var a=r(e,i,t);n(u,e,a)}),u}};h.groupBy=m(function(n,t,r){h.has(n,r)?n[r].push(t):n[r]=[t]}),h.indexBy=m(function(n,t,r){n[r]=t}),h.countBy=m(function(n,t,r){h.has(n,r)?n[r]++:n[r]=1}),h.sortedIndex=function(n,t,r,e){r=h.iteratee(r,e,1);for(var u=r(t),i=0,a=n.length;a>i;){var o=i+a>>>1;r(n[o])t?[]:a.call(n,0,t)},h.initial=function(n,t,r){return a.call(n,0,Math.max(0,n.length-(null==t||r?1:t)))},h.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:a.call(n,Math.max(n.length-t,0))},h.rest=h.tail=h.drop=function(n,t,r){return a.call(n,null==t||r?1:t)},h.compact=function(n){return h.filter(n,h.identity)};var y=function(n,t,r,e){if(t&&h.every(n,h.isArray))return o.apply(e,n);for(var u=0,a=n.length;a>u;u++){var l=n[u];h.isArray(l)||h.isArguments(l)?t?i.apply(e,l):y(l,t,r,e):r||e.push(l)}return e};h.flatten=function(n,t){return y(n,t,!1,[])},h.without=function(n){return h.difference(n,a.call(arguments,1))},h.uniq=h.unique=function(n,t,r,e){if(null==n)return[];h.isBoolean(t)||(e=r,r=t,t=!1),null!=r&&(r=h.iteratee(r,e));for(var u=[],i=[],a=0,o=n.length;o>a;a++){var l=n[a];if(t)a&&i===l||u.push(l),i=l;else if(r){var c=r(l,a,n);h.indexOf(i,c)<0&&(i.push(c),u.push(l))}else h.indexOf(u,l)<0&&u.push(l)}return u},h.union=function(){return h.uniq(y(arguments,!0,!0,[]))},h.intersection=function(n){if(null==n)return[];for(var t=[],r=arguments.length,e=0,u=n.length;u>e;e++){var i=n[e];if(!h.contains(t,i)){for(var a=1;r>a&&h.contains(arguments[a],i);a++);a===r&&t.push(i)}}return t},h.difference=function(n){var t=y(a.call(arguments,1),!0,!0,[]);return h.filter(n,function(n){return!h.contains(t,n)})},h.zip=function(n){if(null==n)return[];for(var t=h.max(arguments,"length").length,r=Array(t),e=0;t>e;e++)r[e]=h.pluck(arguments,e);return r},h.object=function(n,t){if(null==n)return{};for(var r={},e=0,u=n.length;u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},h.indexOf=function(n,t,r){if(null==n)return-1;var e=0,u=n.length;if(r){if("number"!=typeof r)return e=h.sortedIndex(n,t),n[e]===t?e:-1;e=0>r?Math.max(0,u+r):r}for(;u>e;e++)if(n[e]===t)return e;return-1},h.lastIndexOf=function(n,t,r){if(null==n)return-1;var e=n.length;for("number"==typeof r&&(e=0>r?e+r+1:Math.min(e,r+1));--e>=0;)if(n[e]===t)return e;return-1},h.range=function(n,t,r){arguments.length<=1&&(t=n||0,n=0),r=r||1;for(var e=Math.max(Math.ceil((t-n)/r),0),u=Array(e),i=0;e>i;i++,n+=r)u[i]=n;return u};var d=function(){};h.bind=function(n,t){var r,e;if(p&&n.bind===p)return p.apply(n,a.call(arguments,1));if(!h.isFunction(n))throw new TypeError("Bind must be called on a function");return r=a.call(arguments,2),e=function(){if(!(this instanceof e))return n.apply(t,r.concat(a.call(arguments)));d.prototype=n.prototype;var u=new d;d.prototype=null;var i=n.apply(u,r.concat(a.call(arguments)));return h.isObject(i)?i:u}},h.partial=function(n){var t=a.call(arguments,1);return function(){for(var r=0,e=t.slice(),u=0,i=e.length;i>u;u++)e[u]===h&&(e[u]=arguments[r++]);for(;r=e)throw new Error("bindAll must be passed function names");for(t=1;e>t;t++)r=arguments[t],n[r]=h.bind(n[r],n);return n},h.memoize=function(n,t){var r=function(e){var u=r.cache,i=t?t.apply(this,arguments):e;return h.has(u,i)||(u[i]=n.apply(this,arguments)),u[i]};return r.cache={},r},h.delay=function(n,t){var r=a.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},h.defer=function(n){return h.delay.apply(h,[n,1].concat(a.call(arguments,1)))},h.throttle=function(n,t,r){var e,u,i,a=null,o=0;r||(r={});var l=function(){o=r.leading===!1?0:h.now(),a=null,i=n.apply(e,u),a||(e=u=null)};return function(){var c=h.now();o||r.leading!==!1||(o=c);var f=t-(c-o);return e=this,u=arguments,0>=f||f>t?(clearTimeout(a),a=null,o=c,i=n.apply(e,u),a||(e=u=null)):a||r.trailing===!1||(a=setTimeout(l,f)),i}},h.debounce=function(n,t,r){var e,u,i,a,o,l=function(){var c=h.now()-a;t>c&&c>0?e=setTimeout(l,t-c):(e=null,r||(o=n.apply(i,u),e||(i=u=null)))};return function(){i=this,u=arguments,a=h.now();var c=r&&!e;return e||(e=setTimeout(l,t)),c&&(o=n.apply(i,u),i=u=null),o}},h.wrap=function(n,t){return h.partial(t,n)},h.negate=function(n){return function(){return!n.apply(this,arguments)}},h.compose=function(){var n=arguments,t=n.length-1;return function(){for(var r=t,e=n[t].apply(this,arguments);r--;)e=n[r].call(this,e);return e}},h.after=function(n,t){return function(){return--n<1?t.apply(this,arguments):void 0}},h.before=function(n,t){var r;return function(){return--n>0?r=t.apply(this,arguments):t=null,r}},h.once=h.partial(h.before,2),h.keys=function(n){if(!h.isObject(n))return[];if(s)return s(n);var t=[];for(var r in n)h.has(n,r)&&t.push(r);return t},h.values=function(n){for(var t=h.keys(n),r=t.length,e=Array(r),u=0;r>u;u++)e[u]=n[t[u]];return e},h.pairs=function(n){for(var t=h.keys(n),r=t.length,e=Array(r),u=0;r>u;u++)e[u]=[t[u],n[t[u]]];return e},h.invert=function(n){for(var t={},r=h.keys(n),e=0,u=r.length;u>e;e++)t[n[r[e]]]=r[e];return t},h.functions=h.methods=function(n){var t=[];for(var r in n)h.isFunction(n[r])&&t.push(r);return t.sort()},h.extend=function(n){if(!h.isObject(n))return n;for(var t,r,e=1,u=arguments.length;u>e;e++){t=arguments[e];for(r in t)c.call(t,r)&&(n[r]=t[r])}return n},h.pick=function(n,t,r){var e,u={};if(null==n)return u;if(h.isFunction(t)){t=g(t,r);for(e in n){var i=n[e];t(i,e,n)&&(u[e]=i)}}else{var l=o.apply([],a.call(arguments,1));n=new Object(n);for(var c=0,f=l.length;f>c;c++)e=l[c],e in n&&(u[e]=n[e])}return u},h.omit=function(n,t,r){if(h.isFunction(t))t=h.negate(t);else{var e=h.map(o.apply([],a.call(arguments,1)),String);t=function(n,t){return!h.contains(e,t)}}return h.pick(n,t,r)},h.defaults=function(n){if(!h.isObject(n))return n;for(var t=1,r=arguments.length;r>t;t++){var e=arguments[t];for(var u in e)n[u]===void 0&&(n[u]=e[u])}return n},h.clone=function(n){return h.isObject(n)?h.isArray(n)?n.slice():h.extend({},n):n},h.tap=function(n,t){return t(n),n};var b=function(n,t,r,e){if(n===t)return 0!==n||1/n===1/t;if(null==n||null==t)return n===t;n instanceof h&&(n=n._wrapped),t instanceof h&&(t=t._wrapped);var u=l.call(n);if(u!==l.call(t))return!1;switch(u){case"[object RegExp]":case"[object String]":return""+n==""+t;case"[object Number]":return+n!==+n?+t!==+t:0===+n?1/+n===1/t:+n===+t;case"[object Date]":case"[object Boolean]":return+n===+t}if("object"!=typeof n||"object"!=typeof t)return!1;for(var i=r.length;i--;)if(r[i]===n)return e[i]===t;var a=n.constructor,o=t.constructor;if(a!==o&&"constructor"in n&&"constructor"in t&&!(h.isFunction(a)&&a instanceof a&&h.isFunction(o)&&o instanceof o))return!1;r.push(n),e.push(t);var c,f;if("[object Array]"===u){if(c=n.length,f=c===t.length)for(;c--&&(f=b(n[c],t[c],r,e)););}else{var s,p=h.keys(n);if(c=p.length,f=h.keys(t).length===c)for(;c--&&(s=p[c],f=h.has(t,s)&&b(n[s],t[s],r,e)););}return r.pop(),e.pop(),f};h.isEqual=function(n,t){return b(n,t,[],[])},h.isEmpty=function(n){if(null==n)return!0;if(h.isArray(n)||h.isString(n)||h.isArguments(n))return 0===n.length;for(var t in n)if(h.has(n,t))return!1;return!0},h.isElement=function(n){return!(!n||1!==n.nodeType)},h.isArray=f||function(n){return"[object Array]"===l.call(n)},h.isObject=function(n){var t=typeof n;return"function"===t||"object"===t&&!!n},h.each(["Arguments","Function","String","Number","Date","RegExp"],function(n){h["is"+n]=function(t){return l.call(t)==="[object "+n+"]"}}),h.isArguments(arguments)||(h.isArguments=function(n){return h.has(n,"callee")}),"function"!=typeof/./&&(h.isFunction=function(n){return"function"==typeof n||!1}),h.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},h.isNaN=function(n){return h.isNumber(n)&&n!==+n},h.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"===l.call(n)},h.isNull=function(n){return null===n},h.isUndefined=function(n){return n===void 0},h.has=function(n,t){return null!=n&&c.call(n,t)},h.noConflict=function(){return n._=t,this},h.identity=function(n){return n},h.constant=function(n){return function(){return n}},h.noop=function(){},h.property=function(n){return function(t){return t[n]}},h.matches=function(n){var t=h.pairs(n),r=t.length;return function(n){if(null==n)return!r;n=new Object(n);for(var e=0;r>e;e++){var u=t[e],i=u[0];if(u[1]!==n[i]||!(i in n))return!1}return!0}},h.times=function(n,t,r){var e=Array(Math.max(0,n));t=g(t,r,1);for(var u=0;n>u;u++)e[u]=t(u);return e},h.random=function(n,t){return null==t&&(t=n,n=0),n+Math.floor(Math.random()*(t-n+1))},h.now=Date.now||function(){return(new Date).getTime()};var _={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},w=h.invert(_),j=function(n){var t=function(t){return n[t]},r="(?:"+h.keys(n).join("|")+")",e=RegExp(r),u=RegExp(r,"g");return function(n){return n=null==n?"":""+n,e.test(n)?n.replace(u,t):n}};h.escape=j(_),h.unescape=j(w),h.result=function(n,t){if(null==n)return void 0;var r=n[t];return h.isFunction(r)?n[t]():r};var x=0;h.uniqueId=function(n){var t=++x+"";return n?n+t:t},h.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var A=/(.)^/,k={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},O=/\\|'|\r|\n|\u2028|\u2029/g,F=function(n){return"\\"+k[n]};h.template=function(n,t,r){!t&&r&&(t=r),t=h.defaults({},t,h.templateSettings);var e=RegExp([(t.escape||A).source,(t.interpolate||A).source,(t.evaluate||A).source].join("|")+"|$","g"),u=0,i="__p+='";n.replace(e,function(t,r,e,a,o){return i+=n.slice(u,o).replace(O,F),u=o+t.length,r?i+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'":e?i+="'+\n((__t=("+e+"))==null?'':__t)+\n'":a&&(i+="';\n"+a+"\n__p+='"),t}),i+="';\n",t.variable||(i="with(obj||{}){\n"+i+"}\n"),i="var __t,__p='',__j=Array.prototype.join,"+"print=function(){__p+=__j.call(arguments,'');};\n"+i+"return __p;\n";try{var a=new Function(t.variable||"obj","_",i)}catch(o){throw o.source=i,o}var l=function(n){return a.call(this,n,h)},c=t.variable||"obj";return l.source="function("+c+"){\n"+i+"}",l},h.chain=function(n){var t=h(n);return t._chain=!0,t};var E=function(n){return this._chain?h(n).chain():n};h.mixin=function(n){h.each(h.functions(n),function(t){var r=h[t]=n[t];h.prototype[t]=function(){var n=[this._wrapped];return i.apply(n,arguments),E.call(this,r.apply(h,n))}})},h.mixin(h),h.each(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=r[n];h.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!==n&&"splice"!==n||0!==r.length||delete r[0],E.call(this,r)}}),h.each(["concat","join","slice"],function(n){var t=r[n];h.prototype[n]=function(){return E.call(this,t.apply(this._wrapped,arguments))}}),h.prototype.value=function(){return this._wrapped},"function"==typeof define&&define.amd&&define("underscore",[],function(){return h})}).call(this); -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | {description} 294 | Copyright (C) {year} {fullname} 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | 341 | -------------------------------------------------------------------------------- /public/lib/fancybox/jquery.fancybox.pack.js: -------------------------------------------------------------------------------- 1 | /*! fancyBox v2.1.5 fancyapps.com | fancyapps.com/fancybox/#license */ 2 | (function(r,G,f,v){var J=f("html"),n=f(r),p=f(G),b=f.fancybox=function(){b.open.apply(this,arguments)},I=navigator.userAgent.match(/msie/i),B=null,s=G.createTouch!==v,t=function(a){return a&&a.hasOwnProperty&&a instanceof f},q=function(a){return a&&"string"===f.type(a)},E=function(a){return q(a)&&0
    ',image:'',iframe:'",error:'

    The requested content cannot be loaded.
    Please try again later.

    ',closeBtn:'',next:'',prev:''},openEffect:"fade",openSpeed:250,openEasing:"swing",openOpacity:!0, 6 | openMethod:"zoomIn",closeEffect:"fade",closeSpeed:250,closeEasing:"swing",closeOpacity:!0,closeMethod:"zoomOut",nextEffect:"elastic",nextSpeed:250,nextEasing:"swing",nextMethod:"changeIn",prevEffect:"elastic",prevSpeed:250,prevEasing:"swing",prevMethod:"changeOut",helpers:{overlay:!0,title:!0},onCancel:f.noop,beforeLoad:f.noop,afterLoad:f.noop,beforeShow:f.noop,afterShow:f.noop,beforeChange:f.noop,beforeClose:f.noop,afterClose:f.noop},group:{},opts:{},previous:null,coming:null,current:null,isActive:!1, 7 | isOpen:!1,isOpened:!1,wrap:null,skin:null,outer:null,inner:null,player:{timer:null,isActive:!1},ajaxLoad:null,imgPreload:null,transitions:{},helpers:{},open:function(a,d){if(a&&(f.isPlainObject(d)||(d={}),!1!==b.close(!0)))return f.isArray(a)||(a=t(a)?f(a).get():[a]),f.each(a,function(e,c){var k={},g,h,j,m,l;"object"===f.type(c)&&(c.nodeType&&(c=f(c)),t(c)?(k={href:c.data("fancybox-href")||c.attr("href"),title:c.data("fancybox-title")||c.attr("title"),isDom:!0,element:c},f.metadata&&f.extend(!0,k, 8 | c.metadata())):k=c);g=d.href||k.href||(q(c)?c:null);h=d.title!==v?d.title:k.title||"";m=(j=d.content||k.content)?"html":d.type||k.type;!m&&k.isDom&&(m=c.data("fancybox-type"),m||(m=(m=c.prop("class").match(/fancybox\.(\w+)/))?m[1]:null));q(g)&&(m||(b.isImage(g)?m="image":b.isSWF(g)?m="swf":"#"===g.charAt(0)?m="inline":q(c)&&(m="html",j=c)),"ajax"===m&&(l=g.split(/\s+/,2),g=l.shift(),l=l.shift()));j||("inline"===m?g?j=f(q(g)?g.replace(/.*(?=#[^\s]+$)/,""):g):k.isDom&&(j=c):"html"===m?j=g:!m&&(!g&& 9 | k.isDom)&&(m="inline",j=c));f.extend(k,{href:g,type:m,content:j,title:h,selector:l});a[e]=k}),b.opts=f.extend(!0,{},b.defaults,d),d.keys!==v&&(b.opts.keys=d.keys?f.extend({},b.defaults.keys,d.keys):!1),b.group=a,b._start(b.opts.index)},cancel:function(){var a=b.coming;a&&!1!==b.trigger("onCancel")&&(b.hideLoading(),b.ajaxLoad&&b.ajaxLoad.abort(),b.ajaxLoad=null,b.imgPreload&&(b.imgPreload.onload=b.imgPreload.onerror=null),a.wrap&&a.wrap.stop(!0,!0).trigger("onReset").remove(),b.coming=null,b.current|| 10 | b._afterZoomOut(a))},close:function(a){b.cancel();!1!==b.trigger("beforeClose")&&(b.unbindEvents(),b.isActive&&(!b.isOpen||!0===a?(f(".fancybox-wrap").stop(!0).trigger("onReset").remove(),b._afterZoomOut()):(b.isOpen=b.isOpened=!1,b.isClosing=!0,f(".fancybox-item, .fancybox-nav").remove(),b.wrap.stop(!0,!0).removeClass("fancybox-opened"),b.transitions[b.current.closeMethod]())))},play:function(a){var d=function(){clearTimeout(b.player.timer)},e=function(){d();b.current&&b.player.isActive&&(b.player.timer= 11 | setTimeout(b.next,b.current.playSpeed))},c=function(){d();p.unbind(".player");b.player.isActive=!1;b.trigger("onPlayEnd")};if(!0===a||!b.player.isActive&&!1!==a){if(b.current&&(b.current.loop||b.current.index=c.index?"next":"prev"],b.router=e||"jumpto",c.loop&&(0>a&&(a=c.group.length+a%c.group.length),a%=c.group.length),c.group[a]!==v&&(b.cancel(),b._start(a)))},reposition:function(a,d){var e=b.current,c=e?e.wrap:null,k;c&&(k=b._getPosition(d),a&&"scroll"===a.type?(delete k.position,c.stop(!0,!0).animate(k,200)):(c.css(k),e.pos=f.extend({},e.dim,k)))},update:function(a){var d= 13 | a&&a.type,e=!d||"orientationchange"===d;e&&(clearTimeout(B),B=null);b.isOpen&&!B&&(B=setTimeout(function(){var c=b.current;c&&!b.isClosing&&(b.wrap.removeClass("fancybox-tmp"),(e||"load"===d||"resize"===d&&c.autoResize)&&b._setDimension(),"scroll"===d&&c.canShrink||b.reposition(a),b.trigger("onUpdate"),B=null)},e&&!s?0:300))},toggle:function(a){b.isOpen&&(b.current.fitToView="boolean"===f.type(a)?a:!b.current.fitToView,s&&(b.wrap.removeAttr("style").addClass("fancybox-tmp"),b.trigger("onUpdate")), 14 | b.update())},hideLoading:function(){p.unbind(".loading");f("#fancybox-loading").remove()},showLoading:function(){var a,d;b.hideLoading();a=f('
    ').click(b.cancel).appendTo("body");p.bind("keydown.loading",function(a){if(27===(a.which||a.keyCode))a.preventDefault(),b.cancel()});b.defaults.fixed||(d=b.getViewport(),a.css({position:"absolute",top:0.5*d.h+d.y,left:0.5*d.w+d.x}))},getViewport:function(){var a=b.current&&b.current.locked||!1,d={x:n.scrollLeft(), 15 | y:n.scrollTop()};a?(d.w=a[0].clientWidth,d.h=a[0].clientHeight):(d.w=s&&r.innerWidth?r.innerWidth:n.width(),d.h=s&&r.innerHeight?r.innerHeight:n.height());return d},unbindEvents:function(){b.wrap&&t(b.wrap)&&b.wrap.unbind(".fb");p.unbind(".fb");n.unbind(".fb")},bindEvents:function(){var a=b.current,d;a&&(n.bind("orientationchange.fb"+(s?"":" resize.fb")+(a.autoCenter&&!a.locked?" scroll.fb":""),b.update),(d=a.keys)&&p.bind("keydown.fb",function(e){var c=e.which||e.keyCode,k=e.target||e.srcElement; 16 | if(27===c&&b.coming)return!1;!e.ctrlKey&&(!e.altKey&&!e.shiftKey&&!e.metaKey&&(!k||!k.type&&!f(k).is("[contenteditable]")))&&f.each(d,function(d,k){if(1h[0].clientWidth||h[0].clientHeight&&h[0].scrollHeight>h[0].clientHeight),h=f(h).parent();if(0!==c&&!j&&1g||0>k)b.next(0>g?"up":"right");d.preventDefault()}}))},trigger:function(a,d){var e,c=d||b.coming||b.current;if(c){f.isFunction(c[a])&&(e=c[a].apply(c,Array.prototype.slice.call(arguments,1)));if(!1===e)return!1;c.helpers&&f.each(c.helpers,function(d,e){if(e&&b.helpers[d]&&f.isFunction(b.helpers[d][a]))b.helpers[d][a](f.extend(!0, 18 | {},b.helpers[d].defaults,e),c)});p.trigger(a)}},isImage:function(a){return q(a)&&a.match(/(^data:image\/.*,)|(\.(jp(e|g|eg)|gif|png|bmp|webp|svg)((\?|#).*)?$)/i)},isSWF:function(a){return q(a)&&a.match(/\.(swf)((\?|#).*)?$/i)},_start:function(a){var d={},e,c;a=l(a);e=b.group[a]||null;if(!e)return!1;d=f.extend(!0,{},b.opts,e);e=d.margin;c=d.padding;"number"===f.type(e)&&(d.margin=[e,e,e,e]);"number"===f.type(c)&&(d.padding=[c,c,c,c]);d.modal&&f.extend(!0,d,{closeBtn:!1,closeClick:!1,nextClick:!1,arrows:!1, 19 | mouseWheel:!1,keys:null,helpers:{overlay:{closeClick:!1}}});d.autoSize&&(d.autoWidth=d.autoHeight=!0);"auto"===d.width&&(d.autoWidth=!0);"auto"===d.height&&(d.autoHeight=!0);d.group=b.group;d.index=a;b.coming=d;if(!1===b.trigger("beforeLoad"))b.coming=null;else{c=d.type;e=d.href;if(!c)return b.coming=null,b.current&&b.router&&"jumpto"!==b.router?(b.current.index=a,b[b.router](b.direction)):!1;b.isActive=!0;if("image"===c||"swf"===c)d.autoHeight=d.autoWidth=!1,d.scrolling="visible";"image"===c&&(d.aspectRatio= 20 | !0);"iframe"===c&&s&&(d.scrolling="scroll");d.wrap=f(d.tpl.wrap).addClass("fancybox-"+(s?"mobile":"desktop")+" fancybox-type-"+c+" fancybox-tmp "+d.wrapCSS).appendTo(d.parent||"body");f.extend(d,{skin:f(".fancybox-skin",d.wrap),outer:f(".fancybox-outer",d.wrap),inner:f(".fancybox-inner",d.wrap)});f.each(["Top","Right","Bottom","Left"],function(a,b){d.skin.css("padding"+b,w(d.padding[a]))});b.trigger("onReady");if("inline"===c||"html"===c){if(!d.content||!d.content.length)return b._error("content")}else if(!e)return b._error("href"); 21 | "image"===c?b._loadImage():"ajax"===c?b._loadAjax():"iframe"===c?b._loadIframe():b._afterLoad()}},_error:function(a){f.extend(b.coming,{type:"html",autoWidth:!0,autoHeight:!0,minWidth:0,minHeight:0,scrolling:"no",hasError:a,content:b.coming.tpl.error});b._afterLoad()},_loadImage:function(){var a=b.imgPreload=new Image;a.onload=function(){this.onload=this.onerror=null;b.coming.width=this.width/b.opts.pixelRatio;b.coming.height=this.height/b.opts.pixelRatio;b._afterLoad()};a.onerror=function(){this.onload= 22 | this.onerror=null;b._error("image")};a.src=b.coming.href;!0!==a.complete&&b.showLoading()},_loadAjax:function(){var a=b.coming;b.showLoading();b.ajaxLoad=f.ajax(f.extend({},a.ajax,{url:a.href,error:function(a,e){b.coming&&"abort"!==e?b._error("ajax",a):b.hideLoading()},success:function(d,e){"success"===e&&(a.content=d,b._afterLoad())}}))},_loadIframe:function(){var a=b.coming,d=f(a.tpl.iframe.replace(/\{rnd\}/g,(new Date).getTime())).attr("scrolling",s?"auto":a.iframe.scrolling).attr("src",a.href); 23 | f(a.wrap).bind("onReset",function(){try{f(this).find("iframe").hide().attr("src","//about:blank").end().empty()}catch(a){}});a.iframe.preload&&(b.showLoading(),d.one("load",function(){f(this).data("ready",1);s||f(this).bind("load.fb",b.update);f(this).parents(".fancybox-wrap").width("100%").removeClass("fancybox-tmp").show();b._afterLoad()}));a.content=d.appendTo(a.inner);a.iframe.preload||b._afterLoad()},_preloadImages:function(){var a=b.group,d=b.current,e=a.length,c=d.preload?Math.min(d.preload, 24 | e-1):0,f,g;for(g=1;g<=c;g+=1)f=a[(d.index+g)%e],"image"===f.type&&f.href&&((new Image).src=f.href)},_afterLoad:function(){var a=b.coming,d=b.current,e,c,k,g,h;b.hideLoading();if(a&&!1!==b.isActive)if(!1===b.trigger("afterLoad",a,d))a.wrap.stop(!0).trigger("onReset").remove(),b.coming=null;else{d&&(b.trigger("beforeChange",d),d.wrap.stop(!0).removeClass("fancybox-opened").find(".fancybox-item, .fancybox-nav").remove());b.unbindEvents();e=a.content;c=a.type;k=a.scrolling;f.extend(b,{wrap:a.wrap,skin:a.skin, 25 | outer:a.outer,inner:a.inner,current:a,previous:d});g=a.href;switch(c){case "inline":case "ajax":case "html":a.selector?e=f("
    ").html(e).find(a.selector):t(e)&&(e.data("fancybox-placeholder")||e.data("fancybox-placeholder",f('
    ').insertAfter(e).hide()),e=e.show().detach(),a.wrap.bind("onReset",function(){f(this).find(e).length&&e.hide().replaceAll(e.data("fancybox-placeholder")).data("fancybox-placeholder",!1)}));break;case "image":e=a.tpl.image.replace("{href}", 26 | g);break;case "swf":e='',h="",f.each(a.swf,function(a,b){e+='';h+=" "+a+'="'+b+'"'}),e+='"}(!t(e)||!e.parent().is(a.inner))&&a.inner.append(e);b.trigger("beforeShow");a.inner.css("overflow","yes"===k?"scroll": 27 | "no"===k?"hidden":k);b._setDimension();b.reposition();b.isOpen=!1;b.coming=null;b.bindEvents();if(b.isOpened){if(d.prevMethod)b.transitions[d.prevMethod]()}else f(".fancybox-wrap").not(a.wrap).stop(!0).trigger("onReset").remove();b.transitions[b.isOpened?a.nextMethod:a.openMethod]();b._preloadImages()}},_setDimension:function(){var a=b.getViewport(),d=0,e=!1,c=!1,e=b.wrap,k=b.skin,g=b.inner,h=b.current,c=h.width,j=h.height,m=h.minWidth,u=h.minHeight,n=h.maxWidth,p=h.maxHeight,s=h.scrolling,q=h.scrollOutside? 28 | h.scrollbarWidth:0,x=h.margin,y=l(x[1]+x[3]),r=l(x[0]+x[2]),v,z,t,C,A,F,B,D,H;e.add(k).add(g).width("auto").height("auto").removeClass("fancybox-tmp");x=l(k.outerWidth(!0)-k.width());v=l(k.outerHeight(!0)-k.height());z=y+x;t=r+v;C=E(c)?(a.w-z)*l(c)/100:c;A=E(j)?(a.h-t)*l(j)/100:j;if("iframe"===h.type){if(H=h.content,h.autoHeight&&1===H.data("ready"))try{H[0].contentWindow.document.location&&(g.width(C).height(9999),F=H.contents().find("body"),q&&F.css("overflow-x","hidden"),A=F.outerHeight(!0))}catch(G){}}else if(h.autoWidth|| 29 | h.autoHeight)g.addClass("fancybox-tmp"),h.autoWidth||g.width(C),h.autoHeight||g.height(A),h.autoWidth&&(C=g.width()),h.autoHeight&&(A=g.height()),g.removeClass("fancybox-tmp");c=l(C);j=l(A);D=C/A;m=l(E(m)?l(m,"w")-z:m);n=l(E(n)?l(n,"w")-z:n);u=l(E(u)?l(u,"h")-t:u);p=l(E(p)?l(p,"h")-t:p);F=n;B=p;h.fitToView&&(n=Math.min(a.w-z,n),p=Math.min(a.h-t,p));z=a.w-y;r=a.h-r;h.aspectRatio?(c>n&&(c=n,j=l(c/D)),j>p&&(j=p,c=l(j*D)),cz||y>r)&&(c>m&&j>u)&&!(19n&&(c=n,j=l(c/D)),g.width(c).height(j),e.width(c+x),a=e.width(),y=e.height();else c=Math.max(m,Math.min(c,c-(a-z))),j=Math.max(u,Math.min(j,j-(y-r)));q&&("auto"===s&&jz||y>r)&&c>m&&j>u;c=h.aspectRatio?cu&&j
    ').appendTo(b.coming?b.coming.parent:a.parent);this.fixed=!1;a.fixed&&b.defaults.fixed&&(this.overlay.addClass("fancybox-overlay-fixed"),this.fixed=!0)},open:function(a){var d=this;a=f.extend({},this.defaults,a);this.overlay?this.overlay.unbind(".overlay").width("auto").height("auto"):this.create(a);this.fixed||(n.bind("resize.overlay",f.proxy(this.update,this)),this.update());a.closeClick&&this.overlay.bind("click.overlay",function(a){if(f(a.target).hasClass("fancybox-overlay"))return b.isActive? 40 | b.close():d.close(),!1});this.overlay.css(a.css).show()},close:function(){var a,b;n.unbind("resize.overlay");this.el.hasClass("fancybox-lock")&&(f(".fancybox-margin").removeClass("fancybox-margin"),a=n.scrollTop(),b=n.scrollLeft(),this.el.removeClass("fancybox-lock"),n.scrollTop(a).scrollLeft(b));f(".fancybox-overlay").remove().hide();f.extend(this,{overlay:null,fixed:!1})},update:function(){var a="100%",b;this.overlay.width(a).height("100%");I?(b=Math.max(G.documentElement.offsetWidth,G.body.offsetWidth), 41 | p.width()>b&&(a=p.width())):p.width()>n.width()&&(a=p.width());this.overlay.width(a).height(p.height())},onReady:function(a,b){var e=this.overlay;f(".fancybox-overlay").stop(!0,!0);e||this.create(a);a.locked&&(this.fixed&&b.fixed)&&(e||(this.margin=p.height()>n.height()?f("html").css("margin-right").replace("px",""):!1),b.locked=this.overlay.append(b.wrap),b.fixed=!1);!0===a.showEarly&&this.beforeShow.apply(this,arguments)},beforeShow:function(a,b){var e,c;b.locked&&(!1!==this.margin&&(f("*").filter(function(){return"fixed"=== 42 | f(this).css("position")&&!f(this).hasClass("fancybox-overlay")&&!f(this).hasClass("fancybox-wrap")}).addClass("fancybox-margin"),this.el.addClass("fancybox-margin")),e=n.scrollTop(),c=n.scrollLeft(),this.el.addClass("fancybox-lock"),n.scrollTop(e).scrollLeft(c));this.open(a)},onUpdate:function(){this.fixed||this.update()},afterClose:function(a){this.overlay&&!b.coming&&this.overlay.fadeOut(a.speedOut,f.proxy(this.close,this))}};b.helpers.title={defaults:{type:"float",position:"bottom"},beforeShow:function(a){var d= 43 | b.current,e=d.title,c=a.type;f.isFunction(e)&&(e=e.call(d.element,d));if(q(e)&&""!==f.trim(e)){d=f('
    '+e+"
    ");switch(c){case "inside":c=b.skin;break;case "outside":c=b.wrap;break;case "over":c=b.inner;break;default:c=b.skin,d.appendTo("body"),I&&d.width(d.width()),d.wrapInner(''),b.current.margin[2]+=Math.abs(l(d.css("margin-bottom")))}d["top"===a.position?"prependTo":"appendTo"](c)}}};f.fn.fancybox=function(a){var d, 44 | e=f(this),c=this.selector||"",k=function(g){var h=f(this).blur(),j=d,k,l;!g.ctrlKey&&(!g.altKey&&!g.shiftKey&&!g.metaKey)&&!h.is(".fancybox-wrap")&&(k=a.groupAttr||"data-fancybox-group",l=h.attr(k),l||(k="rel",l=h.get(0)[k]),l&&(""!==l&&"nofollow"!==l)&&(h=c.length?f(c):e,h=h.filter("["+k+'="'+l+'"]'),j=h.index(this)),a.index=j,!1!==b.open(h,a)&&g.preventDefault())};a=a||{};d=a.index||0;!c||!1===a.live?e.unbind("click.fb-start").bind("click.fb-start",k):p.undelegate(c,"click.fb-start").delegate(c+ 45 | ":not('.fancybox-item, .fancybox-nav')","click.fb-start",k);this.filter("[data-fancybox-start=1]").trigger("click");return this};p.ready(function(){var a,d;f.scrollbarWidth===v&&(f.scrollbarWidth=function(){var a=f('
    ').appendTo("body"),b=a.children(),b=b.innerWidth()-b.height(99).innerWidth();a.remove();return b});if(f.support.fixedPosition===v){a=f.support;d=f('
    ').appendTo("body");var e=20=== 46 | d[0].offsetTop||15===d[0].offsetTop;d.remove();a.fixedPosition=e}f.extend(b.defaults,{scrollbarWidth:f.scrollbarWidth(),fixed:f.support.fixedPosition,parent:f("body")});a=f(r).width();J.addClass("fancybox-lock-test");d=f(r).width();J.removeClass("fancybox-lock-test");f("").appendTo("head")})})(window,document,jQuery); -------------------------------------------------------------------------------- /public/js/typeahead.bundle.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * typeahead.js 0.10.5 3 | * https://github.com/twitter/typeahead.js 4 | * Copyright 2013-2014 Twitter, Inc. and other contributors; Licensed MIT 5 | */ 6 | 7 | !function(a){var b=function(){"use strict";return{isMsie:function(){return/(msie|trident)/i.test(navigator.userAgent)?navigator.userAgent.match(/(msie |rv:)(\d+(.\d+)?)/i)[2]:!1},isBlankString:function(a){return!a||/^\s*$/.test(a)},escapeRegExChars:function(a){return a.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},isString:function(a){return"string"==typeof a},isNumber:function(a){return"number"==typeof a},isArray:a.isArray,isFunction:a.isFunction,isObject:a.isPlainObject,isUndefined:function(a){return"undefined"==typeof a},toStr:function(a){return b.isUndefined(a)||null===a?"":a+""},bind:a.proxy,each:function(b,c){function d(a,b){return c(b,a)}a.each(b,d)},map:a.map,filter:a.grep,every:function(b,c){var d=!0;return b?(a.each(b,function(a,e){return(d=c.call(null,e,a,b))?void 0:!1}),!!d):d},some:function(b,c){var d=!1;return b?(a.each(b,function(a,e){return(d=c.call(null,e,a,b))?!1:void 0}),!!d):d},mixin:a.extend,getUniqueId:function(){var a=0;return function(){return a++}}(),templatify:function(b){function c(){return String(b)}return a.isFunction(b)?b:c},defer:function(a){setTimeout(a,0)},debounce:function(a,b,c){var d,e;return function(){var f,g,h=this,i=arguments;return f=function(){d=null,c||(e=a.apply(h,i))},g=c&&!d,clearTimeout(d),d=setTimeout(f,b),g&&(e=a.apply(h,i)),e}},throttle:function(a,b){var c,d,e,f,g,h;return g=0,h=function(){g=new Date,e=null,f=a.apply(c,d)},function(){var i=new Date,j=b-(i-g);return c=this,d=arguments,0>=j?(clearTimeout(e),e=null,g=i,f=a.apply(c,d)):e||(e=setTimeout(h,j)),f}},noop:function(){}}}(),c="0.10.5",d=function(){"use strict";function a(a){return a=b.toStr(a),a?a.split(/\s+/):[]}function c(a){return a=b.toStr(a),a?a.split(/\W+/):[]}function d(a){return function(){var c=[].slice.call(arguments,0);return function(d){var e=[];return b.each(c,function(c){e=e.concat(a(b.toStr(d[c])))}),e}}}return{nonword:c,whitespace:a,obj:{nonword:d(c),whitespace:d(a)}}}(),e=function(){"use strict";function c(c){this.maxSize=b.isNumber(c)?c:100,this.reset(),this.maxSize<=0&&(this.set=this.get=a.noop)}function d(){this.head=this.tail=null}function e(a,b){this.key=a,this.val=b,this.prev=this.next=null}return b.mixin(c.prototype,{set:function(a,b){var c,d=this.list.tail;this.size>=this.maxSize&&(this.list.remove(d),delete this.hash[d.key]),(c=this.hash[a])?(c.val=b,this.list.moveToFront(c)):(c=new e(a,b),this.list.add(c),this.hash[a]=c,this.size++)},get:function(a){var b=this.hash[a];return b?(this.list.moveToFront(b),b.val):void 0},reset:function(){this.size=0,this.hash={},this.list=new d}}),b.mixin(d.prototype,{add:function(a){this.head&&(a.next=this.head,this.head.prev=a),this.head=a,this.tail=this.tail||a},remove:function(a){a.prev?a.prev.next=a.next:this.head=a.next,a.next?a.next.prev=a.prev:this.tail=a.prev},moveToFront:function(a){this.remove(a),this.add(a)}}),c}(),f=function(){"use strict";function a(a){this.prefix=["__",a,"__"].join(""),this.ttlKey="__ttl__",this.keyMatcher=new RegExp("^"+b.escapeRegExChars(this.prefix))}function c(){return(new Date).getTime()}function d(a){return JSON.stringify(b.isUndefined(a)?null:a)}function e(a){return JSON.parse(a)}var f,g;try{f=window.localStorage,f.setItem("~~~","!"),f.removeItem("~~~")}catch(h){f=null}return g=f&&window.JSON?{_prefix:function(a){return this.prefix+a},_ttlKey:function(a){return this._prefix(a)+this.ttlKey},get:function(a){return this.isExpired(a)&&this.remove(a),e(f.getItem(this._prefix(a)))},set:function(a,e,g){return b.isNumber(g)?f.setItem(this._ttlKey(a),d(c()+g)):f.removeItem(this._ttlKey(a)),f.setItem(this._prefix(a),d(e))},remove:function(a){return f.removeItem(this._ttlKey(a)),f.removeItem(this._prefix(a)),this},clear:function(){var a,b,c=[],d=f.length;for(a=0;d>a;a++)(b=f.key(a)).match(this.keyMatcher)&&c.push(b.replace(this.keyMatcher,""));for(a=c.length;a--;)this.remove(c[a]);return this},isExpired:function(a){var d=e(f.getItem(this._ttlKey(a)));return b.isNumber(d)&&c()>d?!0:!1}}:{get:b.noop,set:b.noop,remove:b.noop,clear:b.noop,isExpired:b.noop},b.mixin(a.prototype,g),a}(),g=function(){"use strict";function c(b){b=b||{},this.cancelled=!1,this.lastUrl=null,this._send=b.transport?d(b.transport):a.ajax,this._get=b.rateLimiter?b.rateLimiter(this._get):this._get,this._cache=b.cache===!1?new e(0):i}function d(c){return function(d,e){function f(a){b.defer(function(){h.resolve(a)})}function g(a){b.defer(function(){h.reject(a)})}var h=a.Deferred();return c(d,e,f,g),h}}var f=0,g={},h=6,i=new e(10);return c.setMaxPendingRequests=function(a){h=a},c.resetCache=function(){i.reset()},b.mixin(c.prototype,{_get:function(a,b,c){function d(b){c&&c(null,b),k._cache.set(a,b)}function e(){c&&c(!0)}function i(){f--,delete g[a],k.onDeckRequestArgs&&(k._get.apply(k,k.onDeckRequestArgs),k.onDeckRequestArgs=null)}var j,k=this;this.cancelled||a!==this.lastUrl||((j=g[a])?j.done(d).fail(e):h>f?(f++,g[a]=this._send(a,b).done(d).fail(e).always(i)):this.onDeckRequestArgs=[].slice.call(arguments,0))},get:function(a,c,d){var e;return b.isFunction(c)&&(d=c,c={}),this.cancelled=!1,this.lastUrl=a,(e=this._cache.get(a))?b.defer(function(){d&&d(null,e)}):this._get(a,c,d),!!e},cancel:function(){this.cancelled=!0}}),c}(),h=function(){"use strict";function c(b){b=b||{},b.datumTokenizer&&b.queryTokenizer||a.error("datumTokenizer and queryTokenizer are both required"),this.datumTokenizer=b.datumTokenizer,this.queryTokenizer=b.queryTokenizer,this.reset()}function d(a){return a=b.filter(a,function(a){return!!a}),a=b.map(a,function(a){return a.toLowerCase()})}function e(){return{ids:[],children:{}}}function f(a){for(var b={},c=[],d=0,e=a.length;e>d;d++)b[a[d]]||(b[a[d]]=!0,c.push(a[d]));return c}function g(a,b){function c(a,b){return a-b}var d=0,e=0,f=[];a=a.sort(c),b=b.sort(c);for(var g=a.length,h=b.length;g>d&&h>e;)a[d]b[e]?e++:(f.push(a[d]),d++,e++);return f}return b.mixin(c.prototype,{bootstrap:function(a){this.datums=a.datums,this.trie=a.trie},add:function(a){var c=this;a=b.isArray(a)?a:[a],b.each(a,function(a){var f,g;f=c.datums.push(a)-1,g=d(c.datumTokenizer(a)),b.each(g,function(a){var b,d,g;for(b=c.trie,d=a.split("");g=d.shift();)b=b.children[g]||(b.children[g]=e()),b.ids.push(f)})})},get:function(a){var c,e,h=this;return c=d(this.queryTokenizer(a)),b.each(c,function(a){var b,c,d,f;if(e&&0===e.length)return!1;for(b=h.trie,c=a.split("");b&&(d=c.shift());)b=b.children[d];return b&&0===c.length?(f=b.ids.slice(0),void(e=e?g(e,f):f)):(e=[],!1)}),e?b.map(f(e),function(a){return h.datums[a]}):[]},reset:function(){this.datums=[],this.trie=e()},serialize:function(){return{datums:this.datums,trie:this.trie}}}),c}(),i=function(){"use strict";function d(a){return a.local||null}function e(d){var e,f;return f={url:null,thumbprint:"",ttl:864e5,filter:null,ajax:{}},(e=d.prefetch||null)&&(e=b.isString(e)?{url:e}:e,e=b.mixin(f,e),e.thumbprint=c+e.thumbprint,e.ajax.type=e.ajax.type||"GET",e.ajax.dataType=e.ajax.dataType||"json",!e.url&&a.error("prefetch requires url to be set")),e}function f(c){function d(a){return function(c){return b.debounce(c,a)}}function e(a){return function(c){return b.throttle(c,a)}}var f,g;return g={url:null,cache:!0,wildcard:"%QUERY",replace:null,rateLimitBy:"debounce",rateLimitWait:300,send:null,filter:null,ajax:{}},(f=c.remote||null)&&(f=b.isString(f)?{url:f}:f,f=b.mixin(g,f),f.rateLimiter=/^throttle$/i.test(f.rateLimitBy)?e(f.rateLimitWait):d(f.rateLimitWait),f.ajax.type=f.ajax.type||"GET",f.ajax.dataType=f.ajax.dataType||"json",delete f.rateLimitBy,delete f.rateLimitWait,!f.url&&a.error("remote requires url to be set")),f}return{local:d,prefetch:e,remote:f}}();!function(c){"use strict";function e(b){b&&(b.local||b.prefetch||b.remote)||a.error("one of local, prefetch, or remote is required"),this.limit=b.limit||5,this.sorter=j(b.sorter),this.dupDetector=b.dupDetector||k,this.local=i.local(b),this.prefetch=i.prefetch(b),this.remote=i.remote(b),this.cacheKey=this.prefetch?this.prefetch.cacheKey||this.prefetch.url:null,this.index=new h({datumTokenizer:b.datumTokenizer,queryTokenizer:b.queryTokenizer}),this.storage=this.cacheKey?new f(this.cacheKey):null}function j(a){function c(b){return b.sort(a)}function d(a){return a}return b.isFunction(a)?c:d}function k(){return!1}var l,m;return l=c.Bloodhound,m={data:"data",protocol:"protocol",thumbprint:"thumbprint"},c.Bloodhound=e,e.noConflict=function(){return c.Bloodhound=l,e},e.tokenizers=d,b.mixin(e.prototype,{_loadPrefetch:function(b){function c(a){f.clear(),f.add(b.filter?b.filter(a):a),f._saveToStorage(f.index.serialize(),b.thumbprint,b.ttl)}var d,e,f=this;return(d=this._readFromStorage(b.thumbprint))?(this.index.bootstrap(d),e=a.Deferred().resolve()):e=a.ajax(b.url,b.ajax).done(c),e},_getFromRemote:function(a,b){function c(a,c){b(a?[]:f.remote.filter?f.remote.filter(c):c)}var d,e,f=this;if(this.transport)return a=a||"",e=encodeURIComponent(a),d=this.remote.replace?this.remote.replace(this.remote.url,a):this.remote.url.replace(this.remote.wildcard,e),this.transport.get(d,this.remote.ajax,c)},_cancelLastRemoteRequest:function(){this.transport&&this.transport.cancel()},_saveToStorage:function(a,b,c){this.storage&&(this.storage.set(m.data,a,c),this.storage.set(m.protocol,location.protocol,c),this.storage.set(m.thumbprint,b,c))},_readFromStorage:function(a){var b,c={};return this.storage&&(c.data=this.storage.get(m.data),c.protocol=this.storage.get(m.protocol),c.thumbprint=this.storage.get(m.thumbprint)),b=c.thumbprint!==a||c.protocol!==location.protocol,c.data&&!b?c.data:null},_initialize:function(){function c(){e.add(b.isFunction(f)?f():f)}var d,e=this,f=this.local;return d=this.prefetch?this._loadPrefetch(this.prefetch):a.Deferred().resolve(),f&&d.done(c),this.transport=this.remote?new g(this.remote):null,this.initPromise=d.promise()},initialize:function(a){return!this.initPromise||a?this._initialize():this.initPromise},add:function(a){this.index.add(a)},get:function(a,c){function d(a){var d=f.slice(0);b.each(a,function(a){var c;return c=b.some(d,function(b){return e.dupDetector(a,b)}),!c&&d.push(a),d.length0||!this.transport)&&c&&c(f)},clear:function(){this.index.reset()},clearPrefetchCache:function(){this.storage&&this.storage.clear()},clearRemoteCache:function(){this.transport&&g.resetCache()},ttAdapter:function(){return b.bind(this.get,this)}}),e}(this);var j=function(){return{wrapper:'',dropdown:'',dataset:'
    ',suggestions:'',suggestion:'
    '}}(),k=function(){"use strict";var a={wrapper:{position:"relative",display:"inline-block"},hint:{position:"absolute",top:"0",left:"0",borderColor:"transparent",boxShadow:"none",opacity:"1"},input:{position:"relative",verticalAlign:"top",backgroundColor:"transparent"},inputWithNoHint:{position:"relative",verticalAlign:"top"},dropdown:{position:"absolute",top:"100%",left:"0",zIndex:"100",display:"none"},suggestions:{display:"block"},suggestion:{whiteSpace:"nowrap",cursor:"pointer"},suggestionChild:{whiteSpace:"normal"},ltr:{left:"0",right:"auto"},rtl:{left:"auto",right:" 0"}};return b.isMsie()&&b.mixin(a.input,{backgroundImage:"url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)"}),b.isMsie()&&b.isMsie()<=7&&b.mixin(a.input,{marginTop:"-1px"}),a}(),l=function(){"use strict";function c(b){b&&b.el||a.error("EventBus initialized without el"),this.$el=a(b.el)}var d="typeahead:";return b.mixin(c.prototype,{trigger:function(a){var b=[].slice.call(arguments,1);this.$el.trigger(d+a,b)}}),c}(),m=function(){"use strict";function a(a,b,c,d){var e;if(!c)return this;for(b=b.split(i),c=d?h(c,d):c,this._callbacks=this._callbacks||{};e=b.shift();)this._callbacks[e]=this._callbacks[e]||{sync:[],async:[]},this._callbacks[e][a].push(c);return this}function b(b,c,d){return a.call(this,"async",b,c,d)}function c(b,c,d){return a.call(this,"sync",b,c,d)}function d(a){var b;if(!this._callbacks)return this;for(a=a.split(i);b=a.shift();)delete this._callbacks[b];return this}function e(a){var b,c,d,e,g;if(!this._callbacks)return this;for(a=a.split(i),d=[].slice.call(arguments,1);(b=a.shift())&&(c=this._callbacks[b]);)e=f(c.sync,this,[b].concat(d)),g=f(c.async,this,[b].concat(d)),e()&&j(g);return this}function f(a,b,c){function d(){for(var d,e=0,f=a.length;!d&&f>e;e+=1)d=a[e].apply(b,c)===!1;return!d}return d}function g(){var a;return a=window.setImmediate?function(a){setImmediate(function(){a()})}:function(a){setTimeout(function(){a()},0)}}function h(a,b){return a.bind?a.bind(b):function(){a.apply(b,[].slice.call(arguments,0))}}var i=/\s+/,j=g();return{onSync:c,onAsync:b,off:d,trigger:e}}(),n=function(a){"use strict";function c(a,c,d){for(var e,f=[],g=0,h=a.length;h>g;g++)f.push(b.escapeRegExChars(a[g]));return e=d?"\\b("+f.join("|")+")\\b":"("+f.join("|")+")",c?new RegExp(e):new RegExp(e,"i")}var d={node:null,pattern:null,tagName:"strong",className:null,wordsOnly:!1,caseSensitive:!1};return function(e){function f(b){var c,d,f;return(c=h.exec(b.data))&&(f=a.createElement(e.tagName),e.className&&(f.className=e.className),d=b.splitText(c.index),d.splitText(c[0].length),f.appendChild(d.cloneNode(!0)),b.parentNode.replaceChild(f,d)),!!c}function g(a,b){for(var c,d=3,e=0;e