Like SystemiConnectFri 15 Oct 2021, 04:50
Auto Save MessagesLGforumFri 26 Feb 2021, 13:31
New tutorial questionTheCrowMon 15 Feb 2021, 08:12
Support iOS Emojis (and other platforms)LGforumSun 14 Feb 2021, 01:25
LGforum (2806)
Download & Save Private Message Button Vote_lcapDownload & Save Private Message Button Voting_barDownload & Save Private Message Button Vote_rcap 
Mr.Easybb (1587)
Download & Save Private Message Button Vote_lcapDownload & Save Private Message Button Voting_barDownload & Save Private Message Button Vote_rcap 
Bloodbath (745)
Download & Save Private Message Button Vote_lcapDownload & Save Private Message Button Voting_barDownload & Save Private Message Button Vote_rcap 
Rukiafan (533)
Download & Save Private Message Button Vote_lcapDownload & Save Private Message Button Voting_barDownload & Save Private Message Button Vote_rcap 
Dom (513)
Download & Save Private Message Button Vote_lcapDownload & Save Private Message Button Voting_barDownload & Save Private Message Button Vote_rcap 
puppycheese (446)
Download & Save Private Message Button Vote_lcapDownload & Save Private Message Button Voting_barDownload & Save Private Message Button Vote_rcap 
pedro (330)
Download & Save Private Message Button Vote_lcapDownload & Save Private Message Button Voting_barDownload & Save Private Message Button Vote_rcap 
Neymar (301)
Download & Save Private Message Button Vote_lcapDownload & Save Private Message Button Voting_barDownload & Save Private Message Button Vote_rcap 
Hitsu (281)
Download & Save Private Message Button Vote_lcapDownload & Save Private Message Button Voting_barDownload & Save Private Message Button Vote_rcap 
Flora (275)
Download & Save Private Message Button Vote_lcapDownload & Save Private Message Button Voting_barDownload & Save Private Message Button Vote_rcap 


Download & Save Private Message Button

avatarGuest
Sat 28 Feb 2015, 20:43
Hi all,

Because of the 50 messages limit on FM I'm requesting a 'Download & Save PM Button' in my message system to be able to store messages locally in one of my laptop's folders. By saving and storing messages I hope to be able to create a longer lasting PM archive. It doesn't matter where the button goes, whether it'll be in the messages themselves or as check box for each message, as long as it will do the job for at least the INBOX and SENTBOX. The saved files should hold the sender, addressee, date and time and should be stored in a common readable format, like .txt , .xml or .html. Once saved the user should be presented the option to delete the original messages from within the FM PM system.

Thanks,

Samantha.
BloodbathBloodbath
Status : No status yet...

Posts : 745
Join date : 2013-05-31
Age : 28
Sat 28 Feb 2015, 23:39
The file would be served as .xml or .html file anyway (plain text could work but that would ignore images and embedded objects). Either way, this is actually pretty easy, if you have a server set up (can be a free one like x10hosting), then you basically need to set up one simple script to:

1.) set HTTP headers correctly (Content-Disposition)
2.) make a temporary copy of the file to your file system
3.) use PHP's readfile to output your file in binary
4.) delete the temporary file

And then you just add a button that sends a request via Ajax and you're ready to go. I can provide an example code for this if I'm on my PC, coding on phone is messy.
avatarGuest
Sun 01 Mar 2015, 07:01
Thanks for having it a thought, but isn't there another way? I was thinking more of replacing / converting the right-click -> Save As .... for a button, but if we really do NEED to make use of another external server and script for that, I don't see how that's gonna be easy to all FM users. Perhaps my thoughts were a bit too simple on this, idk, it's just a suggestion. OK, let's have a little discussion then before getting started, perhaps with some other members / staff as well.

If what you say is the only way to go, maybe we could ask LG to make it a shared Avacweb service or facility, like AWC and the Thanks system, members only, right?
BloodbathBloodbath
Status : No status yet...

Posts : 745
Join date : 2013-05-31
Age : 28
Sun 01 Mar 2015, 12:33
One single shared host is enough, just like the Thanks system indeed. You basically create some JavaScript to emulate a request to the site if you click the Save button and the shared server will let you download the file. It does not require every user to get a server, just you where you set up this download script.
avatarGuest
Sun 01 Mar 2015, 13:11
@LGforum : Is this idea something we can use on Avacweb and is it possible for you to have such installed for us?
LGforumLGforum
Status : Working to restore AWC!

Posts : 2806
Join date : 2011-10-05
Age : 30
Location : UK
Sun 01 Mar 2015, 14:08
PM area is a member only part of the site. So for an external server to be able to access it, you'd need to either input your username and password on the external server - or send the logged in cookie data on the request which isn't exactly very secure. The risks are minimal I guess.
It's do-able but I'd say it's unwise. Depends how private your private messages are.
avatarGuest
Sun 01 Mar 2015, 14:11
@LGForum : it's about the ability to save messages, so isn't an extra "Save As..." button possible?
BildeBilde
Status : No status yet...

Posts : 142
Join date : 2011-11-04
Location : http://127.0.0.1/
Sun 01 Mar 2015, 19:30
You could try using the HTML5 file API to create a downloadable HTML page?

I can try to whip up something tonight or tomorrow, if I get any time.
avatarGuest
Sun 01 Mar 2015, 19:51
@Bilde : Thanks. Whatever you can come up with would help I guess. I just want it to be user-friendly (automated as much as possible) keeping the original request in mind.
BildeBilde
Status : No status yet...

Posts : 142
Join date : 2011-11-04
Location : http://127.0.0.1/
Tue 03 Mar 2015, 16:33
Here is a prototype for a simple PM downloader. It adds a button right next to the Reply button, that downloads a HTML file with the PM title + content to your computer.

Code:
$(function() {
  if (location.search !== '?folder=inbox') {
    $('form[action^="/privmsg"] .buttons').first().append('<button id="download-pm">Download PM</button>');
    $('#download-pm').click(function(e) {
      var $post = $('form[action^="/privmsg"]');
      var html = '<h1>' + $post.find('.h3')[0].innerHTML + '</h1>' + $post.find('.author')[0].outerHTML + $post.find('.content')[0].outerHTML;
      var link = document.createElement('a');
      document.body.appendChild(link);
      link.setAttribute('href', 'data:text/html;charset=utf-8,' + encodeURIComponent(html));
      link.setAttribute('download', 'Private Message');
      link.click();
      document.body.removeChild(link);
      return false;
    });
  }
});
avatarGuest
Tue 03 Mar 2015, 18:23
OK, thanks. I can see the "Download PM" button and I can click it, but it's not doing anything... Is the board language maybe interfering?
BildeBilde
Status : No status yet...

Posts : 142
Join date : 2011-11-04
Location : http://127.0.0.1/
Tue 03 Mar 2015, 19:42
Well, it turned out to be more of a prototype than I expected Razz

I think I fixed the problem you had (updated my post above)
avatarGuest
Tue 03 Mar 2015, 19:50
It's downloading now alright... without the option to name the file and there's no file extension added (.htm). So, nearly there.... Wink
BildeBilde
Status : No status yet...

Posts : 142
Join date : 2011-11-04
Location : http://127.0.0.1/
Tue 03 Mar 2015, 19:56
If you want, you can add a prompt and file extension by replacing

Code:
link.setAttribute('download', 'Private Message');

with

Code:
var fileName = prompt('File name', 'Private Message');
link.setAttribute('download', fileName + '.html');
avatarGuest
Thu 05 May 2016, 05:28
Topic solved and archived.