Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    Problema passaggio parametri di una textarea

    Premetto che sono alle prime armi di javascript, sto' cercando di modificare una funzione gia' esistente.
    Ho necessita' che premendo un bottone, si passi il valore di una textarea ad una funzione che ne modifica il valore, riaggiornando il valore dellatextarea stessa.
    Grazie per la collaborazione
    ciao


    codice:
    this.btnList = {
    ....
        "pulisciword":    ['PulisciWord',          'PulisciWord',    	 'editor_action(this.id)',  'ed_link.gif'],
    ....
    
    function editor_action(button_id) {
    ...
    	    // insert link
    if (cmdID.toLowerCase() == 'pulisciword'){
          editdoc == wordClean(editdoc);
        }
    end function
    
    
    function wordClean(wordData) {
             // make one line
             wordData = wordData.replace(/\r\n/g, ' ');
             return wordData;
    		}
    Il problema e' proprio come chiamare e riprendere il valore di wordClean

  2. #2
    sarò ingorante ma...

    1. non puoi passare una variabile senprima non la definisci.

    2. non puoi riprenderla se non viene definita in modo assoluto(esterna alle funzioni).

    3. perchè fai una chiamata ad una funzione quando potresti inserire la linea

    worData.replace....

    come

    editdoc=wordData.repalce

  3. #3
    quindi scusami nel mio caso, cosa dovrei fare ?

    codice:
      
      if (cmdID.toLowerCase() == 'pulisciword'){
          x == wordClean(y);
        }
    
    dove wordClean e' la funzione che pulisce il campo textarea
    cosa debbo mettere per x e per y ?
    Grazie
    ciao

    -------
    Editor.js (da cui ho necessita' di richiamare wordclean)
    trova pulisciword nel testo che segue
    -------
    [CODE]
    //
    // htmlArea v2.03 - Copyright (c) 2002 interactivetools.com, inc.
    // This copyright notice MUST stay intact for use (see license.txt).
    //
    // A free WYSIWYG editor replacement for <textarea> fields.
    // For full source code and docs, visit http://www.interactivetools.com/
    //

    // write out styles for UI buttons
    document.write('<style type="text/css">\n');
    document.write('.btn { width: 22px; height: 22px; border: 1px solid buttonface; margin: 0; padding: 0; }\n');
    document.write('.btnOver { width: 22px; height: 22px; border: 1px outset; }\n');
    document.write('.btnDown { width: 22px; height: 22px; border: 1px inset; background-color: buttonhighlight; }\n');
    document.write('.btnNA { width: 22px; height: 22px; border: 1px solid buttonface; filter: alpha(opacity=25); }\n');
    document.write('.cMenu { background-color: threedface; color: menutext; cursor: Default; font-family: MS Sans Serif; font-size: 8pt; padding: 2 12 2 16; }');
    document.write('.cMenuOver { background-color: highlight; color: highlighttext; cursor: Default; font-family: MS Sans Serif; font-size: 8pt; padding: 2 12 2 16; }');
    document.write('.cMenuDivOuter { background-color: threedface; height: 9 }');
    document.write('.cMenuDivInner { margin: 0 4 0 4; border-width: 1; border-style: solid; border-color: threedshadow threedhighlight threedhighlight threedshadow; }');
    document.write('</style>\n');


    /* ---------------------------------------------------------------------- *\
    Function : editor_defaultConfig
    Description : default configuration settings for wysiwyg editor
    \* ---------------------------------------------------------------------- */

    function editor_defaultConfig(objname) {

    this.version = "2.03"

    this.width = "auto";
    this.height = "auto";
    this.bodyStyle = 'background-color: #FFFFFF; font-family: "Verdana"; font-size: x-small;';
    this.imgURL = _editor_url + 'images/';
    this.debug = 0;

    this.replaceNextlines = 0; // replace nextlines from spaces (on output)
    this.plaintextInput = 0; // replace nextlines with breaks (on input)

    this.toolbar = [
    ['fontname'],
    ['fontsize'],
    // ['fontstyle'],
    // ['linebreak'],
    ['bold','italic', 'underline','separator'],
    // ['strikethrough','subscript','superscript','separat or'],
    ['justifyleft','justifycenter','justifyright','sepa rator'],
    ['OrderedList','UnOrderedList','Outdent','Indent',' separator'],
    ['forecolor','backcolor','separator'],
    ['HorizontalRule','Createlink','pulisciword','Inser tImage','InsertTable','htmlmode','separator'],
    // ['custom1','custom2','custom3','separator'],
    ['popupeditor','about']];

    this.fontnames = {
    "Arial": "arial, helvetica, sans-serif",
    "WingDings": "WingDings"};

    this.fontsizes = {
    "1 (8 pt)": "1",
    "2 (10 pt)": "2",
    };

    //this.stylesheet = "http://www.domain.com/sample.css"; // full URL to stylesheet

    this.fontstyles = [ // make sure these exist in the header of page the content is being display as well in or they won't work!
    // { name: "headline", className: "headline", classStyle: "font-family: arial black, arial; font-size: 28px; letter-spacing: -2px;" },
    // { name: "arial red", className: "headline2", classStyle: "font-family: arial black, arial; font-size: 12px; letter-spacing: -2px; color:red" },
    // { name: "verdana blue", className: "headline4", classStyle: "font-family: verdana; font-size: 18px; letter-spacing: -2px; color:blue" },
    ];

    this.btnList = {
    // buttonName: commandID, title, onclick, image,
    "bold": ['Bold', 'Bold', 'editor_action(this.id)', 'ed_format_bold.gif'],
    "italic": ['Italic', 'Italic', 'editor_action(this.id)', 'ed_format_italic.gif'],
    "underline": ['Underline', 'Underline', 'editor_action(this.id)', 'ed_format_underline.gif'],
    "strikethrough": ['StrikeThrough', 'Strikethrough', 'editor_action(this.id)', 'ed_format_strike.gif'],
    "subscript": ['SubScript', 'Subscript', 'editor_action(this.id)', 'ed_format_sub.gif'],
    "superscript": ['SuperScript', 'Superscript', 'editor_action(this.id)', 'ed_format_sup.gif'],
    "outdent": ['Outdent', 'Decrease Indent', 'editor_action(this.id)', 'ed_indent_less.gif'],
    "indent": ['Indent', 'Increase Indent', 'editor_action(this.id)', 'ed_indent_more.gif'],
    "pulisciword": ['PulisciWord', 'PulisciWord', 'editor_action(this.id)', 'ed_link.gif'],
    "insertimage": ['InsertImage', 'Insert Image', 'editor_action(this.id)', 'ed_image.gif'],
    "inserttable": ['InsertTable', 'Insert Table', 'editor_action(this.id)', 'insert_table.gif'],

    }

    /* ---------------------------------------------------------------------- *\
    Function : editor_generate
    Description : replace textarea with wysiwyg editor
    Usage : editor_generate("textarea_id",[height],[width]);
    Arguments : objname - ID of textarea to replace
    w - width of wysiwyg editor
    h - height of wysiwyg editor
    \* ---------------------------------------------------------------------- */


    function editor_generate(objname,userConfig) {

    // Default Settings
    var config = new editor_defaultConfig(objname);
    if (userConfig) {
    for (var thisName in userConfig) {
    if (userConfig[thisName]) { config[thisName] = userConfig[thisName]; }
    }
    }
    document.all[objname].config = config; // store config settings

    // set size to specified size or size of original object
    var obj = document.all[objname];
    if (!config.width || config.width == "auto") {
    if (obj.style.width) { config.width = obj.style.width; } // use css style
    else if (obj.cols) { config.width = (obj.cols * 8) + 22; } // col width + toolbar
    else { config.width = '100%'; } // default
    }
    if (!config.height || config.height == "auto") {
    if (obj.style.height) { config.height = obj.style.height; } // use css style
    else if (obj.rows) { config.height = obj.rows * 17 } // row height
    else { config.height = '200'; } // default
    }

    var tblOpen = '<table border=0 cellspacing=0 cellpadding=0 style="float: left;" unselectable="on"><tr><td style="border: none; padding: 1 0 0 0"><nobr>';
    var tblClose = '</nobr></td></tr></table>\n';

    // build button toolbar

    var toolbar = '';
    var btnGroup, btnItem, aboutEditor;
    for (var btnGroup in config.toolbar) {

    toolbar += tblOpen;
    for (var btnItem in config.toolbar[btnGroup]) {
    var btnName = config.toolbar[btnGroup][btnItem].toLowerCase();

    // buttons
    var btnObj = config.btnList[btnName];
    if (btnName == 'linebreak') { alert("htmlArea error: 'linebreak' must be in a subgroup by itself, not with other buttons.\n\nhtmlArea wysiwyg editor not created."); return; }
    if (!btnObj) { alert("htmlArea error: button '" +btnName+ "' not found in button list when creating the wysiwyg editor for '"+objname+"'.\nPlease make sure you entered the button name correctly.\n\nhtmlArea wysiwyg editor not created."); return; }
    var btnCmdID = btnObj[0];
    var btnTitle = btnObj[1];
    var btnOnClick = btnObj[2];
    var btnImage = btnObj[3];
    toolbar += '<button title="' +btnTitle+ '" id="_' +objname+ '_' +btnCmdID+ '" class="btn" onClick="' +btnOnClick+ '" onmouseover="if(this.className==\'btn\'){this.clas sName=\'btnOver\'}" onmouseout="if(this.className==\'btnOver\'){this.c lassName=\'btn\'}" unselectable="on">[img]' +config.imgURL + btnImage+ '[/img]</button>';


    } // end of button sub-group
    toolbar += tblClose;
    } // end of entire button set

    // build editor

    var editor = '<span id="_editor_toolbar"><table border=0 cellspacing=0 cellpadding=0 bgcolor="buttonface" style="padding: 1 0 0 2" width=' + config.width + ' unselectable="on"><tr><td>\n'
    + toolbar
    + '</td></tr></table>\n'
    + '</td></tr></table></span>\n'
    + '<textarea ID="_' +objname + '_editor" style="width:' +config.width+ '; height:' +config.height+ '; margin-top: -1px; margin-bottom: -1px;" wrap=soft></textarea>';

    // add context menu
    editor += '<div id="_' +objname + '_cMenu" style="position: absolute; visibility: hidden;"></div>';

    // hide original textarea and insert htmlarea after it
    if (!config.debug) { document.all[objname].style.display = "none"; }

    if (config.plaintextInput) { // replace nextlines with breaks
    var contents = document.all[objname].value;
    contents = contents.replace(/\r\n/g, '
    ');
    contents = contents.replace(/\n/g, '
    ');
    contents = contents.replace(/\r/g, '
    ');
    document.all[objname].value = contents;
    }

    // insert wysiwyg
    document.all[objname].insertAdjacentHTML('afterEnd', editor)

    // convert htmlarea from textarea to wysiwyg editor
    editor_setmode(objname, 'init');

    // call filterOutput when user submits form
    for (var idx=0; idx < document.forms.length; idx++) {
    var r = document.forms[idx].attachEvent('onsubmit', function() { editor_filterOutput(objname); });
    if (!r) { alert("Error attaching event to form!"); }
    }

    return true;

    }


    function editor_action(button_id) {

    // split up button name into "editorID" and "cmdID"
    var BtnParts = Array();
    BtnParts = button_id.split("_");
    var objname = button_id.replace(/^_(.*)_[^_]*$/, '$1');
    var cmdID = BtnParts[ BtnParts.length-1 ];
    var button_obj = document.all[button_id];
    var editor_obj = document.all["_" +objname + "_editor"];
    var config = document.all[objname].config;

    // help popup
    if (cmdID == 'showhelp') {
    window.open(_editor_url + "popups/editor_help.html", 'EditorHelp');
    return;
    }

    // popup editor
    if (cmdID == 'popupeditor') {
    window.open(_editor_url + "popups/fullscreen.html?"+objname,
    'FullScreen',
    'toolbar=no,location=no,directories=no,status=yes, menubar=no,scrollbars=yes,resizable=yes,width=640, height=480');
    return;
    }

    // check editor mode (don't perform actions in textedit mode)
    if (editor_obj.tagName.toLowerCase() == 'textarea') { return; }

    var editdoc = editor_obj.contentWindow.document;
    editor_focus(editor_obj);

    // get index and value for pulldowns
    var idx = button_obj.selectedIndex;
    var val = (idx != null) ? button_obj[ idx ].value : null;

    if (0) {} // use else if for easy cutting and pasting

    // execute command for buttons - if we didn't catch the cmdID by here we'll assume it's a
    // commandID and pass it to execCommand(). See http://msdn.microsoft.com/workshop/a...commandids.asp
    else {
    // subscript & superscript, disable one before enabling the other
    if (cmdID.toLowerCase() == 'subscript' && editdoc.queryCommandState('superscript')) { editdoc.execCommand('superscript'); }
    if (cmdID.toLowerCase() == 'superscript' && editdoc.queryCommandState('subscript')) { editdoc.execCommand('subscript'); }

    // insert link
    if (cmdID.toLowerCase() == 'createlink'){
    editdoc.execCommand(cmdID,1);
    }

    // insert link
    if (cmdID.toLowerCase() == 'pulisciword'){
    editdoc == wordClean(editdoc);
    }

    // insert image
    else if (cmdID.toLowerCase() == 'insertimage'){
    showModalDialog(_editor_url + "popups/insert_image.html", editdoc, "resizable: no; help: no; status: no; scroll: no; ");
    }

    // insert table
    else if (cmdID.toLowerCase() == 'inserttable'){
    showModalDialog(_editor_url + "popups/insert_table.html?"+objname,
    window,
    "resizable: yes; help: no; status: no; scroll: no; ");
    }

    // all other commands microsoft Command Identifiers
    else { editdoc.execCommand(cmdID); }
    }

    editor_event(objname);
    }

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.