Phonegap external links - hyperlink

I know that question has been asked and answered before, I have the code I think is the right, but I can't figure it out the right syntax, I think is about the quotes and double quotes.
I'm using phonegap version 2.9, in version 2.2 I could open an external link in Safari, but I had to upgrade to 2.9 or apple won't accept my app. and of course the external links will open inside the app without the back button.
This is an app that links to a mysql database with php trough Json.
This is the part I'm having problems:
if (employee.web) {
$('#actionList').append('<li><a href="#" onclick="window.open("http://' + employee.web + '", "_system");"><h3>Website</h3> ' +
'<p>' + employee.web + '</p></a></li>');
}
This worked perfect without the onclick option (but of course in phonegap version 2.9 it opens inside the application and get stuck there).
But now is just not doing anything when I click on it.
I've been many days trying to solve this problem and is the only thing I need to complete my application.

Yeah, your quotes are a bit messed up. Doing this inline can get hairy to say the least. I would separate my HTML from my JS by creating a separate function. Try something like the below:
if (employee.web) {
$('#actionList').append('<li><h3>Website</h3><p>' + employee.web + '</p></li>');
}
function openLink(url){
window.open('http://' + url, '_system');
}

Related

ReferenceError: Metadata for "GoogleMaps.GMSGeometryDistance" found but symbol not available at runtime

I'm using the nativescript-google-maps-utils plugin in a NativeScript JavaScript project to access GoogleMapsUtils functions (GMSGeometryDistance, GMSGeometryInterpolate, and GMSGeometryHeading) so that I can traverse a polyline. The Android equivalents work fine on Android devices, and the iOS functions listed work on an iOS simulator, but on an iOS device I get the exception,
ReferenceError: Metadata for "GoogleMaps.GMSGeometryDistance" found but symbol not available at runtime.
I've been chasing this for the better part of a day and still don't have any leads; I'd welcome any insight.
[edit]
It's worth mentioning I've done the usual removal of the platforms, hooks, and node-modules folders and rebuilt, with no change in the error.
Here's the first line of code that triggers the error:
let lineDistance = GMSGeometryDistance(latlngs[i], latlngs[i + 1]);
[edit 2]
Still chasing this... I gather from this issue that I need to create a file with a list of exported symbols, and this issue kind of suggests how that could be done, but I'm not understanding how that applies to this situation.
That is, the question at hand now is how can I determine the symbols from the iOS GoogleMapsUtils static library? This is becoming more of an iOS and Xcode question that NativeScript or JavaScript.
[edit 3]
Sigh... I did get this working using the answer I provided below, but now that same approach is no longer working. No idea why :-(
[edit 4]
I re-reviewed the links I referenced above and included the STRIPFLAGS option and now the code works properly. I revised the answer to include this, and to edit build.xcconfig rather than the project file.
After another day's investigation I was able to get this working. Here's what it took.
Navigate to /platforms/iOS/Pods/GoogleMaps/Maps/Frameworks/GoogleMaps.framework/
Run nm --defined-only GoogleMaps | grep " T " | cut -f 3 -d' ' | egrep -v '^$|GoogleMaps'
Notice the names of the symbols. In my case each one I needed was the function name prefixed with an underscore
Create the file exportedSymbols.txt in /app/App_Resources/iOS
Add the symbols to the file. In my case the contents is:
_GMSGeometryDistance
_GMSGeometryHeading
_GMSGeometryInterpolate
Edit the file app/App_Resources/iOS/build.xcconfig and add these two lines
STRIPFLAGS=$(inherited) -s {PROJECT_DIR}/../../app/App_Resources/iOS/exportedSymbols.txt
EXPORTED_SYMBOLS_FILE = ${PROJECT_DIR}/../../app/App_Resources/iOS/exportedSymbols.txt
So far this is working in my tests on both iOS simulators and devices.

NativeScript Webview newbie questions

I am experimenting with using NativeScript to speed up the process of porting an existing Android app to iOS. The app in question uses a great deal of SVG manipulation in a Cordova webview. To keep things simple I want to port all of my existing Webview side code - in essence the entire existing Cordova www folder and its contents - over to the new NativeScript app. The WebView talks to a custom Cordova plugin which I use to talk with my servers to do such things as get new SVGs to show, keep track of user actions etc.
If I an get through these teething issues I am considering using this component to implement bi-direction communications between by current webview JS code and the, new, NativeScript backend that will replace my current Cordova plugin. Someone here is bound to tell me that I don't need to do that... . However, doing so would mean throwing out the baby with the bathwater and rewriting all of my current Webview ES6/JS/CSS code.
This is pretty much Day 1 for me with NativeScript and I have run into a few issues.
I find that I cannot get rid of the ActionBar even though I have followed the instructions here and set the action bar to hidden.
I can use the following markup in home.component.html
to show external web content. However, what I want to really do is to show the local HTML file that is in the www folder in the following folder hierarchy
app
|
____home
|
____www
|
______ index.html
|
______css
|
______ tpl
|
.....
However, when I use the markup
<Page actionBarHidden="true" >
<WebView src="~/www/index.html"></WebView>
</Page>
I am shown the error message
The webpage at file:///data/data/com.example.myapp/files/app/www/index.html is not available.
I'd be most grateful to anyone who might be able to tell me what I am doing wrong here - and also, how I can get rid of that action bar which is currently showing the app title.
About using local HTML file
Is your local HTML file recognized by Webpack (which is enabled by default in NativeScript)? Try to explicitly add the local HTML file to your webpack.config.js file. This way Webpack will "know" that it will have to bundle this file as well.
new CopyWebpackPlugin([
{ from: { glob: "<path-to-your-custom-file-here>/index.html" } }, // HERE
{ from: { glob: "fonts/**" } },
{ from: { glob: "**/*.jpg" } },
{ from: { glob: "**/*.png" } },
]
Example here
About hiding the ActionBar
NativeScript Core only: Try hiding the action bar directly for the frame that holds the page. See the related documentation here
NativeScript Angular: The page-router-outlet will have an action bar by default (you can hide it by using the Page DI as done here). Otherwise, you could create a router-outlet (instead of page-router-outlet). The router-outler won't have the mobile-specific ActionBar.

Search/Find file using file name in IntelliJ Idea (In Mac)?

keyboard shortcut to find/search and open file using file name in IntelliJ idea in Mac?
I tried following, but they are not working with latest version...
cmd+shift+n
[or]
ctrl+shift+n
Press Shift twice and then type name. I'm not sure if you are asking about this but that's my guess. Or maybe you are asking about command + Shift + O ;> There you have list:
https://resources.jetbrains.com/assets/products/intellij-idea/IntelliJIDEA_ReferenceCard_mac.pdf

.NET/MVC4/Jquery Mobile/Knockout/Chrome/iPhone extra # character in URL

Okay, if I could offer a bounty for this I would - I offer virtual karma.
As mentioned in the title I have an .NET/MVC4/Jquery Mobile/Knockout website. On the index page there is a button
<button data-bind="click: getResults" data-theme="f">Search</button>
which calls a javascript function
$.mobile.navigate("/results?option1=a&option2=b", { transition: amw.transitions.slide });
This works great on all browsers and devices except Chrome/iPhone. As far as I can tell the version of Chrome or iOS does not matter. The resulting URL in the address bar is
iPhone/Chrome: http://www.mywebsite.com/#/results?option1=a&option2=b
Other Devices: http://www.mywebsite.com/results?option1=a&option2=b
I have put alerts throughout jQuery mobile to try and figure out what is going on (if someone knows a way to debug chrome on iOS let me know) and I cannot see where the extra # is being added.
This may not seem like a big deal but the url ends up being passed on to a downstream service that really does not like the extra #.
I can put in a hack at the call to the service to strip out the # but I would really like to figure out what is happening.
The only suspect line I can find in jQuery mobile (1.3.0) is line #2298
// if the hash is included in the data make sure the shape
// is consistent for comparison
if( data.hash && data.hash.indexOf( "#" ) === -1) {
data.hash = "#" + data.hash;
}
But I am not sure what this does or why it would occour only on Chrome/iPhone.
so StackOverflow people - what is going on?
Thanks.

loadURL and javascript on iOs - Cannot pass strings

I am encountering a very stragne bug, i am trying to call javascript from AIR like this
this.webView.loadURL( 'javascript:alert(5)' ); -- This works
this.webView.loadURL( 'javascript:alert("hello there")' ); -- This is not working
I am not able to pass strings, in any function. I am not sure why this is happening and it is driving me insane. It works correctly in Android though.
Any help would be greatly appreciated.
Thanks
EDIT: after spending sometime tweaking it seems to be the space. alert("hello") works fine alert("hello there") doesnot.
Ok I think I found it.
You cannot pass whitespaces. You can in Android and Desktop - but no, the glorious iOs refuses to digest such an advanced entity.
So you must encode your whitespaces in strings and make sure that there will be no stray whitespace in your functiond declration
for example
this.webView.loadURL("javascript:test('hey__there')"); //will work
while
this.webView.loadURL("javascript: test('hey__there')"); //this won't
this.webView.loadURL("javascript:test( 'hey__there' )"); //this won't
Good luck

Resources