~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to www/media/browser/browser.js

  • Committer: mattgiuca
  • Date: 2008-02-29 02:07:06 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:622
browser.js: Reinstated upload_callback (previously removed from listing.js).
    This is neccessary to prevent upload making a refresh as soon as the page
    loads, causing unnecessary server usage and currently causing an error as
    well.
__init__.py: Upload callback - changed from refresh() to a call to
    upload_callback() - which is a "smarter" wrapper around refresh().

Show diffs side-by-side

added added

removed removed

Lines of Context:
112
112
 */
113
113
selected_files = [];
114
114
 
 
115
upload_callback_count = 0;      /* See upload_callback */
 
116
 
115
117
/** Calls the server using Ajax, performing an action on the server side.
116
118
 * Receives the response from the server and performs a refresh of the page
117
119
 * contents, updating it to display the returned data (such as a directory
304
306
    }
305
307
}
306
308
 
 
309
/* Called when a form upload comes back (from an iframe).
 
310
 * Refreshes the page.
 
311
 */
 
312
function upload_callback()
 
313
{
 
314
    /* This has a pretty nasty hack, which happens to work.
 
315
     * upload_callback is set as the "onload" callback for the iframe which
 
316
     * receives the response from the server for uploading a file.
 
317
     * This means it gets called twice. Once when initialising the iframe, and
 
318
     * a second time when the actual response comes back.
 
319
     * All we want to do is call navigate to refresh the page. But we CAN'T do
 
320
     * that on the first load or it will just go into an infinite cycle of
 
321
     * refreshing. We need to refresh the page ONLY on the second refresh.
 
322
     * upload_callback_count is reset to 0 just before the iframe is created.
 
323
     */
 
324
    upload_callback_count++;
 
325
    if (upload_callback_count >= 2)
 
326
        refresh();
 
327
}
 
328
 
307
329
/** Deletes all "dynamic" content on the page.
308
330
 * This returns the page back to the state it is in when the HTML arrives to
309
331
 * the browser, ready for another handler to populate it.