How and where is the "Download Array as .json" action coded?

0 favourites
  • 3 posts
From the Asset Store
5 levels with simple coding Source-code (.c3p) + HTML5 Exported
  • Context:

    I am using Construct 2 as a mean to create an app for neuro-psychological testing. It's a precious tool for somebody not knowing how to program enough to write an app of this complexity, but it has one major flaw for my purpose, which is that it is cumbersome to store variables an retrieve their values in a file outside of the app for further analysis.

    I stumbled on the Array-> Json download function. It isn't perfect but it does the trick, at least on Desktop systems where the command opens a "Save as" Dialog and I can save a .json string as a textfile which i can then convert to CSV for further treatment.

    The issue:

    For many reasons beyond my will or control, my app is primarily designed to run on Ipads, not tablets in general, but Ipads. When I test my app on Ipad through Adobe phonegap, the "Download Link" Link is being shown and when i click the button designed to trigger the "Download Array as .json" action, it directly shows me the contents of the string on screen, in the app window.

    What I want is for it to open a dialog like on desktop asking me where to save the file.

    My first step was to ask our local IOS developer for advice. She said that if I could find the part of the code that contains the event, she could adapt it in order for the Ipad to open said Dialog instead of showing it in the window. While searching through the code files we couldn't locate any reference to the button or the array though (the code was NOT minified).

    My question is, in which file and under what format/language is the actual logic/event files/script stored during export (I used a cordova export function)? Is the code always automatically obfuscated or does it contain the names of strings and variables used in the construct editor? Where should I look for this?

    This is probably a question for the devs but someone might have had the same issue before and knows something about Construct's inner magic

    Thank you very much for your time! I will provide a mock .capx wit only the layout concerned by the download function if you think it would be useful, but the question is more general.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Search for "JSONDownload" and you'll find it. You wouldn't find it by searching for the button or array name as the events are stored as data to be parsed by the C2 engine and aren't mixed with the engine code.

    Looking at the code, it checks if the browser supports the 'download' attribute on the anchor tag (which Safari doesn't) and if not it just creates a link to the JSON data and tells the browser to open it. I think your best bet might by finding a way to use the Cordova File API: https://cordova.apache.org/docs/en/late ... index.html.

  • Hello ramones,

    Thank you very much for your answer!

    I will transmit your advice to our programmer and I'm sure we'll find a way around this.

    I'm still open for other suggestions about this issue!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)