-
Notifications
You must be signed in to change notification settings - Fork 0
/
conferenceApp.js
84 lines (81 loc) · 17.8 KB
/
conferenceApp.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/// <reference path="jquery-1.5.2.js" />
/// <reference path="jquery.tmpl.js" />
/// <reference path="knockout.debug.joel.js" />
$(function () {
//for our viewModel, we want track a and track b talks
//separated out by days
var data = events(),
sortByStart = function (a, b) {
var timeRex = /(\d+):(\d+)/,
aTime = timeRex.exec(a.begin),
aHour = +aTime[1],
bTime = timeRex.exec(b.begin),
bHour = +bTime[1];
if (aHour < 8) aHour += 12;
if (bHour < 8) bHour += 12;
if (aHour < bHour) {
return -1;
} else if (aHour > bHour) {
return 1;
} else if (+aTime[2] < +bTime[2]) {
return -1;
} else if (+aTime[2] > +bTime[2]) {
return 1;
} else {
return 0;
}
},
_ = console.log("before massage" + Date.now());
noTitle = function (o) { return !!o.title; },
mondaySessions = ko.utils.arrayFilter(data.track_a.monday, noTitle).concat(
ko.utils.arrayFilter(data.track_b.monday, noTitle)
).sort(sortByStart);
console.log("before viewModel" + Date.now());
var viewModel = {
mondaySessions: ko.observableArray(
ko.utils.arrayMap(mondaySessions, function (o) {
o.selected = ko.observable(false);
o.toggleSelected = function () {
//must rerender template to change icon
var index = ko.utils.arrayIndexOf(
ko.utils.unwrapObservable(viewModel.mondaySessions),
this);
viewModel.mondaySessions.remove(this);
this.selected(!this.selected());
viewModel.mondaySessions.splice(index, 0, this);
};
o.favoriteIcon = ko.dependentObservable(function () {
return this.selected() ? "star" : "plus";
}, o);
return o;
})
),
tuesdaySessions: ko.observableArray(
ko.utils.arrayFilter(
data.track_a.tuesday.concat(data.track_b.tuesday).sort(sortByStart), function (o) {
return !!o.title;
})
),
refreshListView: function () {
//dirty hack to ensure page exists
$("#fullSchedule").page();
//dirty hack to refresh listview (since you cannot currently refresh individual items)
$("#fullSchedule ul").listview("refresh");
}
};
viewModel.myMondaySessions = ko.dependentObservable(function () {
return ko.utils.arrayFilter(this.mondaySessions(), function (o) {
return o.selected();
});
}, viewModel);
console.log("before apply" + Date.now());
ko.applyBindings(viewModel);
console.log("after apply" + Date.now());
function events() {
/// <summary>Returns dummy data you could get from server or localstorage</summary>
//official data from jsconf http://bit.ly/dR16u9
var data = { "_id": "schedule", "_rev": "53-d3e34086c5dc09410defda32dc4cfa95", "track_a": { "monday": [{ "begin": "8:00", "end": "9:00", "name": "", "title": "Registration and Full-on Breakfast", "type": "break" }, { "begin": "9:00", "end": "9:20", "name": "JSConf Team", "title": "Welcome to the JSConf Trail", "type": "break" }, { "begin": "9:20", "end": "10:00", "name": "David Flanagan", "title": "Bytes and Blobs", "href": "http://2011.jsconf.us/#/proposal/7edca1476b18fe06e50883702e26eafa" }, { "begin": "10:00", "end": "10:40", "name": "Malte Ubl and Meno Abels", "title": "Conference Wifi Redux", "href": "http://2011.jsconf.us/#/proposal/c7bf7fec8a0afceeabf584d143bdb9c8" }, { "begin": "10:40", "end": "11:00", "name": "Intermission Entertainment with Popcorn.js", "type": "break", "href": "http://2011.jsconf.us/#/proposal/c7bf7fec8a0afceeabf584d143d0d733" }, { "begin": "11:00", "end": "11:40", "name": "Adam Christian", "title": "Run your JS everywhere, with Jellyfish", "href": "http://2011.jsconf.us/#/proposal/eedf3aa8dabe4621ac6c1cf7f1ef547d" }, { "begin": "11:40", "end": "12:20", "name": "Nick Small", "title": "Fighting Crime and Kicking Apps with Batman.js", "href": "http://2011.jsconf.us/#/proposal/6f23fd600302403a9f53e11390186b11" }, { "begin": "12:20", "end": "13:20", "name": "The Aaron and Paul Show!", "type": "break" }, { "begin": "13:20", "end": "14:00", "name": "Dave Balmer", "title": "Hello, Jo!", "href": "http://2011.jsconf.us/#/proposal/7edca1476b18fe06e50883702e1c02d5" }, { "begin": "14:00", "end": "14:40", "name": "Fabian Jakobs", "title": "Bespin, Skywriter, Ace - The Past, Present and Future of online Code Editing", "href": "http://2011.jsconf.us/#/proposal/eff575eed3ae974073b61c61648b67d4" }, { "begin": "14:40", "end": "15:20", "name": "Jeremy Johnstone", "title": "JavaScript Powered TVs?!", "href": "http://2011.jsconf.us/#/proposal/4615bc127aa33f8c82ff6fccff5c6152" }, { "begin": "15:20", "end": "15:40", "name": "Snack Break", "type": "break" }, { "begin": "15:40", "end": "16:20", "name": "Avni Khatri and Alice Bonhomme-Biais", "title": "How quick can we be? Current data visualization techniques for front-end engineers", "href": "http://2011.jsconf.us/#/proposal/6f23fd600302403a9f53e113900ea477" }, { "begin": "16:20", "end": "17:00", "name": "Ben Combee", "title": "JS for Mobile: The Enyo Framework", "href": "http://2011.jsconf.us/#/proposal/6f23fd600302403a9f53e113900eab1a" }, { "begin": "17:00", "end": "17:20", "name": "Intermission Entertainment with Popcorn.js", "type": "break", "href": "http://2011.jsconf.us/#/proposal/c7bf7fec8a0afceeabf584d143d0d733" }, { "begin": "17:20", "end": "18:00", "name": "Andrew Dupont", "title": "Everything is Permitted: Extending Built-ins", "href": "http://2011.jsconf.us/#/proposal/9b24b4cbddec671383481fe1620bdb97" }, { "begin": "18:00", "end": "18:40", "name": "Mary Rose Cook", "title": "Artificial Intelligence, collision detection and falling in love in Pistol Slut, a 2D platform shooter.", "href": "http://2011.jsconf.us/#/proposal/aa273630746598e4dec3edb9fcb4ddcf" }, { "begin": "18:40", "end": "19:00", "name": "JSConf Team", "title": "Closing Remarks", "type": "break"}], "tuesday": [{ "begin": "8:00", "end": "9:00", "name": "", "title": "Bring on the BACON Breakfast", "type": "break" }, { "begin": "9:00", "end": "9:20", "name": "JSConf Team and Peter van der Zee", "title": "River Fording 101: JS1k #winning", "type": "break" }, { "begin": "9:20", "end": "10:00", "name": "Ray C. Morgan", "title": "App vs Web - Lessons from Zappos.com", "href": "http://2011.jsconf.us/#/proposal/a9fca797d253b4786999888e1032cca1" }, { "begin": "10:00", "end": "10:40", "name": "Dave Herman", "title": "Simple, Powerful Modules for JS.Next", "href": "http://2011.jsconf.us/#/proposal/9b24b4cbddec671383481fe16204278c" }, { "begin": "10:40", "end": "11:00", "name": "Intermission Entertainment with Popcorn.js", "type": "break", "href": "http://2011.jsconf.us/#/proposal/c7bf7fec8a0afceeabf584d143d0d733" }, { "begin": "11:00", "end": "11:40", "name": "Mark Headd", "title": "Telephony and Communication Apps with Node.js", "href": "http://2011.jsconf.us/#/proposal/7edca1476b18fe06e50883702e219c84" }, { "begin": "11:40", "end": "12:20", "name": "Dan Webb", "title": "Pimp Your JS Library", "href": "http://2011.jsconf.us/#/proposal/c7bf7fec8a0afceeabf584d143d16862" }, { "begin": "12:20", "end": "13:20", "name": "The Aaron and Paul Show! Season 2", "type": "break" }, { "begin": "13:20", "end": "14:00", "name": "Matthew Eernisse", "title": "Heaven and Hell: JavaScript Everywhere", "href": "http://2011.jsconf.us/#/proposal/6f23fd600302403a9f53e11390159614" }, { "begin": "14:00", "end": "14:40", "name": "Dethe Elza", "title": "Introducing Waterbear", "href": "http://2011.jsconf.us/#/proposal/eedf3aa8dabe4621ac6c1cf7f1a9b760" }, { "begin": "14:40", "end": "15:20", "name": "Thomas Fuchs", "title": "Nano? Pico? Femto? Atto? Zepto!", "href": "http://2011.jsconf.us/#/proposal/c7bf7fec8a0afceeabf584d1432b5440" }, { "begin": "15:20", "end": "15:40", "name": "Snack Break", "type": "break" }, { "begin": "15:40", "end": "16:20", "name": "Daniel Austin", "title": "Notes on a High-performance JSON Protocol", "href": "http://2011.jsconf.us/#/proposal/eedf3aa8dabe4621ac6c1cf7f1f47fdc" }, { "begin": "16:20", "end": "17:00", "name": "Marijn Haverbeke", "title": "How 2011-era JS engines compile your scripts (and why it matters)", "href": "http://2011.jsconf.us/#/proposal/eff575eed3ae974073b61c6164dc11bb" }, { "begin": "17:00", "end": "17:20", "name": "Intermission Entertainment with Popcorn.js", "type": "break", "href": "http://2011.jsconf.us/#/proposal/c7bf7fec8a0afceeabf584d143d0d733" }, { "begin": "17:20", "end": "18:00", "name": "Jeremy Ashkenas", "title": "CoffeeScript as a JS/Next", "href": "http://2011.jsconf.us/#/proposal/9b24b4cbddec671383481fe16204b9d0" }, { "begin": "18:00", "end": "18:40", "name": "Alex Russell", "title": "Performance of feature detection", "href": "http://2011.jsconf.us/#/dysentery" }, { "begin": "18:40", "end": "19:00", "name": "Chris And Laura Williams", "title": "Closing Remarks", "type": "break"}] }, "track_b": { "monday": [{ "begin": "8:00", "end": "9:00", "name": "", "title": "Registration and Full-on Breakfast", "type": "break" }, { "begin": "9:00", "end": "9:20", "name": "Chris and Laura Williams", "title": "Opening Remarks in Track A", "type": "break" }, { "begin": "9:20", "end": "9:40", "name": "Trevor Lalush-Menagh", "title": "Envjs and Jasmine Headless Tests FTW", "type": "presentation", "email": "[email protected]" }, { "begin": "9:40", "end": "10:00", "name": "Reid Burke", "title": "Modules Made Awesome lessons from YUI Loader on Node.js", "type": "presentation", "email": "[email protected]" }, { "begin": "10:00", "end": "10:20", "name": "unscriptable", "title": "The future is Modules not Frameworks", "type": "presentation", "email": "[email protected]" }, { "begin": "10:20", "end": "10:40", "name": "unscriptable", "title": "Javascript Modules Architecture Demo", "type": "presentation", "email": "[email protected]" }, { "begin": "10:40", "end": "11:00", "name": "Break", "type": "break" }, { "begin": "11:00", "end": "11:20", "name": "Paul Irish", "title": "Going Steady with the Chrome Dev Tools", "type": "presentation", "email": "[email protected]" }, { "begin": "11:20", "end": "11:40", "name": "Tim Caswell", "title": "Node Powered Desktop Apps", "type": "presentation", "email": "[email protected]" }, { "begin": "11:40", "end": "12:00", "name": "Michael Bolin", "title": "with JavaScripts most reviled keyword", "type": "presentation", "email": "[email protected]" }, { "begin": "12:00", "end": "12:20", "name": "Peter van der Zee", "title": "Visual statical analysis tool", "type": "presentation", "email": "[email protected]" }, { "begin": "12:20", "end": "13:20", "name": "Lunch", "type": "break" }, { "begin": "13:20", "end": "13:40", "name": "Armen Nakashian", "title": "Bloombergs Rapid Application Development Environment", "type": "presentation", "email": "[email protected]" }, { "begin": "13:40", "end": "14:00", "name": "John Schulz", "title": "Server Side Canvas with NodeJS", "type": "presentation", "email": "[email protected]" }, { "begin": "14:00", "end": "14:20", "name": "Allen Pike", "title": "Making a JS meetup blow minds", "type": "presentation", "email": "[email protected]" }, { "begin": "14:20", "end": "14:40", "name": "Brian Cavalier", "title": "Awesomer JS MVC with OOCSS", "type": "presentation", "email": "[email protected]" }, { "begin": "14:40", "end": "15:00", "name": "David Kaneda", "title": "Building Rich user experiences with Sencha Touch", "type": "presentation", "email": "[email protected]" }, { "begin": "15:00", "end": "15:20", "name": "Boris Bokowski", "title": "Orion the web is my development environment", "type": "presentation", "email": "[email protected]" }, { "begin": "15:20", "end": "15:40", "name": "Snack Break", "type": "break" }, { "begin": "15:40", "end": "16:00", "name": "Anton Kovalyov", "title": "Code Quality Tools why are they important and what we can (and should) do about them.", "type": "presentation", "email": "[email protected]" }, { "begin": "16:00", "end": "16:20", "name": "Gaurav Seth, Senior Program Manager on the Chakra team", "title": "The return of the JavaScript MOJO in IE with Chakra", "type": "presentation", "email": "[email protected]" }, { "begin": "16:20", "end": "16:40", "name": "Justin Meyer", "title": "JavaScript MVC For Better and Bigger Apps", "type": "presentation", "email": "[email protected]" }, { "begin": "16:40", "end": "17:00", "name": "Brian LeRoux", "title": "mobile knife fight phonegap project automation", "type": "presentation", "email": "[email protected]" }, { "begin": "17:00", "end": "17:20", "name": "Break", "type": "break" }, { "begin": "17:20", "end": "17:40", "name": "John Davidson", "title": "Creating Custom Widgets with Closure", "type": "presentation", "email": "[email protected]" }, { "begin": "17:40", "end": "18:00", "name": "Charlie Robbins", "title": "Running node.js in Production", "type": "presentation", "email": "[email protected]" }, { "begin": "18:00", "end": "18:20", "name": "Dan Beam", "title": "How to be a Player (on the Internet) The making of Yahoos universal JS media player", "type": "presentation", "email": "[email protected]" }, { "begin": "18:20", "end": "18:40", "name": "Paolo Fragomeni (hij1nx)", "title": "Rethinking Templating", "type": "presentation", "email": "[email protected]" }, { "begin": "18:40", "end": "19:00", "name": "Chris And Laura Williams", "title": "Closing Remarks in Track A", "type": "break"}], "tuesday": [{ "begin": "8:00", "end": "9:00", "name": "", "title": "Bring on the BACON Breakfast", "type": "break" }, { "begin": "9:00", "end": "9:20", "name": "Chris and Laura Williams", "title": "Opening Remarks in Track A", "type": "break" }, { "begin": "9:20", "end": "9:40", "name": "Andrew Lunny", "title": "hangover.js", "type": "presentation", "email": "[email protected]" }, { "begin": "9:40", "end": "10:00", "name": "Dave Johnson", "title": "caesar.js", "type": "presentation", "email": "[email protected]" }, { "begin": "10:00", "end": "10:20", "name": "Aaron Heckmann", "title": "Code is cool Products are better", "type": "presentation", "email": "[email protected]" }, { "begin": "10:20", "end": "10:40", "name": "RGA Panel", "title": "Turning Kick ass design into kick ass code", "type": "presentation", "email": "[email protected]" }, { "begin": "10:40", "end": "11:00", "name": "Break", "type": "break" }, { "begin": "11:00", "end": "11:20", "name": "Toby Ho", "title": "Tutti a Fun Way to Browser Test", "type": "presentation", "email": "[email protected]" }, { "begin": "11:20", "end": "11:40", "name": "Adam Baldwin", "title": "Writing an (in)secure webapp in 3 easy steps", "type": "presentation", "email": "[email protected]" }, { "begin": "11:40", "end": "12:00", "name": "Mario Gonzalez and Adam S. Kirschner", "title": "Realtime HTML5 Multiplayer Games with NodeJS", "type": "presentation", "email": "[email protected]" }, { "begin": "12:00", "end": "12:20", "name": "Tom Hughes-Croucher", "title": "Multi-tiered Node Architectures", "type": "presentation", "email": "[email protected]" }, { "begin": "12:20", "end": "13:20", "name": "Lunch", "type": "break" }, { "begin": "13:20", "end": "13:40", "name": "Rebecca Murphey", "title": "Modern JavaScript", "type": "presentation", "email": "[email protected]" }, { "begin": "13:40", "end": "14:00", "name": "Peter Elger", "title": "Low friction development", "type": "presentation", "email": "[email protected]" }, { "begin": "14:00", "end": "14:20", "name": "John-David Dalton", "title": "Benchmarking like a boss", "type": "presentation", "email": "[email protected]" }, { "begin": "14:20", "end": "14:40", "name": "Jonathan Rudenberg", "title": "Node and Shopify for Fun and Profit", "type": "presentation", "email": "[email protected]" }, { "begin": "14:40", "end": "15:00", "name": "Alex Sexton", "title": "Uselessware A Brief History", "type": "presentation", "email": "[email protected]" }, { "begin": "15:00", "end": "15:20", "name": "Misko Hevery", "title": "angular.js", "type": "presentation", "email": "[email protected]" }, { "begin": "15:20", "end": "15:40", "name": "Snack Break", "type": "break" }, { "begin": "15:40", "end": "16:00", "name": "Sean Cribbs", "title": "Javascript Apps on Riak", "type": "presentation", "email": "[email protected]" }, { "begin": "16:00", "end": "16:20", "name": "Keith Norman", "title": "Finch Multivariate Testing with Node.js", "type": "presentation", "email": "[email protected]" }, { "begin": "16:20", "end": "16:40", "name": "Gonzalo Cordero", "title": "Building hybrid mobile apps with YUI3", "type": "presentation", "email": "[email protected]" }, { "begin": "16:40", "end": "17:00", "name": "Nikolai Onken", "title": "Mobile Deathmatch (almost ) ) all you need to know in 20 minutes", "type": "presentation", "email": "[email protected]" }, { "begin": "17:00", "end": "17:20", "name": "Break", "type": "break" }, { "begin": "17:20", "end": "17:40", "name": "Tobias Schneider", "title": "VNC WITH JAVASCRIPT WAS WAITING FOR SOME SUGAR", "type": "presentation", "email": "[email protected]" }, { "begin": "17:40", "end": "18:00", "name": "Antranig Basman", "title": "The Future is Frameworks not Modules", "type": "presentation", "email": "[email protected]" }, { "begin": "18:00", "end": "18:20", "name": "Mike Taylor", "title": "Feature Detection of Performance", "type": "presentation", "email": "[email protected]" }, { "begin": "18:20", "end": "18:40", "name": "John-David Dalton", "title": "Microfibs The small loosely coupled modules of Skynets future.", "type": "presentation", "email": "[email protected]" }, { "begin": "18:40", "end": "19:00", "name": "Chris And Laura Williams", "title": "Closing Remarks in Track A", "type": "break"}]} };
//data.track_a.monday[0].begin
return data;
}
});