I am trying to include a str.js and jit.js file in nev.html. Both are in same directories but it is giving me a reference error: flask file in flask/app1.py When I run it using flask, it gives this error: directory structure /flask/templates directory structure /flask str.js file nev.html Answer Keep css and …
Tag: javascript
Javascript to list all files in directory on the webserver
I know how to do this in server side languages but I was wondering if there is an easy way (as in no active X). Google searches only give me ways for javascript to list files from the user’s computer. How can I use javascript to list all files on the server. That is, if I have a folder /gallary
Parse string in javascript
How can I parse this string on a javascript, var string = “http://www.facebook.com/photo.php?fbid=322916384419110&set=a.265956512115091.68575.100001022542275&type=1”; I just want to get the “265956512115091” on the string. I somehow parse this string but, still not enough to ge…
Test if two lines intersect – JavaScript function
I’ve tried searching for a javascript function that will detect if two lines intersect each other. The function will take the x,y values of both the start end points for each line (we’ll call them line A and line B). Is to return true if they intersect, otherwise false. Example of the function. I&…
Transform JSON Object to another – Format It
I want to transform a JSON formatted output to another. How I can do this? Example: Old JSON New JSON which I want without braces only like this with bracket Answer You could just loop through the items and push them into a new object: example: https://jsfiddle.net/q2Jzb/1/ You are presumably passing these to…
How to get the current viewport of the map out of OpenLayers as geometry, bounding box or wkt?
I’m trying to find some hints where I should search for this topic but I’ve nothing found – and I spent many hours on this. I’m also trying to get the current coordinates out of the current displayed viewport from the OpenLayers map to add only these vectors that are in the current bou…
Convert slug variable to title text with javascript
I’m trying to do something that would be similar to turning a url slug-like variable into text that could be used for a title. So, I have a variable for example that is like this: I’d like to not use a regex to do this if possible somehow, but I don’t think there’s a way to do it witho…
Cross-domain connection in Socket.IO
Is it possible to use Socket.IO in a cross domain manner? If so, how? The possibility is mentioned around the web but no code examples are given anywhere. Answer Quoting the socket.io FAQ: Does Socket.IO support cross-domain connections? Absolutely, on every browser! As to how it does it: Native WebSockets ar…
DOM change event for Opera
So far I found how to do it in Chrome, the DOMSubtreeModified event: Is there a JavaScript/jQuery DOM change listener? Apparently it works in Firefox and IE 9 too. Do you know solutions for detecting DOM changes in other browsers such as Opera? And maybe older versions if IE, because I’m sure the event …
Calling ASP.NET MVC Action Methods from JavaScript
I have sample code like this: How can I write JavaScript code to call the controller action method? Answer Use jQuery ajax: http://api.jquery.com/jQuery.ajax/