From 801b87590b6d6833ced700a7f13fd5429a6671c9 Mon Sep 17 00:00:00 2001 From: jngrt Date: Tue, 19 May 2015 23:41:50 +0200 Subject: [PATCH] fix photo messages outbox things --- web/index.html | 2 +- web/main.js | 85 +++++++++++++++++++++++++------------------------- web/style.css | 15 +++++---- 3 files changed, 50 insertions(+), 52 deletions(-) diff --git a/web/index.html b/web/index.html index f061393..e421bcc 100755 --- a/web/index.html +++ b/web/index.html @@ -47,7 +47,6 @@
- @@ -67,3 +66,4 @@ + diff --git a/web/main.js b/web/main.js index 4aa51d1..2a658a6 100644 --- a/web/main.js +++ b/web/main.js @@ -22,7 +22,7 @@ document.addEventListener('DOMContentLoaded', function(){ // necessary in case connection is lost and messages are not yet sent checkOutbox(); } - + document.getElementById('message-form').onsubmit = onSubmitMessage; //update everything to initialize @@ -75,9 +75,9 @@ function onSubmitMessage(){ var msg = document.getElementById('message').value.replace(/\r?\n/g, "
"); var namm = document.getElementById('name').value || "anonymous"; addOutboxItem( namm, msg ); -}; +} -function addOutboxItem( name, message ){ +function addOutboxItem( namm, message ){ var outStr = localStorage.getItem( 'outbox' ) || ''; var newMsgs = {}; var ddata = new Date().getTime(); @@ -87,7 +87,7 @@ function addOutboxItem( name, message ){ } var contento = { "time" : ddata, - "message" : mess, + "message" : message, "name" : namm, "node" : alias, "hops" : "0" @@ -158,7 +158,7 @@ function removeOutboxItem( timestamp ) { function updateInboxView() { -var localStorageArray = new Array(); +var localStorageArray = []; var contentString = ''; if (localStorage.length>0) { @@ -184,7 +184,7 @@ var localStorageArray = new Array(); }; } } - orderStorage = localStorageArray.sort(function(a,b) { return b.time - a.time } ); + orderStorage = localStorageArray.sort(function(a,b) { return b.time - a.time; } ); for(var i in orderStorage) { if ( i.length === 0 || i === 'outbox' ) { @@ -247,21 +247,21 @@ function onMessageDownload( msg, filename ) { updateInboxView(); } function onIndex( index ) { - var lines = index.split( /\n/ ); - - for(var k in localStorage){ - var l = 1; - for ( var i in lines ) { - var f = lines[i]; + var lines = index.split( /\n/ ); + var k,i,l,f; + for( k in localStorage){ + l = 1; + for ( i in lines ) { + f = lines[i]; if (f == k){ l = 0; } } - if (l == 1){ - localStorage.removeItem(k); + if (l == 1){ + localStorage.removeItem(k); + } } - } -updateInboxView(); + updateInboxView(); - for ( var i in lines ) { + for ( i in lines ) { var fname = lines[i]; if ( localStorage.getItem( fname ) === null ) { //localStorage.setItem( ts, lines[i].substr(lines[i].indexOf(' ')) ); @@ -305,14 +305,14 @@ function getOwnId() { } function getOwnAlias() { - var xhr = new XMLHttpRequest(); - xhr.onreadystatechange = function(){ - if (xhr.readyState == 4 && xhr.status == 200){ - ownAlias = xhr.responseText; - } - } - xhr.open( "GET", 'alias', true); - xhr.send(); + var xhr = new XMLHttpRequest(); + xhr.onreadystatechange = function(){ + if (xhr.readyState == 4 && xhr.status == 200){ + ownAlias = xhr.responseText; + } + }; + xhr.open( "GET", 'alias', true); + xhr.send(); } /* @@ -438,7 +438,7 @@ function onImageLoad() { drawRotated(); } -function onRotateRight(){ +function onRotateRight(){ rotation += 90; drawRotated(); } @@ -482,7 +482,7 @@ function monochrome(imageData, threshold, type){ // Greyscale luminance (sets r pixels to luminance of rgb) for (var i = 0; i <= imageDataLength; i += 4) { imageData.data[i] = Math.floor(lumR[imageData.data[i]] + lumG[imageData.data[i+1]] + lumB[imageData.data[i+2]]); - + } var w = imageData.width; @@ -526,24 +526,23 @@ function monochrome(imageData, threshold, type){ // Set g and b pixels equal to r imageData.data[currentPixel + 1] = imageData.data[currentPixel + 2] = imageData.data[currentPixel]; } - - // Alpha: make white pixels transparent! - var newColor = {r:0,g:0,b:0, a:0}; + // Alpha: make white pixels transparent! + var newColor = {r:0,g:0,b:0, a:0}; - for (var i = 0, n = imageData.data.length; i =200 && g >= 200 && b >= 200){ - // Change the white to whatever. - imageData.data[i] = newColor.r; - imageData.data[i+1] = newColor.g; - imageData.data[i+2] = newColor.b; - imageData.data[i+3] = newColor.a; - } - } + // If its white, or close to white then change it + if(r >=200 && g >= 200 && b >= 200){ + // Change the white to whatever. + imageData.data[i] = newColor.r; + imageData.data[i+1] = newColor.g; + imageData.data[i+2] = newColor.b; + imageData.data[i+3] = newColor.a; + } + } return imageData; } diff --git a/web/style.css b/web/style.css index 071d51f..09d613e 100755 --- a/web/style.css +++ b/web/style.css @@ -14,15 +14,14 @@ body{ } img{ - width:50%; /* disable anti aliasing */ - image-rendering: optimizeSpeed; - image-rendering: -moz-crisp-edges; - image-rendering: -o-crisp-edges; - image-rendering: -webkit-optimize-contrast; - image-rendering: pixelated; - image-rendering: optimize-contrast; - -ms-interpolation-mode: nearest-neighbor; + image-rendering: optimizeSpeed; + image-rendering: -moz-crisp-edges; + image-rendering: -o-crisp-edges; + image-rendering: -webkit-optimize-contrast; + image-rendering: pixelated; + image-rendering: optimize-contrast; + -ms-interpolation-mode: nearest-neighbor; }