Page 1 of 4

Browser with download facilities

Posted: Wed Sep 13, 2017 8:18 pm
by Dutchman
This topic is now obsolete but can be used to investigate the development.
It is about an extension of Dav's browser viewtopic.php?f=20&t=854.
New information is now avaialble in viewtopic.php?f=20&t=2029&p=12290#p12290

Re: Browser with download facilities

Posted: Wed Sep 13, 2017 9:09 pm
by rbytes
Wow! You are riding the lightning. What a great set of tools for circumventing foolishness!

I must set aside my plans for the afternoon and start downloading. :lol:

Re: Browser with download facilities

Posted: Thu Sep 14, 2017 1:04 am
by Dav
This sounds like a great upgrade, Dutchman! I'll be downloading it and give it a go!

- Dav

Re: Browser with download facilities

Posted: Thu Sep 14, 2017 1:18 pm
by Dutchman
My next step would be to connect to my computer.
I found a possible solution at https://www.w3schools.com/Jsref/tryit.a ... load_files
The script is intended to select a file from active servers.
I copied the script to "connect.HTML" and activated it with "Connect.sb"
I can not attach "connect.HTML", it is not accepted for "Place inline", so I copied it in the following code section:

Code: Select all

<html>
<body onload="myFunction()">

<input type="file" id="myFile" multiple size="50" onchange="myFunction()">

<p id="demo"></p>
    
<script>
function myFunction(){
    var x = document.getElementById("myFile");
    var txt = "";
    if ('files' in x) {
        if (x.files.length == 0) {
            txt = "Select one or more files.";
        } else {
            for (var i = 0; i < x.files.length; i++) {
                txt += "<br><strong>" + (i+1) + ". file</strong><br>";
                var file = x.files[i];
                if ('name' in file) {
                    txt += "name: " + file.name + "<br>";
                }
                if ('size' in file) {
                    txt += "size: " + file.size + " bytes <br>";
                }
            }
        }
    } 
    else {
        if (x.value == "") {
            txt += "Select one or more files.";
        } else {
            txt += "The files property is not supported by your browser!";
            txt  += "<br>The path of the selected file: " + x.value; // If the browser does not support the files property, it will return the path of the selected file instead. 
        }
    }
    document.getElementById("demo").innerHTML = txt;
}
</script>

<p><strong>Tip:</strong> Use the Control or the Shift key to select multiple files.</p>

</body>
</html>
The program "Connect.sb" is attached, remove the extension ".txt" before usage.
Connect.sb.txt
(343 Bytes) Downloaded 383 times
After program start on my iPad a browser-page was active with the following content after touching the button:
Button touched.PNG
Button touched.PNG (85.71 KiB) Viewed 5187 times
Apart from the camera and the Photo Library of my iPad, it also shows the Dropbox and FileBrowser apps which obviously are also considered as server to which might be connected. Before usage however some switches had to be set which I discovered after touching "Meer…" (Eng: "More…")
Touched Meer… and switches set.PNG
Touched Meer… and switches set.PNG (80.98 KiB) Viewed 5184 times
After that, I could access my "Smart Basic"-folder on Dropbox:
View into my SB-folder on Dropbox.PNG
View into my SB-folder on Dropbox.PNG (105.93 KiB) Viewed 5187 times
and SURPRISE: into my Mac:
View into my Mac.PNG
View into my Mac.PNG (105.98 KiB) Viewed 5187 times
I expect that the program "Connect.sb" can form the basis for an elegant alternative for the current Dropbox access facility.
I added the two files to the "File transfer" folder on Dropbox.

Re: Browser with download facilities

Posted: Thu Sep 14, 2017 1:47 pm
by Dutchman
I made in Apple's "Human Interface Guidelines" the following screenshot:
Screenshot from  Apple's Human Interface Guidelines.png
Screenshot from Apple's Human Interface Guidelines.png (55.62 KiB) Viewed 5180 times
See https://developer.apple.com/ios/human-i ... -handling/
So it should be allowed for Smart Basic to share files with e.g. the Dropbox app, FileBrowser or other apps.

Re: Browser with download facilities

Posted: Thu Sep 14, 2017 2:00 pm
by Dutchman
I added a 'serial' version of the pdf-document "HTML document interface"

Re: Browser with download facilities

Posted: Thu Sep 14, 2017 2:38 pm
by Mr. Kibernetik
Dutchman wrote:
Thu Sep 14, 2017 1:47 pm
I made in Apple's "Human Interface Guidelines" the following screenshot:
Screenshot from Apple's Human Interface Guidelines.png
See https://developer.apple.com/ios/human-i ... -handling/
So it should be allowed for Smart Basic to share files with e.g. the Dropbox app, FileBrowser or other apps.
I stopped arguing with Apple regarding this topic. They do not understand their own guidelines.

Re: Browser with download facilities

Posted: Fri Sep 15, 2017 7:54 pm
by Dutchman
Several changes have been made.
As indicated in the updated code:
'Changes since first post on http://bit.ly/2wZf2yB
'20170915
' Introduction info moved to "browser initial.info"
' Added warning for overload in Downloads
' Status of buttons moved from global to 'function' "But"
' All subroutines changed to functions
' Height and font of infobar made variable
' Empty battery-part coloured red
' User preferences separated in file "preferences."
' Warning added for attempt to access www offline
• The major change for the user is that the user-settings are moved to a separate file: "preferences." so that they are automatically transferred to new versions. In order to prevent "preferences." from overwriting, you could rename it to e.g. "preferences.name" and change the include-statement in the top of the program accordingly, form {preferences.} to {preferences.name}. Thus you need only to change that statement if an update is installed.
• Furthermore I have modified all subroutines to functions in order to reduce the number of global variables. Most of the variables are now local, which simplifies debugging.
• The height of the topbar is now a variable, so that it can be scaled with the device, as the "preference."-file on iPhone can be different from that on iPad.
• The number of dump-files can grow very fast. Therefore I added a warning, during start-up, if the number of dump-files exceeds a certain threshold.
• It happened to me that I was wondering why a page did not load or refresh, until I discovered that the device in the meantime became offline. Therefore I added a warning in case of such a condition.
• The command-line which calls the launcher has been commented so that it will not cause errors in case it is not implemented.

The screenshots and files have been updated.
Please post suggestions for improvements. ;)

Re: Browser with download facilities

Posted: Fri Sep 15, 2017 11:42 pm
by Dav
Great work, Dutchman. Although I haven't tested it yet, it looks fantastic and I hopefully will get to play around with it this weekend.

Here's something you may be interested in (or maybe not since you are already can download whole pages it looks like). I was going to add this method to my browser because rbytes had asked about an easy way of saving an image on the page.

This example code shows how you can get just a list of images contained in a webpage, and select one to download. I was going to put the image urls in a list and allow the user to select one to download from a list pop up box (like the bookmarks pop up menu). The code below lists all the images on my website main page and downloads bignews.gif to your device if you wish.

- Dav

Code: Select all

'GrabPageImage.txt
'shows how to list every image contained in a web page,
'and save one you choose to your device.
'by Dav.  Note: uses image from my web page as example.

option base 1

'load my website main page for demo...

url$="http://www.qbasicnews.com/dav/"
browser "1" url url$ at 0,0 size 0,0

print "Loading "; url$
print

'get number of images in the document
images=browser_text$("1", "document.images.length")

'if there are any, list them...
if images >0 then

  print "This page has "&images&" images"
  print 

  'show them all...
  for t = 0 to images-1
     print t, browser_text$("1", "document.images["&t&"].src")
  next t
  print

end if

'let's grab one to use...should be bignews.gif
a$=browser_text$("1", "document.images["&2&"].src")

print "Let's use this image for testing..."
print "Image: ";a$
print

'strip out url stuff, just get filename...

'read the url backwards, stopping at a /
a2$=""
for t=len(a$) to 1 step -1
  b$=mid$(a$,t,1)
  if b$="/" then break
  a2$=b$&a2$
next t

'new filename to use when saving to device...
print "Filename for saving: "; a2$

end  '<--- comment this out to save file

'here's how you can save the image to device...

print 
print "Saving ";a2$

http a$ getdim m   'use the full url here.
file a2$ writedim m 'save just the filename.

'now, a bignews.gif should be saved in the folder...


Re: Browser with download facilities

Posted: Sat Sep 16, 2017 6:51 am
by Dutchman
Great idea! I will add an image button to the browser, for downloading images :D