Browse files

integrated changes

  • Loading branch information...
2 parents adccdfb + db0c501 commit 91973aac9acde5c65feb4ba97e4b6ab7322db4fb @JustinBeckwith committed Oct 18, 2012
View
426 frontend/public/js/default.js
@@ -0,0 +1,426 @@
+$(document)
+ .ready(function () {
+ var socket = io.connect();
+ socket.on('connect', function () {
+ var city = '';
+ var urlParts = window.location.href.split("/");
+ for (var i = urlParts.length - 1; i >= 0; i--) {
+ if (urlParts[i]) {
+ city = urlParts[i];
+ break;
+ }
+ }
+ if (!city) {
+ alert('invalid url! please give me a city.');
+ } else {
+ console.log('getting data for ' + city);
+ socket.emit('setCity', { city: city });
+ }
+ });
+
+ socket.on('newPic', function (pic) {
+ var p = JSON.parse(pic);
+ $.each(p.data, function (key, val) {
+ viewModel.addPicture(val.id, val.images, val.user, val.caption, val.location, val.comments, val.likes);
+ });
+ });
+ window.Radar = {
+ Browser: {
+ isMobileQuery: window.msMatchMedia ? window.msMatchMedia("screen and (max-width: 800px) and (max-height: 1280px)") : false
+ },
+ Components: {
+ ThumbnailViewer: {
+ pageSize: 15,
+ }
+ }
+ };
+ if (Radar.Browser.isMobileQuery.matches) {
+ Radar.Components.ThumbnailViewer.pageSize = 12;
+ }
+ Radar.Browser.isMobileQuery.addListener(mediaSizeChanged);
+
+
+ var User = function (username, profile_picture, id, full_name) {
+ this.username = username;
+ this.profile_picture = profile_picture;
+ this.id = id;
+ this.full_name = full_name;
+ };
+
+ var Comment = function (text, from) {
+ this.text = text;
+ this.from = new User(from.username, from.profile_picture, from.id, from.full_name);
+ this.fullHtml = this.text + " <img class='profile' src='" + this.from.profile_picture + "'/> " + this.from.full_name + " (" + this.from.username + ")"
+ };
+
+ var Location = function (latitude, longitude) {
+ this.latitude = latitude;
+ this.longitude = longitude;
+ this.fullText = "(" + this.latitude + ", " + this.longitude + ")";
+ };
+
+ var Picture = function (id, images, user, caption, location, comments, likes) {
+ var self = this;
+ this.id = id;
+ this.images = images;
+ this.user = new User(user.username, user.profile_picture, user.id, user.full_name);
+ if (caption == null) {
+ this.caption = null;
+ } else {
+ this.caption = new Comment(caption.text, caption.from);
+ }
+ this.captionWithFrom = ko.computed(function () {
+ if (this.caption == null) {
+ return null;
+ }
+ return (this.caption.fullHtml);
+ }, this);
+
+ if (location == null) {
+ this.location = null;
+ } else {
+ this.location = new Location(location.latitude, location.longitude);
+ }
+ this.fullLocation = ko.computed(function () {
+ if (this.location == null) {
+ return null;
+ }
+ return (this.location.fullText);
+ }, this);
+
+ if (comments == null) {
+ this.comments = null;
+ } else {
+ this.comments = ko.observableArray([]);
+ $.each(comments.data, function (key, val) {
+ self.comments.push(new Comment(this.text, this.from));
+ });
+ }
+
+ if (likes == null) {
+ this.likes = null;
+ } else {
+ this.likes = ko.observableArray([]);
+ $.each(likes.data, function (key, val) {
+ self.likes.push(new User(this.username, this.profile_picture, this.id, this.full_name));
+ });
+ };
+
+ this.pictureCaptionDisplay = ko.computed(function () {
+ if (self.caption != null && self.caption.text != null) {
+ return self.caption.text;
+ }
+ return "this picture";
+ });
+ };
+
+ var ViewModel = function () {
+ var self = this;
+ this.picturesWithBlanks = ko.observableArray([]);
+ this.backgroundPicture = ko.observable('linear-gradient(white, black);');
+ this.nextBackgroundPictureUrl = undefined;
+ this.detailPicture = ko.observable(null);
+ this.isDetailPicture = ko.observable(false);
+ this.isMapShown = ko.observable(false);
+ this.FindPicture = function(fnc) {
+ var a = this.picturesWithBlanks();
+ if (!fnc || typeof(fnc) != 'function') {
+ return null;
+ }
+ if (!a || !a.length || a.length < 1) return -1;
+ for (var i = 0; i < a.length; i++) {
+ if (fnc(a[i])) return a[i];
+ }
+ return null;
+ };
+ this.addPictureInternal = function(picture) {
+ self.picturesWithBlanks.unshift(picture);
+ viewModel.updateBlanks(Radar.Components.ThumbnailViewer.pageSize);
+ self.addPushPin(picture, false);
+ };
+
+ this.routes = Sammy(function () {
+ this.get('#:picture', function () {
+ var sammy = this;
+
+ var picture = viewModel.FindPicture(function (pic) {
+ return pic.id == decodeURIComponent(sammy.params.picture);
+ });
+
+ if (picture == undefined || picture.id == null) return;
+ var onImgLoad = function (imgSrc) {
+ self.detailPicture(picture);
+ self.isDetailPicture(true);
+
+ // make async call to get updated comment and like data
+
+ var id = picture.id;
+ var url = "http://waztagram.cloudapp.net/media/" + id + "?callback=?";
+ $.ajax({
+ url: url,
+ dataType: 'JSONP',
+ type: 'GET',
+ timeout: 10000,
+ success: callback,
+ error: function (data, textStatus, jqXHR) {
+ console.log("ERROR: " + jqXHR);
+ }
+ });
+ };
+ fetchImage(picture.images.standard_resolution.url, onImgLoad);
+ if ($('#map').hasClass('mapShown')) {
+ $('#map')
+ .addClass("mapHidden").removeClass("mapShown");
+ self.map.entities.remove(self.fullPushPin);
+ self.fullPushPin = null;
+ viewModel.isMapShown(false);
+ return;
+ }
+ });
+ this.get('#:picture/:map', function () {
+ var sammy = this;
+ var picture = viewModel.FindPicture(function (pic) {
+ return pic.id == decodeURIComponent(sammy.params.picture);
+ });
+ if (picture && sammy.params.map == "map") {
+ if ($('#map').hasClass('mapShown')) {
+ $('#map')
+ .addClass("mapHidden").removeClass("mapShown");
+ self.map.entities.remove(self.fullPushPin);
+ self.fullPushPin = null;
+ viewModel.isMapShown(false);
+ return;
+ }
+
+ self.addPushPin(self.detailPicture(), true);
+ self.map.setView({ zoom: 14, center: new Microsoft.Maps.Location(self.detailPicture().location.latitude, self.detailPicture().location.longitude) });
+ $('#map')
+ .removeClass("mapHidden").addClass("mapShown");
+ viewModel.isMapShown(true);
+ }
+
+ });
+ this.get('', function () {
+ if (self.isDetailPicture()) {
+ self.isDetailPicture(false);
+ self.detailPicture(null);
+ }
+ if ($('#map').hasClass('mapShown')) {
+ $('#map')
+ .addClass("mapHidden").removeClass("mapShown");
+ self.map.entities.remove(self.fullPushPin);
+ self.fullPushPin = null;
+ viewModel.isMapShown(false);
+ return;
+ }
+ });
+ }).run();
+
+ this.addPicture = function (id, images, user, caption, location, comments, likes) {
+ var self = this;
+ var newPic = new Picture(id, images, user, caption, location, comments, likes);
+
+ $.each(this.picturesWithBlanks(), function (key, val) {
+ if (val.id == id) {
+ if (val != self.picturesWithBlanks()[key]) {
+ self.picturesWithBlanks()[key] = newPic;
+ }
+ return;
+ }
+ });
+
+ var firstTime = (viewModel.nextBackgroundPictureUrl == undefined);
+ self.nextBackgroundPictureUrl = images.standard_resolution.url;
+ if (firstTime == true) self.updateBackgroundPicture();
+
+ fetchImageFromPicture(newPic, this.addPictureInternal);
+ };
+
+ this.updateBackgroundPicture = function () {
+ var onImgLoad = function (imgSrc) {
+ $('#transitionImageDiv')
+ .css('background-image', 'url(' + imgSrc + ')');
+ $('#transitionImageDiv')
+ .toggleClass('hidden');
+
+ setTimeout(function () {
+ self.backgroundPicture('url(' + imgSrc + ')');
+ // hide the transition div
+ $('#transitionImageDiv')
+ .toggleClass('hidden');
+ }, 500);
+ };
+ fetchImage(self.nextBackgroundPictureUrl, onImgLoad);
+ };
+
+ this.selectPicture = function (picture) {
+ location.hash = encodeURIComponent(picture.id);
+ };
+
+ function callback(data, textStatus, jqXHR) {
+ if (data) {
+ var newPic = new Picture(data.data.id, data.data.images, data.data.user, data.data.caption, data.data.location, data.data.comments, data.data.likes);
+ self.detailPicture(newPic);
+ }
+ }
+
+ this.unSelectPicture = function () {
+ location.hash = "";
+ };
+
+ this.updateBlanks = function (pageSize) {
+ var mod = self.picturesWithBlanks()
+ .length % pageSize;
+ var blankCount = (pageSize - mod) % pageSize;
+
+ var blankPhoto = function () {
+ var blankImages = new Object();
+ var thumbnail = new Object();
+ thumbnail.url = null;
+ blankImages.thumbnail = thumbnail;
+ blankImages.standard_resolution = thumbnail;
+ return new Picture(null, blankImages, new User(null, null, null, null), null, null, null, null);
+ };
+
+ if (self.picturesWithBlanks()[pageSize] == null || self.picturesWithBlanks()[pageSize].id != null) {
+ for (var i = 0; i < pageSize - 1; i++) {
+ var blank = blankPhoto();
+ self.picturesWithBlanks.splice(1, 0, blank);
+ }
+ return;
+ }
+ while (self.picturesWithBlanks()[pageSize] != null && self.picturesWithBlanks()[pageSize].id == null) {
+ self.picturesWithBlanks.remove(self.picturesWithBlanks()[pageSize]);
+ }
+ if (self.picturesWithBlanks()[self.picturesWithBlanks()
+ .length - 1].id != null) {
+ var blank = blankPhoto();
+ self.picturesWithBlanks.push(blank);
+ }
+ };
+
+ document.onreadystatechange = function() {
+ if (this.readyState == 'complete') {
+ var script = document.createElement('script');
+ script.type = 'text/javascript';
+ script.src = 'http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0';
+ document.getElementsByTagName('head')[0].appendChild(script);
+ script.onreadystatechange = function() {
+ if (this.readyState == 'complete') {
+ self.map = new Microsoft.Maps.Map(document.getElementById('myMap'), { credentials: 'Arha1ch48UwizeokfrS6sqAhtuRIwwRZgtI5XHBlQf8gOETZ8G7JEgshVsS8HPJI' });
+ }
+ };
+ }
+
+ };
+
+ this.showMap = function () {
+ if (viewModel.isDetailPicture() && !viewModel.isMapShown()) {
+ location.hash = viewModel.detailPicture().id + "/map";
+ return;
+ }
+ else if (viewModel.isDetailPicture()) {
+ location.hash = viewModel.detailPicture().id;
+ return;
+ }
+ location.hash = "";
+ };
+
+ this.fullPushPin = null;
+
+ this.addPushPin = function (picture, showFull) {
+ var pushpinOptions;
+ if (showFull) {
+ pushpinOptions = {
+ width: null, height: null, htmlContent:
+ "<div class='pushPinDiv'><svg class='pushPinSvg' xmlns='http://www.w3.org/2000/svg' version='1.1'>" +
+ "<circle cx='8vw' cy='8.9vw' r='.7vw' stroke-width='0' fill='#7EECFB'/></svg></div>" +
+ "<svg class='pushPinSvg pushPinSmallSvg' xmlns='http://www.w3.org/2000/svg' version='1.1'>" +
+ "<circle cx='0' cy='0vw' r='.4vw' stroke-width='0' fill='#E34D4D'/></svg>" +
+ "<div class='pushPinContainer'><img class='pushPinImage' src='" + picture.images.thumbnail.url + "'>" + picture.user.username + "</div>"
+ };
+ } else {
+ pushpinOptions = {
+ width: null, height: null, htmlContent:
+ "<div class='hiddenPushPin' id='hidden" + picture.id + "' onmouseover='showFullPreview(\"" + picture.id + "\")' onmouseout='hideFullPreview(\"" + picture.id + "\")'><svg class='pushPinSvg pushPinSmallSvg' xmlns='http://www.w3.org/2000/svg' version='1.1'>" +
+ "<circle cx='.375vw' cy='.375vw' r='.325vw' stroke-width='0' fill='#E34D4D'/></svg></div>" +
+ "<div id='preview" + picture.id + "' class='mapHidden' style='z-index: 10'>" +
+ " <div class='pushPinDiv'><svg class='pushPinSvg' xmlns='http://www.w3.org/2000/svg' version='1.1'>" +
+ " <circle cx='8vw' cy='8.9vw' r='.7vw' stroke-width='0' fill='#7EECFB'/></svg></div>" +
+ " <svg class='pushPinSvg pushPinSmallSvg' xmlns='http://www.w3.org/2000/svg' version='1.1'>" +
+ " <circle cx='0' cy='0vw' r='.4vw' stroke-width='0' fill='#E34D4D'/></svg>" +
+ " <div class='pushPinContainer'><img class='pushPinImage' src='" + picture.images.thumbnail.url + "'>" + picture.user.username + "</div>" +
+ "</div>"
+ };
+ }
+ if (self.map) {
+ var pushpinLocation = new Microsoft.Maps.Location(picture.location.latitude, picture.location.longitude);
+ var pushpin = new Microsoft.Maps.Pushpin(pushpinLocation, pushpinOptions);
+
+ if (showFull) {
+ self.fullPushPin = pushpin;
+ }
+
+ Microsoft.Maps.Events.addHandler(pushpin, 'click', function (e) {
+ self.map.entities.remove(self.fullPushPin);
+
+ self.selectPicture(picture);
+
+ self.addPushPin(picture, true);
+ });
+ self.map.entities.push(pushpin);
+ }
+ };
+ };
+
+ var viewModel = new ViewModel();
+ ko.applyBindings(viewModel);
+ setInterval(viewModel.updateBackgroundPicture, 10000);
+ });
+
+function fetchImage(src, onloadCallback) {
+ var img = new Image();
+ img.src = src;
+ if (onloadCallback != null) {
+ img.onload = function () {
+ onloadCallback(this.src);
+ };
+ }
+}
+
+function fetchImageFromPicture(picture, onloadCallback) {
+ var img = new Image();
+ img.src = picture.images.thumbnail.url;
+ if (onloadCallback != null) {
+ img.onload = function () {
+ onloadCallback(picture);
+ };
+ }
+}
+
+function toggleExpandDetails() {
+ $('#detailSideBar')
+ .toggleClass('expand');
+}
+
+function hideDetails() {
+ $('#detailSideBar')
+ .removeClass('expand');
+}
+
+function mediaSizeChanged() {
+ if (Radar.Browser.isMobileQuery.matches) {
+ Radar.Components.ThumbnailViewer.pageSize = 12;
+ }
+ else {
+ Radar.Components.ThumbnailViewer.pageSize = 15;
+ }
+}
+
+function showFullPreview(pictureId) {
+ document.getElementById("preview" + pictureId).className = '';
+}
+
+function hideFullPreview(pictureId) {
+ document.getElementById("preview" + pictureId).className = 'mapHidden';
+}
View
5 frontend/public/plugins/sammy-latest.min.js
@@ -0,0 +1,5 @@
+// -- Sammy.js -- /sammy.js
+// http://sammyjs.org
+// Version: 0.7.1
+// Built: Sat Mar 31 23:41:58 -0400 2012
+(function(h,j){var p,g="([^/]+)",k=/:([\w\d]+)/g,l=/\?([^#]*)?$/,c=function(q){return Array.prototype.slice.call(q)},d=function(q){return Object.prototype.toString.call(q)==="[object Function]"},m=function(q){return Object.prototype.toString.call(q)==="[object Array]"},i=function(q){return decodeURIComponent((q||"").replace(/\+/g," "))},b=encodeURIComponent,f=function(q){return String(q).replace(/&(?!\w+;)/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")},n=function(q){return function(r,s){return this.route.apply(this,[q,r,s])}},a={},o=!!(j.history&&history.pushState),e=[];p=function(){var r=c(arguments),s,q;p.apps=p.apps||{};if(r.length===0||r[0]&&d(r[0])){return p.apply(p,["body"].concat(r))}else{if(typeof(q=r.shift())=="string"){s=p.apps[q]||new p.Application();s.element_selector=q;if(r.length>0){h.each(r,function(t,u){s.use(u)})}if(s.element_selector!=q){delete p.apps[q]}p.apps[s.element_selector]=s;return s}}};p.VERSION="0.7.1";p.addLogger=function(q){e.push(q)};p.log=function(){var q=c(arguments);q.unshift("["+Date()+"]");h.each(e,function(s,r){r.apply(p,q)})};if(typeof j.console!="undefined"){if(d(j.console.log.apply)){p.addLogger(function(){j.console.log.apply(j.console,arguments)})}else{p.addLogger(function(){j.console.log(arguments)})}}else{if(typeof console!="undefined"){p.addLogger(function(){console.log.apply(console,arguments)})}}h.extend(p,{makeArray:c,isFunction:d,isArray:m});p.Object=function(q){return h.extend(this,q||{})};h.extend(p.Object.prototype,{escapeHTML:f,h:f,toHash:function(){var q={};h.each(this,function(s,r){if(!d(r)){q[s]=r}});return q},toHTML:function(){var q="";h.each(this,function(s,r){if(!d(r)){q+="<strong>"+s+"</strong> "+r+"<br />"}});return q},keys:function(q){var r=[];for(var s in this){if(!d(this[s])||!q){r.push(s)}}return r},has:function(q){return this[q]&&h.trim(this[q].toString())!==""},join:function(){var r=c(arguments);var q=r.shift();return r.join(q)},log:function(){p.log.apply(p,arguments)},toString:function(q){var r=[];h.each(this,function(t,s){if(!d(s)||q){r.push('"'+t+'": '+s.toString())}});return"Sammy.Object: {"+r.join(",")+"}"}});p.DefaultLocationProxy=function(r,q){this.app=r;this.is_native=false;this.has_history=o;this._startPolling(q)};p.DefaultLocationProxy.fullPath=function(q){var r=q.toString().match(/^[^#]*(#.+)$/);var s=r?r[1]:"";return[q.pathname,q.search,s].join("")};p.DefaultLocationProxy.prototype={bind:function(){var r=this,s=this.app,q=p.DefaultLocationProxy;h(j).bind("hashchange."+this.app.eventNamespace(),function(u,t){if(r.is_native===false&&!t){r.is_native=true;j.clearInterval(q._interval)}s.trigger("location-changed")});if(o&&!s.disable_push_state){h(j).bind("popstate."+this.app.eventNamespace(),function(t){s.trigger("location-changed")});h("a").live("click.history-"+this.app.eventNamespace(),function(u){if(u.isDefaultPrevented()){return}var t=q.fullPath(this);if(this.hostname==j.location.hostname&&s.lookupRoute("get",t)){u.preventDefault();r.setLocation(t);return false}})}if(!q._bindings){q._bindings=0}q._bindings++},unbind:function(){h(j).unbind("hashchange."+this.app.eventNamespace());h(j).unbind("popstate."+this.app.eventNamespace());h("a").die("click.history-"+this.app.eventNamespace());p.DefaultLocationProxy._bindings--;if(p.DefaultLocationProxy._bindings<=0){j.clearInterval(p.DefaultLocationProxy._interval)}},getLocation:function(){return p.DefaultLocationProxy.fullPath(j.location)},setLocation:function(q){if(/^([^#\/]|$)/.test(q)){if(o){q="/"+q}else{q="#!/"+q}}if(q!=this.getLocation()){if(o&&/^\//.test(q)){history.pushState({path:q},j.title,q);this.app.trigger("location-changed")}else{return(j.location=q)}}},_startPolling:function(s){var r=this;if(!p.DefaultLocationProxy._interval){if(!s){s=10}var q=function(){var t=r.getLocation();if(typeof p.DefaultLocationProxy._last_location=="undefined"||t!=p.DefaultLocationProxy._last_location){j.setTimeout(function(){h(j).trigger("hashchange",[true])},0)}p.DefaultLocationProxy._last_location=t};q();p.DefaultLocationProxy._interval=j.setInterval(q,s)}}};p.Application=function(q){var r=this;this.routes={};this.listeners=new p.Object({});this.arounds=[];this.befores=[];this.namespace=(new Date()).getTime()+"-"+parseInt(Math.random()*1000,10);this.context_prototype=function(){p.EventContext.apply(this,arguments)};this.context_prototype.prototype=new p.EventContext();if(d(q)){q.apply(this,[this])}if(!this._location_proxy){this.setLocationProxy(new p.DefaultLocationProxy(this,this.run_interval_every))}if(this.debug){this.bindToAllEvents(function(t,s){r.log(r.toString(),t.cleaned_type,s||{})})}};p.Application.prototype=h.extend({},p.Object.prototype,{ROUTE_VERBS:["get","post","put","delete"],APP_EVENTS:["run","unload","lookup-route","run-route","route-found","event-context-before","event-context-after","changed","error","check-form-submission","redirect","location-changed"],_last_route:null,_location_proxy:null,_running:false,element_selector:"body",debug:false,raise_errors:false,run_interval_every:50,disable_push_state:false,template_engine:null,toString:function(){return"Sammy.Application:"+this.element_selector},$element:function(q){return q?h(this.element_selector).find(q):h(this.element_selector)},use:function(){var q=c(arguments),s=q.shift(),r=s||"";try{q.unshift(this);if(typeof s=="string"){r="Sammy."+s;s=p[s]}s.apply(this,q)}catch(t){if(typeof s==="undefined"){this.error("Plugin Error: called use() but plugin ("+r.toString()+") is not defined",t)}else{if(!d(s)){this.error("Plugin Error: called use() but '"+r.toString()+"' is not a function",t)}else{this.error("Plugin Error",t)}}}return this},setLocationProxy:function(q){var r=this._location_proxy;this._location_proxy=q;if(this.isRunning()){if(r){r.unbind()}this._location_proxy.bind()}},log:function(){p.log.apply(p,Array.prototype.concat.apply([this.element_selector],arguments))},route:function(u,r,w){var t=this,v=[],q,s;if(!w&&d(r)){r=u;w=r;u="any"}u=u.toLowerCase();if(r.constructor==String){k.lastIndex=0;while((s=k.exec(r))!==null){v.push(s[1])}r=new RegExp(r.replace(k,g)+"$")}if(typeof w=="string"){w=t[w]}q=function(x){var y={verb:x,path:r,callback:w,param_names:v};t.routes[x]=t.routes[x]||[];t.routes[x].push(y)};if(u==="any"){h.each(this.ROUTE_VERBS,function(y,x){q(x)})}else{q(u)}return this},get:n("get"),post:n("post"),put:n("put"),del:n("delete"),any:n("any"),mapRoutes:function(r){var q=this;h.each(r,function(s,t){q.route.apply(q,t)});return this},eventNamespace:function(){return["sammy-app",this.namespace].join("-")},bind:function(q,s,u){var t=this;if(typeof u=="undefined"){u=s}var r=function(){var x,v,w;x=arguments[0];w=arguments[1];if(w&&w.context){v=w.context;delete w.context}else{v=new t.context_prototype(t,"bind",x.type,w,x.target)}x.cleaned_type=x.type.replace(t.eventNamespace(),"");u.apply(v,[x,w])};if(!this.listeners[q]){this.listeners[q]=[]}this.listeners[q].push(r);if(this.isRunning()){this._listen(q,r)}return this},trigger:function(q,r){this.$element().trigger([q,this.eventNamespace()].join("."),[r]);return this},refresh:function(){this.last_location=null;this.trigger("location-changed");return this},before:function(q,r){if(d(q)){r=q;q={}}this.befores.push([q,r]);return this},after:function(q){return this.bind("event-context-after",q)},around:function(q){this.arounds.push(q);return this},isRunning:function(){return this._running},helpers:function(q){h.extend(this.context_prototype.prototype,q);return this},helper:function(q,r){this.context_prototype.prototype[q]=r;return this},run:function(q){if(this.isRunning()){return false}var r=this;h.each(this.listeners.toHash(),function(s,t){h.each(t,function(v,u){r._listen(s,u)})});this.trigger("run",{start_url:q});this._running=true;this.last_location=null;if(!(/\#(.+)/.test(this.getLocation()))&&typeof q!="undefined"){this.setLocation(q)}this._checkLocation();this._location_proxy.bind();this.bind("location-changed",function(){r._checkLocation()});this.bind("submit",function(t){var s=r._checkFormSubmission(h(t.target).closest("form"));return(s===false)?t.preventDefault():false});h(j).bind("unload",function(){r.unload()});return this.trigger("changed")},unload:function(){if(!this.isRunning()){return false}var q=this;this.trigger("unload");this._location_proxy.unbind();this.$element().unbind("submit").removeClass(q.eventNamespace());h.each(this.listeners.toHash(),function(r,s){h.each(s,function(u,t){q._unlisten(r,t)})});this._running=false;return this},bindToAllEvents:function(r){var q=this;h.each(this.APP_EVENTS,function(s,t){q.bind(t,r)});h.each(this.listeners.keys(true),function(t,s){if(h.inArray(s,q.APP_EVENTS)==-1){q.bind(s,r)}});return this},routablePath:function(q){return q.replace(l,"")},lookupRoute:function(w,u){var v=this,t=false,s=0,q,r;if(typeof this.routes[w]!="undefined"){q=this.routes[w].length;for(;s<q;s++){r=this.routes[w][s];if(v.routablePath(u).match(r.path)){t=r;break}}}return t},runRoute:function(s,F,u,x){var t=this,D=this.lookupRoute(s,F),r,A,v,z,E,B,y,C,q;this.log("runRoute",[s,F].join(" "));this.trigger("run-route",{verb:s,path:F,params:u});if(typeof u=="undefined"){u={}}h.extend(u,this._parseQueryString(F));if(D){this.trigger("route-found",{route:D});if((C=D.path.exec(this.routablePath(F)))!==null){C.shift();h.each(C,function(G,H){if(D.param_names[G]){u[D.param_names[G]]=i(H)}else{if(!u.splat){u.splat=[]}u.splat.push(i(H))}})}r=new this.context_prototype(this,s,F,u,x);v=this.arounds.slice(0);E=this.befores.slice(0);y=[r].concat(u.splat);A=function(){var G;while(E.length>0){B=E.shift();if(t.contextMatchesOptions(r,B[0])){G=B[1].apply(r,[r]);if(G===false){return false}}}t.last_route=D;r.trigger("event-context-before",{context:r});G=D.callback.apply(r,y);r.trigger("event-context-after",{context:r});return G};h.each(v.reverse(),function(G,H){var I=A;A=function(){return H.apply(r,[I])}});try{q=A()}catch(w){this.error(["500 Error",s,F].join(" "),w)}return q}else{return this.notFound(s,F)}},contextMatchesOptions:function(r,t,y){var z=t;if(typeof z==="undefined"||h.isPlainObject(z)){return true}if(typeof y==="undefined"){y=true}if(typeof z==="string"||d(z.test)){z={path:z}}if(m(z.path)){var x,u,q;x=[];for(u in z.path){q=h.extend({},z,{path:z.path[u]});x.push(this.contextMatchesOptions(r,q))}var s=h.inArray(true,x)>-1?true:false;return y?s:!s}if(z.only){return this.contextMatchesOptions(r,z.only,true)}else{if(z.except){return this.contextMatchesOptions(r,z.except,false)}}var v=true,w=true;if(z.path){if(!d(z.path.test)){z.path=new RegExp(z.path.toString()+"$")}v=z.path.test(r.path)}if(z.verb){if(typeof z.verb==="string"){w=z.verb===r.verb}else{w=z.verb.indexOf(r.verb)>-1}}return y?(w&&v):!(w&&v)},getLocation:function(){return this._location_proxy.getLocation()},setLocation:function(q){return this._location_proxy.setLocation(q)},swap:function(r,s){var q=this.$element().html(r);if(d(s)){s(r)}return q},templateCache:function(q,r){if(typeof r!="undefined"){return a[q]=r}else{return a[q]}},clearTemplateCache:function(){return a={}},notFound:function(s,r){var q=this.error(["404 Not Found",s,r].join(" "));return(s==="get")?q:true},error:function(r,q){if(!q){q=new Error()}q.message=[r,q.message].join(" ");this.trigger("error",{message:q.message,error:q});if(this.raise_errors){throw (q)}else{this.log(q.message,q)}},_checkLocation:function(){var q,r;q=this.getLocation();if(!this.last_location||this.last_location[0]!="get"||this.last_location[1]!=q){this.last_location=["get",q];r=this.runRoute("get",q)}return r},_getFormVerb:function(s){var r=h(s),t,q;q=r.find('input[name="_method"]');if(q.length>0){t=q.val()}if(!t){t=r[0].getAttribute("method")}if(!t||t==""){t="get"}return h.trim(t.toString().toLowerCase())},_checkFormSubmission:function(s){var q,t,v,u,r;this.trigger("check-form-submission",{form:s});q=h(s);t=q.attr("action")||"";v=this._getFormVerb(q);this.log("_checkFormSubmission",q,t,v);if(v==="get"){u=this._serializeFormParams(q);if(u!==""){t+="?"+u}this.setLocation(t);r=false}else{u=h.extend({},this._parseFormParams(q));r=this.runRoute(v,t,u,s.get(0))}return(typeof r=="undefined")?false:r},_serializeFormParams:function(r){var t="",q=r.serializeArray(),s;if(q.length>0){t=this._encodeFormPair(q[0].name,q[0].value);for(s=1;s<q.length;s++){t=t+"&"+this._encodeFormPair(q[s].name,q[s].value)}}return t},_encodeFormPair:function(q,r){return b(q)+"="+b(r)},_parseFormParams:function(q){var t={},s=q.serializeArray(),r;for(r=0;r<s.length;r++){t=this._parseParamPair(t,s[r].name,s[r].value)}return t},_parseQueryString:function(t){var v={},s,r,u,q;s=t.match(l);if(s){r=s[1].split("&");for(q=0;q<r.length;q++){u=r[q].split("=");v=this._parseParamPair(v,i(u[0]),i(u[1]||""))}}return v},_parseParamPair:function(s,q,r){if(typeof s[q]!=="undefined"){if(m(s[q])){s[q].push(r)}else{s[q]=[s[q],r]}}else{s[q]=r}return s},_listen:function(q,r){return this.$element().bind([q,this.eventNamespace()].join("."),r)},_unlisten:function(q,r){return this.$element().unbind([q,this.eventNamespace()].join("."),r)}});p.RenderContext=function(q){this.event_context=q;this.callbacks=[];this.previous_content=null;this.content=null;this.next_engine=false;this.waiting=false};p.RenderContext.prototype=h.extend({},p.Object.prototype,{then:function(s){if(!d(s)){if(typeof s==="string"&&s in this.event_context){var r=this.event_context[s];s=function(t){return r.apply(this.event_context,[t])}}else{return this}}var q=this;if(this.waiting){this.callbacks.push(s)}else{this.wait();j.setTimeout(function(){var t=s.apply(q,[q.content,q.previous_content]);if(t!==false){q.next(t)}},0)}return this},wait:function(){this.waiting=true},next:function(q){this.waiting=false;if(typeof q!=="undefined"){this.previous_content=this.content;this.content=q}if(this.callbacks.length>0){this.then(this.callbacks.shift())}},load:function(q,r,t){var s=this;return this.then(function(){var u,v,x,w;if(d(r)){t=r;r={}}else{r=h.extend({},r)}if(t){this.then(t)}if(typeof q==="string"){x=(q.match(/\.json$/)||r.json);u=((x&&r.cache===true)||r.cache!==false);s.next_engine=s.event_context.engineFor(q);delete r.cache;delete r.json;if(r.engine){s.next_engine=r.engine;delete r.engine}if(u&&(v=this.event_context.app.templateCache(q))){return v}this.wait();h.ajax(h.extend({url:q,data:{},dataType:x?"json":"text",type:"get",success:function(y){if(u){s.event_context.app.templateCache(q,y)}s.next(y)}},r));return false}else{if(q.nodeType){return q.innerHTML}if(q.selector){s.next_engine=q.attr("data-engine");if(r.clone===false){return q.remove()[0].innerHTML.toString()}else{return q[0].innerHTML.toString()}}}})},loadPartials:function(r){var q;if(r){this.partials=this.partials||{};for(q in r){(function(t,s){t.load(r[s]).then(function(u){this.partials[s]=u})})(this,q)}}return this},render:function(q,s,t,r){if(d(q)&&!s){return this.then(q)}else{return this.loadPartials(r).load(q).interpolate(s,q).then(t)}},partial:function(q,r,s){if(d(s)){return this.render(q,r).swap(s)}else{if(!s&&d(r)){return this.render(q).swap(r)}else{return this.render(q,r).swap()}}},send:function(){var s=this,r=c(arguments),q=r.shift();if(m(r[0])){r=r[0]}return this.then(function(t){r.push(function(u){s.next(u)});s.wait();q.apply(q,r);return false})},collect:function(u,t,q){var s=this;var r=function(){if(d(u)){t=u;u=this.content}var v=[],w=false;h.each(u,function(x,z){var y=t.apply(s,[x,z]);if(y.jquery&&y.length==1){y=y[0];w=true}v.push(y);return y});return w?v:v.join("")};return q?r():this.then(r)},renderEach:function(q,r,s,t){if(m(r)){t=s;s=r;r=null}return this.load(q).then(function(v){var u=this;if(!s){s=m(this.previous_content)?this.previous_content:[]}if(t){h.each(s,function(w,y){var z={},x=this.next_engine||q;r?(z[r]=y):(z=y);t(y,u.event_context.interpolate(v,z,x))})}else{return this.collect(s,function(w,y){var z={},x=this.next_engine||q;r?(z[r]=y):(z=y);return this.event_context.interpolate(v,z,x)},true)}})},interpolate:function(t,s,q){var r=this;return this.then(function(v,u){if(!t&&u){t=u}if(this.next_engine){s=this.next_engine;this.next_engine=false}var w=r.event_context.interpolate(v,t,s,this.partials);return q?u+w:w})},swap:function(q){return this.then(function(r){this.event_context.swap(r,q);return r}).trigger("changed",{})},appendTo:function(q){return this.then(function(r){h(q).append(r)}).trigger("changed",{})},prependTo:function(q){return this.then(function(r){h(q).prepend(r)}).trigger("changed",{})},replace:function(q){return this.then(function(r){h(q).html(r)}).trigger("changed",{})},trigger:function(q,r){return this.then(function(s){if(typeof r=="undefined"){r={content:s}}this.event_context.trigger(q,r);return s})}});p.EventContext=function(u,t,r,s,q){this.app=u;this.verb=t;this.path=r;this.params=new p.Object(s);this.target=q};p.EventContext.prototype=h.extend({},p.Object.prototype,{$element:function(){return this.app.$element(c(arguments).shift())},engineFor:function(s){var r=this,q;if(d(s)){return s}s=(s||r.app.template_engine).toString();if((q=s.match(/\.([^\.\?\#]+)$/))){s=q[1]}if(s&&d(r[s])){return r[s]}if(r.app.template_engine){return this.engineFor(r.app.template_engine)}return function(t,u){return t}},interpolate:function(s,t,r,q){return this.engineFor(r).apply(this,[s,t,q])},render:function(q,s,t,r){return new p.RenderContext(this).render(q,s,t,r)},renderEach:function(q,r,s,t){return new p.RenderContext(this).renderEach(q,r,s,t)},load:function(q,r,s){return new p.RenderContext(this).load(q,r,s)},partial:function(q,r,s){return new p.RenderContext(this).partial(q,r,s)},send:function(){var q=new p.RenderContext(this);return q.send.apply(q,arguments)},redirect:function(){var y,w=c(arguments),v=this.app.getLocation(),r=w.length;if(r>1){var u=0,z=[],q=[],t={},x=false;for(;u<r;u++){if(typeof w[u]=="string"){z.push(w[u])}else{h.extend(t,w[u]);x=true}}y=z.join("/");if(x){for(var s in t){q.push(this.app._encodeFormPair(s,t[s]))}y+="?"+q.join("&")}}else{y=w[0]}this.trigger("redirect",{to:y});this.app.last_location=[this.verb,this.path];this.app.setLocation(y);if(new RegExp(y).test(v)){this.app.trigger("location-changed")}},trigger:function(q,r){if(typeof r=="undefined"){r={}}if(!r.context){r.context=this}return this.app.trigger(q,r)},eventNamespace:function(){return this.app.eventNamespace()},swap:function(q,r){return this.app.swap(q,r)},notFound:function(){return this.app.notFound(this.verb,this.path)},json:function(q){return h.parseJSON(q)},toString:function(){return"Sammy.EventContext: "+[this.verb,this.path,this.params].join(" ")}});h.sammy=j.Sammy=p})(jQuery,window);
View
26 frontend/public/scripts/default.js
@@ -26,7 +26,7 @@
});
window.Radar = {
Browser: {
- isMobileQuery: false//window.msMatchMedia("screen and (max-width: 800px) and (max-height: 1280px)")
+ isMobileQuery: window.msMatchMedia ? window.msMatchMedia("screen and (max-width: 800px) and (max-height: 1280px)") : false
},
Components: {
ThumbnailViewer: {
@@ -37,7 +37,9 @@
if (Radar.Browser.isMobileQuery.matches) {
Radar.Components.ThumbnailViewer.pageSize = 12;
}
- //Radar.Browser.isMobileQuery.addListener(mediaSizeChanged);
+
+ // this breaks in chrome (jb)
+ // Radar.Browser.isMobileQuery.addListener(mediaSizeChanged);
var User = function (username, profile_picture, id, full_name) {
@@ -231,24 +233,8 @@
self.picturesWithBlanks.push(blank);
}
};
-
- //document.onreadystatechange = function () {
- // if (this.readyState == 'complete') {
- // var script = document.createElement('script');
- // script.type = 'text/javascript';
- // script.src = 'http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0';
- // document.getElementsByTagName('head')[0].appendChild(script);
- // script.onreadystatechange = function () {
- // if (this.readyState == 'complete') {
- // self.map = new Microsoft.Maps.Map(document.getElementById('myMap'), { credentials: 'Arha1ch48UwizeokfrS6sqAhtuRIwwRZgtI5XHBlQf8gOETZ8G7JEgshVsS8HPJI' });
- // }
- // };
- // }
- //
- //}
- console.log('here');
- this.map = new Microsoft.Maps.Map(document.getElementById('myMap'), { credentials: 'Arha1ch48UwizeokfrS6sqAhtuRIwwRZgtI5XHBlQf8gOETZ8G7JEgshVsS8HPJI' });
- console.log('gone');
+
+ this.map = new Microsoft.Maps.Map(document.getElementById('myMap'), { credentials: 'Arha1ch48UwizeokfrS6sqAhtuRIwwRZgtI5XHBlQf8gOETZ8G7JEgshVsS8HPJI' });
this.showMap = function () {
if ($('#map').hasClass('mapShown')) {
View
5 frontend/views/images.html
@@ -5,10 +5,11 @@
<script src="/socket.io/socket.io.js"></script>
<script src="plugins/jquery-1.8.1.js"></script>
<script src="plugins/knockout-2.1.0.js"></script>
+ <script src="plugins/sammy-latest.min.js"></script>
<script src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"></script>
- <script src="scripts/default.js"></script>
+ <script src="scripts/default.js"></script>
<link href="stylesheets/default.css" rel="stylesheet" />
- <link href="stylesheets/fonts.css" rel="stylesheet" />
+ <link href="stylesheets/fonts.css" rel="stylesheet" />
</head>
<body>
<img class="logo" alt="radar logo" src="images/radar-logo.png"/>

0 comments on commit 91973aa

Please sign in to comment.