Menu

Suggestion...

Anonymous
2012-12-29
2013-04-24
  • Anonymous

    Anonymous - 2012-12-29

    Hi,
    I have came up with a simple suggestion for this awesome project.

    When using this project the textareas are only included after the pade loads.
    if this were to be added the user could call

    CodePress.run();
    

    whenever they wanted to include more dynamically generated textareas as CodePress editors.

    CodePress.run = function() {
        s = document.getElementsByTagName('script');
        for(var i=0,n=s.length;i<n;i++) {
            if(s[i].src.match('codepress.js')) {
                CodePress.path = s[i].src.replace('codepress.js','');
            }
        }
        t = document.getElementsByTagName('textarea');
        for(var i=0,n=t.length;i<n;i++) {
            if(t[i].className.match('codepress')) {
                id = t[i].id;
                if (id.slice(id.lastIndexOf('_'), id.length) != "_cp") { //add this
                    t[i].id = id+'_cp';
                    eval(id+' = new CodePress(t[i])');
                    t[i].parentNode.insertBefore(eval(id), t[i]);
                } //and this
            } 
        }
    }
    

    Obviously all is does is check that the ids of the textares do not have a '_cp' at the end before making them CodePress editors.

    Thanks for the cool project.

     
  • Franchie

    Franchie - 2013-01-08

    Great suggestion and thanks for your interest!
    I'll be sure to implement that whenever I find the time to get back to it!

    Regards,
    Franchie.

     
  • Franchie

    Franchie - 2013-01-08

    Whoops, wrong forum.
    My bad, sorry…

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.