summaryrefslogtreecommitdiff
path: root/static
diff options
context:
space:
mode:
Diffstat (limited to 'static')
-rw-r--r--static/js/fullscreen.js118
1 files changed, 109 insertions, 9 deletions
diff --git a/static/js/fullscreen.js b/static/js/fullscreen.js
index cf2d997..192f92a 100644
--- a/static/js/fullscreen.js
+++ b/static/js/fullscreen.js
@@ -1,9 +1,10 @@
function initFullscreen(){
- Room = "dumpfm";
- refresh()
- ImageCache = []
- SeenImages = {}
- $('#tools-button').click(toolsToggle);
+ Room = "dumpfm";
+ refresh();
+ ImageCache = [];
+ SeenImages = {};
+ FavedMap = {};
+ $('#tools-button').click(toolsToggle);
}
function toolsToggle(){
if ($("#msgInputDiv").css("display") == "none")
@@ -26,12 +27,35 @@ function scanMessagesForImages(messages){
NextImage = new Image()
NextImage.onload = displayImage
NextImage.src = images[i]
+ NextImage.msg_id = messages[m].msg_id;
}
}
}
+function clickImage(img) {
+ if (!LoggedIn) return;
+ var msg_id = $(img).attr('msg_id');
+ if (!$(img).hasClass('fullscreen-favorite')) {
+ FavedMap[msg_id] = true;
+ $('#fav-indicator').show();
+ console.log('faving ' + msg_id);
+ Tag.add(msg_id, "favorite");
+ $(img).addClass("fullscreen-favorite");
+ } else {
+ delete FavedMap[msg_id];
+ $('#fav-indicator').hide();
+ console.log('defaving ' + msg_id);
+ Tag.rm(msg_id, "favorite");
+ $(img).removeClass("fullscreen-favorite");
+ }
+}
+
function displayImage(){
- $("#big-image").html('<img src="'+this.src+'">')
+ $("#big-image").html('<img src="'+this.src+'" msg_id = "' + this.msg_id + '" onclick="clickImage(this)">');
+ if (FavedMap[this.msg_id])
+ $('#fav-indicator').show();
+ else
+ $('#fav-indicator').hide();
}
function refresh() {
@@ -43,12 +67,11 @@ function refresh() {
} catch(e) {
}
-
- setTimeout(refresh, 1000);
+ setTimeout(refresh, 1000);
};
var onError = function(resp, textStatus, errorThrown) {
- setTimeout(refresh, 1000);
+ setTimeout(refresh, 4000);
};
$.ajax({
@@ -63,9 +86,86 @@ function refresh() {
});
}
+function initLogin() {
+ $('#logininner').ridgificate('2px solid #dd0000',
+ '2px solid #fe6230',
+ '2px solid #fef600',
+ '2px solid #00bc00',
+ '2px solid #009bfe',
+ '2px solid #000083',
+ '2px solid #30009b',
+ '2px solid #dd0000',
+ '2px solid #fe6230',
+ '2px solid #fef600',
+ '2px solid #00bc00',
+ '2px solid #009bfe',
+ '2px solid #000083',
+ '2px solid #30009b');
+}
+function showLogin() {
+ $('#loginbox').show().center().center();
+ $('#username').focus();
+ $('input').removeAttr('disabled');
+}
+function login() {
+ $('#spinner').show();
+ $('input').attr('disabled', 'disabled');
+ var nick = $('#nickInput').val();
+ var password = $('#passwordInput').val();
+ var rememberme = $('#remembermeInput').attr('checked') ? 'yes' : '';
+ var hash = hex_sha1(nick + '$' + password + '$dumpfm');
+ var onSuccess = function(json) {
+ if (typeof pageTracker !== 'undefined') {
+ pageTracker._setCustomVar(1, "logged-in", nick);
+ }
+ LoggedIn = true;
+ $('#loginbox').hide();
+ $('.sublogo').text('click to fav');
+ };
+ var onError = function(resp, textStatus, errorThrown) {
+ $('#spinner').hide();
+ $('input').removeAttr('disabled');
+ $('#errormsg').text("Couldn't log you in :( Bad password?");
+ }
+
+ $.ajax({
+ type: 'POST',
+ timeout: 5000,
+ url: '/login',
+ data: {'nick': nick, ts: '', 'hash': hash, 'rememberme': rememberme},
+ cache: false,
+ dataType: 'json',
+ success: onSuccess,
+ error: onError
+ });
+}
+// http://plugins.jquery.com/project/autocenter
+(function($){
+ $.fn.extend({
+ center: function () {
+ return this.each(function() {
+ var top = ($(window).height() - $(this).outerHeight()) / 2;
+ var left = ($(window).width() - $(this).outerWidth()) / 2;
+ $(this).css({position:'absolute', margin:0, top: (top > 0 ? top : 0)+'px', left: (left > 0 ? left : 0)+'px'});
+ });
+ }
+ });
+})(jQuery);
+// me (scottbot) (dumpco 2010 ltd inc)
+(function($) {
+ $.fn.extend({
+ ridgificate: function() {
+ var ridges = arguments;
+ return this.each(function() {
+ for (var i = 0; i < ridges.length; i++) {
+ $(this).wrap('<div style="border: ' + ridges[i] + '">');
+ }
+ });
+ }});
+})(jQuery);