Autor | Zpráva | ||
---|---|---|---|
šárinka Profil |
#1 · Zasláno: 8. 3. 2008, 20:21:34
Ahoj all, mám udělanou návštěvní knihu a když píšu příspěvek tak když kliknu na smajlíka tak se mi zobrazí jenom prostě text toho smajlíku a pak při výpisu to přepisuji ale já chci udělat když se třeba v poli kde se píše text objeví :-) takat to neukazeje jenom znaky ale at to zobrazí obrázek ale pak at to zas při zápisu do mysql to zapíše jen znaky, jak mám udělat takovej převod?
|
||
Zbystr Profil * |
#2 · Zasláno: 8. 3. 2008, 22:03:11
pokud chces zobrazit primo po napsani aby se zobrazili img smailiky, tak asi budes muset pouzit misto klasicke textarea iframe s designmode on, kontrolovat event keyup a pomoci replace nahradit :) na <img src='neco'/>
pro ulozeni do db to v php udelas replace naopak |
||
peta Profil |
#3 · Zasláno: 9. 3. 2008, 11:29:30
šárinka
Tot funguje trochu jinak, ale predpokladam, ze zvladas princip prikladu a poradis si a upravis pro sve potreby ===JS=== function writeSmilies(xImg) { var f=parent.document; if (Boolean(f) && Boolean(xImg) && Boolean(xImg[0])) { var i,o,o1,oX,xClick; o=objGet2(f,'smilies'); for (i=0;i<xImg.length;i++) { o1=creEL(f,'SPAN'); o1.setAttribute('title',"*"+i+"* "+xImg[i].title); oX=creImg(f,xImg[i].src,"*"+i+"*",15,15); setxEvent(oX,"onclick","smlPut(\'"+i+"\');showHideId('smilies')"); appEL(o1,oX); appEL(o,o1); creaddTN(f,o," "); } } } //filter smilies number->img link->AHREF [mracek] function filterLine(source,zImg,xSett) { var f = parent.document; if (Boolean(f)) { var reg,a,b,c,d,i,j,x,sml, o,oX,xSml; d = ">"; //divider // http://en.wikipedia.org/wiki/Domain_name // http://www.ietf.org/rfc/rfc3986.txt var xSource = new Array(); var xData = new Array(); var ip0 = "(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])"; //255-250 249-200 199-100 99-10 9-0 var ip = "(?:(?:"+ ip0 +"\\.){3}"+ ip0 +")"; a = "[A-Za-z0-9](?:(?:"; b = "?[a-zA-Z0-9]+)*)"; var hostsep = "[_\\.-]"; var linksep = "[#%&-;\\.\\/\\=\\?_~]"; var mailsep = "[\\!#\\$%&\\'\\*\\+-\\/\\=\\?\\^_\\`\\{\\|\\}~]"; var xProtocol = "(?:(?:file|ftp|ftps|gopher|http|https|news|nntp|sftp|telnet)\\:\\/\\/ |"+ ip +")"; var xDomain = "(?:(?:"+ a + hostsep + b + "\\.[a-zA-Z]{2,9})|localhost|"+ ip +")"; // havaruje na http://localhost1/... var xPort = "(?:\\:[0-9]{2,4})?"; var xFilter = new Array (); /*smile*/ xFilter[0]="\\*([1-2]?[0-9])\\*"; xSml = (xSett.charAt(3))*1; /*link*/ if ((xSett.charAt(4))*1==0) {xFilter[2]="(("+ xProtocol + xDomain +")"+ xPort +"(?:\\/" + a + linksep + b +"[\\/]?)?)";} // http://msdn.microsoft.com:80/scripting/default.htm /*mail*/ if ((xSett.charAt(5))*1==0) {xFilter[3]= a + mailsep + b + "@"+ xDomain + xPort;} // RFC2821/RFC2822 e-mailAddress[64]@domainName[255] // me@24.111.232.1 joe_smith@here.com you.me.hello@somewhere.else.cc u-s_e.r1@s-ub2.domain-name.museum:8080 PN=Joe/OU=X400/@gateway.com //source = source.replace(/@/g,"@"); //innerHTML bug Opera @" source = source.replace(/"/g,"\""); //innerHTML bug Opera @" //source = source.replace(/&/g,"\&"); j = 0; for (i in xFilter) { //alert(i + ": " + (xFilter[i].split("(")).join("\n(")); reg = new RegExp(xFilter[i],""); //alert(reg.source) a = 1; while (a>0) { if (x = reg.exec(source)) { b = 0; if (Boolean(x) && Boolean(x[0])) { i = i*1; //bug for(i in array) xSource[j] = i; switch (i) { case 0: xData[j] = x[1]*1; b = 1; xSource[j] = xSml; break; case 2: xData[j] = new Array( x[1],x[2] ); b = 1; break; case 3: xData[j] = x[0]; b = 1; break; } } if (b) {b = d; j++;} else {b = "";} source = source.replace(reg,d); //alert(x[1]) a = 2; } a--; } } // add object smiley/link if (xData.length>0) { o = creEL(f,'SPAN'); source = source.split(d); for (i in source) { creaddTN(f,o,source[i]); x = xData[i]; switch (xSource[i]) { case 0: //smile img if (Boolean(zImg[x])) { creaddTN(f,o," "); o1=creEL(f,'SPAN'); o1.className = "smile"; o1.setAttribute('title',"*"+x+"* "+zImg[x].title); oX = creImg(f,zImg[x].src,"*"+x+"*",15,15); setxEvent(oX,"onclick","smlPut(\'"+x+"\')"); appEL(o1,oX); appEL(o,o1); creaddTN(f,o," "); } break; case 1: //smile text if (Boolean(zImg[x])) { a = zImg[x].title; b = (a!=="") ? a : "*"+x+"*"; creaddTN(f,o," "+b+" "); } break; case 2: creaddTN(f,o," "); o1=creEL(f,'A'); o1.className = "www"; o1.setAttribute('href',x[0]); o1.setAttribute('title',"URL = "+x[0]); o1.setAttribute('target',"_blank"); creaddTN(f,o1,x[1]); appEL(o,o1); creaddTN(f,o," "); break; case 3: creaddTN(f,o," "); o1=creEL(f,'A'); o1.className = "mail"; o1.setAttribute('href',"mailto:"+x); o1.setAttribute('title',"MAIL = "+x); o1.setAttribute('target',"_blank"); creaddTN(f,o1,x); appEL(o,o1); creaddTN(f,o," "); break; } } } else { o = creTN(f,source); } return o; } } ===PHP=== <?php //filter replace image and text smilles //filter smiley text->text [mracek] function filterSmlText2Text($text) { $search = array ( "/\:\-\)\)+|\:o\)\)+|\:\)\)+|;\-\)\)+|;o\)\)+|;\)\)+|\:D|\:\-D|;D|;\- D/", "/\:o\(\(+|\:\(\(+|;\-\(\(+|;o\(\(+|;\(\(+/", "/O\:\-\)|O\:o\)|O\:\)|O;\-\)|O;o\)|O;\)/", "/\]\:\-\)|\]\:o\)|\]\:\)|\];\-\)|\];o\)|\];\)|\]\:\-\>|\]\:o\> |\]:\>|\];\-\>|\];o\>|\];\>/", "/\:\-\)|\:o\)|\:\)/", "/;\-\)|;o\)|;\)/", "/\:\-\(|\:o\(|\:\(|;\-\(|;o\(|;\(/", "/\:\-P|\:oP|\:P|;\-P|;oP|;P/", "/\:\-\*|\:o\*|\:\*|;\-\*|;o\*|;\*/", "/\<3/", "/B\-\)|Bo\)|B\)/", "/\=\^\-\^\=/", "/\*\^\-\^\*/" ); $replace = array ( " :\)\) ", " :\(\( ", " O:\) ", " \]:\> ", " :\) ", " ;\) ", " :\( ", " :P ", " :\* ", " \<3 ", " B\) ", " \=\^\-\^\= ", " \*\^\-\^\* " ); $text = preg_replace($search, $replace, $text); $text = stripslashes($text); return $text; } //filter smiley number->text [mracek] // //function filterSmlNumber2Text($text) //{ //$search = array ( // "/\*1\*|\*12\*|\*101\*/", // "/\*74\*|\*5\*/", // "/\*233\*|\*235\*/", // "/\*243\*|\*256\*/", // "/\*94\*/", // "/\*20\*/", // "/\*95\*/", // "/\*17\*|\*98\*/", // "/\*22\*|\*43\*|\*93\*|\*286\*/", // "/\*79\*|\*85\*|\*267\*|\*273\*|\*279\*|\*292\*|\*294\*/", // "/\*65\*/", // "/\*58\*/", // "/\*29\*|\*89\*/" // ); //$replace = array ( // " :\)\) ", // " :\(\( ", // " O:\) ", // " \]:\> ", // " :\) ", // " ;\) ", // " :\( ", // " :P ", // " :\* ", // " \<3 ", // " B\) ", // " \=\^\-\^\= ", // " \*\^\-\^\* " // ); //$text = preg_replace($search, $replace, $text); //$text = stripslashes($text); //return $text; //} //filter smiley text->number [mracek] function filterSmlText2Number($text) { $search = array ( "/\:\)\)/", "/\:\(\(/", "/O\:\)/", "/\]\:\>/", "/\:\)/", "/;\)/", "/\:\(/", "/\:P/", "/\:\*/", "/\<3/", "/B\)/", "/\=\^\-\^\=/", "/\*\^\-\^\*/" ); $replace = array ( "\*0\*", "\*3\*", "\*16\*", "\*17\*", "\*1\*", "\*1\*", "\*2\*", "\*0\*", "\*13\*", "\*12\*", "\*1\*", "\*7\*", "\*15\*" ); $text = preg_replace($search, $replace, $text); $text = stripslashes($text); return $text; } /* //filter smiley number->IMG [temistokles] function filterSmlNumber2Img($text) { $i=0; $reg="/\*[0-9]{1,3}\*/ /* "; preg_match($reg, $text, $smajlici, PREG_OFFSET_CAPTURE); while ( |
||
Časová prodleva: 16 let
|
0