Communication between RS422 serial device and Javascript - javascript

I've written a simple web page that uses Javascript to control a Quicktime plugin for movie playback. There's also some AJAX stuff using jquery to get info on the movies from an MSSQL database. The web page is served to the user from an Apache 2.0 server, this also hosts MSSQL. The end users will view the page in IE6 (unfortunately).
My problem is that the end users now want to use an RS422 jog/shuttle deck control to drive the movie timeline, in place of another jog/shuttle unit that relied on emulating keypresses which was easy for me to detect.
As I'm not a programmer I'm at a loss what to start looking at for a solution to receive the RS422 data and then send that to the Javascript to control the timeline. Is this something that a custom activeX bit of code could do? I've googled ActiveX with Javascript but it's unclear to me (as a novice) how the two work together, or whether this would be suitable at all.
If anyone could give me an overview of what to start researching that'd be much appreciated.
Many thanks.
Jon

JavaScript runs in a sandbox and has no access to the computer at all (for security reasons; you really don't want to make it any more simple for frauds to get at your credit card data).
ActiveX would work but it's a security risk, too. ActiveX is written in C++, no JavaScript there. You'll find information about that on the M$ Website. Note that ActiveX is usually disabled today because of said security risks. Depending how serious your client take security, the virus scanner might not allow to start an A/X control.
Another option would be to write small program which is installed on the client's computer that reads the serial port and send that to the web server where your JavaScript can query it. Okay, that's more than a bit convoluted but probably the least risky.
Or you write a program which transforms the serial codes into key presses (just create the event and post it to Windows). Again, you need C++ or maybe Python with the win32 package.
Your client must understand that this is something which sounds incredibly simple but you'll have to jump through a lot of hoops to make it work. A web browser is not a local application with full reign of the hardware (and it must never be).

Related

Any way to create an application with the local web page as an interface?

A few days ago I decided to make my own "interface" to make it easier to organize (and work with) some of my personal files. You know when a lot of related data, pictures and links are right in front of you and you can change them in a couple of clicks, this is very convenient.
I started by studying HTML, CSS and JS, because I thought that the changes made to the local page would be saved somewhere on my PC so I can just run Index.html and do whatever I want. But they didn't. Refreshing the page erased all changes.
Using browser localstorage does not suit me, because if I change the browser, the data will be lost. I wanted it to just open with Index.html and work fine even if I change my browser or move the site folder to another computer.
Then I decided to learn more about server-side languages (such as PHP or Node.js) because they are directly related to databases, so I was hoping to save changes through them. But these languages required me to really open the server, with ip and port tracking. And I just wanted to open a local page through one file, without any ports or connections via the console. So this method scared me off quickly.
So is there an easy way to make a local page like this? Maybe I have not studied well one of the above methods and it has this opportunity?
Or the best I can hope for is a simple application that will use that local page as an interface to interact with data? I accidentally heard about this possibility a long time ago. Then I will ask you to give at least a hint as to which language to choose for this.
I don't understand well everything that lies outside of vanilla HTML, CSS and JS, so a complete study of a complex language like Java or Python will be too difficult for me, and the goal is not worth such a lot of effort.
I hope I understand correcly what you are trying to do.
If your goal is to make an application to manage your files, I think the simplest solution will be, as you said, to look into NodeJS and the File system api which will let you interact with your files through javascript code.
Your program will have to be in two part that will have to interact:
the "front" html page
the "back" nodejs script
The downside is that you'll have to go deeper into your study of the language to learn how to create the interactions you want between your html file and your NodeJS application.
However, there is no need to open your server to the web to make it work. The NodeJS application can be set to listen to requests from only the computer that runs it (localhost).
I obviously can't get too much into details without knowing precisely what you want to do but you'll probably have to learn to make a local server with node (search "nodejs http" or "nodejs express"), then make requests to it via the html page's scripts (search "ajax request").
What you need to look into are (web based) content management systems. like strapi or "grand old dame" WordPress.

Run client side powershell script using javascript

I have a requirement from a customer to develop a Javascript application that allows users to pick a geographic location. Based off this selection they want to run a powershell script that resides locally on the desktop to run and change timezone and locale settings.
I have the map and ability to select the geographic location nailed down. I have tried use node-powershell and child_process to call the PS script but I don't think anything server side using NodeJS will work since it is all client side. I am struggling to find client side options that would work.
This is a bad idea. I recommend coding the whole thing in powershell. If you feel comfortable enough to violate the sacred sandbox there's an article about how you can use powershell to host javascript files and render them in a Internet Explorer here. It goes without saying that this is extremely insecure and if a competent tech lead or sysadmin catches you doing this, they will get really mad at you.
Javascript is designed to be used on the web, to tell a process living in a sandbox what to do under certain circumstances. It's recently been modified and re-purposed for node and other systems applications, but in my opinion it's still very weak and not a good substitute for systems programming yet.
Powershell is an extension of C#, and though there are some weaknesses, it carries almost as much power.
If I were undertaking a project, such as allowing remote users to change their time zone based on visuals, I would use the PictureBox Class to render a map of the world, and then attempt to translate the X,Y coordinates on the map to some sort of multi-dimensional array that translated those fields into timezones.
You could also put buttons on top of the map image, so that users press the button that corresponds to their location.

NodeJS + Tampermonkey can they work together?

I am creating software that helps me and my colleagues to work on tickets at work, as our current software is really bad. At this moment I am using program that I wrote in Tampermonkey, it is giving information about queue and all other fancy stuff. But I reached limit of that, as website is a limitation, so I started to create website that could do much more, yet I am not sure how to connect it as when I am using Tampermonkey to create overlay with all needed data. My idea was to: 1) Gather all data by tampermonkey and send it to nodejs server. Node would keep array (that's all I need) locally and then I would be able to access it.
Is this possible, is this a correct approach? Unfortunately I am limited by options that I can use by company security policy.

After Effects as backend movie engine?

I'm working right now on a project that could allow me to generate movies based on the user input. User will upload some samples (photos, movies) to the web app and web server should generate movie based on that input and some predefined movie compositions.
I know that there are plenty of libraries for ffmpeg that could let me connect movies, photos programmatically (for example https://github.com/schaermu/node-fluent-ffmpeg for node.js) , but I was wondering if it's possible to use Aftereffects for that purpose since I have some knowledge in that software. I imagine that there should be set of scripts in Aftereffects that could import user uploaded data, fire the movie renderer and save output to the given location.
Do you think this is achievable using Aftereffects? Or maybe someone had similar problem and solved that differently ?
Cheers!
I have done the exactly same thing.
I DO NOT suggest you use script to do it. I have made the same mistake. Script is fine for a small job, but when you try to use it on a web server and run constantly for days and days it's very unstable. You will be facing a lot of crashing.
I would suggest you use sdk to do the job. It's much more difficult to use sdk than using script, but is more stable and much faster! When you try to create a web service app, you want it to be stable and fast, don't you?
Yes, this is definitely possible. There are existing scripts for rendering and uploading via FTP, and the possibilities are pretty much endless. The part that jumps out at me as needing clarification is "scripts in Aftereffects that could import user uploaded data". This suggests a need for a back-end that "looks for" or "waits for" elements to "appear" in a directory to kick off the ExtendScript script in AE. This is where it gets slightly dicey in that you have to devise a way to do this with a "daemon" in your preferred operating system using any number of languages -- python, Java, AppleScript, shell, batch, etc. The rest of it ("import user uploaded data, fire the movie renderer and save output to the given location") could be done in ExtendScript.

How can I protect javascript assets in an Adobe AIR app?

I have a large javascript / HTML Adobe AIR app and am looking for a way to protect the javascript files that get packaged up in the installer and installed (in plain text) onto an end user's PC. I'm thinking maybe there's a good encryption scheme to use. I'd like it to be a solution that I can apply when I create the installer and (since the app is already pretty large) ideally I'd like it to be a solution that doesn't require me to change the location of the js files in my code base, though that's doable if necessary.
Someone recommended maybe embedded them in a Flash file, but then I'd need to extract them at runtime, etc. It seems like there's probably a simpler solution.
Important: I'm looking for more than just minimizing the js or obfuscating it, I'm looking, ideally, for a solution involving encryption, but am open to other suggestions.
Any ideas? I've done a lot of googling around for solutions and have tried a popular user's group, but no luck. I would think this would be relevant for pretty much anyone making an AIR app in js/HTML that isn't for an open source app.
Thanks!
What you want to achieve is inherently impossible, unless your end users are using a trusted computing platform, ie. a platform that can be trusted to not obey orders from its owner (sometimes called treacherous computing for that reason). It's not just hard or not solved yet, it's as impossible as perpetual motion machine and you will save yourself a lot of trouble if you accept that fact.
The problem is that any encryption that you use would eventually need to be deciphered on the client computer, so you have to distribute any key that is needed to decrypt your code together with the encrypted code which is completely pointless and would give you no security whatsoever. It's not even a matter of algorithms used, it's just the fact that you have to give the secret keys to everyone.
If I understand what you're trying to do, we have just recently tested that with our encryption/protection tool kit. The key is that the executable that is installed on the user's machine is encrypted, so the javascript is never in plain text. Decryption happens at runtime via symmetric key exchange. Keys are stored either in software or in a hardware device (dongle).
However, because you're using Air and not just c++ or something similar, there are some issues that may not be solvable by our toolset. You can PM me for more info if you need it. But I don't think it's necessarily impossible.

Categories