Welcome to mirror list, hosted at ThFree Co, Russian Federation.

update-location.js « js - github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b8b001dfdba5ca04fb9cdfbd1053795e5ad57e96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
 * Scripts to update location to allow bookmarking of frameset
 * and restoring the bookmark once the page is loaded.
 *
 * @version $Id$
 */

var hash_to_set = "";
var hash_init_done = 0;

/**
 * Sets hash part in URL, either calls itself in parent frame or does the
 * work itself. The hash is not set directly if we did not yet process old 
 * one.
 */
function setURLHash(hash) {
    if (jQuery.browser.webkit) {
        /* 
         * Setting hash leads to reload in webkit: 
         * http://www.quirksmode.org/bugreports/archives/2005/05/Safari_13_visual_anomaly_with_windowlocationhref.html
         */
        return;
    }
    if (window.parent != window && window.parent.setURLHash) {
        window.parent.setURLHash(hash);
    } else {
        /* Do not set if we're not updating frameset */
        var path = window.location.pathname;
        if (path.substring(path.length - 9, path.length) != "index.php") {
            return;
        }
        if (hash_init_done) {
            window.location.hash = "PMAURL:" + hash;
        } else {
            hash_to_set = "PMAURL:" + hash;
        }
    }
}

/**
 * Handler for changing url according to the hash part, which is updated
 * on each page to allow bookmarks.
 */
$(document).ready(function(){
    /* Don't do anything if we're not root Window */
    if (window.parent != window && window.parent.setURLHash) {
        return;
    }
    /* Check if hash contains parameters */
    if (window.location.hash.substring(0, 8) == '#PMAURL:') {
        window.location = 'index.php?' + window.location.hash.substring(8);
        return;
    }
    /* Check if we should set URL */
    if (hash_to_set != "") {
        window.location.hash = hash_to_set;
        hash_to_set = "";
    }
    /* Indicate that we're done (and we are not going to change location */
    hash_init_done = 1;
})