Send e-mail with Intel XDK - intel-xdk

i have a problem with XDK.I'm trying to send an email but i don't know what is wrong. My code:
<script type="text/javascript">
function notEmpty(){
var myTextField = document.getElementById('Name').value,document.getElementById('Mail').value;
if(myTextField.value != ""){
intel.xdk.device.sendEmail(myTextField.value, 'mail#mail.comr', 'Contact', true, null, null)
}else{
alert("Would you please enter some text?")
}
}
</script>
...
<input class="wide-control" placeholder="Placeholder Text" type="text" id="Nome">
</div>
<div class="table-thing with-label widget uib_w_2 d-margins" data-uib="app_framework/input" data-ver="1">
<label class="narrow-control label-inline" for="Mail">Input</label>
<input class="wide-control" placeholder="Placeholder Text" type="text" id="Mail">
</div>
<a class="button widget uib_w_3 d-margins" data-uib="app_framework/button" data-ver="1">Button</a>
<button onclick="notEmpty()">Click me</button>
....

Intel XDK's SendEmail method: https://software.intel.com/en-us/node/493039
This will open the phone's native e-mail application with the parameters you provide prepopulated. For this to work, you must have the "email" options checked in the build settings for Cordova Plugin. You also need to be testing the compiled application Intel XDK provides after the build process.
This feature IS NOT observable when testing in the "emulator" or in a browser. The Javascript API needs to hook into native phone functionality to work.

Related

<form action="https://www.google.com/search" method="GET"> has to redirect to the website when I type a URL in the input field

I have a simple search input box in my webpage that has google search action to it.This is the code.
<div className="search-container">
<form action="https://www.google.com/search" method="GET">
<input type="search" id="search" name="q" placeholder="Search Google or type URL" />
<button className="icon" type="submit"><i className="small material-icons">search</i></button>
</form>
</div>
This is the image of search box
So if i type anything for example like apple, it searches google for apple and displays the content. But if I type a url like http://facebook.com, it again searches google and displays the search result for facebook.
But I need it to redirect to that particular website when I enter a url. If i enter http://facebook.com and press enter, It must redirect me to the facebook website and not to the google search results page for facebook.
Please help me out in this. Thanks in advance.
Effectively what you want here is for the one button to do two different things (search via google, or redirect to a URL). Because you want one element to do two different things, I would recommend using Javascript so that the page can decide which thing to do.
The following code will take in a string from an input box and either redirect if it starts with "HTTP://" or searches google if it doesn't:
<html>
<head>
<script>
function search(query){
if(query.slice(0, 7) == "http://"){
window.location.href = query
}
else{
window.location.href = "https://www.google.com/search?q=" + query
}
}
</script>
</head>
<body>
<label for="url">Enter a URL or search query</label>
<input type="text" name="search" id="search">
<button type="submit" onclick="search(document.getElementById('search').value)">search</button>
</body>
</html>
You can add JS to check whether the input value is a URL.
function go() {
const val = document.getElementById('input').value
window.open(
(isURL(val) ? '' :
'https://google.com/search?q=') + val,
'_blank')
}
function isURL(url) {
try {
new URL(url)
return true
} catch (e) {
return false
}
}
<input type="text" id="input" placeholder="Search Google or type URL" />
<button onclick="go()">Search</button>

RequiredPageContentNotPresent error in geb 0.12.2

I am getting the following error when trying to run a geb test as a part of a Maven build in Eclipse:
Scenario: Perform login Time elapsed: 0.009 sec <<< FAILURE!
geb.error.RequiredPageContentNotPresent: The required page content 'userName - SimplePageContent (owner: LoginPage, args: [], value: null)' is not present
The only pattern to the error seems to be that it is thrown every time I try to use the geb selector to select/find some page content, but using the selector should work out-of-the-box, right?
I am using the following tools and libraries:
Eclipse Mars Java EE ID (version: 4.5.1)
geb (version 0.12.2)
Selenium (version 2.48.2)
Groovy (version 2.4.5)
Cucumber (version 1.2.4)
Here is my .feature file:
Feature: Login
Scenario: Perform login
Given the user is at the login page
When the user enters <some_uid> and <some_pwd>
Then the user should be logged in
Here is my steps definition:
package stepdefs
import pages.LoginPage
import static cucumber.api.groovy.EN.*
Given(~"the user is at the login page") { ->
to LoginPage
assert at(LoginPage)
}
When(~"the user enters (.*) (.*)") { user, password ->
at LoginPage
page.doLogin(user,password)
}
Then(~"the user should be logged in"){ ->
assert at(LoginResultPage)
}
Here is my page definition:
package pages
import geb.Page
class LoginPage extends Page {
static url = "/TSADG_BORGER/loginpin.do"
static at = { title == "TastSelv Borger" }
static content = {
loginForm { $($/form/$,id:"mainForm") }
userName { loginForm.find("input",id:"pnr") }
pass { loginForm.find("input",id:"tastselvKode") }
buttonLogin { loginForm.find("input",id:"bt1") }
}
def doLogin(user, password) {
userName = user
pass = password
buttonLogin.click()
}
}
Here is the HTML for the form:
<form id="mainForm" action="/TSADG_BORGER/loginpin.do" role="form" method="post" autocomplete="off">
<input type="hidden" name="dispatch" value="Valider">
<div class="row skts-centered-padding">
<div class="col-sm-12">
<h1>Log på med TastSelv-kode</h1>
</div>
<div class="col-sm-6">
<div class="skts-process-form-section skts-required ">
<p><label for="pnr">Cpr-nummer</label></p>
<div>
<input id="pnr" type="text" value="" class="form-control skts-required-val" name="pnr" size="16" maxlength="14" data-validation-event="blur" data-show-type="string" data-show-facets="pattern" data-show-facet-values="/(^\d{10}$)|(^\d{6}\-\d{4}$)/" aria-required="true" aria-invalid="false" aria-describedby="pnrError " autocomplete="off">
</div>
</div>
<div class="skts-process-form-section skts-required">
<p><label for="tastselvKode">TastSelv-kode</label></p>
<div>
<input id="tastselvKode" type="password" value="" class="form-control skts-required-val" name="tastselvKode" size="16" maxlength="16" data-show-type="string" data-show-facets="pattern" data-show-facet-values="/^[^]{7,16}$/" data-validation-event="blur" aria-required="true" aria-invalid="false" aria-describedby="tastSelvKodeError " autocomplete="off">
</div>
</div>
<br>
<p>
<input type="submit" id="bt1" class="btn btn-primary skts-validate" value="Fortsæt" autocomplete="off">
</p>
</div>
</div>
</form>
Any help and input is appreciated.
I would rearrange your content section a bit:
static content = {
loginForm { $("form#mainForm"") }
userName { $("input#pnr") }
pass { $("input#tastselvKode") }
buttonLogin { $("input#bt1") }
}
Use jQuery selectors in Geb! They are very handy. Note that if you use unique ids $("#mainForm"") will have the same effect as $("form#mainForm""). First version is easier, second is more expressive ;)
More info: http://www.w3schools.com/jquery/jquery_ref_selectors.asp
And: http://www.gebish.org/manual/current/#the-jquery-ish-navigator-api
The problem has been resolved.
I was so convinced that it had to be a problem with the selectors, so it took me a while to get my head out of the sand and take a step back. When I did that, I realised that the URL in the "LoginPage" class actually did a redirect to another page, which I was not expecting. The page I was redirected to did obviously not contain any of the objects I was looking for in my contents section. So, when the error message stated that "The required page content...is not present", then that was absolutely correct.
Really silly mistake on my part...

AngularJS ng-submit not working with PhoneGap iOS app

I'm trying to use the native keyboard "Go" button in my login form in a PhoneGap iOS app made with AngularJS, when the user click on the "Go" button i want to launch the "connect()" function of my controller. the "ng-submit" directive is not working :
<form ng-submit="connect(mail,password);" >
<input iscroll-bug type="mail" ng-model="mail" placeholder="E-mail">
<input iscroll-bug id='password' type="password" ng-model="password" placeholder="Mot de passe" >
<div ng-hide='loader' class="yellow_btn" ng-click="connect(mail,password);" ><p>Se connecter</p></div>
<img style='width:30px;' class='center' ng-show='loader' src='img/ajax-loader.gif' /><br/>
</form>
I think maybe the solution is in create a new Directive to force the action of the "onSubmit" event, i tried something like this :
// Other directive i Have
.directive('submitForm', function ($timeout, callbackOnSubmit) {
return {
link : function(scope, element, attrs) {
element.submit(function () {
callbackOnSubmit();
})
}
}
});
and use it like this :
<form submitForm="connect(mail,password)" >
Not working so I'm probably getting it wrong in my directive, is anyone already have this similar issues and solve it ?
Thanks
I had a <input type="submit"> with a display:none style, when i display it, it's working so just use visibility:hidden and it's working just fine with the native keyboard "go" button and ng-submit

onsubmit() does not call my function but the form does get submitted

I have a external js file that has the following function in it. It is supped to be called by the forms onsubmit but it doesn't appear to be happening. The form is just submitted without validation. At one point this was working but now it is not. Where am I going wrong? Any help is appreciated.
function validateDelete(form)
{
alert("Validation Started!");
var photoName=form.deleteName;
if (photoName === "")
{
alert("Photo Name Required");
return false;
}
}
<script src="galleryScripts/validation.js" type="text/javascript" ></script>
<form action="galleryScripts/deletePhoto.php?submit=true" name="deleteForm" onsubmit="return validateDelete(this);" id="deleteForm" method="post">
<label>
File Name: <input name="deleteName" type="text" id="deleteName">
</label>
<label>
<input type="submit" name="deleteButton" id="deleteButton" value="Delete" />
</label>
</form>
Make sure that your js is included.
For example under mozilla press CTRL+U and click on a link to your validation.js file.
Also you can just paste in tag in your tag it should work.

Embedded Payment return url shown in iframe

I'm trying to implement adaptive payments as embedded payment with lightbox.
It works fine until a user makes a payment, but after user completes the payment
page specified by return url gets loaded within the iframe.
I'm expecting it to be loaded in the window NOT in the iframe.
Following is the code that I have. Am I missing something?
Environment
Java(play framework)
PayPal_Platform_Java_SDK_N
Expected Page Transfer Scenario
PageA - ("pay with paypal" button click)
→ paypal dialog - ("close" button click)
→ PageB
PageA.html
<form action="https://www.sandbox.paypal.com/webapps/adaptivepayment/flow/pay" target="PPDGFrame">
<dl>
<dt></dt>
<dd>
<input id="type" type="hidden" name="expType" value="light">
<input id="paykey" type="hidden" name="paykey" value="AP-KEY">
<input type="submit" id="paypalSubmitBtn" value="Pay with paypal" />
</dd>
</dl>
</form>
<script type="text/javascript">
var dgFlow;
$(function(){
dgFlow = new PAYPAL.apps.DGFlow({ trigger: 'paypalSubmitBtn' });
});
</script>
PageB.html
<p>Thank you for your payment!</p>
<script type="text/javascript">
function handleEmbeddedFlow() {
if (top && top.opener && top.opener.top) {
top.opener.top.dgFlow.closeFlow();
}
else{
top.dgFlow.closeFlow();
}
top.close();
}
jQuery.event.add(window, "load", function(){
alert("window.load");
handleEmbeddedFlow();
});
</script>
I also noticed that dgFlow can not be resolved in else case's top.dgFlow.closeFlow(); in PageB.html.
You can try to detect if the page is running in an iframe, and if so redirect to the page directly.
How to detect:
How to identify if a webpage is being loaded inside an iframe or directly into the browser window?
How to redirect:
Redirect the parent page from IFrame