Javascript Nesting Quotes not clear - nested

What will be the Nesting Quotes for this
"javascript:window.open('http://localhost:9000/index.html#/mypage/detailspage\',
'details-page','width=300,height=250');"
I tried this not working
"javascript:window.open(\'http://localhost:9000/index.html#/mypage/detailspage\',
\'details-page\',\'width=300,height=250\');"

var y="javascript:window.open('http://localhost:9000/index.html#/mypage/detailspage\' ,\'details-page\',\'width=300,height=250\'')";
alert(y);
This works fine in browser i guess.

Thanks guys for the reply but it is now working for me. Actually my requirement is that from my app I am passing the value as a post request to another app in that app I am not able to see my code as I am sending it. Below is the example
<input type="hidden" name="value11" id="value11" ng-model="indexedArray[34]" value="javascript:window.open('http://localhost:9000/index.html#/abc/details-page\' ,\'details-page\',\'width=300,height=250\'');" autocomplete="off" class="ng-pristine ng-untouched ng-valid ng-empty">
In response I am getting this

Related

How to delete an NDB object from a Google Database using its key, not even compiling

I am new to Python, using currently versión 3.8. I uploaded a basic Project into the Google Cloud platform. Unfortunately and despite trying all answers here, using urlsafe and reconstructing strings as a way to identify my object, the Google cloud either does not compile the code or once executed gives me errors I cannot trace because all are "proven solutions"
I created an object inherited from NDB
from google.cloud import ndb
class Contact(ndb.Model):
name = ndb.StringProperty()
phone = ndb.StringProperty()
email = ndb.StringProperty()
In my deletion form, I refer to its "id" using this call
<form action="/delete" method="post">
<input type="hidden" name="uid" value="{{ contact.key.id() }}">
<button type="submit">Eliminar</button>
</form>
in my main program, the delete function (method) I use this:
#app.route(r'/delete', methods=['POST'])
def delete_contact():
client = ndb.Client()
with client.context():
contact = Contact.get_by_id(int(request.form.get('uid')))
contact.key.delete()
return render_template('contact.html')
This is the original code and it is supposed to work. I check the documentation and tried other alternatives that compile but give me execution errors such as the urlsafe. It compiles but does not work even when I get the key in my handler.
The line that does not compile is "contact.key.delete()". The contact is indeed retreived but somehow the method to delete it does not work.
Any ideas? I am new to Python, so I will prefer a solution rather than an explanation, thanks.
Carlos
Even though nobody answered me, I finally got it fixed despite the errors. I had a serialization error, a defname error in that method (I had to separate def from the name of the method itself), an ahref error fixed by writing "a href", an indentation error and an invalid method error. Since I was uploading everything into the Google Cloud, it suddenly started working by itself!

How can I find an element without an ID in HTML for VBA code?

The aim is to write login and password to a website through VBA code. I stucked on lines without id.
Below is the part of HTML from a website, after pointing out on interesting box/window, where login show up (after we writing it on our keyboard):
<input propdescname="login" width="0" class="prePopulatedCredentials"
type="text" size="30" maxLength="127" jQuery15206231273379102914="6"
autocomplete="off" spellcheck="false" autofocus="true"/>
When I try to find a box/window to put this login from VBA level – there is a problem, because there is no ID.
I tried with Atribute “Name” but it failed IE.Document.getElementByName("login").innerHTML = "name"- occurs Run Time Error 438, Object doesn’t support this property or method.
The same issue is with window/box password.
Its code line is below:
<input propdescname="passwd" width="0" class="prePopulatedCredentials"
type="password" size="30" maxLength="127" autocomplete="off"
spellcheck="false"/>
There is no problem with button Log on, because it has an id:
<input class="custombutton login_page" id="Log_On" type="submit"
jQuery15206231273379102914="9" value="Log On"/>
IE.Document.getElementById("Log_on").Click
I have IE8. I read that when I install IE11 there are more possibilities. But maybe someone can help me to find solution in IE8?
Can you give this a try to see if that works for you?
Dim UserName As Object
Dim PW As Object
Set UserName = IE.document.getElementsByClassName("prePopulatedCredentials")(0)
UserName.Value = "Your User Name"
Set PW = IE.document.getElementsByClassName("prePopulatedCredentials")(1)
PW.Value = "Your Password"
thank you for your answers. I am filled with grateful!
But in the meantime I found a line, which works! And it is:
IE.Document.forms(0).all("login").Value = "my login"
IE.Document.forms(0).all("passwd").Value = "password"
I try to follow this video below (guy is amazing :)), but commend regarding login / password didn't work for me.
https://www.youtube.com/watch?v=0vwb_OaT2e0

Send a POST XMLHttpRequest with a body to an express node server

Basic background:
I have an express node server running a really simple website. The first page of the site has two inputs (1 text, 1 number)
<input type="text" name="xml_url" id="xml_in" placeholder="Required" />
<input type="number" min="0" name="c2" id="c2_in" placeholder="Required" />
As of right now really simple, the user inputs a url and a number, my app builds something and returns a link to a file.
My node server (basically) looks like this:
app.post('/secondPage', function(req, res){
var url = req.body.xml_url
, c2 = req.body.c2;
//some stuff happens etc...
res.render('finalpage.html', {
foo: c2andsomething
url: newurl
});
My Question/Issue:
I want to be able to not use my front end. I believe the code will basically work (besides the render, I believe I will need something along the lines of
res.send(aJsonResponse); // obviously I will need to build the json
I just don't know how I can fake this post request. I'm sort of drawing a blank here. So far I've only really tried a few websites that claim they'll send a post request etc.. and tried in the browser just typing in my url with a query string, but my app doesn't accept GET..
Hopefully this wasn't too much rambling, but I would love to hear some suggestions. Will remove if this question makes no sense.
EDIT:
Okay so I always seem to jump the gun with these questions. I just tried in the console:
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("POST", "http://192.168.1.1:3000/secondPage", true);
xmlhttp.send("foobar");
And I'm getting a CORS error.. I think I'll be able to figure this out here shortly, if you have any suggestions I would still really love to hear them.
Thanks
EDIT 2:
So I'm able to send the request and such no CORS issues.. but I'm not sure how to set the body in the request.
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("POST", "http://192.168.1.1:3000/secondPage", true);
xmlhttp.send({"xml_in":"I-thought-this-was-the-body"});
but req.body is {}
Well I solved my issue using cURL, so not the best answer but here was what I used
curl -d "xml_in=http://google.com&c2=12345" http://192.168.1.1:3000/secondPage

fixed urls on polymer

I'm working with polymer and I'm testing all in my local environment and all is working as expected, but the problem is when I'll move it into production, where the url shouldn't be the same as in my local. In node.js I can set it via the config.json file and catch it with app.get('config') or something like that, but in polymer I cant get it, and the only chance I have is to create another endpoint with all the config.json config file, but, and here is the best part, I should hardcode this url in polymer!! (so annoying). There is some way or library or component or something that I'm missing ?
Thanks in advance guys! StackOverflow and the users helped my a lot!
UPDATE
The thing is that I'm using custom elements (because I had handlebars too and there is a little problem with the {{}}) so, in the custom elements that I created I have this (for example in the core-ajax call):
<core-ajax id="login" auto="false" method="POST" contentType="application/json" url="/app/middle/login" ....></core-ajax>
as you can see the url is a little bit hardcoded, I want to use something like this (this is what I have on the node.js endpoint application):
router.post(endpoint.login, function (req, res) {
and I want to got something like that over polymer
<core-ajax id="login" auto="false" method="POST" contentType="application/json" url="{{login}}" ... ></core-ajax>
<script>
Polymer('log-form', {
login: endpoint.login,
ready: function () {
....
})
});
</script>
I'ts more clear now? I'm not so strong on english language.
Thanks Guys, for all!

Haskell how to parse file uploads/multipart form data using Hack?

I'm creating a simple Hack2 app, and I can read body data with:
directory :: Application
directory env = do
body <- input_bytestring env
...
I'm trying to switch my form to use file uploads
<form action="/directory" method="POST" enctype='multipart/form-data'>
<div><input type="file" name="data"></div>
<div><input type="submit"></div>
</form>
But it's giving me a ShortWriteException. Maybe input_bytestring can't handle multipart. Is there a library that can handle multipart form data? Any examples of doing this with Hack2?
I never did figure this out. I switched to Happstack-lite, because I couldn't figure this out, and it seems like nobody is using Hack2.

Resources