Html程序  |  83行  |  2.18 KB

<!DOCTYPE html>
<html>
<head>

<script>
function addRow(name, url, isdir, size, date_modified) {
  if (name == ".")
    return;

  var root = "" + document.location;
  if (root.substr(-1) !== "/")
    root += "/";

  var table = document.getElementById("table");
  var row = document.createElement("tr");
  var file_cell = document.createElement("td");
  var link = document.createElement("a");
  if (name == "..") {
    link.href = root + "..";
    link.innerText = document.getElementById("parentDirText").innerText;
    size = "";
    date_modified = "";
  } else {
    if (isdir) {
      name = name + "/";
      url = url + "/";
      size = "";
    }
    link.innerText = name;
    link.href = root + url;
  }
  file_cell.appendChild(link);

  row.appendChild(file_cell);
  row.appendChild(createCell(size));
  row.appendChild(createCell(date_modified));

  table.appendChild(row);
}

function createCell(text) {
  var cell = document.createElement("td");
  cell.setAttribute("class", "detailsColumn");
  cell.innerText = text;
  return cell;
}

function start(location) {
  var header = document.getElementById("header");
  header.innerText = header.innerText.replace("LOCATION", location);

  document.getElementById("title").innerText = header.innerText;
}

function onListingParsingError() {
  var box = document.getElementById("listingParsingErrorBox");
  box.innerHTML = box.innerHTML.replace("LOCATION", document.location + "?raw");
  box.style.display = "";
}
</script>

<title id="title"></title>
<style>
  h1 { white-space: nowrap; }
  td.detailsColumn { text-align: right; padding-left: 30px; white-space: nowrap; }
  #listingParsingErrorBox { border: 1px solid black; background: #fae691; padding: 10px; display: none }
</style>
</head>
<body>
<div id="listingParsingErrorBox" i18n-values=".innerHTML:listingParsingErrorBoxText"></div>
<span id="parentDirText" style="display:none" i18n-content="parentDirText"></span>
<h1 id="header" i18n-content="header"></h1>
<hr/>
<table id="table">
<tr style="font-weight: bold">
 <td i18n-content="headerName"></td>
 <td class="detailsColumn" i18n-content="headerSize"></td>
 <td class="detailsColumn" i18n-content="headerDateModified"></td>
</tr>
</table>
</body>
</html>