Alexander Afanasyev | 3c95c85 | 2013-03-01 18:58:50 -0800 | [diff] [blame] | 1 | $.Class ("ChronoShare", { }, |
| 2 | { |
| 3 | init: function (username, foldername) { |
| 4 | $("#folder-name").text (foldername); |
| 5 | $("#user-name").text (username); |
Alexander Afanasyev | 46bd806 | 2013-02-27 23:59:15 -0800 | [diff] [blame] | 6 | |
Alexander Afanasyev | 3c95c85 | 2013-03-01 18:58:50 -0800 | [diff] [blame] | 7 | this.username = new Name (username); |
| 8 | this.files = new Name ("/localhost").add (this.username).add ("chronoshare").add (foldername).add ("info").add ("files").add ("folder"); |
Alexander Afanasyev | 46bd806 | 2013-02-27 23:59:15 -0800 | [diff] [blame] | 9 | |
Alexander Afanasyev | 3c95c85 | 2013-03-01 18:58:50 -0800 | [diff] [blame] | 10 | this.actions = new Name ("/localhost").add (this.username).add ("chronoshare").add (foldername).add ("info").add ("actions"); |
Alexander Afanasyev | 46bd806 | 2013-02-27 23:59:15 -0800 | [diff] [blame] | 11 | |
Alexander Afanasyev | 3c95c85 | 2013-03-01 18:58:50 -0800 | [diff] [blame] | 12 | this.restore = new Name ("/localhost").add (this.username).add ("chronoshare").add (foldername).add ("cmd").add ("restore").add ("file"); |
Alexander Afanasyev | 46bd806 | 2013-02-27 23:59:15 -0800 | [diff] [blame] | 13 | |
Alexander Afanasyev | 3c95c85 | 2013-03-01 18:58:50 -0800 | [diff] [blame] | 14 | this.ndn = new NDN ({host:"127.0.0.1"}); |
Alexander Afanasyev | 1663a41 | 2013-03-02 13:52:00 -0800 | [diff] [blame] | 15 | this.ndn.verify = false; //disable content verification, works WAAAAY faster |
Alexander Afanasyev | 3c95c85 | 2013-03-01 18:58:50 -0800 | [diff] [blame] | 16 | }, |
Alexander Afanasyev | 46bd806 | 2013-02-27 23:59:15 -0800 | [diff] [blame] | 17 | |
Alexander Afanasyev | 3c95c85 | 2013-03-01 18:58:50 -0800 | [diff] [blame] | 18 | run: function () { |
| 19 | console.log ("RUN page: " + PAGE); |
| 20 | $("#loader").fadeIn (500); |
| 21 | $("#error").addClass ("hidden"); |
Alexander Afanasyev | 46bd806 | 2013-02-27 23:59:15 -0800 | [diff] [blame] | 22 | |
Alexander Afanasyev | 3c95c85 | 2013-03-01 18:58:50 -0800 | [diff] [blame] | 23 | cmd = {}; |
| 24 | if (PAGE == "fileList") { |
| 25 | cmd = this.info_files (PARAMS.item); |
| 26 | } |
| 27 | else if (PAGE == "folderHistory") { |
| 28 | cmd = this.info_actions ("folder", PARAMS.item); |
| 29 | } |
| 30 | else if (PAGE == "fileHistory") { |
| 31 | cmd = this.info_actions ("file", PARAMS.item); |
| 32 | } |
Alexander Afanasyev | f63a514 | 2013-02-28 02:21:42 -0800 | [diff] [blame] | 33 | |
Alexander Afanasyev | 3c95c85 | 2013-03-01 18:58:50 -0800 | [diff] [blame] | 34 | if (cmd.request && cmd.callback) { |
| 35 | console.log (cmd.request.to_uri ()); |
| 36 | this.ndn.expressInterest (cmd.request, cmd.callback); |
| 37 | } |
| 38 | else { |
| 39 | $("#loader").fadeOut (500); // ("hidden"); |
| 40 | $("#content").empty (); |
| 41 | if (cmd.error) { |
| 42 | $("#error").html (cmd.error); |
| 43 | } |
| 44 | else { |
| 45 | $("#error").html ("Unknown error with " + PAGE); |
| 46 | } |
| 47 | $("#error").removeClass ("hidden"); |
| 48 | } |
| 49 | }, |
Alexander Afanasyev | f63a514 | 2013-02-28 02:21:42 -0800 | [diff] [blame] | 50 | |
Alexander Afanasyev | 3c95c85 | 2013-03-01 18:58:50 -0800 | [diff] [blame] | 51 | info_files: function(folder) { |
| 52 | request = new Name ().add (this.files)./*add (folder_in_question).*/addSegment (PARAMS.offset?PARAMS.offset:0); |
| 53 | return { request:request, callback: new FilesClosure (this) }; |
| 54 | }, |
Alexander Afanasyev | f63a514 | 2013-02-28 02:21:42 -0800 | [diff] [blame] | 55 | |
Alexander Afanasyev | 3c95c85 | 2013-03-01 18:58:50 -0800 | [diff] [blame] | 56 | info_actions: function (type/*"file" or "folder"*/, fileOrFolder /*file or folder name*/) { |
| 57 | if (type=="file" && !fileOrFolder) { |
| 58 | return { error: "info_actions: fileOrFolder parameter is missing" }; |
| 59 | } |
Alexander Afanasyev | f63a514 | 2013-02-28 02:21:42 -0800 | [diff] [blame] | 60 | |
Alexander Afanasyev | 3c95c85 | 2013-03-01 18:58:50 -0800 | [diff] [blame] | 61 | request = new Name ().add (this.actions).add (type); |
| 62 | if (fileOrFolder) { |
| 63 | request.add (fileOrFolder); |
| 64 | } |
| 65 | request.addSegment (PARAMS.offset?PARAMS.offset:0); |
| 66 | return { request: request, callback: new HistoryClosure (this) }; |
| 67 | }, |
Alexander Afanasyev | 46bd806 | 2013-02-27 23:59:15 -0800 | [diff] [blame] | 68 | |
Alexander Afanasyev | 4c17b48 | 2013-03-02 01:32:35 -0800 | [diff] [blame] | 69 | cmd_restore_file: function (filename, version, hash, callback/*function (bool <- data received, status <- returned status)*/) { |
Alexander Afanasyev | 3c95c85 | 2013-03-01 18:58:50 -0800 | [diff] [blame] | 70 | request = new Name ().add (this.restore) |
| 71 | .add (filename) |
| 72 | .addSegment (version) |
| 73 | .add (hash); |
| 74 | console.log (request.to_uri ()); |
Alexander Afanasyev | 4c17b48 | 2013-03-02 01:32:35 -0800 | [diff] [blame] | 75 | this.ndn.expressInterest (request, new CmdRestoreFileClosure (this, callback)); |
Alexander Afanasyev | 3c95c85 | 2013-03-01 18:58:50 -0800 | [diff] [blame] | 76 | } |
| 77 | }); |
Zhenkai Zhu | 5c2475b | 2013-02-26 22:57:31 -0800 | [diff] [blame] | 78 | |
Alexander Afanasyev | 4c17b48 | 2013-03-02 01:32:35 -0800 | [diff] [blame] | 79 | $.Class ("CmdRestoreFileClosure", {}, { |
| 80 | init: function (chronoshare, callback) { |
| 81 | this.chronoshare = chronoshare; |
| 82 | this.callback = callback; |
| 83 | }, |
| 84 | upcall: function(kind, upcallInfo) { |
Alexander Afanasyev | 1663a41 | 2013-03-02 13:52:00 -0800 | [diff] [blame] | 85 | if (kind == Closure.UPCALL_CONTENT || kind == Closure.UPCALL_CONTENT_UNVERIFIED) { //disable content verification |
Alexander Afanasyev | 4c17b48 | 2013-03-02 01:32:35 -0800 | [diff] [blame] | 86 | convertedData = DataUtils.toString (upcallInfo.contentObject.content); |
| 87 | this.callback (true, convertedData); |
| 88 | } |
| 89 | else if (kind == Closure.UPCALL_INTEREST_TIMED_OUT) { |
| 90 | this.callback (false, "Interest timed out"); |
| 91 | } |
| 92 | else { |
| 93 | this.callback (false, "Unknown error happened"); |
| 94 | } |
| 95 | } |
| 96 | }); |
| 97 | |
Alexander Afanasyev | 1663a41 | 2013-03-02 13:52:00 -0800 | [diff] [blame] | 98 | $.Class ("RestPipelineClosure", {}, { |
| 99 | init: function (collectionName, moreName) { |
| 100 | this.collectionName = collectionName; |
| 101 | this.moreName = moreName; |
| 102 | $("#json").empty (); |
| 103 | |
| 104 | this.collection = []; |
Alexander Afanasyev | 46bd806 | 2013-02-27 23:59:15 -0800 | [diff] [blame] | 105 | }, |
| 106 | |
Alexander Afanasyev | fd5e627 | 2013-02-27 20:25:20 -0800 | [diff] [blame] | 107 | upcall: function(kind, upcallInfo) { |
Alexander Afanasyev | 1663a41 | 2013-03-02 13:52:00 -0800 | [diff] [blame] | 108 | if (kind == Closure.UPCALL_CONTENT || kind == Closure.UPCALL_CONTENT_UNVERIFIED) { //disable content verification |
| 109 | |
Alexander Afanasyev | fd5e627 | 2013-02-27 20:25:20 -0800 | [diff] [blame] | 110 | convertedData = DataUtils.toString (upcallInfo.contentObject.content); |
Alexander Afanasyev | c15e016 | 2013-02-28 23:38:52 -0800 | [diff] [blame] | 111 | if (PARAMS.debug) { |
Alexander Afanasyev | 1663a41 | 2013-03-02 13:52:00 -0800 | [diff] [blame] | 112 | $("#json").append ($(document.createTextNode(convertedData))); |
Alexander Afanasyev | c15e016 | 2013-02-28 23:38:52 -0800 | [diff] [blame] | 113 | $("#json").removeClass ("hidden"); |
| 114 | } |
Alexander Afanasyev | fd5e627 | 2013-02-27 20:25:20 -0800 | [diff] [blame] | 115 | data = JSON.parse (convertedData); |
Zhenkai Zhu | 5c2475b | 2013-02-26 22:57:31 -0800 | [diff] [blame] | 116 | |
Alexander Afanasyev | 1663a41 | 2013-03-02 13:52:00 -0800 | [diff] [blame] | 117 | this.collection = this.collection.concat (data[this.collectionName]); |
| 118 | if (data[this.moreName] !== undefined) { |
| 119 | nextSegment = upcallInfo.interest.name.cut (1).addSegment (data[this.moreName]); |
| 120 | console.log ("MORE: " +nextSegment.to_uri ()); |
| 121 | CHRONOSHARE.ndn.expressInterest (nextSegment, this); |
| 122 | } |
| 123 | else { |
| 124 | $("#loader").fadeOut (500); // ("hidden"); |
| 125 | this.onData (this.collection); |
| 126 | } |
| 127 | } |
Alexander Afanasyev | fd5e627 | 2013-02-27 20:25:20 -0800 | [diff] [blame] | 128 | else if (kind == Closure.UPCALL_INTEREST_TIMED_OUT) { |
Alexander Afanasyev | 1663a41 | 2013-03-02 13:52:00 -0800 | [diff] [blame] | 129 | $("#loader").fadeOut (500); // ("hidden"); |
| 130 | this.onTimeout (upcallInfo.interest); |
Alexander Afanasyev | fd5e627 | 2013-02-27 20:25:20 -0800 | [diff] [blame] | 131 | } |
| 132 | else { |
Alexander Afanasyev | 1663a41 | 2013-03-02 13:52:00 -0800 | [diff] [blame] | 133 | $("#loader").fadeOut (500); // ("hidden"); |
| 134 | this.onUnknownError (upcallInfo.interest); |
Alexander Afanasyev | fd5e627 | 2013-02-27 20:25:20 -0800 | [diff] [blame] | 135 | } |
Alexander Afanasyev | 1663a41 | 2013-03-02 13:52:00 -0800 | [diff] [blame] | 136 | |
| 137 | return Closure.RESULT_OK; // make sure we never re-express the interest |
| 138 | }, |
| 139 | |
| 140 | onData: function(data) { |
| 141 | }, |
| 142 | |
| 143 | onTimeout: function () { |
| 144 | $("#error").html ("Interest timed out"); |
| 145 | $("#error").removeClass ("hidden"); |
| 146 | }, |
| 147 | |
| 148 | onUnknownError: function () { |
| 149 | $("#error").html ("Unknown error happened"); |
| 150 | $("#error").removeClass ("hidden"); |
| 151 | } |
| 152 | }); |
| 153 | |
| 154 | // $.Class ("FilesClosure", {}, { |
| 155 | RestPipelineClosure ("FilesClosure", {}, { |
| 156 | init: function (chronoshare) { |
| 157 | this._super("files", "more"); |
| 158 | this.chronoshare = chronoshare; |
| 159 | }, |
| 160 | |
| 161 | onData: function(data) { |
| 162 | tbody = $("<tbody />", { "id": "file-list-files" }); |
| 163 | |
| 164 | /// @todo Eventually set title for other pages |
| 165 | $("title").text ("ChronoShare - List of files" + (PARAMS.item?" - "+PARAMS.item:"")); |
| 166 | |
| 167 | // error handling? |
| 168 | newcontent = $("<div />", { "id": "content" }).append ( |
| 169 | $("<h2 />").append ($(document.createTextNode("List of files ")), $("<green />").text (PARAMS.item)), |
| 170 | $("<table />", { "class": "item-list" }) |
| 171 | .append ($("<thead />") |
| 172 | .append ($("<tr />") |
| 173 | .append ($("<th />", { "class": "filename border-left", "scope": "col" }).text ("Filename")) |
| 174 | .append ($("<th />", { "class": "version", "scope": "col" }).text ("Version")) |
| 175 | .append ($("<th />", { "class": "size", "scope": "col" }).text ("Size")) |
| 176 | .append ($("<th />", { "class": "modified", "scope": "col" }).text ("Modified")) |
| 177 | .append ($("<th />", { "class": "modified-by border-right", "scope": "col" }).text ("Modified By")))) |
| 178 | .append (tbody) |
| 179 | .append ($("<tfoot />") |
| 180 | .append ($("<tr />") |
| 181 | .append ($("<td />", { "colspan": "5", "class": "border-right border-left" }))))); |
| 182 | newcontent.hide (); |
| 183 | |
| 184 | for (var i = 0; i < data.length; i++) { |
| 185 | file = data[i]; |
| 186 | |
| 187 | row = $("<tr />", { "class": "with-context-menu" } ); |
| 188 | if (i%2) { row.addClass ("odd"); } |
| 189 | |
| 190 | row.bind('mouseenter mouseleave', function() { |
| 191 | $(this).toggleClass('highlighted'); |
| 192 | }); |
| 193 | |
| 194 | row.attr ("filename", file.filename); //encodeURIComponent(encodeURIComponent(file.filename))); |
| 195 | row.bind('click', function (e) { openHistoryForItem ($(this).attr ("filename")) }); |
| 196 | |
| 197 | row.append ($("<td />", { "class": "filename border-left" }) |
| 198 | .text (file.filename) |
| 199 | .prepend ($("<img />", { "src": fileExtension(file.filename) }))); |
| 200 | row.append ($("<td />", { "class": "version" }).text (file.version)); |
| 201 | row.append ($("<td />", { "class": "size" }).text (SegNumToFileSize (file.segNum))); |
| 202 | row.append ($("<td />", { "class": "modified" }).text (new Date (file.timestamp+"+00:00"))); // convert from UTC |
| 203 | row.append ($("<td />", { "class": "modified-by border-right"}) |
| 204 | .append ($("<userName />").text (file.owner.userName)) |
| 205 | .append ($("<seqNo> /").text (file.owner.seqNo))); |
| 206 | |
| 207 | tbody = tbody.append (row); |
| 208 | } |
| 209 | |
| 210 | $("#content").fadeOut ("fast", function () { |
| 211 | $(this).replaceWith (newcontent); |
| 212 | $("#content").fadeIn ("fast"); |
| 213 | }); |
| 214 | |
| 215 | $.contextMenu( 'destroy', ".with-context-menu" ); // cleanup |
| 216 | $.contextMenu({ |
| 217 | selector: ".with-context-menu", |
| 218 | items: { |
| 219 | "info": {name: "x", type: "html", html: "<b>File operations</b>"}, |
| 220 | "sep1": "---------", |
| 221 | history: {name: "View file history", |
| 222 | icon: "quit", // need a better icon |
| 223 | callback: function(key, opt) { |
| 224 | openHistoryForItem (opt.$trigger.attr ("filename")); |
| 225 | }}, |
| 226 | } |
| 227 | }); |
Alexander Afanasyev | 3c95c85 | 2013-03-01 18:58:50 -0800 | [diff] [blame] | 228 | }, |
| 229 | |
| 230 | base_url: function () { |
| 231 | url = "#fileList"+ |
| 232 | "&user="+encodeURIComponent (encodeURIComponent (PARAMS.user)) + |
| 233 | "&folder="+encodeURIComponent (encodeURIComponent (PARAMS.folder)); |
| 234 | if (PARAMS.item !== undefined) { |
| 235 | url += "&item="+encodeURIComponent (encodeURIComponent (PARAMS.item)); |
| 236 | } |
| 237 | return url; |
Zhenkai Zhu | 5c2475b | 2013-02-26 22:57:31 -0800 | [diff] [blame] | 238 | } |
Alexander Afanasyev | fd5e627 | 2013-02-27 20:25:20 -0800 | [diff] [blame] | 239 | }); |
Zhenkai Zhu | 5c2475b | 2013-02-26 22:57:31 -0800 | [diff] [blame] | 240 | |
Alexander Afanasyev | fd5e627 | 2013-02-27 20:25:20 -0800 | [diff] [blame] | 241 | |
Alexander Afanasyev | 1663a41 | 2013-03-02 13:52:00 -0800 | [diff] [blame] | 242 | RestPipelineClosure ("HistoryClosure", {}, { |
Alexander Afanasyev | f63a514 | 2013-02-28 02:21:42 -0800 | [diff] [blame] | 243 | init: function (chronoshare) { |
Alexander Afanasyev | 1663a41 | 2013-03-02 13:52:00 -0800 | [diff] [blame] | 244 | this._super("actions", "more"); |
Alexander Afanasyev | f63a514 | 2013-02-28 02:21:42 -0800 | [diff] [blame] | 245 | this.chronoshare = chronoshare; |
| 246 | }, |
| 247 | |
Alexander Afanasyev | 1663a41 | 2013-03-02 13:52:00 -0800 | [diff] [blame] | 248 | onData: function(data) { |
| 249 | tbody = $("<tbody />", { "id": "history-list-actions" }); |
| 250 | |
| 251 | /// @todo Eventually set title for other pages |
| 252 | $("title").text ("ChronoShare - Recent actions" + (PARAMS.item?" - "+PARAMS.item:"")); |
| 253 | |
| 254 | newcontent = $("<div />", { "id": "content" }).append ( |
| 255 | $("<h2 />").append ($(document.createTextNode("Recent actions ")), $("<green />").text (PARAMS.item)), |
| 256 | $("<table />", { "class": "item-list" }) |
| 257 | .append ($("<thead />") |
| 258 | .append ($("<tr />") |
| 259 | .append ($("<th />", { "class": "filename border-left", "scope": "col" }).text ("Filename")) |
| 260 | .append ($("<th />", { "class": "version", "scope": "col" }).text ("Version")) |
| 261 | .append ($("<th />", { "class": "size", "scope": "col" }).text ("Size")) |
| 262 | .append ($("<th />", { "class": "modified", "scope": "col" }).text ("Modified")) |
| 263 | .append ($("<th />", { "class": "modified-by border-right", "scope": "col" }).text ("Modified By")))) |
| 264 | .append (tbody) |
| 265 | .append ($("<tfoot />") |
| 266 | .append ($("<tr />") |
| 267 | .append ($("<td />", { "colspan": "5", "class": "border-right border-left" }))))); |
| 268 | |
| 269 | for (var i = 0; i < data.length; i++) { |
| 270 | action = data[i]; |
| 271 | |
| 272 | row = $("<tr />"); |
| 273 | if (i%2) { row.addClass ("odd"); } |
| 274 | if (action.action=="DELETE") { |
| 275 | row.addClass ("delete"); |
Alexander Afanasyev | c15e016 | 2013-02-28 23:38:52 -0800 | [diff] [blame] | 276 | } |
Alexander Afanasyev | 1663a41 | 2013-03-02 13:52:00 -0800 | [diff] [blame] | 277 | else { |
| 278 | row.addClass ("with-context-menu"); |
| 279 | row.attr ("file_version", action.version); |
| 280 | row.attr ("file_hash", action.update.hash); |
| 281 | row.attr ("file_modified_by", action.id.userName); |
| 282 | } |
Alexander Afanasyev | f63a514 | 2013-02-28 02:21:42 -0800 | [diff] [blame] | 283 | |
Alexander Afanasyev | 1663a41 | 2013-03-02 13:52:00 -0800 | [diff] [blame] | 284 | row.attr ("filename", action.filename); |
| 285 | row.bind('click', function (e) { openHistoryForItem ($(this).attr ("filename")) }); |
Alexander Afanasyev | 3c95c85 | 2013-03-01 18:58:50 -0800 | [diff] [blame] | 286 | |
Alexander Afanasyev | 1663a41 | 2013-03-02 13:52:00 -0800 | [diff] [blame] | 287 | row.bind('mouseenter mouseleave', function() { |
| 288 | $(this).toggleClass('highlighted'); |
| 289 | }); |
Alexander Afanasyev | 4c17b48 | 2013-03-02 01:32:35 -0800 | [diff] [blame] | 290 | |
Alexander Afanasyev | 1663a41 | 2013-03-02 13:52:00 -0800 | [diff] [blame] | 291 | row.append ($("<td />", { "class": "filename border-left" }) |
| 292 | .text (action.filename) |
| 293 | .prepend ($("<img />", { "src": fileExtension(action.filename) }))); |
| 294 | row.append ($("<td />", { "class": "version" }).text (action.version)); |
| 295 | row.append ($("<td />", { "class": "size" }).text (action.update?SegNumToFileSize (action.update.segNum):"")); |
| 296 | row.append ($("<td />", { "class": "timestamp" }).text (new Date (action.timestamp+"+00:00"))); // conversion from UTC timezone (we store action time in UTC) |
| 297 | row.append ($("<td />", { "class": "modified-by border-right" }) |
| 298 | .append ($("<userName />").text (action.id.userName)) |
| 299 | .append ($("<seqNo> /").text (action.id.seqNo))); |
Alexander Afanasyev | f63a514 | 2013-02-28 02:21:42 -0800 | [diff] [blame] | 300 | |
Alexander Afanasyev | 1663a41 | 2013-03-02 13:52:00 -0800 | [diff] [blame] | 301 | tbody = tbody.append (row); |
| 302 | } |
Alexander Afanasyev | f63a514 | 2013-02-28 02:21:42 -0800 | [diff] [blame] | 303 | |
Alexander Afanasyev | 1663a41 | 2013-03-02 13:52:00 -0800 | [diff] [blame] | 304 | $("#content").fadeOut ("fast", function () { |
| 305 | $(this).replaceWith (newcontent); |
| 306 | $("#content").fadeIn ("fast"); |
| 307 | }); |
Alexander Afanasyev | 4c17b48 | 2013-03-02 01:32:35 -0800 | [diff] [blame] | 308 | |
Alexander Afanasyev | 1663a41 | 2013-03-02 13:52:00 -0800 | [diff] [blame] | 309 | $.contextMenu( 'destroy', ".with-context-menu" ); // cleanup |
| 310 | $.contextMenu({ |
| 311 | selector: ".with-context-menu", |
| 312 | items: { |
| 313 | "sep1": "---------", |
| 314 | restore: {name: "Restore this revision", |
| 315 | icon: "cut", // need a better icon |
| 316 | callback: function(key, opt) { |
| 317 | filename = opt.$trigger.attr ("filename"); |
| 318 | version = opt.$trigger.attr ("file_version"); |
| 319 | hash = DataUtils.toNumbers (opt.$trigger.attr ("file_hash")); |
| 320 | console.log (hash); |
| 321 | modified_by = opt.$trigger.attr ("file_modified_by"); |
Alexander Afanasyev | f63a514 | 2013-02-28 02:21:42 -0800 | [diff] [blame] | 322 | |
Alexander Afanasyev | 1663a41 | 2013-03-02 13:52:00 -0800 | [diff] [blame] | 323 | $("<div />", { "title": "Restore version " + version + "?" }) |
| 324 | .append ($("<p />") |
| 325 | .append ($("<span />", { "class": "ui-icon ui-icon-alert", |
| 326 | "style": "float: left; margin: 0 7px 50px 0;" }), |
| 327 | $(document.createTextNode ("Are you sure you want restore version ")), |
| 328 | $("<green/>").text (version), |
| 329 | $(document.createTextNode (" by ")), |
| 330 | $("<green/>").text (modified_by))) |
| 331 | .dialog ({ |
| 332 | resizable: true, |
| 333 | height:200, |
| 334 | width:300, |
| 335 | modal: true, |
| 336 | buttons: { |
| 337 | "Restore": function() { |
| 338 | self = $(this); |
| 339 | CHRONOSHARE.cmd_restore_file (filename, version, hash, function(didGetData, response) { |
| 340 | if (!didGetData || response != "OK") { |
| 341 | custom_alert (response); |
| 342 | } |
| 343 | console.log (response); |
| 344 | self.dialog ("close"); |
Alexander Afanasyev | f63a514 | 2013-02-28 02:21:42 -0800 | [diff] [blame] | 345 | |
Alexander Afanasyev | 1663a41 | 2013-03-02 13:52:00 -0800 | [diff] [blame] | 346 | $.timer (function() {CHRONOSHARE.run ();}).once (1000); |
| 347 | }); |
| 348 | }, |
| 349 | Cancel: function() { |
| 350 | $(this).dialog ("close"); |
Alexander Afanasyev | 4c17b48 | 2013-03-02 01:32:35 -0800 | [diff] [blame] | 351 | } |
Alexander Afanasyev | 1663a41 | 2013-03-02 13:52:00 -0800 | [diff] [blame] | 352 | } |
| 353 | }); |
| 354 | // openHistoryForItem (opt.$trigger.attr ("filename")); |
| 355 | }}, |
| 356 | "sep2": "---------", |
| 357 | } |
| 358 | }); |
Alexander Afanasyev | 3c95c85 | 2013-03-01 18:58:50 -0800 | [diff] [blame] | 359 | }, |
| 360 | |
| 361 | base_url: function (page) { |
| 362 | url = "#"+page+ |
| 363 | "&user="+encodeURIComponent (encodeURIComponent (PARAMS.user)) + |
| 364 | "&folder="+encodeURIComponent (encodeURIComponent (PARAMS.folder)); |
| 365 | if (PARAMS.item !== undefined) { |
| 366 | url += "&item="+encodeURIComponent (encodeURIComponent (PARAMS.item)); |
| 367 | } |
| 368 | return url; |
Alexander Afanasyev | f63a514 | 2013-02-28 02:21:42 -0800 | [diff] [blame] | 369 | } |
| 370 | }); |
| 371 | |
| 372 | |
Alexander Afanasyev | fd5e627 | 2013-02-27 20:25:20 -0800 | [diff] [blame] | 373 | |
| 374 | |