For some reason, abour 50% of the time, if I scan a standard book ISBN barcode into Chrome, it will read 9781782941972 as 9780008134372?!
We have a web based data management system with a web form that requires a barcode. It will then return the book's data to another div. It's worked for years but over the past few months it's started reading the wrong barcodes.
The html looks like this...
<form id="location_lookup" name="location_lookup" method="get" style="float:left;">
<div style="float:left;clear:left;margin-bottom:10px;">
<label for="isbn13">Barcode/Product Code :</label>
<input id="isbn13" name="isbn13" type="text" value="" />
<input id="isbn13" name="function" type="hidden" value="lookupProduct" />
</div>
<div style="float:left;clear:left;">
<input type="submit" value="Send" class="bigbutton" />
<input type="reset" value="Clear" id="formReset" class="bigbutton"/>
</div>
</form>
so the input with id isbn13 has a 13-digit number dumped into it by a simple barcode scanner. The barcode scanner is set to enter a CR after the barcode is dumped (and hence submit the form). Then this runs...
$("#location_lookup").submit(function(event) {
event.preventDefault();
var isbn13 = $("input[name='isbn13']").val();
$.ajax({
url: "location_functions.php",
type: "get",
data: values,
async: false,
beforeSend: function(x) {
if(x && x.overrideMimeType) {
x.overrideMimeType("application/j-son;charset=UTF-8");
}
},
dataType: "json",
success: function(values){
//does more stuff...
It's a boring, perfectly normal barcode reader that's being scanned into a basic PHP web input. I've tried swapping over the scanners but it still seems to happen. I've also tried disabling the anti-virus but again, it still happens!
I just don't get what's happening!
Related
Since I wanted an application that would act more like a search engine, I have used custom search.ai. However, in the production environment, I see queries and subscription keys, I have to enter. I wish to obtain these codes, so could you please explain how I go about getting them.
Your help is greatly appreciated!
You can use :
<form method="GET" action="https://www.bing.com" target="_blank">
Search Bing: <input type="text" name="q" placeholder="Search..."/>
<input type="submit" value="Search"/>
</form>
And if you want to do a custom site search then you can use:
var q = document.getElementById("query");
var val= document.getElementById('hidden').value = "+site:reddit.com";
document.getElementById('search').onclick = function() {
window.location.href='http://bing.com/search?q='+q.value+val;
};
// Submitting value when 'Enter' is pressed
document.addEventListener("keydown", event => {
if (event.isComposing || event.keyCode !== 13) {
return;
}
window.location.href='http://bing.com/search?q='+q.value+val;
});
<input id="query" type="text" name="q" maxlength="255" placeholder="Search in the site" value="">
<input id="hidden" name="q" type="hidden">
<input id="search" name="q" maxlength="255" placeholder="Search in the site" type="button" value="Search">
You can also use this to open images,videos, etc. directly.
Here is my code to upload document in liferay via jsonapi. i am adding file inside document liberary. But it show error "No JSON web service action associated with path /dlapp/add-file-entry". I am using liferay 6.2.4 ga5.
Thanks
<html>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script>
$( document ).ready(function() {
$("#submit").click(function(e) {
e.preventDefault();
var formData = new FormData($(this)[0]);
$.ajax({
url: 'http://localhost:8080/api/jsonws/dlapp/add-file-entry?repositoryId=27058&folderId=34530&sourceFileName=Screenshot&mimeType=image/png&title=hello&description=test&changeLog=not',
type: 'POST',
data: formData,
async: false,
cache: false,
contentType: false,
enctype: 'multipart/form-data',
processData: false,
success: function (response) {
alert(response);
}
});
});
});
</script>
<form>
<input type="file" name="file"/>
<input type="button" value="submit" id="submit"/>
</form>
</html>
Liferay JIRA
You could be encountering LPS-31943. It was a known issue related to this resource action. Please use the patching tool to upgrade to the latest patch version. I see in the comments that users are stating this problem still persists despite the bug being closed in some versions of Chrome.
Error Message
This error message is most commonly seen when you are missing required data from the request. Assuming you are fully patched, it is very likely that your data object is not correct. Even though you are sending the data as query parameters (which could be an issue depending on your JSON WS properties), the data object is still wrong and is therefore giving you the error message.
The HTTP Request
Firstly, Is there a particular reason you are calling the service this way? I believe you can achieve a better result using only HTML
<form action="http://localhost:8080/api/jsonws/dlapp/add-file-entry" method="POST" enctype="multipart/form-data">
<input type="hidden" name="repositoryId" value="27058"/>
<input type="hidden" name="folderId" value="34530"/>
<input type="hidden" name="title" value="hello"/>
<input type="hidden" name="description" value="test"/>
<input type="hidden" name="changeLog" value="not"/>
<input type="file" name="file"/>
<input type="submit" value="addFileEntry(file)">Submit</input>
</form>
This code is taken from the official Liferay knowledge base and adapted for your specific example. If you insist on using jQuery you need to stringify your data object. I would do something like this.
<html>
<head></head>
<body>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script>
$( document ).ready(function() {
$("#submit").click(function(e) {
e.preventDefault();
var formData = JSON.stringify($("form:first").serializeArray());
$.ajax({
url: 'http://localhost:8080/api/jsonws/dlapp/add-file-entry',
type: 'POST',
data: formData,
async: false,
cache: false,
contentType: false,
enctype: 'multipart/form-data',
processData: false,
success: function (response) {
alert(response);
}
});
});
});
</script>
<form>
<input type="hidden" name="repositoryId" value="27058"/>
<input type="hidden" name="folderId" value="34530"/>
<input type="hidden" name="title" value="hello"/>
<input type="hidden" name="description" value="test"/>
<input type="hidden" name="changeLog" value="not"/>
<input type="file" name="file"/>
<input type="button" value="submit" id="submit"/>
</form>
</body>
</html>
Best Practice
The sample's above are fine if you are invoking this service from an external application. If, however, you are invoking this from inside the portal (a JavaScript portlet for example) I would definitely utilize Liferay's JavaScript API and the AlloyUI tag libraries.
Liferay.Service(
'/dlapp/add-file-entry',
{
repositoryId: 12345,
folderId: 2345,
sourceFileName: 'Screenshoot',
mimeType: '',
title: '',
description: '',
changeLog: '',
cmd: {"/dlapp/add-file-entry":{}},
file: null
},
function(obj) {
console.log(obj);
}
);
Also if you are building something new you be using Liferay 7 or DXP as it is much more current.
i have made this simple app with gmaps.js but i need the search functions like they show it here:
http://hpneo.github.io/gmaps/examples/geocoding.html
i looked at the source code and all but it aint working.. The search button reloads the page...
my code is a follows:
<script>
$('#geocoding_form').submit(function(e){
e.preventDefault();
GMaps.geocode({
address: $('#address').val().trim(),
callback: function(results, status){
if(status=='OK'){
var latlng = results[0].geometry.location;
map.setCenter(latlng.lat(), latlng.lng());
}
}
});
});
</script>
<form method="post" id="geocoding_form">
<label for="address">Address:</label>
<div class="input">
<input type="text" id="address" name="address" />
<input type="submit" class="btn" value="Search" />
</div>
</form>
<div id="map"></div>
the rest is loaded in from scripts.js you can see it in sourcecode. Why is this happening and how can i fix this?
The web app is located here, http://travelers.work/trein/
You need to change
map.setCenter(latlng.lat(), latlng.lng());
to
map.setCenter(latlng);
because the search returns a LatLng object as a result, and that's what is needed as an input for setCenter.
Here's a JS demo with your code: http://jsfiddle.net/DuRhR/3/
EDIT after comments:
Alternatively, you can pass to setCenter a LatLngLiteral
map.setCenter({lat: latlng.lat(), lng: latlng.lng()});
To put this briefly I am testing a Google drive form that will record votes for a school election to ensure that it is secure.
Is there a way to open a form from the shared URL and list/input data? In short, can I write a script to act like a bot that will vote and try to crash the form?
Sample URL: http://docs.google.com/forms/d/RANDOM_STRING/viewform
Edit: Some time around the end of 2014 a change in the Google Forms service invalidated this hack. Look at Is it possible to 'prefill' a google form using data from a google spreadsheet? and How to prefill Google form checkboxes? for a solution that relies on the Form methods.
A Google Form, when shown as a "live form", is just an HTML Form, with all the regular behaviors of a form. You can view the HTML source of a live form, and get the information that will help you simulate POST requests.
HTML Form
For example, look at the form from Spreadsheet Email Trigger. Here is the form HTML, cleaned up for readability:
<form action="https://docs.google.com/spreadsheet/formResponse?formkey=#FORMKEY#&ifq"
method="POST" id="ss-form">
<br>
<label class="ss-q-title" for="entry_0">First Name
<span class="ss-required-asterisk">*</span>
</label>
<label class="ss-q-help" for="entry_0"></label>
<input type="text" name="entry.0.single" value="" class="ss-q-short" id="entry_0">
<br>
<label class="ss-q-title" for="entry_1">No of User
<span class="ss-required-asterisk">*</span>
</label>
<label class="ss-q-help" for="entry_1"></label>
<select name="entry.1.single" id="entry_1">
<option value="5">5</option>
<option value="10">10</option>
<option value="20">20</option>
<option value="30">30</option>
</select>
<br>
<label class="ss-q-title" for="entry_2">Email ID
<span class="ss-required-asterisk">*</span>
</label>
<label class="ss-q-help" for="entry_2"></label>
<input type="text" name="entry.2.single" value="" class="ss-q-short" id="entry_2">
<br>
<input type="hidden" name="pageNumber" value="0">
<input type="hidden" name="backupCache" value="">
<input type="submit" name="submit" value="Submit">
<div class="password-warning">Never submit passwords through Google Forms.</div>
</form>
Important elements are marked in this screenshot:
Script to simulate a Google Form submission
Armed with the action URL and field names, we can code a function to programmatically submit a form, by modifying the example from the UrlFetch documentation:
// Simulate POST to form
function sendHttpPost() {
// Copy the entire URL from <form action>
var formAction = "https://docs.google.com/spreadsheet/formResponse?formkey=#FORMKEY#&ifq";
var payload = {
"entry.0.single": "Nelson", // First Name
"entry.1.single": "10", // No of users
"entry.2.single": "user#example.com" // Email ID
};
// Because payload is a JavaScript object, it will be interpreted as
// an HTML form. (We do not need to specify contentType; it will
// automatically default to either 'application/x-www-form-urlencoded'
// or 'multipart/form-data')
var options = {
"method": "post",
"payload": payload
};
var response = UrlFetchApp.fetch(formAction, options);
}
Result
Here's the result of the above script, a form response has been added to the spreadsheet.
I am trying to figure out how to write an oAuth/Twitter signin feature with Cucumber/Capybara. Part of it, consists in visiting the page: http://www.twitter.com/sessions/new and filling in the username, the password and then clicking on the 'Sign in' button. That last step is not working as expected, the html code for that page looks like this (located in french):
<fieldset class="textbox">
<label class="username">
<span>Nom d'utilisateur ou e-mail</span>
<input type="text" value="" name="session[username_or_email]" autocomplete="on" />
</label>
<label class="password">
<span>Mot de passe</span>
<input type="password" value="" name="session[password]" />
</label>
</fieldset>
<fieldset class="subchck">
<button type="submit" class="submit button">Se connecter</button>
I have a defined the step like this in web.steps (note that I am not using the default capybara driver but capybara-mechanize):
Given /^I sign in$/ do
visit 'http://twitter.com/sessions/new'
fill_in "Username or email", :with => 'xxx'
fill_in "Password", :with => 'xxx'
find(:xpath, 'button[#class="submit button"]')
....
end
The find(:xpath,..) line is not working properly. I tried to put a '/s' (regex for space character) but I still get this error message:
Unable to find '//button[#class="submit\sbutton"]' (Capybara::ElementNotFound)
I also tried:
xpath_for("submit button")
But I get a stack level too deep error!
I am not really confident with my regex/xpath element finding skills so please tell me what is wrong with my code and how I could find that button?
Thanks so much for helping me!
[EDIT]
Turns out the default selector is :css. I changed it to :xpath:
Capybara.default_selector = :xpath
But it still doesn't solve my problem.
What if you try
click_on "Se connecter"
EDIT: Trying in nokogiri (cause capybara uses nokogiri) it doesn't work for me when I use your HTML as is (meaning it doesn't even see the element in the document). But when I enclose everything in a single root node, it works.. don't know if there's an issue with your page HTML or something.. with a well formed page, it "should" work. not sure how much this helps
<html>
<fieldset class="textbox">
<label class="username">
<span>Nom d'utilisateur ou e-mail</span>
<input type="text" value="" name="session[username_or_email]" autocomplete="on" />
</label>
<label class="password">
<span>Mot de passe</span>
<input type="password" value="" name="session[password]" />
</label>
</fieldset>
<fieldset class="subchck">
<button type="submit" class="submit button">Se connecter</button>
</html>
with this HTML, I can just use the xpath
xpath('//button')
Instead:
find(:xpath, 'button[#class="submit button"]')
you should have:
find('button.submit.button')
Above is css, since it's default selector.
If you want solution with XPath look at https://stackoverflow.com/a/11752824/507018, but it's uglier.
If you have the exact match to class of button <button class="submit button">, you can try just the following:
find(:xpath, '//button[#class="submit button"]')
Make sure that you didn't forget the double slash in the beginning of the search string.