From ec86b9572b5ed777af6f5cbc443451fe15daeed3 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sun, 30 Dec 2012 16:44:35 -0500 Subject: dragging/dropping images in chrome --- static/js/pichat.js | 21 +++++++++++++-------- static/js/pichat2.js | 21 +++++++++++++-------- static/js/src/chat.js | 2 +- static/js/src/drag.js | 18 +++++++++++------- 4 files changed, 38 insertions(+), 24 deletions(-) diff --git a/static/js/pichat.js b/static/js/pichat.js index 5f20803..ceeb397 100644 --- a/static/js/pichat.js +++ b/static/js/pichat.js @@ -445,7 +445,7 @@ function removeOldMessages(){ } } -window.TextEnabled = Preferences.getProperty("chat.textEnabled", "true") == "none"; +window.TextEnabled = Preferences.getProperty("chat.textEnabled", "true") == "true"; window.ImgsEnabled = Preferences.getProperty("chat.imgsEnabled", "true") == "true"; function muteSelector() { @@ -547,6 +547,7 @@ function dragTarget (target, callbacks) { } base.enter = function(e){ base.target.classList.add('over'); + console.log(e.target); if ('enter' in callbacks) { callbacks.enter(Drag.url); } @@ -577,17 +578,21 @@ function dragTarget (target, callbacks) { } base.drop = function(e){ base.target.classList.remove('over'); - if (e.stopPropagation) { - e.stopPropagation(); // stops the browser from redirecting. - } - if (e.preventDefault) { - e.preventDefault(); - } + e.stopPropagation(); // stops the browser from redirecting. + e.preventDefault(); if ('drop' in callbacks) { - callbacks.drop(Drag.url); + if (e.dataTransfer) { + var url = e.dataTransfer.getData("url"); + if (url) { + callbacks.drop(url); + } + } else { + callbacks.drop(Drag.url); + } } return false; } + base.init(); }; diff --git a/static/js/pichat2.js b/static/js/pichat2.js index 5f20803..ceeb397 100644 --- a/static/js/pichat2.js +++ b/static/js/pichat2.js @@ -445,7 +445,7 @@ function removeOldMessages(){ } } -window.TextEnabled = Preferences.getProperty("chat.textEnabled", "true") == "none"; +window.TextEnabled = Preferences.getProperty("chat.textEnabled", "true") == "true"; window.ImgsEnabled = Preferences.getProperty("chat.imgsEnabled", "true") == "true"; function muteSelector() { @@ -547,6 +547,7 @@ function dragTarget (target, callbacks) { } base.enter = function(e){ base.target.classList.add('over'); + console.log(e.target); if ('enter' in callbacks) { callbacks.enter(Drag.url); } @@ -577,17 +578,21 @@ function dragTarget (target, callbacks) { } base.drop = function(e){ base.target.classList.remove('over'); - if (e.stopPropagation) { - e.stopPropagation(); // stops the browser from redirecting. - } - if (e.preventDefault) { - e.preventDefault(); - } + e.stopPropagation(); // stops the browser from redirecting. + e.preventDefault(); if ('drop' in callbacks) { - callbacks.drop(Drag.url); + if (e.dataTransfer) { + var url = e.dataTransfer.getData("url"); + if (url) { + callbacks.drop(url); + } + } else { + callbacks.drop(Drag.url); + } } return false; } + base.init(); }; diff --git a/static/js/src/chat.js b/static/js/src/chat.js index 09954de..f24917c 100644 --- a/static/js/src/chat.js +++ b/static/js/src/chat.js @@ -166,7 +166,7 @@ function removeOldMessages(){ } } -window.TextEnabled = Preferences.getProperty("chat.textEnabled", "true") == "none"; +window.TextEnabled = Preferences.getProperty("chat.textEnabled", "true") == "true"; window.ImgsEnabled = Preferences.getProperty("chat.imgsEnabled", "true") == "true"; function muteSelector() { diff --git a/static/js/src/drag.js b/static/js/src/drag.js index b48c365..48b3266 100644 --- a/static/js/src/drag.js +++ b/static/js/src/drag.js @@ -45,17 +45,21 @@ function dragTarget (target, callbacks) { } base.drop = function(e){ base.target.classList.remove('over'); - if (e.stopPropagation) { - e.stopPropagation(); // stops the browser from redirecting. - } - if (e.preventDefault) { - e.preventDefault(); - } + e.stopPropagation(); // stops the browser from redirecting. + e.preventDefault(); if ('drop' in callbacks) { - callbacks.drop(Drag.url); + if (e.dataTransfer) { + var url = e.dataTransfer.getData("url"); + if (url) { + callbacks.drop(url); + } + } else { + callbacks.drop(Drag.url); + } } return false; } + base.init(); }; -- cgit v1.2.3-70-g09d2 From 8cfebc8014ff7dc72442d1eba8e5674160063d4a Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sun, 30 Dec 2012 17:51:32 -0500 Subject: serve fullscreen on root --- src/site.clj | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/site.clj b/src/site.clj index f38c67b..df15342 100644 --- a/src/site.clj +++ b/src/site.clj @@ -193,6 +193,13 @@ ;; Landing +(defn serve-meme [session meme] + (if-let [st (fetch-template meme session)] + (let [now (System/currentTimeMillis)] + (.setAttribute st "timestamp" now) + (.toString st)) + (unknown-page))) + (defn- parse-front-page-date [dt-str] (if-let [dt (parse-yyyymmdd-date dt-str)] [(advance-date dt -1) @@ -219,13 +226,15 @@ (def num-frontpage-dumps 20) (defn front-page - ([session] (front-page session (format-yyyymmdd (Date.)))) + ([session] + (cond + (not (:nick session)) (serve-meme session "fullscreen") + :else (front-page session (format-yyyymmdd (Date.))) )) ([session dt-str] (let [today (Date.)] (if-let [[prev-date cur-date next-date] (parse-front-page-date dt-str)] (cond (.before cur-date earliest-daily-hall) (redirect-to "/") (.after cur-date today) (redirect-to "/") - ;(not (:nick session)) (serve-meme session "fullscreen") :else (let [st (fetch-template "frontpage" session) dumps (map process-message-for-output (if (:nick session) @@ -1159,13 +1168,6 @@ WHERE user_id IN [200 err] (do-upload-avatar session image))))) -(defn serve-meme [session meme] - (if-let [st (fetch-template meme session)] - (let [now (System/currentTimeMillis)] - (.setAttribute st "timestamp" now) - (.toString st)) - (unknown-page))) - (defn hall-of-fame [session] (let [st (fetch-template "fame" session) msgs (fetch-redis-hall (:nick session))] -- cgit v1.2.3-70-g09d2 From ab3c66a6db7c4c2dbc3795c3b11132a535a3aeb3 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sun, 30 Dec 2012 20:03:59 -0500 Subject: new fullscreen page --- src/site.clj | 2 +- static/js/register.js | 8 +- template/fullscreen.st | 345 +++++++++++++++++++++++++++++-------------------- 3 files changed, 212 insertions(+), 143 deletions(-) diff --git a/src/site.clj b/src/site.clj index df15342..a736562 100644 --- a/src/site.clj +++ b/src/site.clj @@ -724,7 +724,7 @@ WHERE user_id IN (let [roomkey (room :key) st (fetch-template "log" session) logger (make-time-logger) - offset (maybe-parse-int offset 0) + offset (maybe-parse-int offset 0) dump-offset (* offset *dumps-per-page*) image-only (and (not (room :admin_only)) (not= (params :show) "all")) diff --git a/static/js/register.js b/static/js/register.js index 0f5bb1f..ff93b0b 100755 --- a/static/js/register.js +++ b/static/js/register.js @@ -5,11 +5,11 @@ function validateEmail(email) { } function submitRegistration() { - var nick = $('#nickInput').val(); - var email = $('#emailInput').val(); + var nick = $('#regNickInput').val(); + var email = $('#regEmailInput').val(); var terms = $('#terms').val(); - var password = $('#passwordInput').val() || ""; - var password2 = $('#passwordInput2').val() || ""; + var password = $('#regPasswordInput').val() || ""; + var password2 = $('#regPasswordInput2').val() || ""; if (nick.length < 3 || nick.length > 12) { alert("Nicks must be between 3 and 12 characters long."); diff --git a/template/fullscreen.st b/template/fullscreen.st index 9556bf2..cd3a3cf 100644 --- a/template/fullscreen.st +++ b/template/fullscreen.st @@ -4,6 +4,10 @@ + $if(user_nick)$ + $else$ + + $endif$ - + + $if(user_nick)$ - $else$ -
-
-

this is dump.fm, the first ever real-time image sharing website. behind me is a fullscreen feed of whats currently going on. - if you're a member of the club, sign in bellow. if not feel free to close this window and enjoy the sick pix.

-
-

username :

-

password :

-

- remember me?

+
x +
+

+ this is dump.fm, the first ever real-time image sharing website. + behind this is a fullscreen feed of whats currently being posted. + Register to join the club. + +

username

+

password

+

+ remember me?

+ + +
+ +
- - -
- -
+ +
+ +

+ + +

+ + +

+ + +

+ + +

+ +

+
$endif$
+ function choice(a) { return a[Math.floor(Math.random()*a.length)] } + var urls = [ + "http://dumpfm.s3.amazonaws.com/images/20100601/1275428508049-dumpfm-foot-oie_oie_overlay-1.gif", + "http://dumpfm.s3.amazonaws.com/images/20100928/1285728674225-dumpfm-timb-running.unicorn.gif", + "http://dumpfm.s3.amazonaws.com/images/20100726/1280119193796-dumpfm-enso-human-condition.gif", + "http://dumpfm.s3.amazonaws.com/images/20100521/1274415795577-dumpfm-ucnv-mx.gif", + "http://dump.fm/images/replaced/20100912/crabmonster.gif", + "http://dump.fm/images/20110927/1317105622918-dumpfm-peachfist-test8scam.gif", + "http://dump.fm/images/20110323/1300915179773-dumpfm-blingscience-fishtank.gif", + "http://dump.fm/images/20110418/1303108538834-dumpfm-LAVARLAMAR-lettuce_lavarlamar.gif", + "http://i.asdf.us/im/84/gradient_horse_1318306378_1322355741_ryz_1337322355_ryz.gif", + "http://dumpfm.s3.amazonaws.com/images/20110724/1311552093462-dumpfm-hologrampa-1291586335941-dumpfm-jeeeelings-cat_face_wink_hologrampa-lettuce.gif", + "http://i.asdf.us/im/be/tt7620731fltt_1315431978.gif" + ] + document.getElementById("big-image").innerHTML = "" + initFullscreen() + jQuery(startChatUpdater) + jQuery("#reglink").click(function(e){ + e.preventDefault(); + jQuery("#loginbox").hide(); + jQuery("#registerbox").show().addClass("b"); + initRegister() + return false; + }); + $if(user_nick)$ + $else$ + $endif$ + $google_analytics()$ -- cgit v1.2.3-70-g09d2