SurveyJS async onValueChanging handler - surveyjs

I'm trying to find a way to build a handler to validate the new value by capturing user input through a dialog. I guess it's not what onValueChanging expecting, as the handler wants options.value = options.oldValue insight its body, if I need to reject the change.
If I try to save options for later reassignment, it doesn't work. I wonder if anybody tried to do something similar, to make the handler asynchronous-like.
Thanks in advance

Related

Vue changing the component without URL changes

I'm in Registration.vue component. The component contains registration form with email, password, etc.. fields.
I would like to thanks user for successful registering (with instruction that he should go check email).
What is the best solution to do this?
I was thinking about:
redirecting to second component using this.$router.push or this.$router.replace but this will change URL and when somebody go this URL without registering he will see message that he should check email...
replacing current component with other when registering action successful but I dont know how to do this (without URL change, and with good code).
using <component v-bind:is="currentView"> but I am not sure if this is best solution. I need to make three files (for parent component with :is, for form and for thanks). Also i need to emit event from child that registration went well, but on the other hand i should fire vuex registration action and dont expect for response (see the next sequence)
The other thing is that we should not wait for the vuex action to be completed, but i need to know if registration went well - https://github.com/vuejs/vuex/issues/46#issuecomment-174539828
I am using vue.js 2, vue-router, vuex
Thanks
You could use something like Sweet Alert to display a success or error dialog. It supports Ajax requests so you can display a "your registration is processing, please check your email" message while it is being handled.
The first approach is suitable when user successfully registers and then redirected to login page.
Now issue how to check whether user has entered required field? So there comes form validations. You can use vee-validate plugin and it's perfect for all projects. I am using it and it has so many available validations.
With these UI validations, after they are passed successfully then only submit action will be fired or else user will be prompted for entering required field.
You can see basic example here - http://vee-validate.logaretm.com/index.html#basic-example
When action is performed,
///main.js
...
Vue.use(VeeValidate)
...
// register.vue
this.$validator.validateAll().then((result) => {
if (result) {
//done
this.$router.replace( '/login' );
}
else{
// throw error
}
Simple as that.
Try this approach if you want the UI validations on the form.

Auto login to website using script or bookmark

I've been trying to figure this out using various different methods. I'm trying to create a script/bookmark or some type of quick action to open a browser tab or window with a specific URL, and automatically log me in using my credentials. I'm not all that concerned about security for this at the moment.
At first I figured I'd try to use a javascript bookmark to do this, but nothing I found in my research worked. Next I tried to create a bash script, but I couldn't figure out how to send the credentials in via the terminal. Most recently, I literally copied the source code of a site, created a local file and tried to hack together something where I could prefill the form data with credentials and use JS to submit the form, and I've gotten close with this, but for some reason when I use the JS submit function, it errors out and says that the username and password are invalid. But when i turn off the submit function and manually click "log in" on my local html page, it works as expected. I want this to be a one click process, so the idea of using onload/submit or something to that affect is really important to me.
The site I'm testing with has a Rails backend and my next attempt might be trying to use POST to do what I'm thinking, but that's currently outside of my level of knowledge on the subject.
Anyone answering: i do not want to use a password manager to accomplish this.
My requirement is that i will either be able to a) run a script or b) use a 1-click option to do this per website. Ideally i'd be able to set this up in a sort of programmatic way to do this with multiple sites, but I'd be happy with 1 at the moment.
i know similar questions have been answered before, but I haven't been able to use information from those posts (the ones I've seen anyway) to figure out a good way to do this.
Create a bookmark for the current page you have opened.
Edit the bookmark
Change the value for the URL to something like this.
(javascript:(function(){CODE_GOES_HERE_FROM_BELLOW})();
find the field for username and password on the page.
Given example for hotmail
var inputs = document.getElementsByTagName('input'); for(var i=0;i<inputs.length;i++){if(inputs[i].name === 'passwd'){inputs[i].value = 'YOUR_PASSWORD'}else if(inputs[i].name === 'loginfmt'){inputs[i].value = 'YOUR_USERNAME'}}; document.getElementById(document.getElementsByTagName('form')[0].id).submit();
OR
try out casperjs.
The proposed solution didn't work for me and rather than spending tons of time installing a testing framework that I'll never use other than for this purpose, I decided to try to do this another way.
First, I found out that the reason my JS wasn't working before is because the site did not allow a JS submit to be done, or atleast that's what it seemed to be when I got this error: "Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience"
The javascript I was using was in fact working, just not submitting. I used the following code to fill the fields (using "Class Name" elements on the page since there was no name or ID):
document.getElementsByClassName('username')[0].setAttribute('value', 'user');
document.getElementsByClassName('password')[0].setAttribute('value', 'password');
As I mentioned, the problem was when I tried to use JQuery to submit the form: document.getElementsByClassName('loginForm')[0].submit();
Which is when the above error cropped up. I can't really say for sure whether this is the root of the cause, but the page does submit, but I get an invalid username/password error when I do
I haven't figured out a great way to get around this just yet, but my short-term, "hacky" solution was to use Applescript to send a return keystroke to the browser to submit the form. I'd ideally like to figure out how to get the submission to work using JQuery, but I'm not sure how to get around it.

MVC unobtrusive general message

Im working in a project where the validations messages with unobtrusive system works fine.
When any attribute is uncompleted or wrong the proper error messages appear, at client side ofc.
The problem is the following. I need to set an general error message at the top of the site (besides to each field validation message error). I know i can use #Html.ValidationSummary but i dont want the list of fields, what i need is one general message telling the user that there is something wrong with the form.
Regards.
Edit: On jquery before submit i'm doing $("#frmSubmit").valid();
Did you try using the ValidationSummary(bool) overload? Supplying true excludes property errors.
Why not just have check ModelState on your view like this:
#if (!ViewContext.ViewData.ModelState.IsValid)
{
<div>Your error message here...</div>
}
Then style your div to be errorish...

Where to put js code for polling tile notifications for windows8 js&html app

http://msdn.microsoft.com/en-us/library/windows/apps/hh761476.aspx
Those instructions are great, but where do I put the below code (grabbed from article above)? In my default.js file, above the app.addEventListener("activated", function (args) { line of code? Below that line? Elsewhere? Thanks Microsoft, but tell me where to put the code!
var notifications = Windows.UI.Notifications;
var recurrence = notifications.PeriodicUpdateRecurrence.hour;
var url = new Windows.Foundation.Uri("http://mytileprovider.com/tile.xml");
notifications.TileUpdateManager.createTileUpdaterForApplication().startPeriodicUpdate(url, recurrence);
Ideally this would just be a manifest setting with a dropdown of "Frequency" and an input box for the url to grab it from. That would be oh so helpful and convenient.
The answer is... it depends. :)
Where do you want to set up the tile and the polling? Is it an "always on" feature that is core to your application? If so, then put in inside the activated event for your default page (usually inside default.js). Or maybe you are adding tiles based on content that the user interacts with (i.e., selecting a stock to pin to the Start page). In that case, you would put that code inside the page that handles the user action that.
The simple answer is... inside the activated event. The real answer, as you can see, can be more involved.

Determing whether dijit.dialog content has displayed

Does anyone know of a way to determine whether the content of a dijit.dialog has become visible to the user? As in if the content of the dialog has actually been displayed yet or not.
Thanks
There's also an onShow event that you could connect to, or even set:
dijit.byId("dialog1").onShow = function(){console.log("hello world")};
The function onDownloadEnd() is called when the dialog's download finishes.
You could connect your own code to that event using dojo.connect().