Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import_view() - getting VE.Top is not defined error #393

Closed
mesurinna opened this issue May 15, 2018 · 5 comments
Closed

import_view() - getting VE.Top is not defined error #393

mesurinna opened this issue May 15, 2018 · 5 comments

Comments

@mesurinna
Copy link

mesurinna commented May 15, 2018

Expected behavior

On window.beforeUnload i save all data in the SessionStorage with export_view(). If i import then on page reload all data is shown correctly with the import_view() method. But when i want to use the terminal i am getting an JS Error VE.Top is not defined?

what did i missed?

This is my Code where i initialize the terminal:

`

   $('.terminal_demo').terminal(

        function(command) {
            if (command !== '') {
				$(".cmdInput").val(command);
				$(".cmdInput").change();
				this.pause();    				
            }
        }, {
            greetings: 'Terminal Emulator Demo',
            import_history: true,
            name: 'js_demo',	        
            prompt: '> '
	    }
    );

    if (sessionStorage.getItem(rootFormName + " ." + str_class[0]) != null) {
    var restoreData = JSON.parse(sessionStorage.getItem(rootFormName + " ." + str_class[0]));
    $('.terminal_demo').terminal().import_view(restoreData);
}   

`

@jcubic
Copy link
Owner

jcubic commented May 15, 2018

The problem is that export_view data is not suitable to JSON.stringify because it have interpreter Stack Structure with functions, so if you export view with nested interpreter you will get the same interpreter.

I can make it ignore interpreters if it's not Stack object.

@jcubic
Copy link
Owner

jcubic commented May 15, 2018

Also lines have finalize functions but they will just be ignored by JSON.stringify

@mesurinna
Copy link
Author

Saving data without JSON.stingify in sessionStorage and wihtout JSON.parse to read is resulting in another JS Error Ae.Push is not a function.

How can i save these data and reload them on a page refresh?

@mesurinna
Copy link
Author

can i just echo out the data exported by export_view()? Just want to reload just all stuff happened before.

@jcubic
Copy link
Owner

jcubic commented May 15, 2018

In devel branch you now can restore view from JSON but you will not get restored:

  • if you echo function (like default greetings)
  • if you echo with finalize (you will not have some data on your commands like a11y attributes or command class)
  • stack of interpreters (if you call push it will not be restored)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants