Php photo gallery TWG | JFUploader | TWG Flash upload | WFU | Forum
https://www.tinywebgallery.com/forum/

Opening files directly
https://www.tinywebgallery.com/forum/viewtopic.php?f=13&t=3633
Page 1 of 1

Author:  GeRobert [ 10. Jan 2014, 14:06 ]
Post subject:  Opening files directly

Hi,

First of all, thank you for that great component. I would like to know whether there is a way opening the files directly from the flash by doubleclick on the name of the file?I have read something similar in the „How I open PDF file ones I upload in a new window” topic, and already watched all the demos, but I couldn't set up that. I have a Standart Edition License, which runs on a Joomla 1.5.

Author:  TinyWebGallery [ 10. Jan 2014, 17:16 ]
Post subject:  Re: Opening files directly

No - This is not supported directly by the list component.
But you can set $show_full_url_for_selected_file=true. than you get a direct link in the status bar which you can click and which opens the file directly.

The other option is that if you select a file a direct link is generated below the flash where you can than open it in anything you like (new window, lighbox..). Se the pro demo for an example.

Best, Michael

Author:  GeRobert [ 13. Jan 2014, 22:16 ]
Post subject:  Re: Opening files directly

Thanks for your reply. I've already switch on the 'Show full url' option on the 'Registered Flash Uploader setting' tab, and the direct link appeared, but I don't want to show the full path, and it doesn't work on FireFox and Opera, because of the UTF-8 encoding characters.
So the second option would be interested for me, but I can't find its way exactly. I think you mean this demo: http://www.tinywebgallery.com/en/tfu/web_demo2.php as pro demo, and I've downloaded the tfu_demo_reg.zip as well, but unfortunetly it couldn't help for me.
However I've set to 'something' the 'Enable Javascript preview call' on the 'Registered Flash Uploader settings' and on the 'Joomla Settings' tab set the 'Text after the flash' to the following:
<script type="text/javascript">
function previewSelect(loc,id,fullname) {
window.open(fullname,'_blank');
}
</script>

It works, opens the selected file, but at least twice. How can I avoid the multiply opening?

Regards, Róbert

Author:  TinyWebGallery [ 14. Jan 2014, 00:05 ]
Post subject:  Re: Opening files directly

preview select is than called twice by the flash. I have to check why this happens.

Meanwhile you can simply catch the 2nd call. use a global counter variable which only return the file if the counter is even.

So something like this (untested):
<script type="text/javascript">
var counter = 0
function previewSelect(loc,id,fullname) {
if (counter++ % 0) {
window.open(fullname,'_blank');
}
}
</script>

Best, Michael

Author:  GeRobert [ 14. Jan 2014, 22:26 ]
Post subject:  Re: Opening files directly

Well, I tried your suggestion, but unfortunately it didn't work. I think it should be used a well known variable from outside the script, which remain after the script, such as the identity of the new window, so I was looking for a while, and wrote this:
<script type="text/javascript">
function previewSelect(loc,id,fullname)
{
if (typeof(MyWin)== 'undefined')
{
MyWin = {};
}

if (typeof(MyWin[id])== 'undefined' || MyWin[id].closed)
{
MyWin[id]=window.open(fullname,id,'titlebar=no');
MyWin[id].moveTo(0,0);
}
else
{
// MyWin[id].location.href= fullname;
MyWin[id].focus();
}
}
</script>

This script opens only ones those files, which have as extension as the browser opens in a new window, these files are typically images. But, if you click on a file which has an unknown extension (for the browser), you will get many dialog forms (to choose between the opening and downloading). The number of the dialog boxes is 2+n, where n is the number of the calling the previewSelect function, that equal the click on the file names after the last load the whole site/flash.
So, is there a reason why calls the flash more and more that same script, and if it is, how can I bypass it?

Best, Róbert

Author:  TinyWebGallery [ 14. Jan 2014, 22:53 ]
Post subject:  Re: Opening files directly

As I said. I have to check why it is called twiche.
counter is outside the function so it should work fine.

Above in my script are the == missing.

Best, Michael

Author:  TinyWebGallery [ 14. Jan 2014, 23:24 ]
Post subject:  Re: Opening files directly

I just checked the code. for images the Javascript is called twice. Once before it it loaded and once after it is loaded.
I'll change this in the next build that it is only called one after it is loaded.

Best, Michael

Author:  GeRobert [ 15. Jan 2014, 12:08 ]
Post subject:  Re: Opening files directly

Ok, this is the final solution:
<script type="text/javascript">
var n= 0;
var m= 0;
var i= 0;
function previewSelect(loc,id,fullname)
{
n++;
i= 0;
m= 0;
while (m< n)
{
m= m+ i;
i++;
}

if (n== m)
{
window.open(fullname,'_blank');
}
}
</script>

Thank you for your advices!

Best, Róbert

Author:  TinyWebGallery [ 15. Jan 2014, 12:43 ]
Post subject:  Re: Opening files directly

And I have found why it is called twice. I will update this in the next minor upate of the flash.
And I still think a simple modulo calcualation should have worked as well ;).

Best, Michael

Page 1 of 1 All times are UTC + 1 hour [ DST ]
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/