[freeside-commits] freeside/httemplate/elements file-upload.html, NONE, 1.1 header-minimal.html, NONE, 1.1

Jeff Finucane,420,, jeff at wavetail.420.am
Tue Apr 15 13:47:59 PDT 2008


Update of /home/cvs/cvsroot/freeside/httemplate/elements
In directory wavetail.420.am:/tmp/cvs-serv11472/httemplate/elements

Added Files:
	file-upload.html header-minimal.html 
Log Message:
(finally) wrap up new tax rate engine (for now)

--- NEW FILE: header-minimal.html ---
%
%  my($title, $menubar) = ( shift, shift ); #$menubar is unused here though
%  my $etc = @_ ? shift : ''; #$etc is for things like onLoad= etc.
%  my $head = @_ ? shift : ''; #$head is for things that go in the <HEAD> section
%  my $conf = new FS::Conf;
%

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
  <HEAD>
    <TITLE>
      <% $title %>
    </TITLE>
    <META HTTP-Equiv="Cache-Control" Content="no-cache">
    <META HTTP-Equiv="Pragma" Content="no-cache">
    <META HTTP-Equiv="Expires" Content="0"> 
    <% $head %>
  </HEAD>
  <BODY BGCOLOR="#e8e8e8" <% $etc %>>

--- NEW FILE: file-upload.html ---

<script type="text/javascript">

  function doUpload(form, callback) {
    var name = 'form' + Math.floor(Math.random() * 99999); // perlize?
    var d = document.createElement('DIV');
    d.innerHTML = '<iframe style="display:none" src="about:blank" id="'+name+'" name="'+name+'" onload="uploadComplete(\''+name+'\')"></iframe>';
    document.body.appendChild(d);

    var i = document.getElementById(name);
    if (callback && typeof(callback) == 'function') {
      i.onComplete = callback;
    }

    form.setAttribute('target', name);
    return true;
  }

  function uploadComplete(id) {
    var i = document.getElementById(id);
    if (i.contentDocument) {
      var d = i.contentDocument;
    } else if (i.contentWindow) {
      var d = i.contentWindow.document;
    } else {
      var d = window.frames[id].document;
    }
    if (d.location.href == "about:blank") {
      return;
    }

    document.getElementById('r').innerHTML = d.body.innerHTML;
    if (typeof(i.onComplete) == 'function') {
      var p;
      if (p = d.body.innerHTML.indexOf("Freeside File Upload Successful ") >= 0) {
        var v = d.body.innerHTML.substr(p+33)
        var u = document.getElementById('uploaded_files');
        v = v.substr(0, v.indexOf(';'));
        u.value = v;
        i.onComplete(true, '');
      }else{
        i.onComplete(false, d.body.innerHTML);
      }
    }
  }

</script>

    <input type="hidden" name="uploaded_files" id="uploaded_files" value="" />
    <input type="hidden" name="upload_fields" value="<% join(',', @field) %>" />
% foreach (@field) {
    <tr>
      <th><% shift @label %></th>
      <td><input type="file" name="<% $_ %>" /></td>
    </tr>
% }
  <div style="display:<% $debug ? 'visible' : 'none' %>">Debugging: <pre id="r"></pre></div>

<%init>
my %param = @_;

my $debug = $param{'debug'};

my $callback = $param{'callback'} || "''";

my @label = ();
if ( ref($param{'label'}) ) {
  push @label, @{$param{'label'}};
}else{
  push @label, $param{'label'};
}

my @field = ();
if ( ref($param{'field'}) ) {
  push @field, @{$param{'field'}};
}else{
  push @field, $param{'field'};
}

</%init>



More information about the freeside-commits mailing list