jSignature - generated value won't render - javascript

I'm using the latest jSignature (https://github.com/brinley/jSignature), generating base30 signatures and saving them in a mysql database. This usually works great; on this occasion, though, the user input a signature, it saved, but the signature won't render. Instead, a very non-descript javascript error appears in the dev tools. I have a jsfiddle of it up here:
https://jsfiddle.net/evilpluto/onh3z3k0/
To activate it, I just pull from a hidden form field like so
$(".signature_form").height("170px").jSignature("reset").jSignature("importData", 'data:'+ $(".hiddenSigDataForm").val());
It just seems like the base30 that was generated is corrupt in some way, but I'm not sure why it would generate the javascript error. In the jfiddle I put a working button (loads fine) and then the base30 string that errors as the "non-working" button.
Any ideas?

Uh, oops. The problem was not that jsignature magically couldn't render anymore. The problem was I stored the value in a varchar(255), and the base30 value was truncated to the point that it was unusable. My others worked because they were smaller.
Then I figured out that mysql now allows > 255 in varchars...this has been a very educational night.

Related

(Moodle) I keep getting raw data when exporting .xlsx file containing HighCharts Images

This issue has baffled me, mainly because it makes no sense. I have some custom PHP code that I wrote on top of my LMS system (Moodle) to display some of its collected data in a HighCharts Table. What makes no sense is that I can almost GUARANTEE the code isn't broken because I checked older working versions of it and the same problem occurs. I never ran an update on Moodle in a long time so no known changes could have affected this.
Here are some weird things I found while troubleshooting:
Only this report is giving this issue.
Whenever I move this ENTIRE code to another PHP with a different name the issue doesn't occur.
Some more important details:
Uses the online version of highcharts.js scripts
The scripts I'm using are:
"https://code.highcharts.com/highcharts.js"
"https://code.highcharts.com/highcharts-more.js"
"https://code.highcharts.com/modules/exporting.js"
"https://code.highcharts.com/modules/export-data.js"
"https://code.highcharts.com/modules/accessibility.js
Please let me know if you've seen this issue before and what step you took to fix it. Also, I can't share the website this issue is on because the content password locked within my Organization.
CLICK HERE FOR IMAGE: This is what happens when I click the export button. The URL changes to something long and then outputs this.

convert pdf with filled form fields to image

After much searching and experimenting, I cannot find a way to programmatically generate an image from a PDF file which contains filled form fields. More specifically, it's not that the libraries I've tried don't generate an image (they do!), but the filled form fields end up blank.
Can anyone point me to a library/solution that works? Ideally in python or javascript, but I'd take just about anything at this point. Ultimately, it needs to end up as an AWS Lambda function.
I'm going to keep trying, but so far PyMuPDF and ImageMagick (ghostscript) don't seem to work, unless there's some options to enable it that I'm missing.
pdf2image (pdftoppm) correctly handles filled form fields. I tested it using this example: https://stackoverflow.com/a/48583124/2009581

Difficulty sending values to input fields (sounds ridiculous)

EDITED: New information: When I inspect the field, and the code is highligted (in the inspector), then the statements all work as they should, but when the field isn't highlighted anymore, the statements do not appear to work. Hopefully this helps diagnose the issue.
I have a wufoo form (a hosted form that you can embedd, send to spefic email on submit etc). I have a field on that form that I am trying to populate with a certain piece of data once I click a button. I believe I have the correct code to make this happen, and it should work:
$('#my-button').click(function() {
$('#Field3').val("something");
});
I have tried many different ways:
$('input[id="Field3"]').val("something");
$('input[name="Field3"]').val("something");
and a few reaches which I didn't really think would work..
$('#Field3').append("something");
$('#Field3').text("something");
There are a few things that confuse me here, and I will post screens below showing what I mean. I can type all of these commands in the console once the page is loaded and nothing will happen to the field (with the id of Field3)...most of the time. But on several occasions, I would reload the page, try a few statements again, yes the same ones, and then it would work. No idea why or how, but it is sort of an intermittent thing. Obviously that's probably not the case, but I am pretty confused as to why this is happening;
Below are three screens of my console. For the first two, the field finally populated after about 10 or more tries in the console, and then continued to work while using commands that didn't work before. The last screen is an attempt that did not work at all:
[![Eventually Works After Last Command][1]][1]
[![Eventually Works After Last Command][2]][2]
[![Did Not Work][3]][3]
[1]: http://i.stack.imgur.com/JKVxY.jpg
[2]: http://i.stack.imgur.com/MLca8.jpg
[3]: http://i.stack.imgur.com/0viRA.jpg
(Apologies for the way I had to post these images, I keep getting formatting errors that will not let me continue to save the post unless I cmd+k them)
I try everything in the console first, but I can not find any patterns here. Any ideas or input would be greatly appreciated, and thank you for your time.
At this point I'm pretty sure the problem has to do with the form-code switching or adding certain classes under certain conditions, so I downloaded the code from my Wufoo account rather than embedding it. Then I only added the code for the view (not css or JS), and it works now.
My original statements (not the reachers) all work fine now when I try them. Thanks for the time everyone.
I know you solved your issue, but figured I'd chime in in case you or others have this issue again in the future. It sounds like your issue was related to execution order. Wufoo's embed scripts are asynchronous, so it's very likely that the input fields in question didn't yet exist on your page at the time your jQuery click handler was evaluated. Changing your original code to jQuery's "on" method instead of "click" would likely have solved your problem, as "on" provides a delegated event listener. At any rate, glad you got everything sorted out!
In the console I assume there is no jQuery loaded.
I usually write:
document.getElementById('Field3').value = "something";
Updated your Jsfiddle. The only thing I changes, I added the reference of the
Jquery. Might be that's the problem.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>

Selenium + PhantomJS in Python 2.7, file upload

I've been struggling with this function for a few hours now and I can't get it to work in any way shape or form.
Assume my element location and image path are correct at all times. (Seriously, I've been going over this for the past 4 hours, it's not the element location and it's not the file path.)
What I started with was a sendkeys to the input element. This gave no error but caused the script to hang for ever; it wouldn't get past it and no images were being uploaded.
I literally tried every single possible variation of the sendkeys method listed on the first 4 pages of Google when looking for "Python PhanthomJS Selenium upload file sendkeys". Back to the drawing board.
Currently I am looking into executing a bit of JavaScript through Python to upload the file, though I have no idea how to go about this.
The page which I am trying to upload to has its form set to hidden and only shows a button which opens an upload dialog on normal browsers. I feel this is why sendkeys was not working.
Can anyone give me some input or suggestions as what to try next? Or how to execute some JavaScript from Python?
EDIT:
I learned how to execute JavaScript while using selenium in python and it saved my day.
To anyone coming here from google or whatever with the same problem, let me explain what I did:
The fact that my .send_keys() was hanging when sending keys to the input[file=input] element had me wondering before I made the topic but since the webdriver was still able to find the element I wasn't thinking too much of it and shrugged it off as something random. Later however I came with a suggestion that because it had a css type display: hidden !important the webdriver might have been able to find it, but not interact with it, and for some reason selenium just decided to hang itself instead of crashing / giving an error.
With that in mind I started browsing the docs and found the .execute_script() command, turns out we can use this to run a piece of JavaScript through the webdriver. Why I wanted this, is to see if the class styling had anything to do with it at all, how you ask? Well we can use the following line of code to change the class attribute of the input[type=file] element: document.querySelector("input").className="". This is not the most elegant solution since we are basically deleting the entire class responsible for the display: hidden !important styling. If the class were to hold more important data I'd suggest changing the class instead of renaming it to "" or deleting.
Moving on and trying it out, it showed the input button just like I hoped it would! After this I simply re-tried sending the keys and found no problems at all. There is no need for a click, submit or anything. driver.find_element_by_css_selector('input[type=file]').send_keys('path/to/file') However I did note that the way you structure the path seems to be pretty important. For example I am testing on windows and path/to/file did not upload or select any image for me, using path\\to\\file however, worked completely fine.
tldr:
driver.execute_script('document.querySelector("input")').className=""
followed by:
driver.find_element_by_css_selector('input[type=file]').send_keys('path/to/file')
Is what worked for me, and if you are in any alike situation your
variation on the script should upload the image as intended.

When Injecting Javascript into a UIWebView from Settings I only get numbers?

OK here goes,
This one i find complicated to explain, but I have attached the project if you want to test it out what I am trying to say:-)
I have 1 app - 2 views.
1 UIWebView with a local html file with a form
1 ViewController with 2 buttons and 2 labels to interact with the view and then 2 labels that show the result when the buttons are pressed.
Now when I use the method stringByEvaluatingJavaScriptFromString and have set the content to import in the settings bundle I can only inject numbers, when I set letters in the settings app, they do not get injected. However when I inject it straight from the app there is no problem.
On the View Controller, I can retrieve both letters and numbers.
This would have me believe that the problem lies with the stringByEvaluatingJavaScriptFromString method.
Now I am not sure where the bug lies with this, because using that injection method and setting the letters or text in the ViewController works fine.
I need the webView, but when pulling content from the settings bundle it will only show the numbers in the textField. If you watch the console though, you will see that the letters and numbers are being recognized.
I am happy to give any additional details if I have left anything out.
Please if someone would be so kind to download the project and have a look, to see if what I am trying to say makes any sense, I would greatly appreciate that.
it is written with the 5.1 SDK
Kind Regards,
Jeff
Download Project
Ok, after pulling out all my hairs I have found the answer:
%#", field01];
I had the code above, but for some reason that only lets through numbers or maybe they are integers anyway, no letters are being let through, yet to a label they are.
so I compared a hardcoded string to a dynamic string that I require and noticed that they hard coded string had the value between ' & ' so I put the %# between those and it fixed the problem.
so '%#'", field01]; fixed it all:-)
Cheers

Categories

Resources