How to get AS error log to local document using JS? - javascript

I have created an application, where I need to get error logs (if any) when web services fail. I'm planning to go ahead using ExternalInterface in Flex and using JavaScript. Does anyone have any experience with this?

You can log errors though the javascript console (viewable in Firebug, for example) with the following line of code:
ExternalInterface.call("console.log","Error: Error message goes here");

What do you plan to do once you pass data from Flash to JavaScript? Were you expecting JavaScript to create data in local files? Is that even possible?
I would recommend looking at Flash Shared Objects to store limited data locally. They are kind of like the Flash version of browser cookies. If you're using AIR then just create a local File and dump your relevant data in it.

Related

Google Tag Manager preview a.match is not a function

When trying to use GTM preview, I'm getting the follow error in the console, which is crashing our application. I've been asked by our Analytics team to resolve the problem, but i'm not too familiar with GTM, so i'm not sure if this is a problem caused by GTM itself, or whether the error is being generated by our frontend application.
Would anyone be able to point me in the direction of where I would need to start to debug this?
It is causing by GTM. From the error message, looks like it is coming from one of your html tag or custom javascript variable.
A quick way to check the problem:
Export the GTM container and download the json file.
Open the json file in text and search for .match.
You should see some code and debug for them. Most of the situation is we need to determine the variable is string or not then do the match function.

Using Azure's azcopy tool from within a javascript azure function

My setup is the following: I have 1 storage account with a container and I have another storage account with a different container. What I want to do is have a blob trigger activate whenever someone uploads a file to the first storage account, and have that blob be copied to the second storage account's container. azcopy works well with the command line, but I have not found a way to use it within an azure function. Any help is appreciated, thanks.
For NodeJS, you would just use Child Processes (or a wrapper like execa) to run executables but isn't something I would recommend you do. Also, when running on Azure, you will have to make sure azcopy is present and if you still need to go down this path, Custom Containers would be your best bet.
In the case of Azure Functions if the file just must be copied to a different container, you could just use the Blob Output Binding which would achieve this with almost no code.
For more complex scenarios where the output binding lacks, you could just use the Blob Storage NodeJS SDK directly in your code.

How to set and get values in local storage with .jar (in Drupal 7)?

I've been tasked to create a module that requires and me to set and get variables in local storage. I cannot use PHP's cookies. The example code I've been pointed to simply has the line:
Drupal.Jar.setItem('email', $('.user__email').val());
I'm guessing this sets a value, taken from the DOM, in local storage. But how do I then retrieve that value? I tried searching online but didn't come up with any documentation around .Jar or Drupal.Jar.
As a test, I tried adding the below to my .js file (guessing that getItem() would be used to retrieve the value:
Drupal.Jar.setItem('test', $('.some-div').val());
var testitem = Drupal.Jar.getItem('test');
console.log('testitem: ' + testitem);
But this returns nothing (no errors either).
Would anyone know what I can do to set and get a value with Jar?
There is no built-in Java .jar implementation in Drupal 7.
I'm guessing the example code is from a custom module's javascript using Drupal.Jar as a namespace.
If you have the full code (and the dependencies) perhaps you can modify it to your needs.
Or if you or going to create your javascript from scratch, you may wanna check out MDN documentation for Web Storage API.

Saving / Retriving all the fields value's of an HTML form into / from a local file using JavaScript

I have a typical HTML form, with some fields of various types on it.
What I'm trying to achieve is the following:
Once the form's input fields are filled out with values, a button to be able to save all the filled-out field/value pairs into a local file of some sort that allows me in a future ocassion to...
Automatically fill the very same HTML form by retriving the field/values pairs from said file instead of typing them manually.
Ideally this would have to be achived thru JavaScript, because the webpage that contains the HTML form is served by an embedded system where PHP or other server side scripting is not available.
Is it possible to achive this thru JavaScript (or any other browser-side effort method)? If so, how?
Many thanks.
EDIT: The target environment is a regular user in a regular PC/laptop using any one of the 4 major browsers. It's acceptable to have "Cookies enabled" and "latest browser version installed" as requisites, but external plugins/addins are not.
Later: NullUserException has achived something in this direction. He's been able to read from a local file using JavaScript:
Using a local file as a data source in JavaScript
I think, for your particular site you can store data in local storage. Only your application will be able to access to that data. Also you can encrypt it before storing.
You can refer
diveintohtml5.info/storage to start with.
Happy coding.
Pretty sure you won't be able to save a file locally and then pick it up again.
However there are obviously cookies but there, and this is only in a modern browser, is also LocalStorage that can hold quite a bit of data that can be retrieved by Javascript and jQuery.
This is probably the way I would go but it does depend on your browser version.
question is some what ambiguous please specify what you are trying to do.
i can't tell if you want to do something just for you if so:
https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/

How to locally fetch JSON without AJAX

I'm building a game using HTML5 Canvas and Javascript and I'm using JSON formatted tile maps for my levels. The tiles render correctly in FireFox, but when I use Chrome, the JSON fetching fails with a "Origin null is not allowed by Access-Control-Allow-Origin." I was using jQuery's $.ajax command and all my files are in one directory.
I would use this post's solution, but I can't use the web server solution.
Is there any other way to fetch JSON files to be parsed and read from? Something akin to loading an image just by giving the URL? Or is there some way to quickly convert my JSON files into globally available strings so I can parse it with JSON.parse()?
Why is the local web server not an option? Apache is free, can be installed on anything, and easy to use, IMO. Also, for Chrome specifically, look into --allow-file-access-from-files
But if nothing else works, maybe you could just add links to the files in script tags, and then append var SomeGlobalObject = ... to the top of each file. You might even be able to do this dynamically by using JS to append the script tag to head. But in the end, instead of using AJAX, you can just do JSON.parse(SomeGlobalObject)
In other words, load the files into the global namespace by adding script tags. Normally this would be considered bad practice, but used ONLY for testing, in the absence of any other options, it may work.
One option which may work for you in Chrome is to invoke the browser with the command line switch --allow-file-access-from-files. This question addresses the issue : Google Chrome --allow-file-access-from-files disabled for Chrome Beta 8
Another possibility is to fetch the JSON data as a script, setting a global variable to the JSON value

Categories