summaryrefslogtreecommitdiffstats
path: root/content/manager/editAccountOverlay.js
blob: 7fdc18f80ff2c51d4bcf6d99d77bf0c90754a6e2 (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
/*
 * This file is part of EAS-4-TbSync.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 
 */

"use strict";

const eas = TbSync.providers.eas;

var tbSyncEditAccountOverlay = {

    onload: function (window, accountData) {
        this.accountData = accountData;
        
        // special treatment for configuration label, which is a permanent setting and will not change by switching modes
        let configlabel = window.document.getElementById("tbsync.accountsettings.label.config");
        if (configlabel) {
            configlabel.setAttribute("value", TbSync.getString("config.custom", "eas"));
        }
    },

    stripHost: function (document) {
        let host = document.getElementById('tbsync.AccountPropertys.pref.host').value;
        if (host.indexOf("https://") == 0) {
            host = host.replace("https://","");
            document.getElementById('tbsync.AccountPropertys.pref.https').checked = true;
            this.accountData.setAccountProperty("https", true);
        } else if (host.indexOf("http://") == 0) {
            host = host.replace("http://","");
            document.getElementById('tbsync.AccountPropertys.pref.https').checked = false;
           this.accountData.setAccountProperty("https", false);
        }
        
        while (host.endsWith("/")) { host = host.slice(0,-1); }        
        document.getElementById('tbsync.AccountPropertys.pref.host').value = host
       this.accountData.setAccountProperty("host", host);
    },
    
    deleteFolder: function() {
        let folderList = document.getElementById("tbsync.accountsettings.folderlist");
        if (folderList.selectedItem !== null && !folderList.disabled) {
            let folderData = folderList.selectedItem.folderData;

            //only trashed folders can be purged (for example O365 does not show deleted folders but also does not allow to purge them)
            if (!eas.tools.parentIsTrash(folderData)) return;
            
            if (folderData.getFolderProperty("selected")) window.alert(TbSync.getString("deletefolder.notallowed::" + folderData.getFolderProperty("foldername"), "eas"));
            else if (window.confirm(TbSync.getString("deletefolder.confirm::" + folderData.getFolderProperty("foldername"), "eas"))) {
                folderData.sync({syncList: false, syncJob: "deletefolder"});
            } 
        }            
    }    
};