Shoutbox issue on mr3040

Posted by koalatron.9000 
This forum is currently read only. You can not log in or make any changes. This is a temporary situation.
Now, this forum is in read-only mode. You find details Details hereContinue on /r/PirateBox
Shoutbox issue on mr3040
January 07, 2015 08:38PM
Hey guys I just got my 3040 yesterday to make my mobile Piratebox and everything is working-ish.
The only issue I've found is that the chat doesn't update properly. I've only had time to test this on my phone and with the help of 2 other phones. 2 iphones(I don't know the models, I don't think it should matter but for the sake of details...) and I am using a Galaxy S3.
when I first arrive on the home page I type in a message but it doesn't show up. However if someone else joins the network and goes to the homepage the message is there. and they can type and the messages appear normally. I have found that I can emulate this with one phone by opening a second tab and going to the homepage on the second tab. just as on another phone that second tab shows all of the messages and updates with new ones. I reproduced this in the stock browser, Firefox and Safari(on the iphones).
also jumping back and forth between tab 2 in the stock browser and tab 2 in firefox shows everything. i.e. what I type in stock tab 2 appears on firefox tab 2 and vice versa.

Has anyone ran into this? Does anyone have an idea how to fix this?

Thanks in advance!
Re: Shoutbox issue on mr3040
January 07, 2015 09:09PM
Hi,
that sounds very strange.

Did you change something?
Is a ethernet cable connected to a home-router?
Can you access the page using any dns name? Or only IP?

Please run the following commands and post the output
 cat /etc/pbx_custom_image
 cat /etc/openwrt_release
 cat /opt/piratebox/version
 cat /etc/config/network
 cat /etc/config/wireless

Matthias
Re: Shoutbox issue on mr3040
January 07, 2015 10:51PM
Did you change something?
No, I just followed the instructions found at: [www.piratebox.cc]

Is a ethernet cable connected to a home-router?
No it is just the router broadcasting wirelessly

Can you access the page using any dns name? Or only IP?
Yes, I can access via any website. usually "a.com" or something similar.

and I will provide those outputs in about an hour and a half when I get home.
Re: Shoutbox issue on mr3040
January 08, 2015 12:33AM
here are the outputs you asked for.
Language: PHP
cat /etc/pbx_custom_image PBX_auto_Image_2.2   cat /etc/openwrt_release DISTRIB_ID="OpenWrt_backports" DISTRIB_RELEASE="12.09.2" DISTRIB_REVISION="r42647" DISTRIB_CODENAME="attitude_adjustment" DISTRIB_TARGET="ar71xx/generic" DISTRIB_DESCRIPTION="OpenWrt_backports Attitude Adjustment 12.09.2" DISTRIB_BACKPORT="V0.2.1"   cat /opt/piratebox/version piratebox-ws_1.0.2   cat /etc/config/network   config interface ';loopback'; option ifname ';lo'; option proto ';static'; option ipaddr ';127.0.0.1'; option netmask ';255.0.0.0';   config interface ';lan'; option ifname ';eth0'; option type ';bridge'; option proto ';static'; option ipaddr ';192.168.1.1'; option netmask ';255.255.255.0';   cat /etc/config/wireless   config wifi-device ';radio0'; option type ';mac80211'; option channel ';11'; option hwmode ';11ng'; option macaddr ';c4:6e:1f:39:51:be'; option htmode ';HT20'; list ht_capab ';SHORT-GI-20'; list ht_capab ';SHORT-GI-40'; list ht_capab ';RX-STBC1'; list ht_capab ';DSSS_CCK-40'; option disabled ';0';   config wifi-iface option device ';radio0'; option network ';lan'; option mode ';ap'; option encryption ';none'; option ssid ';PirateBox - Share Freely';

Also the mr3040 is version 2.4.



Edited 1 time(s). Last edit at 01/08/2015 01:53AM by koalatron.9000.
Re: Shoutbox issue on mr3040
January 08, 2015 10:28AM
Hi,
mh. I updated one of my test boxes to the 1.0.2 version of PirateBox and it works on my iPhone and on the attached computer's firefox.

I know, that before release 1.0.2 I explicitly tested the shoutbox, because there are some changes in that bugfix release.

As the shoutbox uses some JavaScript, do you have any restrictions set up in your browser?
Can you access
Language: PHP
http://piratebox.lan/chat_content.html
without any issues?

regards Matthias
Re: Shoutbox issue on mr3040
January 08, 2015 01:33PM
I can get to that address no problem, however it always says:
00:00:00 PirateBox: Chat and share files anonymously!
Even after sending messages and confirming they were received via my tab 1/tab 2 work around.

Also if i connect to the piratebox and then go to that page (skipping the homepage) it seems to disable my workaround.
I can then only replicate the workaround again if i close out all tabs and then go to the homepage.
Trying the tab1/tab 2 idea with 2 tabs of "[piratebox.lan]; doesn't show the messages either.
Re: Shoutbox issue on mr3040
January 11, 2015 09:53AM
Can you check if you get any javascript errors in the browser using the development console?
Re: Shoutbox issue on mr3040
January 11, 2015 10:18AM
here is the output from when i logged on and then tried to post a message in the chat:

The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must be declared in the document or in the transfer protocol. www.face.com

Empty string passed to getElementById(). jquery.min.js:2
Re: Shoutbox issue on mr3040
January 11, 2015 11:51AM
update: refreshing the page after sending that first message works(so no need for multiple tabs). After the first message appears the chat updates any following messages properly and the page at
Language: HTML
http://piratebox.lan/chat_content.html
shows the message.
But it doesn't work if you refresh the page before sending a message. I don't know if that provides any clarification.
Re: Shoutbox issue on mr3040
January 11, 2015 12:27PM
Experienced similar behaviour myself when using an iPhone or iPad. Had to manually refresh to get the chat to update. However, no problems when using my PowerBook. Cant help but think this is a browser caching issue.
Re: Shoutbox issue on mr3040
February 06, 2015 08:24AM
Same problem on the MR3020. Have a windows phone and it doesn't update automatically. Seems to work on the iPhone 5.
Re: Shoutbox issue on mr3040
February 06, 2015 09:40AM
Hi,
I can't reproduce it hardly, but I observed it somewhere - I think. I was only able to reproduce it somehow using my dev. branch.... but that is not comparable, because there are major differences (and bugs maybe).

So you are running 1.0.2 right?
The refresh time should be around 10 seconds.
Can you gather some informations out of the browser like you could do it with firefox-inspect element. ?

I just tested it again with my 1.0.2 box , firefox on my Linux notebook and the iPhone with iOS8.x - that worked. I opened the browser on each system, entered the IP or any URL (depending how the system is connected to the box) and chatted with myself. Worked.
I'm using a full UTF8 character set everwhere...

that is weired...



regards Matthias
Re: Shoutbox issue on mr3040
February 11, 2015 08:47AM
Will give it a try this week and see if it refreshes within the 10 seconds.
Re: Shoutbox issue on mr3040
February 19, 2015 02:29AM
Hi, I have my PB 1.0 in my mr3040 and I have the same problem as koalatron.9000, exactly the same, is there a way to change the refresh time to be lower than 10 seconds?
Re: Shoutbox issue on mr3040
February 19, 2015 07:51AM
I don't think that will help... but

login to your box using ssh like you did in the post-install steps
edit scripts.js

vi /opt/piratebox/www/scripts.js
Line 113 , the time is in ms

you can see the script online here [github.com]

regards Matthias
Re: Shoutbox issue on mr3040
February 19, 2015 08:26AM
Changing the refresh time indeed doesn't help. It seems the chat doesn't refresh at all.
Re: Shoutbox issue on mr3040
February 19, 2015 01:30PM
The page get's sort of a refresh, what is entered for the chat is processed and the input field is blank again while the chat_content.html is updated. But somehow the chat content doesn't show in the browser.

Could it be something with caching within the browser? The script itself seems to be working as intended but updates only show if you do a 'hard' refresh in the browser.
Re: Shoutbox issue on mr3040
February 19, 2015 04:51PM
Then the browser violates the "no cache" rule.
On the generated chat_content.html

... We should send this on the index page, but it seems it got lost on the way to 1.0 sad smiley

Can you try to add this to the index.html on the piratebox at the end of line 8
[code=html]<meta http-equiv='cache-control' content='no-cache'>[/code]

But, as the request is sent by JavaScript, it should work even without the no-cache statement. ...
Re: Shoutbox issue on mr3040
February 20, 2015 09:53AM
No difference with adding the no-cache option. Strange behavior because it looks like part of the javascript is working as it should but the refreshing of the shout box is the only piece that doesn't.
Re: Shoutbox issue on mr3040
February 20, 2015 10:43AM
if you already tested the iframe thingy, can you post a copy of the scipts.js and index.html ?


This is only my signature.
Re: Shoutbox issue on mr3040
February 20, 2015 12:31PM
Here's my current index.html, the script.js is not touched so is the same as after initial installation of Piratebox.

Language: HTML
<!DOCTYPE html> </ul> </nav> </div> </header>   <section id="content"> <div class="container"> <div id="welcome" class="card"> <h2>Welcome</h2> <p>Now, first of all, there is nothing illegal or scary going on here. This is a social p lace where you can chat and share files with people around you, <strong>anonymously</strong>! This is an off-line network, specially designed and developed for file-sharing and chat services. Staying off the grid is a precauti on to maintain your full anonymity. Please have fun, chat with people, and feel free to share any files you may l ike.</p> <input id="thanks" class="button" type="submit" value="Thanks"> </div> <div id="sidebar"> <div id="upload" class="card"> <h2>Upload</h2> <iframe width="100%" height="80" src=';http://sharebox.lan:8080';> Your browser does not support iframes.. If you want to upload something, follow this <a href=';http://sharebox.lan:8080';>Link</a>. </iframe> <h3><a href="/Shared">Browse Files -></a></h3> </div> </div>   <div id="main"> <br>   <iframe name="psoread" src="/cgi-bin/psoread.py" width="95%" height="275" frameBorder="1" #ccc> Your browser does not support inline frames or is currently configured not to dis play inline frames.</iframe></p> <script language="javascript"> <!-- function reset() { self.document.psowrte.data.value=""; self.document.psowrte.data.focus(); } --> </script>   <form method="POST" action="/cgi-bin/psowrte.py" target="psoread" name="psowrte" onsubmit ="setTimeout(';reset()';,10)"> <b>Name:</b><input type="text" value="anonymous" name="name" size="10">&nbsp;&nbsp; <b>Me ssage:</b><input type="text" name="data" size="20">&nbsp;&nbsp; <input type="submit" value="PirateBox Chat" name="submit"><br> <b>Color:</b> Default<input type="radio" value="def" name="color" checked> | <font color="#0000FF">Blue</font><input type="radio" value="blue" name="color"> | <font color="#008000">Green</font><input type="radio" value="green" name="color"> | <font color="#FF8040">Orange</font><input type="radio" value="orange" name="color"> | <font color="#FF0000">Red</font><input type="radio" value="red" name="color"></p> </form> </div> </div> </section>   <footer id="about"> <div class="container"> <p class="to-top"><a href="#header">Back to top</a></p> <h2>About ShareBox</h2> <p>Inspired by pirate radio and the free culture movement, ShareBox (original PirateBox) is a sel f-contained mobile collaboration and file sharing device. ShareBox utilizes Free, Libre and Open Source software (FLOSS) to create mobile wireless file sharing networks where users can anonymously share images, video, audio, d ocuments, and other digital content.</p> <p>ShareBox is designed to be safe and secure. No logins are required and no user data is logged. The system is purposely not connected to the Internet in order to prevent tracking and preserve user privacy.</p > <small>PirateBox is licensed under GPLv3.</small> </div> </footer>   </body> </html>



Edited 1 time(s). Last edit at 02/20/2015 12:44PM by ReVmAn.
Re: Shoutbox issue on mr3040
February 20, 2015 01:38PM
Well, got it working, sorta... Had to add the refresh function to the reset function else the new data wouldn't show. As sad, it is working but not as I want it to work though. With the refreshing of the iframe you see the text disappearing for a few milli seconds. The javascript way is much better without the 'flickering' of the chat messages....
Re: Shoutbox issue on mr3040
February 20, 2015 01:53PM
I just solved it different, but I'm not able to make the colors working.

/opt/piratebox/www/index.html
Language: HTML
<h2 data-l10n-id="mainChatChat">Chat</h2> <div id="shoutbox" class="shoutbox_content"> <iframe name="psoread" src="/chat_content.html" width="100%" height="100%" frameBorder="1" >   Your browser does not support inline frames or is currently configured not to dis play inline frames.</iframe> </div>

/opt/piratebox/www/scripts.js
Language: Javascript
function refresh_shoutbox () { // $.get(';chat_content.html';, function(data) { // $(';div#shoutbox';).html(data); // }); }

/opt/piratebox/python_lib/psogen.py
Language: Python
htmlstring = "<html><head><meta http-equiv=';cache-control'; content=" \ "';no-cache';><meta name=';GENERATOR'; content=';PyShoutOut';><meta http-equiv=';refresh'; content=';10'; />" \ "<title>Shout-Out Data</title><body>" htmlstring += content

But that is not a very good solution. Having a working Javascript, that decides if it needs an iframe or use a normal callback, would be much better.

regards Matthias



Edited 1 time(s). Last edit at 02/20/2015 01:55PM by Matthias.
Re: Shoutbox issue on mr3040
February 20, 2015 02:00PM
??
i don't understand your last post about the changed javascript. Does it apply to your modifications?

because on the stock javascript, an update is already running:
Language: Javascript
function refresh_shoutbox () { $.get(';chat_content.html';, function(data) { $(';div#shoutbox';).html(data); }); } function refresh_time_sb () { // Refresh rate in milli seconds mytime=setTimeout(';display_shoutbox()';, 10000); } function post_shoutbox () { $.post("/cgi-bin/psowrte.py" , $("#sb_form").serialize()) .success(function() { refresh_shoutbox(); }); $(';#shoutbox-input .message';).val(';';); }
Re: Shoutbox issue on mr3040
February 20, 2015 02:21PM
The refresh function below is working for the windows phone...

Language: Javascript
function refresh() { frame = document.getElementsByName( ';psoread'; )[0]; frame.contentWindow.location.reload() }

Can I put this somewhere in the scripts.js?

I'll try your posted solution as well.



Edited 1 time(s). Last edit at 02/20/2015 02:25PM by ReVmAn.
Re: Shoutbox issue on mr3040
February 20, 2015 02:25PM
Not the scripts.js, but in the index.html, below code in the index.html

Language: Javascript
<script type="text/javascript"> function refresh() { frame = document.getElementsByName( ';psoread'; )[0]; > frame.contentWindow.location.reload() } interval = window.setInterval( ';refresh()';, 8000 ); </script>     <script language="javascript"> <!-- function reset() { self.document.psowrte.data.value=""; self.document.psowrte.data.focus(); refresh(); } --> </script>
Re: Shoutbox issue on mr3040
February 20, 2015 02:34PM
Well, then the correct fix on the original PirateBox should be

.. quickly summed up..
Language: Javascript
$(document).ready(function() { ..... refresh_time_sb(); display_shoutbox(); ... }   function refresh_time_sb () { // Refresh rate in milli seconds interval = window.setInterval( ';refresh_shoutbox()';, 10000 ); }   function display_shoutbox() { refresh_shoutbox(); }
Re: Shoutbox issue on mr3040
February 20, 2015 03:06PM
Did the changes, but still no luck. This is a IE thing. The look and feel on my laptop, connected to piratbox, looks like garbage....
Re: Shoutbox issue on mr3040
March 05, 2015 11:10PM
I had the same problem as koalatron.9000 and the post from February 20, 2015 08:34AM fixed it!
Thank you Matthias!



Edited 1 time(s). Last edit at 03/05/2015 11:12PM by locobgr.
Re: Shoutbox issue on mr3040
March 09, 2015 11:52AM
Hi,
I found the root cause of the problem!

The thing is, that the PirateBox scripts generate the chat_content.html before the system clock is set to a normal value. So the file is generated in the year 1970. It seems that confuses some software like the browser and/or lighttpd.
Trying to reproduce the problem with a proper date&time set, wasn't possible for me.

Can somebody else try to confirm this?

regards Matthias