Local Javascript File with Google Hangout API without HTTPS - javascript

I am adding a google hangout api to my application, and am trying to keep the JS locally for development purposes.
The XML file is available publicly on a server (as required by google).
The only way I was able to get it to work right now is to point the XML file to my local server using an HTTPS protocol. Otherwise, I get an error in the JS browser console that the insecure JS code is blocked.
This is the snippet that asks for the local JS file:
<script src="//localhost:3000/hangouts.js"></script>
The Hangout documentation and example apps don't reference https in any way and make it seem like it should work out of the box with a local JS file, so hopefully this can serve as another point of reference.
It seems like a pain to have to run the local server with SSL in development mode, so I'm wondering if there is a way around this or a better way to handle it?

Take a look at the hangoutiframer. It's a tool that provides an interface to automatically generate an .xml file that wraps an HTML page, and allows you to host your html where ever you want during developmen.

Related

How to search the Local file system of Windows using Javascript?

Operating system : Windows 8.
Input-from : A text field from a html page .
Input-type: text.
Output : the file that was searched.
What I want : I want the user to enter some keywords and have JavaScript search the user's local files...
Is there any way? or A javascript Library?....
And how I can query the file system about the files using Javascript..in Windows..
EDIT::
Thanks everyone for the reply...
The way I get it is ,either I have to develop my own browser based in Java that has sufficient permissions.. or
I would have to implement a file crawler that indexes everything that sends that file to the a server , so that javascript can then access it through xmlhttp requests to the server ....
This was just a curiosity and I don't want to expose anyone's personal files on the Internet.
A fun project.. That all tinkered in my mind.
This is not possible from a web page because of the browser's security restrictions. You could access the local file system with Node.js or an Electron app, but I don't know if that would suit your use case
No. That's simply not possible and even if it is, it should not be used, as it would make one's local file system open to various threats because you are directly exposing your machine on the internet. That's sufficient enough reason for a webapp not to access one's local file system in any manner whatsoever.
P.S: If you really want it, There are a few third party libraries which use Sandboxed file systems. You can try that if you want.
I havent tried it personally, but found the below link via quick googling so i am not sure if its officially supported up until now.
https://www.html5rocks.com/en/tutorials/file/filesystem/
Use <input type="file">, which implements ability for user to select file from local filesystem.

Simulate XMLHttpRequest as from localhost or Remote Connection to a machine

I have a website hosted in ISS (can be other) that loads when it's called on localhost but not from extern :) like: http://:8081/Website.html.
The verification whether the website is called from localhost it's on the client in a js script that I can’t modify as it’s encrypted.
So I was thinking at two options:
Develop an ASP application that has a remote desktop connection to the machine that host the website (not some many example on how to).
Maybe configure the IIS configuration (didn't found how)
I'm out of ideas
Do you have any other solution or can you point on how can I do one of the above?
I have tried the WinForm solution from here: https://www.codeproject.com/kb/cs/remotedesktop_csharpnet.aspx and it doesn't work. And I prefer a website.
Updates:
The only working solution that I have for now is to configure a Remote Desktop Services (Web Access) as I hosted the application on Server 2008 R2. Then I only shared the browser that has the localhost page as default page
The javascript files are all minified and encrypted, meaning that if I search localhost as a word in all the files, nothing shows up. So fixing the client will be hard.
Is it possible to create a new Site Binding on IIS and access the site using the binding hostname? This requires your network DNS to register the hostname to the IP Address.
I assume you are dealing with encrypted(???) javascript that is hardcoded to display DOM only if it is loaded from localhost.
If by encrypted you mean minified you should still be able to find reference to "localhost" and modify javascript in minified version. If it is really encrypted by a wrapper of third party javascript library then I would suggest you to rewrite javascript. I mean how can there be any quality code in javascript code that is hardcoded to load only from localhost?
Fix the client and stop exploring other solutions like remote desktop connection. None of them are practical and sustainable solutions.
I think you need to use WebRTC, but it's supported for Chrome and Firefox. It allows two users to communicate directly, browser to browser using the RTCPeerConnection API.

Save Javascript or Replace Javascript File in Chrome Developer Tools

Is there a way to replace a .js file in the website sources with a file on my workstation, or make a modification to a .js file and refresh the website to see the changes?
I am developing client-side JavaScript code against a SharePoint website on a server. I cannot create a local version of the website, so I need to modify the script, save the file to the server, refresh, etc. I do not have direct access to the server, and saving a file in a SP doc library or web part takes a lot of time between edits.
I can make small modifications using the dev tools while breaking on certain lines and applying snippets, but I am hoping for a better way.
Thanks!
If you have access the server that's hosting the file you should be able to replace or modify the JS file. Alternately you can use local hosting tools to test your file and then upload it to the server once you've confirmed it's working.
If you explain what you level of access to your host is we can offer better suggestions.

Using javascript to move a file on a server

So I have this html page. Inside of it is a bit of javascript code that talks to a flash application.
During the flash application's lifecycle, it'll save a file to a place on the server using the javascript on the html page.
How can I use javascript to take the file I just saved and move it to a different location?
You cannot. Javascript works on a client and don't have an access to the server's filesystem.
You can only trigger a script on the server that does that.
As you said you have node js installed and running on the server,it is possible for you to move a file using the nodejs filesystem api: http://nodejs.org/api/fs.html#fs_fs_rename_oldpath_newpath_callback
For this to work you would need to monitor and detect when new files are saved in a certain folder, which should be possible using: http://nodejs.org/api/fs.html#fs_fs_watch_filename_options_listener
Happy coding!

Read local JSON file (no web-server) with JavaScript

It seems that this has been asked a number of times, but I would like to make sure there are still no other alternatives.
So what I need to do is:
Generate a .JSON file from .net (easy)
Read the local JSON file with JavaScript and produce an html page with useful graphs etc (using Raphaeljs).
Deliver the outcome (HTML + associated JavaScript) to the client.
I wouldn't mind installing a local Apache to read the JSON file easily but since I cannot ask the client to do this, I am looking for a way to read a local JSON file (on the filesystem, no web server) with JavaScript, so that I eventually provide the client with the HTML, .js and .json and he can see the associated graphs.
I 've been reading that FileReader class is an option but I want to have the flexibility to support these on a number of IE browsers (let say IE7 to IE10).
Any help on how to work round this would be much appreciated.
Web browsers are not able to read files from the file system due to security reasons. If I've understood correctly, you have a .NET application running on the local machine?
If this is the case, you can host a WCF service to serve the JSON from your application. WCF self-hosting is described on this MSDN page. You should be able to make AJAX requests from the browser to a server hosted within you application on localhost.
If you want to support older IE, you need to go into ActiveX Security setting hell. Look into var fso = new ActiveXObject("Scripting.FileSystemObject");
But if you are delivering the content and HTML files to the client, why don't you just add the JSON markup directly into the html document? Seems like the EASY solution.
You can't read file from local disk in browser (security restriction). But once you are going to deliver HTML + js and JSON (in zip?) you can read json like from regular web server. Just use relative links and if JSON will be in same folder where HTML and JS is located. Or you may put your JSON as a part of HTML you deliver to customer.
But if you are going to show a page (HTML and JS) on your site in web, you should better ask client to upload their JSON file, and than download it from server (in AJAX style).

Categories

Resources