I'm still at step one.
How can i load this local html document with a query string?
I tried using the Copy action to dynamically rename the html file to include the entire query. This was a step in the right direction, as Web View can now open the queried html document. The obstacle now is that the page is not displayed with the results of the JavaScript.
I can test that the method of renaming the file works by opening it in a my browser (A11 below). The page appears correctly for my time and location, as seen in the first picture...the results of the JavaScript is everything in the blue box.
If I uncheck "Access Phone" in the scene, then the page is opened with the message to turn on JavaScript, as seen in the second picture...as expected.
When I check that box, the page is opened in the same style as before, without the warning to enable JavaScript...so I'm pretty sure the webpage recognizes that JavaScript is enabled. But it is not displaying the results of the JavaScript... so I'm thinking that the code is not being run.
Test Sun_Moon (249)
A1: Variable Set [ Name:%space To: Do Maths:Off Append:Off ]
A2: Perform Task [ Name:LOC Convert Priority:%priority+1 Parameter 1 (%par1): Parameter 2 (%par2): Return Value Variable: Stop:Off ]
A3: Variable Split [ Name:%LocLatLon Splitter:%space Delete Base:Off ]
A4: Variable Set [ Name:%query To:?Place='%LocCity'&Lat=%LocLatLon1&Long=%LocLatLon2&TZ=-5&TZname='EST' Do Maths:Off Append:Off ]
A5: Variable Set [ Name:%path To:/storage/emulated/0/Tasker/JavaScript/sun_moon.html Do Maths:Off Append:Off ]
A6: Variable Set [ Name:%tempfile To:%path%query Do Maths:Off Append:Off ]
A7: Copy File [ From:%path To:%tempfile Use Root:Off ]
A8: Show Scene [ Name:Sun_and_moon Display As:Activity, Full Window Horizontal Position:100 Vertical Position:100 Animation:System Show Exit Button:On Continue Task Immediately:On ]
A9: Wait [ MS:0 Seconds:10 Minutes:0 Hours:0 Days:0 ]
A10: Destroy Scene [ Name:Sun_and_moon ]
A11: [X] Launch App [ App:Chrome Data:file://%tempfile Exclude From Recent Apps:Off ]
A12: Delete File [ File:%tempfile Shred Level:0 Use Root:Off ]
Scene: Sun_and_moon
P:1062x1608 L:-1x-1
Element: WebView1/WebView
Geometry:
P:26,0 1034x1602 L:-1,-1 -1x-1
Content:
Mode: File
Source: %tempfile
Allow Phone Access: On
Self Handle Links: Off
App Cache API: Off
DB API: Off
Well, I haven't really got that far yet. I'm still trying to figure out a way to use a URL query string on this locally saved html file, opened in a Web View element.
Once I can do that, then I need to edit the html to create those variables...and no, I new that I needed to use setLocal, but i didnt realize that was a Tasker function, so I would not have prefixed with tk. Thank you for that!
Thanks Matt. Your advice is verymuch alleviated!
Okay, I've figured out how to query my local html document! Check this out... I'm certain that I tried this multiple times yesterday, but i must've done something different...
In the scene, use URL as the source (not File). Then point to the local file:
file:///<path to file>
So my method of dynamically renaming the [/sun_moon.html] file to include the query [/sun_html ?Place='%LocCity'&Lat=%LocLatLon1&Long=%LocLatLon2&TZ=-5&TZname='EST'] works! The task that i posted above is now working as I had intended it to last night. See screenshot.
Now, I think I can start playing with those variables and trying to get those to work!
Something odd that I noticed. If you look at the first picture attached to my second post on this thread...that is an example of how the page is displayed when working correctly. After getting this to work, I noticed that moon set times are missing...In fact, even when I run this online through the author's website, that information is missing??
Weird. I did mess around last night with my saved document, with exactly the moonset display. I don't understand why that would have anything to do with the results processed through the authors website though??
I deleted all of my saved copies of the html document, and the library of .js files and style sheet. I wiped Chrome cash and Tasker cache from app settings, wiped cache and dalvic from recovery, rebooted and let the rom settle.
I'll figure that out later I guess, but very pleased to figure out how to query my local doc!
I need to keep researching JavaScript and studying the userguide for a bit. I've got the gist of how to set this variable, but not exactly the syntax or proper placement in the script.
I'm using [URL="https://play.google.com/store/apps/details?id=com.aor.droidedit"] DroidEdit [/URL] to edit the code. My code is in the pic.
I'm trying to set mooonr in the html, and testing by running a Flash [%mooonr] action in the Page Loaded event tab. So far, no dice. But I'm encouraged.
Thanks! I'm feeling accomplished now...although this was just to get me information to use in a project I haven't started yet. Very happy to have overcome this challenge so far!
It bothers me that I can't edit posts here. There are several typos above, but this one might confuse people in the future:
In the scene, use URL as the source (not File). Then point to the local file:
I've been referencing "source" a few times when I meant to put "mode" when referring to URL/File. My source has always been a local file. I got the query to work by accessing the file with the URL mode.
There might be more than one instance of that typo, so please keep that in mind, if anyone tries to duplicate this!
Nice work!
Matt
--
You received this message because you are subscribed to a topic in the Google Groups "Tasker" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tasker/GP9JNlpWOlE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tasker+un...@googlegroups.com.
Visit this group at http://groups.google.com/group/tasker.
For more options, visit https://groups.google.com/d/optout.
Also, for later, I don't think the JavaScript will run when you create the scene. You have to do the show scene action. But you could always make it tiny and transparent.
This was correct. The script won't run unless Show Scene is used. I made the scene tiny, transparent, and changed to Overlay... Self destructs after a second.
Working well.
So, this has been working well on my device for some time and I've made this into a fairly complex project that takes that base information and calculates major/minor periods and makes a very detailed weather analysis to calculate hourly scores for fish/game activity. It had been working well and scores Jane been very accurate!
I can potentially make this a factory ready project to add to the wiki, or make an app to put on the store. So a friend has been testing this on his device, and the Web View element is not performing the JavaScript or even loading the html document.
His device is on Android 4.1.2 and mine is on 4.3....we are both using Tasker 4.6u2
I can't find any documentation on whether or not there is a minimum android version requirement for this feature to work.
Does anyone know if there is a minimum version requirement for either javascript, or Web View with the ability to perform embedded javascript? Or can point me to the docs?