JS alert for particular location href/pathnames - javascript

Hi :) I'm a bit new to Javascript and Jquery in general, so I apologize if the question may seem confusing and whatnot.
I'm running a roleplaying forum (on the Jcink forum host), and I wanted some parts of the forum (which are technically "Out-of-Bounds" locations for members' characters, i.e., dangerous places in-character-wise) to display alerts whenever members access that particular part of the site.
I have tried to use
if(location.pathname == "[pathname here]") {
alert("[message]");
}
in order to achieve this, although it does not seem to be working. Can anybody help me? :) Much thanks in advance!

Related

Here API findpickups example doesn't work

We are trying to use the findpickup api to find the best route for several waypoints. Despite the fact that we trying to understand how the pickup and drop params exactly work we were not able to get a successfully response from the example at
https://developer.here.com/documentation/routing-waypoints/dev_guide/topics/example-pickup.html
https://wse.ls.hereapi.com/2/findpickups.json?mode=fastest;car;traffic:disabled&start=waypoint0;50.115620,8.631210;pickup:GRAPEFRUITS,value:1000&departure=2016-10-14T07:30:00+02:00&vehicleCost=0.29&driverCost=20&maxDetour=60&restTimes=disabled&end=waypoint7;50.132540,8.649280&destination0=waypoint1;50.118578,8.636551;drop:APPLES,value:30&destination1=waypoint2;50.122540,8.631070;pickup:BANANAS&destination2=waypoint3;50.128920,8.629830;drop:BANANAS,value:30&destination3=waypoint4;50.118654,8.619956;pickup:APPLES&destination4=waypoint5;50.123998,8.640626;drop:PEACHES,value:50&destination5=waypoint6;50.130299,8.613031;pickup:PEACHES&apiKey={YOUR_API_KEY}
It is always complaining not finding a match for a street.
After finding a similar question on stackoverflow describing this problem
Here Map findpickups Cannot match onto a road link with 1000.0m search radius
we switched to the alternative domain. But now the entire pickup/drop thing confused us even more after reading the error message that drop-off point is missing.
Regardless where we are changing params for pickup/drop it stills complains that a contraint for pickup is not fullfilled.
Would be awesome if someone has any idea what is going wrong with the example from the HERE Docs.
And more importantly if someone can explain how the pickup/drop implementation actually works.
#HERE developer support
Thanks a lot for your reply.
My new additional notes would be too long as a comment. So I edited my questions with further information for describing the actually problem we have.
Obviously makes sense that GRAPEFRUIT has to be removed in a pickup waypoint. We already tried that. Sorry that we didn't mentioned that.
The thing is that in our use case will drop or pickup multiple items on each waypoint.
According docs this must work.
https://developer.here.com/documentation/routing-waypoints/dev_guide/topics/api-reference-type-waypoint.html .
Unfortunately it doesn't work. See following request
https://fleet.ls.hereapi.com/2/findpickups.json?driverCost=20&mode=fastest;car&vehicleCost=0.20&start=wp1;50.41256,8.02943&destination1=wp2;50.0766,8.22699;pickup:item1&destination2=wp3;50.07735,8.22185;pickup:item2&destination3=wp4;50.06563,8.19155;drop:item1,value:100;drop:item2,value:100&end=wp5;50.41256,8.02943&apikey=YOUR_API_KEY
Would love to get some hints and a solution for our use case.
You would have to switch to the new domain https://fleet.ls.hereapi.com/2/findpickups.json and also change the departure time format as well as remove the pickup condition for the GRAPEFRUITS. The below request should work:
https://fleet.ls.hereapi.com/2/findpickups.json?mode=fastest;car;traffic:disabled&start=waypoint0;50.115620,8.631210&driverCost=20&maxDetour=60&restTimes=disabled&destination0=waypoint1;50.118578,8.636551;drop:APPLES,value:30&destination1=waypoint2;50.122540,8.631070;pickup:BANANAS&destination3=waypoint4;50.118654,8.619956;pickup:APPLES&destination4=waypoint5;50.123998,8.640626;drop:PEACHES,value:50&destination5=waypoint6;50.130299,8.613031;pickup:PEACHES&departure=2016-10-14T07:30:00&vehicleCost=0.29&end=waypoint7;50.132540,8.649280&destination2=waypoint3;50.18920,8.629830;drop:BANANAS,value:30&apikey=YOUR_API_KEY
We have reported the issue to API team, ask is to correct/simplify the example.

AJAX JQUERY PHP - Creating a viewpane for information

I've been really stumped on this issue for the past week and after countless hours of it not working, I am hoping someone more knowledgeable may be able to help! :)
I am creating a view pane which has a list of divs done one side holding a small bit of information such as a title and then once these have been clicked on more detailed information shows on the left. To do this have it linked up to a database which stores information ( for this it is record information).
The image attached shows an outline of what I am aiming for. There is also a screen grab of my database uploaded.
I have created the basic outline of it (albeit a rather ugly one for now! ) but I cannot get the information to show on the left hand side when it is clicked on.
The only error I have on the console is : Uncaught SyntaxError: Unexpected token <
On the connect_and_get page. I have already run the code through visual studio but didn't find any errors.
I would really appreciate any help.
Please see the code attached: https://bitbucket.org/snippets/AimeeH/je56K
Many many thanks in advance
Layout I'm aiming for
This is a syntax error
<?php
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script> is not valid php. Either exit the PHP (?>) or echo the line.
For anyone who might want to reference this, I did get it working in the end although I am not completely sure as to why ( I am still very new at this!) here's what I remember doing, I really hope it helps!!
I changed all the " marks into ' (turned all the quotes into singular ones) as I read that PHP can sometimes have issues with this.
I actually uploaded the code to an online server (I used C-Panel) instead of running it on my computer with a local server running. This also meant that I made a new database for c-panel as the data would now all be accessed through this.
I added the user name in front of the table name (as this was how cpanel recognised the table name)
These were the main changes I made, and then using the console on Google chrome I worked through all the errors that popped up. As now the error messages being given were clear and useful.
I hope this helps :)

XPages: How to fetch documents in view and read values?

I am a beginner with XPages, and I have looked at the TLCC Intro free training. I have also seen tutorials here. I have no experience with Lotus Notes, XPages or flat-structured databases. But, I do have some experience in JavaScript and good experience (IMO) in Java and Android.
I am facing the following problems.
1) I am trying to implement a very basic login mechanism.
Currently, I add users manually, based on a form. Now, I want to create a login page. I take a user and a password, and click on a button.
In the button, I want to read all documents associated with a view (that displays all usernames/passwords), compare with entered value, and if it exists check if the password fields match too.
Can someone please guide me in the correct direction? I can't figure out which functions to use. Also, should I be using Scope Variables? Is there a good document/tutorial regarding that?
I have tried the "view.getAllEntries()" method but it always returns null.
Am I approaching this correctly? Are there in-depth tutorials that can help me with this?
2) What is the method to debug SSJS? I am currently putting everything in a try/catch and printing the error there.
I apologize if this question has been asked elsewhere, I haven't really found anything regarding this. Please point me if there is this is a duplicate.
1.
Use view.getDocumentByKey(theUserName) to find a user document in your view. It returns the user document as NotesDocument or null if user is not in view. The view has to have a first sorted column with the usernamens.
2.
As of Notes Domino version 9 you can debug SSJS.

Sandboxed JavasScript function

I'm creating an extension for Chrome (Just noraml HTML/JS). I would like to make an advanced scripting mode for users.
In a form I'll put this:
function generateString(){
//EDITABLE PART
return val;
}
if somebody for example put window.location="", nothing should happen, or if somebody put myVar=55; (previously defined in my code), it shouldn't do anything either. The only thing that I want to access is the return value.
Is this possible somehow? Googled for it and found something about putting it into a iframe, but they could still do window.location="javascript:dosomehaxing()", right?
Thanks a lot!
Since nobody posted an answer in the answer section, I'll post my findings here:
From the thread that serg commented with, the question "Is It Possible to Sandbox JavaScript Running In the Browser?", JSandbox seems to be the best, lightweight option to me. Its syntax is quite simple, too.

Javascript - Add an error msg when xml is unavailable

I've built an iPhone app that's working great so far. I've had some great help here optimising the code, but wondered if I could please obtain some help to display an error msg when the following conditions are met.
When the xml file is unavailable
When one of the xml data fields is missing (eg. brisbane is currently not listed in the xml for function 1, but should be - http://www.arpansa.gov.au/uvindex/realtime/xml/uvvalues.xml)
My current code: http://pastebin.com/VgBmdXjd
At the moment I've got the error msg working when the xml data field is empty (not missing), which should be apparent in the code. Please let me know if it isn't.
Also, both functions are setup a little differently, which might affect the way the condition is formatted. If anyone is able to explain the differences, that would be great too.
Any help is sincerely appreciated.
Kind Regards,
Glen
You need to set up the ajax error event handler in jQuery. Good Example

Categories

Resources