Changeset 1683 in ExiteCMS


Ignore:
Timestamp:
08/25/08 17:37:11 (3 years ago)
Author:
hverton
Message:

fixed added a line-break in front of an inserted smiley
fixed not inserting hyperlinks (url or email) in RTF mode when no text was selected (now uses the url entered are link text)
fixed convering BBcode's to uppercase
fixed font size issues when converting from HTML to BBcode (todo: safari code!)

Location:
trunk/includes/jscripts/hoteditor-4.2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/jscripts/hoteditor-4.2/editor.js

    r1648 r1683  
    3434|   The ExiteCMS team decoded the original obfusicated code in order to make changes to 
    3535|   the way some BBcodes were parsed. We didn't tamper with the copyright en credit code 
    36 |   in any way. We hope this doesn't violate the author's wishes.  
     36|   in any way. We hope this doesn't violate the author's wishes, as the licencing 
     37|   conditions of the free version aren't exactly clear.  
    3738| 
    3839+-------------------------------------------------------------------------- 
     
    6465//---------------- FOR WYSIWYG EDITOR (BBCODE EDITOR) ---------------- 
    6566 
    66 var TitleText = "ExiteCMS - Rich Text Editor"; 
     67var TitleText = "Rich Text Editor"; 
    6768var iframe_meta_tag = "<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>\n"; 
    6869var iframe_style = "BODY{font-family:Verdana,Arial,Sans-Serif,Tahoma;font-size:12px;color: black;}"; 
     
    9697//---------------- FOR BBCODE EDITOR ---------------- 
    9798 
    98 var TitleText_Texarea ="ExiteCMS - BBCode Editor"; 
     99var TitleText_Texarea ="BBCode Editor"; 
    99100 
    100101var textarea_toolbar1 ="SPACE,btFont_Name,btFont_Size,btFont_Color,btHighlight,btRemove_Format,SPACE,btBold,btItalic,btUnderline"; 
     
    376377        b = b.replace(/[\n\r]/gi, ""); 
    377378        b = HTMLToBBCode(b); 
    378         b = b.replace(/\[table\]\n+/gi, "[TABLE]"); 
    379         b = b.replace(/\n+\[td\]/gi, "[TD]"); 
    380         b = b.replace(/\n+\[\/table\]/gi, "[/TABLE]"); 
    381         b = b.replace(/\n+\[\/td\]/gi, "[/TD]"); 
    382         b = b.replace(/\n+\[tr\]/gi, "[TR]"); 
    383         b = b.replace(/\n+\[\/tr\]/gi, "[/TR]"); 
     379        b = b.replace(/\[table\]\n+/gi, "[table]"); 
     380        b = b.replace(/\n+\[td\]/gi, "[td]"); 
     381        b = b.replace(/\n+\[\/table\]/gi, "[/table]"); 
     382        b = b.replace(/\n+\[\/td\]/gi, "[/td]"); 
     383        b = b.replace(/\n+\[tr\]/gi, "[tr]"); 
     384        b = b.replace(/\n+\[\/tr\]/gi, "[/tr]"); 
    384385        document.getElementById("hoteditor_bbcode_ouput_" + a).value = b; 
    385386        document.getElementById("hoteditor_html_ouput_" + a).value = BBCodeToHTML(b); 
     
    394395        document.getElementById("hoteditor_html_ouput_" + a).value = b; 
    395396        b = HTMLToBBCode(b); 
    396         b = b.replace(/\[table\]\n+/gi, "[TABLE]"); 
    397         b = b.replace(/\n+\[td\]/gi, "[TD]"); 
    398         b = b.replace(/\n+\[\/table\]/gi, "[/TABLE]"); 
    399         b = b.replace(/\n+\[\/td\]/gi, "[/TD]"); 
    400         b = b.replace(/\n+\[tr\]/gi, "[TR]"); 
    401         b = b.replace(/\n+\[\/tr\]/gi, "[/TR]"); 
     397        b = b.replace(/\[table\]\n+/gi, "[table]"); 
     398        b = b.replace(/\n+\[td\]/gi, "[td]"); 
     399        b = b.replace(/\n+\[\/table\]/gi, "[/table]"); 
     400        b = b.replace(/\n+\[\/td\]/gi, "[/td]"); 
     401        b = b.replace(/\n+\[tr\]/gi, "[tr]"); 
     402        b = b.replace(/\n+\[\/tr\]/gi, "[/tr]"); 
    402403        document.getElementById("hoteditor_bbcode_ouput_" + a).value = b; 
    403404    } 
     
    12951296                n = flash_height_number_default; 
    12961297            } 
    1297             var o = "[" + b.toUpperCase() + "=" + m + "," + n + "]" + l + "[/" + b.toUpperCase() + "]"; 
     1298            var o = "[" + b.toLowerCase() + "=" + m + "," + n + "]" + l + "[/" + b.toLowerCase() + "]"; 
    12981299            if (isIE) { 
    12991300                d.document.execCommand("removeformat", false, ""); 
     
    13231324            WriteHTML(r, a); 
    13241325        } 
    1325     } else if (b == "youtube" || b == "google" || b == "yahoo") { 
    1326         if (b == "youtube") { 
    1327             var l = prompt(promptYouTube, URLDefaultYouTube); 
    1328             if (l != null) { 
    1329                 l = l.replace(/watch\?v=/gi, "v/"); 
    1330             } 
    1331         } else if (b == "google") { 
    1332             var l = prompt(promptGoogle, URLDefaultGoogle); 
    1333             if (l != null) { 
    1334                 l = l.replace(/videoplay/i, "googleplayer.swf"); 
    1335                 l = l.replace(/\&hl=en/i, ""); 
    1336             } 
    1337         } else if (b == "yahoo") { 
    1338             var l = prompt(promptYahoo, URLDefaultYahoo); 
    1339             if (l != null) { 
    1340                 l.match(/flashvars='id=(.*?)&emailUrl=(.*?)'/i); 
    1341                 l = "http://us.i1.yimg.com/cosmos.bcst.yahoo.com/player/media/swf/FLVVideoSolo.swf?id=" + RegExp.$1; 
    1342             } 
    1343         } 
     1326    } else if (b == "youtube") { 
     1327        var l = prompt(promptYouTube, URLDefaultYouTube); 
    13441328        if (l != null) { 
    1345             var o = "[" + bbFlash.toUpperCase() + "=" + flash_width_number_default + "," + flash_height_number_default + "]" + l + "[/" + bbFlash.toUpperCase() + "]"; 
     1329            l = l.replace(/watch\?v=/gi, "v/"); 
     1330        } 
     1331        if (l != null) { 
     1332            var o = "[" + b.toLowerCase() + "]" + l + "[/" + b.toLowerCase() + "]"; 
    13461333            if (isIE) { 
    13471334                d.document.execCommand("removeformat", false, ""); 
     
    13551342            } 
    13561343        } 
     1344    } else if (b == "google" || b == "yahoo") { 
     1345        if (b == "google") { 
     1346            var l = prompt(promptGoogle, URLDefaultGoogle); 
     1347            if (l != null) { 
     1348                l = l.replace(/videoplay/i, "googleplayer.swf"); 
     1349                l = l.replace(/\&hl=en/i, ""); 
     1350            } 
     1351        } else if (b == "yahoo") { 
     1352            var l = prompt(promptYahoo, URLDefaultYahoo); 
     1353            if (l != null) { 
     1354                l.match(/flashvars='id=(.*?)&emailUrl=(.*?)'/i); 
     1355                l = "http://us.i1.yimg.com/cosmos.bcst.yahoo.com/player/media/swf/FLVVideoSolo.swf?id=" + RegExp.$1; 
     1356            } 
     1357        } 
     1358        if (l != null) { 
     1359            var o = "[" + bbFlash.toLowerCase() + "=" + flash_width_number_default + "," + flash_height_number_default + "]" + l + "[/" + bbFlash.toLowerCase() + "]"; 
     1360            if (isIE) { 
     1361                d.document.execCommand("removeformat", false, ""); 
     1362                rng.pasteHTML(""); 
     1363                rng.pasteHTML(o); 
     1364            } else if (isSafari) { 
     1365                d.document.execCommand("InsertText", false, o); 
     1366            } else { 
     1367                d.focus(); 
     1368                d.document.execCommand("InsertHTML", false, o); 
     1369            } 
     1370        } 
    13571371    } else if (b == "quote" || b == "code" || b == "php" || b == "html") { 
    1358         b = b.toUpperCase(); 
     1372        b = b.toLowerCase(); 
    13591373        var u = ""; 
    13601374        if (isIE) { 
     
    13671381            } 
    13681382        } 
    1369         if (b == "code" || b == "php" || b == "html") { 
    1370             u = u.replace(/[\n\r]/gi, ""); 
    1371             u = u.replace(/<(br|p|div|li).*?>/gi, "[br/]"); 
    1372             u = u.replace(/<\/(p|div).*?>/gi, ""); 
    1373             u = u.replace(/(<([^>]+)>)/gi, ""); 
    1374             u = u.replace(/\[br\/\]/gi, "<br>"); 
    1375         } 
    1376         u = "[" + b + "]" + u + "[/" + b + "]"; 
     1383//      ExiteCMS: don't tamper with the contents of a code block! 
     1384//      if (b == "code" || b == "php" || b == "html") { 
     1385//          u = u.replace(/[\n\r]/gi, ""); 
     1386//          u = u.replace(/<(br|p|div|li).*?>/gi, "[br/]"); 
     1387//          u = u.replace(/<\/(p|div).*?>/gi, ""); 
     1388//          u = u.replace(/(<([^>]+)>)/gi, ""); 
     1389//          u = u.replace(/\[br\/\]/gi, "<br>"); 
     1390//      } 
     1391        if (b == "quote" && hoteditor_reply_to != "") { 
     1392            u = "[" + b + "=" + hoteditor_reply_to + "]" + u + "[/" + b + "]"; 
     1393        } else { 
     1394            u = "[" + b + "]" + u + "[/" + b + "]"; 
     1395        } 
    13771396        WriteHTML(u, a); 
    13781397    } else if (b == "symbol") { 
     
    14871506        } else { 
    14881507            try { 
    1489                 d.document.execCommand("Unlink", false, null); 
    1490                 d.document.execCommand("CreateLink", false, l); 
     1508                // ExiteCMS: no text selected, then use the link itself as text 
     1509                if (rng == null) { 
     1510                    WriteHTML("<a href='" + l + "'>" + l +"</a>", a); 
     1511                } else { 
     1512                    d.document.execCommand("Unlink", false, null); 
     1513                    d.document.execCommand("CreateLink", false, l); 
     1514                } 
    14911515            } catch (e) { 
    14921516            } 
     
    22752299    a = a.replace(/\[font=(.*?)\]/gi, "<font face=\"$1\">"); 
    22762300    a = a.replace(/\[color=(.*?)\]/gi, "<font color=\"$1\">"); 
    2277     a = a.replace(/\[size=(.*?)\]/gi, "<font size=\"$1\">"); 
     2301    a = a.replace(/\[size=(.*?)\]/gi, "<font style=\"font-size:$1px\">"); 
    22782302    a = a.replace(/\[\/(font|color|size)\]/gi, "</font>"); 
    22792303    a = a.replace(/\[highlight=(.*?)\]/gi, "<span style=\"background-color:$1\">"); 
     
    23082332        } 
    23092333    } 
     2334 
    23102335    if (isOpera9 || isIE) { 
    23112336        a = a.replace(/<li>/gi, "</li><li>"); 
     
    23432368                c += "[list=a]"; 
    23442369            } else if (f == "text-align") { 
    2345                 g = g.toUpperCase(); 
     2370                g = g.toLowerCase(); 
    23462371                c += "[" + g + "]"; 
    23472372            } else if (f == "margin-left" || f == "margin-right") { 
     
    24252450        a = htmlentities(a); 
    24262451    } 
     2452    var px = new Array(0, 6, 8,10,12,14,18,24,28); 
    24272453    var b = a.split("<"); 
    24282454    var c = new Array; 
     
    25562582                        } 
    25572583                    } else if (k.align) { 
    2558                         m = "[" + k.align.toUpperCase() + "]" + "[list=1]"; 
     2584                        m = "[" + k.align.toLowerCase() + "]" + "[list=1]"; 
    25592585                    } else { 
    25602586                        m = "[list=1]"; 
     
    25642590                        m = AnalyzeHTMLBlock(g, k) + "[list]"; 
    25652591                    } else if (k.align) { 
    2566                         m = "[" + k.align.toUpperCase() + "]" + "[list=1]"; 
     2592                        m = "[" + k.align.toLowerCase() + "]" + "[list=1]"; 
    25672593                    } else { 
    25682594                        m = "[list]"; 
    25692595                    } 
    2570                 } else if (g == "font" || 
    2571                     g == "h1" || 
    2572                     g == "h2" || 
    2573                     g == "h3" || g == "h4" || g == "h5" || g == "h6") { 
     2596                } else if (g == "h1" || g == "h2" || g == "h3" || g == "h4" || g == "h5" || g == "h6") { 
     2597                    m += "[size=" + px[8 - g.substr(1)] + "]"; 
     2598                } else if (g == "font") { 
    25742599                    if (j.length > 0) { 
    25752600                        for (var r in k) { 
     
    25792604                            } else if (r == "size") { 
    25802605                                if (isNaN(parseInt(k.size))) { 
    2581                                     k.size = 2; 
     2606                                    k.size = 3; 
    25822607                                } 
    2583                                 var px = new Array(0, 6, 8,10,12,14,18,24,36); 
    2584                                 if (k.size > 7) { 
     2608                                if (k.size > 8) { 
    25852609                                    m += "[size=" + k.size + "]"; 
    25862610                                } else { 
    2587                                     m += "[size=" + px[k.size] + "]"; 
     2611                                    m += "[size=" + px[(k.size+1)] + "]"; 
    25882612                                } 
    25892613                            } else if (r == "face") { 
     
    25982622                        m = AnalyzeHTMLBlock(g, k); 
    25992623                    } else if (k.align) { 
    2600                         m = "[" + k.align.toUpperCase() + "]"; 
     2624                        m = "[" + k.align.toLowerCase() + "]"; 
    26012625                    } else { 
    26022626                        m = "[HOTEDITOR_NEW_LINE]"; 
     
    27042728        C = C.replace(/\[\/tr\]/gi, "\n[/tr]"); 
    27052729        C = C.replace(/\[tr\]/gi, "\n[tr]"); 
    2706         C = C.replace(/\[td\]/gi, "\n[rd]"); 
     2730        C = C.replace(/\[td\]/gi, "\n[td]"); 
    27072731        C = C.replace(/\[\/table\]/gi, "\n[/table]"); 
    27082732        C = C.replace(/\[\/table\]$/gi, "[/table]\n"); 
  • trunk/includes/jscripts/hoteditor-4.2/show_it.php

    r1648 r1683  
    211211<script language=javascript> 
    212212    var my_what ="$what"; 
    213     if(my_what=="smileys"){ 
     213    if(my_what=="smiley"){ 
    214214        self.parent.Set_smiles_path("$script_url?step=1&what=$what"); 
    215215    } 
     
    353353 
    354354    var my_what ="$what"; 
    355     if(my_what=="smileys"){ 
     355    if(my_what=="smiley"){ 
    356356        my_document.Set_smiles_path("$script_url?$q_string"); 
    357357    } 
     
    374374            } 
    375375            else{ 
    376                 if(my_what =="smileys"){ 
     376                if(my_what =="smiley"){ 
    377377                    my_document.InsertSymbol("<img border=0 src='" + data + "'> &nbsp;"); 
    378378                } 
Note: See TracChangeset for help on using the changeset viewer.