Code Search for Developers
 
 
  

check_spelling.html from AlphaMail at Krugle


Show check_spelling.html syntax highlighted

% # vim:set syntax=mason:
<& /mail/header.mhtml, title => "Spell check" &>
% if($user->getAttribute('dom_edit')) { 
   <script type="text/javascript" language="javascript">
      <!--
      // Change the select to an edit box if the user desires
      function morph(id)
      {
         var sp = document.getElementById(id);
         var sel = sp.firstChild;
         var val = sel.item(sel.selectedIndex).value;
         if(val == "Edit...") {
            var ed = document.createElement("INPUT");
            ed.setAttribute("name", id);
            ed.setAttribute("type", "text");
            ed.setAttribute("value", sel.item(0).value);
            ed.setAttribute("size", sel.item(0).value.length+2);
            sp.replaceChild(ed, sel);
            // Safari hack
            sp.style.width = "1px";
            ed.focus();
         }
      }
      // -->
   </script>
% }
   <form method="post" action="<% $base %>/mail/fix_spelling.html" enctype="multipart/form-data">
      <div class="controls">
         <input type="submit" name="spellcheck" value="Fix and return to compose"> 
      </div>
      <table class="composition_form">
         <tr>
            <td class="composition_field_label">
               <div class="composition_field_label">
                  To:
               </div>
            </td>
            <td>
               <div class="noneditable">
                  <% $to |h %>&nbsp;
               </div>
            </td>
         </tr>
         <tr>
            <td class="composition_field_label">
               <div class="composition_field_label">
                  Cc:
               </div>
            </td>
            <td>
               <div class="noneditable">
                  <% $cc |h %>&nbsp;
               </div>
            </td>
         </tr>
         <tr>
            <td class="composition_field_label">
               <div class="composition_field_label">
                  Bcc:
               </div>
            </td>
            <td>
               <div class="noneditable">
                  <% $bcc |h %>&nbsp;
               </div>
            </td>
         </tr>
         <tr>
            <td class="composition_field_label">
               <div class="composition_field_label">
                  Subject:
               </div>
            </td>
            <td>
               <div class="noneditable">
                  <% $subject |h %>&nbsp;
               </div>
            </td>
         </tr>
         <tr>
            <td colspan="2">
               <div class="noneditable">
% for my $l (@lines) {
<% $l %><br>
% }
&nbsp;
               </div>
            </td>
         </tr>
      </table>
      <div class="controls">
         <input type="submit" name="spellcheck" value="Fix and return to compose"> 
% if(@$attachments) {
         <p>Current attachments:
%    for(my $i =0; $i < @{$attachments}; $i++) {
               <% mimewords_to_utf8($attachments->[$i]{filename}) |h %> (<% $attachments->[$i]{size} %> bytes),
%    }
% }
      </div>
   </form>
<& /mail/footer.mhtml &>
<%init>
my $user = Apache2::SiteControl->getCurrentUser($r);
my $username = $user->getUsername();
my $error = 0;

$logger->debug("Beginning a spell check");
my $composition = new AlphaMail::Message($user, $config);
$composition->load();

my $body = $composition->getBody();
$m->redirect(build_url("$base/mail/compose.html", {message => 'nothing to check.'})) if(!$body || $body !~ m/[[:ascii:]]/);

my ($to, $cc, $bcc) = $composition->getAddresses();
my $subject = $composition->getSubject();
my $attachments = $composition->getAttachments();

my (@lines, $i, $s, $e, $v, @nearmisses, @fixes, $html, $box, $word);

@lines = split /\r?\n/, $body;
for($i = 0; $i <= $#lines && $i < 4000; $i++) {
   $logger->debug("i: $i, lines: " . scalar(@lines));
   $v = $lines[$i];
   chomp $v;
   @fixes = ();
   # Find the mistakes
   while(scalar($v =~ m"(\b[a-z][-a-z']*[a-z]\b)"ig)) {
      $word = $1;
      $s = pos($v) - length($word);
      $e = pos($v) - 1;
      if(!$speller->check($word)) {
         @nearmisses = $speller->suggest($word);
         push @fixes, { a => $s, b => $e, word => $word, corrections => [ @nearmisses ] };
      } 
   }

   # Create the HTML correction selection stuff
   @fixes = sort { $b->{a} <=> $a->{a} } @fixes;
   my $html = $v;
   for my $fix (@fixes) 
   {
      my $box;
      my $cname = "c_${i}_$fix->{a}_$fix->{b}";
      $box = qq(<span id="$cname"><select name="$cname" onChange="morph('$cname')">);
      $box .= qq(<option value="$fix->{word}">$fix->{word}</option>);
      for my $c (@{$fix->{corrections}}) {
         $box .= qq(\t<option value="$c">$c</option>);
      }
      if(!$user->getAttribute('dom_edit')) {
         $box .= qq(<option value="FIX: $fix->{word}">FIX:$fix->{word}</option>) 
      } else {
         $box .= qq(<option value="Edit...">Edit...</option>) 
      }
      $box .= qq(</select></span>);
      $html = substr($html, 0, $fix->{a}) . $box . substr($html, $fix->{b}+1,length($html) - $fix->{b});
   }
   $lines[$i] = $html;
}
</%init>
<%once>
use AlphaMail::MailTool qw(mimewords_to_utf8);
use AlphaMail::HTMLHelper qw(build_url);
our $logger = Log::Log4perl->get_logger('alphamail');
our $base = $config->get('base_uri');
</%once>




See more files for this project here

AlphaMail

AlphaMail is an accelerated web mail interface with a C++ middleware layer that is more effective than an IMAP proxy which is a highly scalable (10k+ users). The interface includes modern features, Section 508 compliance, and universal browser support.

Project homepage: http://sourceforge.net/projects/alphamail
Programming language(s): C++,Java,JavaScript,Perl
License: other

  addressbook/
    edit.mhtml
    import.mhtml
    import_complete.html
    import_csv.html
    import_csv_save.html
    import_fname.html
    import_imho.html
    import_lname.html
    index.html
    lists.mhtml
    process_edit.html
    process_lists.html
    process_take.html
    take.html
  admin/
    autohandler
    index.html
    show_stats.mhtml
    test.mhtml
  docs/
    faq/
      colors.gif
      dates1.gif
      drafts.gif
      filter.gif
      general.html
      index.html
      notrash1.gif
      notrash2.gif
      notrash3.gif
      other.html
      sort.gif
      timeout.gif
    new_features.html
  settings/
    add_filter.html
    altfolder_update.html
    altprefix_update.html
    edit_folders.html
    export.mhtml
    export_mail.html
    filters.mhtml
    folders.mhtml
    general.mhtml
    index.html
    share.mhtml
    sharing_agree.html
    signatures.mhtml
    update_folderlist.html
    update_general.html
    update_signatures.html
  viewers/
    excel.html
    html.html
    targz.html
    text.html
    word.html
    zip.html
  address_mail.html
  addresslist.html
  autohandler
  check_spelling.html
  compose.html
  feedback.html
  first_login.html
  fix_spelling.html
  folderlist.mhtml
  footer.mhtml
  get_attachment.html
  header.mhtml
  help.html
  index.html
  logout.html
  menu.mhtml
  other_folders.html
  process_compose.html
  process_first_login.html
  process_messages.html
  process_read_message.html
  process_search.html
  quota.html
  quota_graph.html
  raw.html
  read.html
  remove_attachment.html
  renew_session.html
  resume_compose.html
  sanitized.html
  share_options.html
  share_upload.html
  verify_password.html
  view_attachment.html