});
});
}
+
+/**
+ * Fires off an AJAX request to retrieve the current status of a Sone.
+ *
+ * @param soneId
+ * The ID of the Sone
+ */
+function getSoneStatus(soneId) {
+ $.getJSON("ajax/getSoneStatus.ajax", {"sone": soneId}, function(data, textStatus) {
+ updateSoneStatus(soneId, data.status, data.modified, data.lastUpdated);
+ /* seconds! */
+ updateInterval = 60;
+ if (data.age < 600) {
+ updateInterval = 5;
+ } else if (data.age < 86400) {
+ updateInterval = 30;
+ }
+ setTimeout(function() {
+ getSoneStatus(soneId);
+ }, updateInterval * 1000);
+ });
+}
+
+/**
+ * Updates the status of the given Sone.
+ *
+ * @param soneId
+ * The ID of the Sone to update
+ * @param status
+ * The status of the Sone (“idle”, “unknown”, “inserting”,
+ * “downloading”)
+ * @param modified
+ * Whether the Sone is modified
+ * @param lastUpdated
+ * The date and time of the last update (formatted for display)
+ */
+function updateSoneStatus(soneId, status, modified, lastUpdated) {
+ $("#sone .sone#" + soneId).
+ toggleClass("unknown", status == "unknown").
+ toggleClass("idle", status == "idle").
+ toggleClass("inserting", status == "inserting").
+ toggleClass("downloading", status == "downloading").
+ toggleClass("modified", modified);
+ $("#sone .sone#" + soneId + " .last-update span.time").text(lastUpdated);
+}
+
+var watchedSones = {};
+
+/**
+ * Watches this Sone for updates to its status.
+ *
+ * @param soneId
+ * The ID of the Sone to watch
+ */
+function watchSone(soneId) {
+ if (watchedSones[soneId]) {
+ return;
+ }
+ watchedSones[soneId] = true;
+ (function(soneId) {
+ setTimeout(function() {
+ getSoneStatus(soneId);
+ }, 5000);
+ })(soneId);
+}
<script src="javascript/sone.js" language="javascript"></script>
<script language="javascript">
+ /* this initializes the status update input field. */
$(document).ready(function() {
registerInputTextareaSwap("#sone #update-status .status-input", "WebInterface.DefaultText.StatusUpdate", "text", false);
});
</script>
+ <script language="javascript">
+ /* these functions are necessary for updating Sone statuses. */
+ $(document).ready(function() {
+ $("#sone .sone").each(function() {
+ watchSone($(this).attr("id"));
+ });
+ });
+ </script>
+
+ <script language="javascript">
+ /* this initializes all reply input fields. */
+ $(document).ready(function() {
+ registerInputTextareaSwap("#sone input.reply-input", "WebInterface.DefaultText.Reply", "text", false);
+ addCommentLinks();
+ });
+ </script>
+
<div id="main">
<div id="profile" class="<%ifnull currentSone>offline<%else>online<%/if>">
-<script language="javascript">
-
- function getStatus(soneId) {
- $.getJSON("ajax/getSoneStatus.ajax", {"sone": soneId}, function(data, textStatus) {
- updateStatus(soneId, data.status, data.modified, data.lastUpdated);
- /* seconds! */
- updateInterval = 60;
- if (data.age < 600) {
- updateInterval = 5;
- } else if (data.age < 86400) {
- updateInterval = 30;
- }
- setTimeout(function() {
- getStatus(soneId);
- }, updateInterval * 1000);
- });
- }
-
- function updateStatus(soneId, status, modified, lastUpdated) {
- $("#sone .sone#" + soneId).
- toggleClass("unknown", status == "unknown").
- toggleClass("idle", status == "idle").
- toggleClass("inserting", status == "inserting").
- toggleClass("downloading", status == "downloading").
- toggleClass("modified", modified);
- $("#sone .sone#" + soneId + " .last-update span.time").text(lastUpdated);
- }
-
- registeredSones = {};
-
- $(document).ready(function() {
- $("#sone .sone").each(function() {
- soneId = $(this).attr("id");
- if (registeredSones[soneId]) {
- return;
- }
- registeredSones[soneId] = true;
- (function(soneId) {
- setTimeout(function() {
- getStatus(soneId);
- }, 5000);
- })(soneId);
- });
- });
-</script>
-
<div id="<% sone.id|html>" class="sone <% sone.status|html><%if sone.modified> modified<%/if>">
<div class="unknown-marker" title="<%= View.Sone.Status.Unknown|l10n|html>">?</div>
<div class="modified-marker" title="<%= View.Sone.Status.Modified|l10n|html>">!</div>
<%include include/head.html>
- <script language="javascript">
- /* register input field/textarea swap. */
- $(document).ready(function() {
- registerInputTextareaSwap("#sone input.reply-input", "WebInterface.DefaultText.Reply", "text", false);
- addCommentLinks();
- });
- </script>
-
<h1><%= Page.Index.PostList.Title|l10n|html></h1>
<div id="posts">
<%include include/head.html>
- <script language="javascript">
- $(document).ready(function() {
- addCommentLinks();
- });
- </script>
-
<%ifnull sone.name>
<h1><%= Page.ViewSone.Page.TitleWithoutSone|l10n|html></h1>