WebGUI.php

Go to the documentation of this file.
00001 <?
00002 
00003 /***************************************************************************
00004  *   Copyright (C) 2005 by Ferenc Veres   *
00005  *   lion@netngine.hu   *
00006  *                                                                         *
00007  *   This program is free software; you can redistribute it and/or modify  *
00008  *   it under the terms of the GNU General Public License as published by  *
00009  *   the Free Software Foundation; either version 2 of the License, or     *
00010  *   (at your option) any later version.                                   *
00011  *                                                                         *
00012  *   This program is distributed in the hope that it will be useful,       *
00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00015  *   GNU General Public License for more details.                          *
00016  *                                                                         *
00017  *   You should have received a copy of the GNU General Public License     *
00018  *   along with this program; if not, write to the                         *
00019  *   Free Software Foundation, Inc.,                                       *
00020  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00021  ***************************************************************************/
00022 include('WebBackend.php');
00023 
00024 $backend = new WebBackend();
00025 $backend->EventHandler();
00026 
00027 ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
00028 <html>
00029 <head>
00030 <title>TranslationMemory</title>
00031 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
00032 <link rel="stylesheet" href="style.css" type="text/css" media="screen" />
00033 <script type="text/javascript" src="diff.js"></script>
00034 </head>
00035 <body>
00036 <form action="WebGUI.php" method="post" name="__Form" id="__Form">
00037 <input type="hidden" name="__Event" value="" id="__Event" />
00038 
00039 <!-- backend variables (documented in TranslationBackend class) -->
00040 <input type="hidden" name="xStringID" value="<? echo $backend->xStringID ?>" id="xStringID" />
00041 <input type="hidden" name="xProjectID" value="<? echo $backend->xProjectID ?>" id="xProjectID" />
00042 <input type="hidden" name="xOldLocaleID" value="<? echo $backend->xOldLocaleID ?>" id="xOldLocaleID" />
00043 
00044 <input type="hidden" name="xStringStack" value="<? echo $backend->xStringStack ?>" id="xStringStack" />
00045 <input type="hidden" name="xBrowserHelper" value="<? echo $backend->xBrowserHelper ?>" id="xBrowserHelper" />
00046 <input type="hidden" name="xDelStringID" value="0" id="xDelStringID" />
00047 <input type="hidden" name="xDelProjectID" value="0" id="xDelProjectID" />
00048 
00049 <!-- client side variables -->
00050 
00051 <!-- Editor field changed and operation requires confirmation -->
00052 <input type="hidden" name="htmlEditorChanged" value="0" id="htmlEditorChanged" />
00053 
00054 <!-- Value of the stack when this page was loaded, to mark older items -->
00055 <input type="hidden" name="htmlPageLoadStack" value="<? echo $backend->xStringStack ?>" id="htmlPageLoadStack" />
00056 
00057 <!-- The English original of the current string, for diff.js comparison -->
00058 <input type="hidden" name="htmlOriginalString" value="<?
00059         if(!empty($backend->LocatedString))
00060         {
00061                 echo FixQuot($backend->LocatedString->GetOriginal());
00062         }
00063         ?>" id="htmlOriginalString"/>
00064 
00065 <table class="layout">
00066 <tr><td valign="top" class="projecttree">
00067 
00068         <!-- *** PROJECT TREE *** -->
00069 
00070 <?
00071         if(!empty($backend->LocatedProjects))
00072         {
00073                 // Display project path down from root to current in nested LI-st.
00074                 for($i = count($backend->LocatedProjects)-1; $i >= 0; $i--)
00075                 {
00076                         // css class for current project
00077                         $css = "";
00078                         if($backend->LocatedProjects[$i]->GetID() == $backend->xProjectID)
00079                         {
00080                                 $css = " class=\"current\"";
00081                         }
00082 
00083                         // Show project tree entry
00084                         echo "<ul class=\"projecttree\">\n<li$css><a href=\"javascript:__TriggerEvent('setproject', true, 'xProjectID','". $backend->LocatedProjects[$i]->GetID()."')\">";
00085                         echo $backend->LocatedProjects[$i]->GetName();
00086                         echo "</a>";
00087                         
00088                         // Dead project?
00089                         if($backend->RootLastSeen > $backend->LocatedProjects[$i]->GetLastSeen())
00090                         {
00091                                 echo " +";
00092                         }
00093                 }
00094 
00095                 // Any childprojects in the iterator? List them!
00096                 if($backend->ChildProjects->valid())
00097                 {
00098                         echo "<ul class=\"projecttree\">\n";
00099                         foreach($backend->ChildProjects as $project)
00100                         {
00101                                 // css class for current project
00102                                 $css = "";
00103                                 if($project->GetID() == $backend->xProjectID)
00104                                 {
00105                                         $css = " class=\"current\"";
00106                                 }
00107                                 echo("<li$css><a href=\"javascript:__TriggerEvent('setproject', true, 'xProjectID','". $project->GetID()."')\">");
00108                                 echo($project->GetName());
00109                                 echo("</a>");
00110                                 
00111                                 // Dead project?
00112                                 if($backend->RootLastSeen > $project->GetLastSeen())
00113                                 {
00114                                         echo " +++";
00115                                 }
00116                                 
00117                                 echo("</li>\n");
00118                         }
00119                         echo "</ul>";
00120                         
00121                 }
00122                 for($i = count($backend->LocatedProjects)-1; $i >= 0; $i--)
00123                 {
00124                         echo "</li>\n</ul>\n";
00125                 }
00126         }
00127 ?>
00128 </td>
00129 
00130 <td valign="top">
00131 
00132         <!-- *** ONE STRING EDITOR *** -->
00133 
00134 <?
00135         // Show one string details if it was a locate event
00136         if(!empty($backend->LocatedString))
00137         {
00138                 ?>
00139                 <h1>Translation string editor area</h1>
00140 
00141                 <?
00142                 $stringIsDead = ($backend->RootLastSeen > $backend->LocatedString->GetLastSeen());
00143                 if($stringIsDead)
00144                 {
00145                         // Open a dark gray area
00146                         echo("<div class=\"located-dead\">");
00147                 }
00148                 ?>
00149                 <table class="located">
00150                 <tr><th>Project Path</th>
00151                 <td><? 
00152         
00153                 // Display project path
00154                 if(!empty($backend->LocatedProjects))
00155                 {
00156                         for($i = count($backend->LocatedProjects)-1; $i >= 0; $i--)
00157                         {
00158                                 // HARDCODE: XARAYA Warning
00159                                 $style = "";
00160                                 if($i == 0 && $backend->LocatedProjects[$i]->GetName() == "fuzzy.xml")
00161                                 {
00162                                         $style = "style=\"font-size: 25px\"";
00163                                 }
00164 
00165                                 // Display project path entries
00166                                 echo "<a $style href=\"javascript:__TriggerEvent('setproject', true, 'xProjectID','". $backend->LocatedProjects[$i]->GetID()."')\">";
00167                                 echo $backend->LocatedProjects[$i]->GetName();
00168                                 echo "</a>";
00169                                 if($i != 0)
00170                                 {
00171                                         echo " -&gt; ";
00172                                 }
00173                         }
00174                 }
00175                 ?></td></tr>
00176                 <tr><th>Original</th>
00177                 <td><? echo FixQuot($backend->LocatedString->GetOriginal()) ?></td></tr>
00178                 <tr><th><u>E</u>dit translation</th>
00179                 <td><?
00180                         $disableField = ($stringIsDead ? "disabled=\"disabled\"" : "");
00181                         // Long or short input fields for editing
00182                         if(strlen($backend->LocatedString->GetOriginal()) < 100)
00183                         {
00184                                 echo "<input class=\"editshort\" type=\"text\" accesskey=\"e\" name=\"txtEditString_".$backend->xBrowserHelper."\" id=\"txtEditString_".$backend->xBrowserHelper."\" value=\"";
00185                                 echo FixQuot($backend->LocatedString->GetTranslation());
00186                                 echo "\" onchange=\"editorChanged();\" tabindex=\"1\" $disableField/>";
00187                         }
00188                         else
00189                         {
00190                                 echo "<textarea class=\"editlong\" cols=\"80\" rows=\"8\" accesskey=\"e\" name=\"txtEditString_".$backend->xBrowserHelper."\" id=\"txtEditString_".$backend->xBrowserHelper."\" onchange=\"editorChanged();\" tabindex=\"1\" $disableField>";
00191                                 echo FixQuot($backend->LocatedString->GetTranslation());
00192                                 echo "</textarea>";
00193                         }
00194                 ?>
00195                 </td></tr>
00196                 </table>
00197                 <?
00198                 // Enable/disable various buttons
00199                 $stackLength = 0;
00200                 if($backend->xStringStack != "")
00201                 {
00202                         $stackLength = count(split(',', $backend->xStringStack));
00203                 }
00204                 $saveDisabled = "class=\"button-disabled\" disabled=\"disabled\"";
00205                 $saveEnabled = "class=\"button\"";
00206                 if($stringIsDead)
00207                 {
00208                         // Close dark gray area
00209                         echo("</div>");
00210 
00211                         $saveType = $saveDisabled;
00212                         $saveTypePop = $saveDisabled;
00213                 }
00214                 else
00215                 {
00216                         $saveType = $saveEnabled;
00217                         $saveTypePop = $saveEnabled;
00218 
00219                         // If no stack disable "save + pop" and "save to all stacked"
00220                         if($stackLength == 0)
00221                         {
00222                                 $saveTypePop = $saveDisabled;
00223                         }
00224                 }
00225                 ?>
00226                 <input <? echo $saveType; ?> type="button" onclick="__TriggerEvent('savenext', false);" value="Save + Next" tabindex="2" />
00227                 <button <? echo $saveType; ?> type="button" onclick="__TriggerEvent('savenextmissing', false);" tabindex="3" accesskey="s"><u>S</u>ave + Next missing</button>
00228                 <input <? echo $saveType; ?> type="button" onclick="__TriggerEvent('save', false);" value="Save" tabindex="4" />
00229                 <!-- input class="button" type="button" onclick="__TriggerEvent('previous');" value="Previous" />
00230                 <input class="button" type="button" onclick="__TriggerEvent('previoumissing');" value="Previous missing" / -->
00231                 <input class="button" type="button" onclick="__TriggerEvent('next', true);" value="Next" tabindex="5" />
00232                 <button class="button" type="button" onclick="__TriggerEvent('nextmissing', true);" tabindex="6" accesskey="n" tabindex="6"><u>N</u>ext missing</button>
00233                 
00234                 Stack control: <button <? echo $saveTypePop; ?> type="button" onclick="__TriggerEvent('savepopstack', false);" tabindex="7" accesskey="p" id="btnSavePopStack">Save + <u>p</u>op</button>
00235                 <input <? echo $saveType; ?> type="button" onclick="if(confirm('Operation will OVERWRITE all selected strings and current string!')) { __TriggerEvent('savetoallchecked', false); }" value="Save to all chekced" tabindex="8" />
00236                 <?
00237                 }
00238 
00239 ?>
00240         <!-- *** STACK *** -->
00241 
00242 <div id="stack">
00243 <h1>Stack</h1>
00244 Contents: [<span id="plhStackView"></span>]
00245 <?
00246 if(!empty($backend->LocatedString))
00247 {
00248         ?>
00249         <input class="codebutton" type="button" onclick="pushToStack('<? echo($backend->LocatedString->GetStringID()); ?>');" value="push" tabindex="7" />
00250         <?
00251 }
00252 ?>
00253 <input class="codebutton" type="button" onclick="popFromStack();" value="pop" tabindex="9" />
00254 <input class="codebutton" type="button" onclick="clearStack();" value="clear" tabindex="10" />
00255 </div>
00256 <?
00257 
00258 if(!empty($backend->CurrentStrings))
00259 {
00260         ?>
00261         
00262         <!-- *** CURRENT PROJECT'S STRINGS *** -->
00263 
00264         <p><a href="javascript:toggleStrings()" accesskey="t"><span class="underunder">t</span>oggle strings</a></p>
00265         <div id="divStrings">
00266         <h1>Strings in the currently selected project</h1>
00267         <?
00268 
00269         $addHeader = true;
00270         foreach($backend->CurrentStrings as $str)
00271         {
00272                 // Draw header if not done yet
00273                 if($addHeader)
00274                 {
00275                         ?>
00276                         <table class="strings">
00277                         <tr><th>Original string</th>
00278                         <th>Translated string</th>
00279                         <th>Action</th></tr>
00280                         <?
00281                         $addHeader = false;
00282                 }
00283                 if(!empty($backend->LocatedString) && $backend->LocatedString->GetStringID() == $str->GetStringID())
00284                 {
00285                         echo("<tr class=\"selected\">");
00286                 }
00287                 else
00288                 {
00289                         echo("<tr>");
00290                 }
00291                 
00292                 echo("<td class=\"string-original\">".FixQuot($str->GetOriginal())."</td>");
00293                 echo("<td class=\"string-translation\">".FixQuot($str->GetTranslation())."</td>");
00294                 echo("<td><a href=\"javascript:__TriggerEvent('editstring', true, 'xStringID','".$str->GetStringID()."');\">Edit</a>");
00295                 
00296                 // Dead string?
00297                 if($backend->RootLastSeen > $str->GetLastSeen())
00298                 {
00299                         echo " +++ ";
00300                         echo("<a href=\"javascript:if(confirm('Are you sure to delete from Translation Memory?')) { __TriggerEvent('deletestring', true, 'xDelStringID', '".$str->GetStringID()."'); }\">Del</a>");
00301                 }
00302 
00303                 echo("</td>");
00304                 echo("</tr>\n");
00305         }
00306         if($addHeader)
00307         {
00308                 // No strings for this project: "next" buttons only
00309                 ?>
00310                 <p>There are no strings in the current project.</p>
00311                 Find strings: <input class="button" type="button" onclick="__TriggerEvent('next', true);" value="Next" />
00312                 <button class="button" type="button" onclick="__TriggerEvent('nextmissing', true);" accesskey="n"><u>N</u>ext missing</button>
00313                 <?
00314                 
00315                 // Deletion of empty and dead projects
00316                 $backend->ChildProjects->rewind();
00317 
00318                 if($backend->RootLastSeen > $backend->LocatedProjects[0]->GetLastSeen() &&
00319                         !$backend->ChildProjects->valid())
00320                 {
00321                         echo("<p>The <em>".$backend->LocatedProjects[0]->GetName()."</em> is an empty and dead project. ");
00322                         echo("<input class=\"button\" type=\"button\" onclick=\"javascript:if(confirm('Are you sure to delete from Translation Memory?')) { __TriggerEvent('deleteproject', false, 'xDelProjectID', '". $backend->LocatedProjects[0]->GetID()."'); }\" value=\"Delete project\"/></p>");
00323                 }
00324 
00325         }
00326         else
00327         {
00328                 echo("</table>");
00329         }
00330         ?></div><?
00331 }
00332 
00333 $sel = " selected=\"selected\"";
00334 ?>      <h1>Search</h1><a name="searchresults"></a>
00335 
00336         <!-- *** CUSTOM SEARCH BOX *** -->
00337 
00338 <p>
00339 <select name="ddlSearchType" id="ddlSearchType">
00340 <option value="0"<? echo ($backend->ddlSearchType == 0 ? $sel : ""); ?>>Word index</option>
00341 <option value="1"<? echo ($backend->ddlSearchType == 1 ? $sel : ""); ?>>Part in original</option>
00342 <option value="2"<? echo ($backend->ddlSearchType == 2 ? $sel : ""); ?>>Part in translation</option>
00343 </select>
00344 <a href="javascript:clearFindText();">clear></a>
00345 <input type="text"  size="35" id="txtFindText" name="txtFindText" value="<? echo FixQuot( $backend->txtFindText); ?>">
00346 <input class="button" type="button" value="Find" onclick="__TriggerEvent('find', true);"/>
00347 <!-- input class="button" type="button" value="Original"/--></p>
00348 
00349 
00350         <!-- *** SEARCH RESULTS *** -->
00351 
00352 
00353 <?
00354 // Show search results if there is any!
00355 if(!empty($backend->Translations))
00356 {
00357         $accessKey = 1;
00358         ?>
00359         <table class="guesses">
00360         <tr><th></th>
00361         <th>Match</th>
00362         <th>Original string</th>
00363         <?
00364         if(!empty($backend->LocatedString))
00365         {
00366                 echo("<th>alt</th>");
00367         }
00368         ?>
00369         <th>Translated string (take by click)</th>
00370         <th>Action</th></tr>
00371         <?
00372 
00373         foreach($backend->Translations as $id => $tr)
00374         {
00375                 foreach($tr["strings"] as $key => $str)
00376                 {
00377                         // Selected color or normal table row
00378                         if(!empty($backend->LocatedString) && $backend->LocatedString->GetStringID() == $str->GetStringID())
00379                         {
00380                                 echo("<tr id=\"tr_search_".$str->GetStringID()."\" class=\"selected\">");
00381                         }
00382                         else
00383                         {
00384                                 echo("<tr id=\"tr_search_".$str->GetStringID()."\">");
00385                         }
00386 
00387                         // Checkbox column
00388                         echo("<td class=\"guess-checkbox\">");
00389                         if($backend->RootLastSeen <= $str->GetLastSeen())
00390                         {
00391                                 echo(" <input type=\"checkbox\" name=\"chkSearchSelects[]\" value=\"".$str->GetStringID()."\"/>");
00392                         }
00393                         echo("</td>");
00394 
00395                         // Percent column
00396                         echo("<td class=\"guess-percent\">");
00397                         if($backend->ddlSearchType == 0)
00398                         {
00399                                 // Exact match? (Not only 100%, word index match, but same string.)
00400                                 if(!empty($backend->LocatedString) && $backend->LocatedString->GetOriginal() == $str->GetOriginal()) {
00401                                         echo("<b>identical</b>");
00402                                 }
00403                                 else
00404                                 {
00405                                         echo($tr["percent"]."%");
00406                                         echo(" <a id=\"diffLink_".$str->GetStringID()."\" href=\"javascript:diffToOriginal(".$str->GetStringID().");\">(?)</a>");
00407                                 }
00408                         }
00409                         echo("</td>");
00410 
00411                         // String columns
00412                         echo("<td id=\"original_".$str->GetStringID()."\" class=\"guess-original\">".FixQuot($str->GetOriginal())."</td>");
00413                         
00414                         // Add "Take string" link if editing one, no link otherwise
00415                         if(!empty($backend->LocatedString))
00416                         {
00417                                 // Accesskey 1-9
00418                                 echo("<td class=\"guess-accesskey\">");
00419                                 if($accessKey < 10 && $str->GetTranslation() != "")
00420                                 {
00421                                         echo("<a accesskey=\"$accessKey\" href=\"javascript:takeTranslation(".$str->GetStringID().");\"><span class=\"underunder\">$accessKey</span></a>");
00422                                         $accessKey++;
00423                                 }
00424                                 echo("</td>");
00425 
00426                                 // Translation with take link
00427                                 echo("<td class=\"guess-translated\">");
00428                                 echo("<a id=\"results_".$str->GetStringID()."\" href=\"javascript:takeTranslation(".$str->GetStringID().");\">".FixQuot($str->GetTranslation())."</a>");
00429                                 echo("</td>");
00430                         }
00431                         else
00432                         {
00433                                 // Not pickable translation
00434                                 echo("<td class=\"guess-translated\">");
00435                                 echo(FixQuot($str->GetTranslation()));
00436                                 echo("</td>");
00437                         }
00438                         
00439                         echo("<td class=\"guess-action\">");
00440 
00441                         // Edit link (for dead strings too, to identify them)
00442                         echo("<a href=\"javascript:__TriggerEvent('editstring', true, 'xStringID', '".$str->GetStringID()."');\">Edit</a>");
00443                         
00444                         // Dead string?
00445                         if($backend->RootLastSeen > $str->GetLastSeen())
00446                         {
00447                                 // Plus sign and Del link
00448                                 echo " +++ ";
00449                                 echo("<a href=\"javascript:if(confirm('Are you sure to delete from Translation Memory?')) { __TriggerEvent('deletestring', true, 'xDelStringID', '".$str->GetStringID()."'); }\">Del</a>");
00450                         }
00451                         else
00452                         {
00453                                 // Not dead, "push" to stack link
00454                                 echo(" | <a href=\"javascript:pushToStack('".$str->GetStringID()."');\">push</a>");
00455                         }
00456                         echo("</td></tr>\n");
00457                 }
00458         }
00459         ?></table><?
00460         if($backend->ddlSearchType != 0)
00461         {
00462                 echo("Displayed ".count($backend->Translations)." results.<br/>");
00463         }
00464 }
00465 ?>
00466 
00467         <!-- *** SEARCH REFRESH CONTROLS *** -->
00468 
00469 <select name="ddlFindPercent">
00470 <?
00471 foreach(array(30,40,50,60,70,80,90) as $percent)
00472 {
00473         $sel = "";
00474         if($backend->ddlFindPercent == $percent)
00475         {
00476                 $sel = " selected=\"selected\"";
00477         }
00478         echo "<option value=\"$percent\"$sel>&gt; $percent%</option>";
00479 }
00480 ?>
00481 </select>
00482 (<input type="checkbox"> Ignore dead strings)
00483 <input type="button" value="Refresh" class="button" onclick="__TriggerEvent('find', true);"/><br/>
00484 
00485 </td>
00486 
00487 </tr>
00488 </table>
00489 <div class="localeswitch">
00490 <?
00491         echo "<select name=\"ddlLocaleID\">\n";
00492         foreach(TranslationProject::$LocaleIDCache as $name => $id)
00493         {
00494                 $sel = "";
00495                 if($backend->ddlLocaleID == $id)
00496                 {
00497                         $sel = " selected=\"selected\"";
00498                 }
00499                 echo "<option value=\"$id\"$sel>$name</option>\n";
00500         }
00501         echo "</select>\n";
00502 ?>
00503 <input type="button" value="Switch Locale" class="button" onclick="__TriggerEvent('setlocale', true);"/> |
00504 
00505 <? if($CONFIG['enable_web_export']) { ?>
00506 <input type="button" value="Export language pack" class="button" onclick="__TriggerEvent('exportpack', true);"/> |
00507 <? } ?>
00508 
00509 <a href="http://xartm.xaraya.hu">Homepage</a> | (c) 2006 Ferenc 'Lion/Kempelen' Veres
00510 </div>
00511 </form>
00512 
00513 <script type="text/javascript">
00514 
00515 /* EVENT SYSTEM FUNCTIONS */
00516 
00517 // Clear eventhandler
00518 document.getElementById('__Event').value = ''; 
00519 document.getElementById('__Form').onsubmit = __FormSubmit(); 
00520 
00521 // Set default Event for plain submit
00522 function __FormSubmit()
00523 {
00524         if(document.getElementById('__Event').value == '')
00525         {
00526                 document.getElementById('__Event').value = 'find';
00527         }
00528 }
00529 // Trigger the specified event, fill hidden variables with name,value pairs from variable args list.
00530 function __TriggerEvent(event, confirmEvent, args)
00531 {
00532         // If field changed, confirm wanted, and not confirmed: cancel operation
00533         if(document.getElementById('htmlEditorChanged').value == "1" &&
00534                 confirmEvent &&
00535                 !confirm("Discard current editing?"))
00536         {
00537                 return;
00538         }
00539 
00540         // Copy custom arguments to object values (the only supported method)
00541         for(i=2;i<arguments.length;i+=2)
00542         {
00543                 document.getElementById(arguments[i]).value = arguments[i+1];
00544         }
00545         document.getElementById('__Event').value = event;
00546         document.getElementById('__Form').submit();
00547 }
00548 
00549 /* EDITING FUNCTIONS */
00550 
00551 // Copy a translation from the search results to current editor
00552 function takeTranslation(stringID)
00553 {
00554         translation = document.getElementById('results_' + stringID).innerHTML;
00555         
00556         // Fix some entities and such
00557         translation = fixHtmlTags(translation);
00558 
00559         document.getElementById('txtEditString_<? echo $backend->xBrowserHelper ?>').value = translation;
00560         editorChanged();
00561 
00562         // Move focus and window to editor
00563         window.scroll(0,0);
00564         var txtEditString = document.getElementById('txtEditString_<? echo $backend->xBrowserHelper; ?>');
00565         txtEditString.focus();
00566         
00567 }
00568 
00569 // Fix some entities and such things when picking string from TD contents
00570 function fixHtmlTags(str)
00571 {
00572         str = str.replace(/\n/g, " ");
00573         str = str.replace(/\&gt;/g, ">");
00574         str = str.replace(/\&lt;/g, "<");
00575         str = str.replace(/\&amp;/g, "&");
00576         
00577         return str;
00578 }
00579 
00580 // Show or hide the strings table.
00581 function toggleStrings()
00582 {
00583         if(document.getElementById('divStrings').style.display == 'none')
00584         {
00585                 document.getElementById('divStrings').style.display = 'block';
00586         }
00587         else
00588         {
00589                 document.getElementById('divStrings').style.display = 'none';
00590         }
00591 }
00592 
00593 // Called when user types in some translation, to confirm losing it.
00594 function editorChanged()
00595 {
00596         document.getElementById('htmlEditorChanged').value = "1";
00597 }
00598 
00599 // Clear the search box
00600 function clearFindText()
00601 {
00602         document.getElementById('txtFindText').value = "";
00603 }
00604 
00605 // Show DIFF-erences to the original string from a picked one
00606 function diffToOriginal(stringID)
00607 {
00608         // Compare to this
00609         var testedString = fixHtmlTags(document.getElementById('original_' + stringID).innerHTML);
00610 
00611         // This is the original (if found while displaying search results!)
00612         var masterString = document.getElementById('htmlOriginalString').value;
00613         if(masterString == "")
00614         {
00615                 alert("There is no current string selected to comapre to.");
00616                 return;
00617         }
00618 
00619         document.getElementById('original_' + stringID).innerHTML = StringDiff(masterString, testedString);
00620         document.getElementById('diffLink_' + stringID).innerHTML = "";
00621 }
00622 
00623 /*
00624 function togglekSearchSelection(chkChecker, stringID)
00625 {
00626         if(chkChecker.checked)
00627         {
00628                 document.getElementById('tr_search_' + stringID).style.backgroundColor = "#cccccc";
00629         } 
00630         else
00631         {
00632                 document.getElementById('tr_search_' + stringID).style.backgroundColor = "transparent";
00633         }
00634 }
00635 */
00636 
00637 /* STACK RELATED FUNCTIONS */
00638 
00639 // Push current string id to the stack for later editing
00640 function pushToStack(stringID)
00641 {
00642         var stackVar = document.getElementById('xStringStack');
00643         if(stackVar.value != "")
00644         {
00645                 stackVar.value += ",";
00646         }
00647         stackVar.value += stringID;
00648         
00649         // Update the stack number list view
00650         showStack();
00651 
00652 }
00653 
00654 // Pop the latest string ID from the stack for editing now
00655 function popFromStack()
00656 {
00657         var stringVar = document.getElementById('xStringID');
00658         var stackVar = document.getElementById('xStringStack');
00659         
00660         if(stackVar.value.length == 0)
00661         {
00662                 alert("String stack is emtpy.");
00663                 return;
00664         }
00665 
00666         // Take next or one entry from stack with regexps
00667         rx1 = new RegExp('^\(.*\),\([0-9]+\)$'); // multiple values with comma
00668         rx2 = new RegExp('^\([0-9]+\)$'); // one single value
00669         if(stackVar.value.match(rx1))
00670         {
00671                 // Multiple values
00672                 var newID = stackVar.value.replace(rx1, "$2");
00673                 var newStack = stackVar.value.replace(rx1, "$1");
00674         }
00675         else if(stackVar.value.match(rx2))
00676         {
00677                 // One single ID in stack
00678                 var newID = stackVar.value;
00679                 var newStack = "";
00680         }
00681         
00682         if(confirm("Take " + newID + " out from stack and edit?"))
00683         {
00684                 __TriggerEvent('editstring', true, 'xStringID', newID, 'xStringStack', newStack);
00685         }
00686 }
00687 
00688 // Clear stack contents
00689 function clearStack()
00690 {
00691         var stackVar = document.getElementById('xStringStack');
00692                 
00693         if(stackVar.value.length == 0)
00694         {
00695                 alert("String stack is emtpy.");
00696                 return;
00697         }
00698 
00699 
00700         if(confirm("Clear stack?"))
00701         {
00702                 stackVar.value = "";
00703                 showStack();
00704         }
00705         
00706 }
00707 
00708 // Display stack info next to the buttons
00709 function showStack()
00710 {
00711         // Get stack, mark page load time part, remove last comma, add spaces for linebreaking
00712         var stackVar = document.getElementById('xStringStack');
00713         var pageLoadStack = document.getElementById('htmlPageLoadStack');
00714         rx = new RegExp("\(^" + pageLoadStack.value + "\)");
00715         stackString = stackVar.value;
00716         stackString = stackString.replace(rx, '<span class="oldstack">$1</span>');
00717         stackString = stackString.replace(/,/g,", ");
00718 
00719         // Display it
00720         var stackView = document.getElementById('plhStackView');
00721         stackView.innerHTML = stackString;
00722 
00723         // Enable/Disable the "save+pop" and "Save to all stack" buttons
00724         var btnSavePop = document.getElementById('btnSavePopStack');
00725         if(btnSavePop)
00726         {
00727                 if(stackVar.value != "")
00728                 {
00729                         btnSavePop.disabled = false;
00730                         btnSavePop.className = "button";
00731                 }
00732                 else
00733                 {
00734                         btnSavePop.disabled = true;
00735                         btnSavePop.className = "button-disabled";
00736                 }
00737         }
00738 }
00739 
00740 // Call the save current string to all stacked IDs function if confirmed and valid
00741 function callSaveToAllStack()
00742 {
00743         stackVar = document.getElementById('xStringStack');
00744         
00745         if(stackVar.value.length == 0)
00746         {
00747                 alert("String stack is emtpy.");
00748                 return;
00749         }
00750         
00751         if(confirm("Operation will OVERWRITE all strings in the stack and current string!"))
00752         {
00753                 __TriggerEvent('savetoallstack', false);
00754         }
00755 }
00756 
00757 // Display the stack values on page load
00758 showStack();
00759 
00760 <? if(!empty($backend->LocatedString))
00761 {
00762 ?>
00763         var txtEditString = document.getElementById('txtEditString_<? echo $backend->xBrowserHelper; ?>');
00764         txtEditString.focus();
00765 <?
00766 }
00767 ?>
00768 
00769 </script>
00770 
00771 </body>
00772 </html>

Generated on Tue Mar 20 00:42:40 2007 for XarayaTranslationMemory by  doxygen 1.4.7