Welcome, Guest
  • Author Topic: Text Editor HTML output  (Read 22960 times)

    triangle man

    • Server what's that
    • *
    • Posts: 5
      • View Profile
    Text Editor HTML output
    « on: 04/26/05, 07:32 »
    Hello good people,
    I have been playing around with GOVINDA SARKHEL's awesome text editor for a while now.  Really great work by the way.  And thank you Govinda :)

    I just have a few Q's about some of the string manipulations in the function htmlView().

    I have subtituted this part of the function:
    str = str.split("> <");
       tot = "";
       for (var i = 0; i<=str.length-1; i++) {
          if (i != str.length-1) {
             tot += str+">&nbsp;<";
          } else {
             tot += str;
          }
       }


    with this:
    str = str.split("&apos;");
       tot = "";
       for (var i = 0; i<=str.length-1; i++) {
          if (i != str.length-1) {
             //substitute problematic characters here
             tot += str+"'";
          } else {
             tot += str;
          }
       }


    in order to allow the submitted  text to be reloaded into Flash and still use the ( ' ) symbol.  Also that got rid of the previous and probimatic ">&nbsp;<".  Flash of course thinks it has hit a new variable in external text when it reads "&".

    question:  Is there any reason NOT to do this.  I have had no problems with it so far but as my wife will be using it for the site I've made her, I would like to avoid any unforseen disaster. ::)

    Thanks to anyone who might offer help.
    « Last Edit: 04/26/05, 07:34 by triangle man »

    triangle man

    • Server what's that
    • *
    • Posts: 5
      • View Profile
    Re: Text Editor HTML output
    « Reply #1 on: 04/26/05, 10:04 »
    well after I wrote that note I realized that I was maybe going about the whole problem wrong.  I actually went ahead and changed that function back to its original state.  And instead I put this in the php file that writes the text to the external file:

     $receivedFromFlashData = str_replace("&nbsp;", "", $receivedFromFlashData);
     $receivedFromFlashData = str_replace("&quot;", "\"", $receivedFromFlashData);
     $receivedFromFlashData = str_replace("&apos;", "'", $receivedFromFlashData);
     $receivedFromFlashData = str_replace("&amp;", "*", $receivedFromFlashData);
     $receivedFromFlashData = str_replace("&lt;", "*", $receivedFromFlashData);
     $receivedFromFlashData = str_replace("&gt;", "*", $receivedFromFlashData);
     $receivedFromFlashData = str_replace("+", "{plus}", $receivedFromFlashData);
    (how do you mark something as code)

    Again I am not sure that everything isn't going to blow up so I would still like to hear from someone who is more experienced than me.
    And did I miss any dangerous characters?
    Ive got:   ', ", &nbsp;, &,  <, >, +
    I hope that wraps it up :-\

    Govinda

    • Moderator
    • Systems Administrator
    • *****
    • Posts: 510
    • If You Want To Be Big Then Solve Big Problems
      • View Profile
      • Mitr Learning & Media
      • Email
    Re: Text Editor HTML output
    « Reply #2 on: 04/27/05, 07:01 »
    str = str.split("&apos;");
       tot = "";
       for (var i = 0; i<=str.length-1; i++) {
          if (i != str.length-1) {
             //substitute problematic characters here
             tot += str+"'";
          } else {
             tot += str;
          }
       }

    I didn't get you ??? Do you want to replace &apos; with &nbsp;
    .: Govinda :.

    triangle man

    • Server what's that
    • *
    • Posts: 5
      • View Profile
    Re: Text Editor HTML output
    « Reply #3 on: 04/27/05, 08:59 »
    oh hi Govinda!!!,
    I love that text editor.  Thanks for all the work that went into making it!
    Well Im using the text editor to give my wife the ability to edit her flash website's news section.  So she makes edits and then the editor saves the changes to an external file.txt.  Then that text file is loaded into her site's news section when someone views the site... yada, yada, yada.  But ofcourse the problem is that all the '&'s screw everything up on import because flash thinks its reading a new variable in the text file.  So I was using your string manipulation in htmlView() to at least get rid of the &apos; and replace them with the ( ' ) symbol, instead of adding &nbsp; in all the spaces (which was ofcourse another problematic thing on import).

    Anyway after trying to write a long script that took out ALL the &'s and having flash crash on me before I saved I thought "hey bozo,what are you doing?  This would be cake if you left Govinda's code the way it is suposed to be and did your cleanup in the php file used to write to the text file."  Hence my second post.

    Anyway I'll get the hang of this so no worries.  Just wondering now if there is a better way to write that php stuff.  And wether or not Ive forgotten anything.

    have a nice day and thanks again for that GREAT editor!  SUPER!

    Govinda

    • Moderator
    • Systems Administrator
    • *****
    • Posts: 510
    • If You Want To Be Big Then Solve Big Problems
      • View Profile
      • Mitr Learning & Media
      • Email
    Re: Text Editor HTML output
    « Reply #4 on: 04/28/05, 00:02 »
    I'll suggest, that don't use LoadVars in this case, otherwise you'll face a lot HTML related problems. My suggestion is to go for XML with CDATA. I suppose you're familiar with XML, if not then I'll give you an example.
    .: Govinda :.

    triangle man

    • Server what's that
    • *
    • Posts: 5
      • View Profile
    Re: Text Editor HTML output
    « Reply #5 on: 04/28/05, 03:57 »
    Well, I do know enough about XML to import and parse suff into flash like for a gallery or mp3 player.  But this is the first Ive heard about CDATA.  I did a quick look into w3schools and I see now what CDATA is for though.  I would love an example if you have the time. 

    I have one concern.  I am also loading the saved text into an html version of her site.  Will this remain as easy to import with a little php (I am really still new to php)?

    what do you think?

    Thank you for any help.

    Govinda

    • Moderator
    • Systems Administrator
    • *****
    • Posts: 510
    • If You Want To Be Big Then Solve Big Problems
      • View Profile
      • Mitr Learning & Media
      • Email
    Re: Text Editor HTML output
    « Reply #6 on: 04/28/05, 04:16 »
    Here is a simple example

    <node>
       <node><![CDATA[This is a <b>simple</b> example]]></node>
    </node>



    So in this case you don't have to use &...
    .: Govinda :.

    triangle man

    • Server what's that
    • *
    • Posts: 5
      • View Profile
    Re: Text Editor HTML output
    « Reply #7 on: 04/28/05, 08:13 »
    gosh.  I guess I never thought to put the formatted text in an XML file because when I first started playing arround with your editor I was still an XML infant.  But OF COURSE it shoud be read and written to an XML file and not a simple text file.  I didnt need CDATA after all.  Im glad I know about it now but it wasnt needed.  As long as I save and load using XML everything works great!

    Thanks a buch for the knock on the head.  I feel silly.

    Have a very nice day.

    till

    • Seasoned Programmer
    • ***
    • Posts: 200
      • View Profile
      • Email
    Re: Text Editor HTML output
    « Reply #8 on: 05/06/05, 08:23 »
    hi.
    tis s till.

    try:

    %26

    and when saving:

    $lock = ereg_replace("&amp;","%26",$lock);
    $lock = ereg_replace("%26data","&data",$lock);

    works fine within my textfiles.

    and use:

    system.useCodepage = true;

    in flash

    till
    « Last Edit: 05/06/05, 08:47 by till »

    tilderman

    • Server what's that
    • *
    • Posts: 13
      • View Profile
      • Email
    Re: Text Editor HTML output
    « Reply #9 on: 05/08/05, 11:32 »
    please I´m a noob in xml, explain me how to save html text from the flash text editor to a mysql database and load it from another swf whitout losing the html format....

    I´ve tried whit other editor, and whitout xml, and not works...

    I will appreciate your help, excuse my bad english hope you understand well.

    THANKS YOU IN ADVANCE!!!!!


    Govinda

    • Moderator
    • Systems Administrator
    • *****
    • Posts: 510
    • If You Want To Be Big Then Solve Big Problems
      • View Profile
      • Mitr Learning & Media
      • Email
    Re: Text Editor HTML output
    « Reply #10 on: 05/09/05, 00:06 »
    For this you need a server-side script. So please write which server-side script are you going to use.
    .: Govinda :.

    tilderman

    • Server what's that
    • *
    • Posts: 13
      • View Profile
      • Email
    Re: Text Editor HTML output
    « Reply #11 on: 05/12/05, 07:00 »
    My server uses php...

    Govinda

    • Moderator
    • Systems Administrator
    • *****
    • Posts: 510
    • If You Want To Be Big Then Solve Big Problems
      • View Profile
      • Mitr Learning & Media
      • Email
    Re: Text Editor HTML output
    « Reply #12 on: 05/12/05, 07:36 »
    I don't know php  :(

    Let other board members solve your problem..
    .: Govinda :.

    till

    • Seasoned Programmer
    • ***
    • Posts: 200
      • View Profile
      • Email
    Re: Text Editor HTML output
    « Reply #13 on: 05/13/05, 01:54 »
    hi.

    i configured Govindas editor.
    load.php looks for every file.txt in a folder.
    you can choose whitch file to load, change it and save.
    with ScrollBar.swf you can display it without loosing html format.

    fla and files are here: http://www.strategies.ufg.ac.at/editor.zip

    till.

    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re: Text Editor HTML output
    « Reply #14 on: 05/13/05, 03:55 »
    Hi till

    Can we post the file as an extension for Govinda textEditor in Flash-db?
    Can you write a briefly explanation to include with it?

    Jorge