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

Saving as HTML Locally #1207

Open
jinshang opened this issue Jun 16, 2014 · 0 comments
Open

Saving as HTML Locally #1207

jinshang opened this issue Jun 16, 2014 · 0 comments
Labels

Comments

@jinshang
Copy link

I did a search and you guys did a great job in guiding us on how to save the file to the server side. How if let say I just want to have a pure HTML file which is editable? I want it to be like a document which I can edit and open on the browser which means I can tell the browser to save / replace the current HTML.

I found a script which allows me to save a text in a form, but is there any script which allows me to save the page from the browser after I edit it?

HTML:

Script:

 Ext.onReady(function(){ 
 var editor = new Ext.form.container-fluid({id:'note'}); 
 editor.applyTo('note'); 
 }) 

 var contentHtml; 

 function savePage (){ 
 //alert("Hello World!"); 
 var content; 
 // iterate all dom elements which have been made aloha editable 
 jQuery.each(GENTICS.Aloha.editables,function (index, editable) { 
 // and get their clean and valid html5 content, and remember it to fake saving 
 content = content + "Editable ID: " + editable.getId() +"\nHTML code: " + editable.getContents() + "\n\n"; 
 publishContent(editable.getContents()); 
 contentHtml = editable.getContents(); 
 editable.disable(); 
 this.obj.deactivateEditable(); 

 // set scope for floating menu 
 this.obj.FloatingMenu.setScope('GENTICS.Aloha.empty'); 

 //this.activeEditable = null; 
 //alert(contentHtml); 
 }); 
 // this fakes the saving of the content to your backend. 
 // TODO implement this to save the edited aloha content into your backend 
 //alert("Hello World!123"); 
 //alert(""+content); 

 }; 

 /// method publishes this content to the url '/TestEditor/saveContent', which directs the request to a servlet to process it ( servlet further can store the content in database and retrieve back for the publishing) 

 function publishContent(content) { 
 //alert('this is publish content-'+content); 
 //alert('checkUserName'); 
 url = '/TestEditor/saveContent'; 
 if (window.XMLHttpRequest) { 
 // alert('this is window.XMLHttpRequest-'+document.myform.container-fluid.value); 
 // obtain new object 
 obj = new XMLHttpRequest(); 
 // callback function 
 obj.onreadystatechange = processChange; 
 // this will perform a GET with the url 
 obj.open("POST", url, true); 

 obj.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); 
 if (content != null){ 
 // alert('content available now'+content); 
 obj.send('container-fluid='+content); 

 } else 
 obj.send('container-fluid='+document.myform.container-fluid.value); 
 // IE/Windows ActiveX object 
 } else if (window.ActiveXObject) { 
 obj = new ActiveXObject("Microsoft.XMLHTTP"); 
 if (obj) { 
 obj.onreadystatechange = processChange; 
 obj.open("POST", url, true); 
 // don't send null for ActiveX 
 obj.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); 
 obj.send('container-fluid='+document.myform.container-fluid.value); 
 } 
 } else { 
 alert("Your browser does not support AJAX"); 
 } 

 } 

 // just after it publish, I force editor to deactivate, which it require to press Edit button for user to again start editing 

 function activateEditable(){ 
 //alert('activateEditable'); 
 jQuery.each(GENTICS.Aloha.editables,function (index, editable) { 
 //alert('enabling'); 
 //editable.activate(); 
 editable.enable(); 
 }); 
 }; 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants