Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/Sketchometry.activity/js/url.js
blob: e8fe67b74ba2e8bed731dd98b8307bb3627294f2 (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
JXG.extend(GUI, {

    parseURL: function(str) {

        var url = {}, tmp, param, i;

        tmp = str.split('?');
        url.base = tmp[0];
        url.data = tmp[1];
        url.anchor = '';

        if (url.base.indexOf('#') > -1) {
            tmp = url.base.split('#');
            url.base = tmp[0];
            url.anchor = tmp[1];
        } else if (url.data && url.data.indexOf('#') > -1) {
            tmp = url.data.split('#');
            url.data = tmp[0];
            url.anchor = tmp[1];
        }

        url.param = {};

        if (url.data) {
            tmp = url.data.split('&');

            for (i = 0; i < tmp.length; i++) {
                param = tmp[i].split('=');
                url.param[param[0]] = param[1];
            }
        }

        return url;
    }
});

/*global JXG:true, GUI:true, jQuery:true, init_jsx_gui:true, unescape: true, Piwik:true */

$(document).ready(function () {
    var url, name, gallery = true, id;

    if (!JXG.supportsSVG()) {
        $('#splash-hint > h3').html('We\'re sorry, but your browser is not supported.');
        return;
    }

    init_jsx_gui('jxgbox');
    GUI.Gallery.init();

    // Parse the URL and read out the GET parameters
    url = GUI.parseURL(window.location.href);

    if (url.param.edit === 'true') {
        gallery = false;

        if (!url.param.source) {
            url.param.source = 'ls';
        }

        if (url.param.source === 'ls' && !url.param.id) {
            url.param.id = GUI.Gallery.files[GUI.Gallery.currentItem].fullid;
        }

        id = url.param.id;
    }

    if (url.param.source === 'url') {
        name = url.param.name || GUI.Lang.std.untitled + '-' + (GUI.fileCounter + 1);
        id = GUI.Gallery.createStorageItem(name, url.param.id);
    }

    $('#splash').hide();

    // update file list, start loading the previews, etc...
    GUI.Gallery.switchGallery();

    if (!gallery) {
        GUI.currentConstruction = {
            source: url.param.source,
            id: id,
            redirect: unescape(url.param.redirect)
        };
        // this is required to actually show the axis. see comment 6 on ticket #225
        //GUI.loadConstruction(name, GUI.Storage.getItem(name), axis);
        //$.mobile.changePage($('#mainWindow'), {transition: GUI.transition});
        GUI.Gallery.switchMainWindow();
    }
});