summaryrefslogtreecommitdiff
path: root/public/assets/js/app.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/assets/js/app.js')
-rw-r--r--public/assets/js/app.js65
1 files changed, 65 insertions, 0 deletions
diff --git a/public/assets/js/app.js b/public/assets/js/app.js
new file mode 100644
index 0000000..af541b9
--- /dev/null
+++ b/public/assets/js/app.js
@@ -0,0 +1,65 @@
+var app = (function() {
+
+ var app = {}
+ var last_t = 0, initial_t = 0
+
+ app.init = function() {
+ app.loader = new Loader ()
+ app.bind()
+ app.bindSocket()
+ app.build()
+ app.resize()
+ app.ready()
+ $("body,html").scrollTop(0)
+ }
+
+ app.bind = function() {
+ if (is_mobile) {
+ // FastClick.attach(document.body)
+ }
+ $(window).resize(app.resize)
+ }
+
+ app.bindSocket = function(){
+ app.socket = io(window.location.origin)
+ }
+
+ app.build = function() {
+ window.scrollTo(0,0)
+ app.views = {}
+ app.views.home = new HomeView ()
+ app.views.upload = new UploadView ()
+ app.router = new SiteRouter ()
+ }
+
+ app.ready = function() {
+ if (last_t) return
+ setTimeout(function () {
+ $("html").removeClass("loading")
+ window.scrollTo(0,0)
+ }, 50)
+ app.view = null
+ app.router.launch()
+ // app.animate(0)
+ }
+
+// app.animate = function (t) {
+// requestAnimationFrame(app.animate)
+// if (! initial_t) {
+// initial_t = t
+// return
+// }
+// t -= initial_t
+// var dt = t - last_t
+// last_t = t
+// // environment.update(t, dt)
+// }
+
+ app.resize = function () {
+ }
+
+ return app
+
+})()
+
+document.addEventListener('DOMContentLoaded', app.init)