Đăng Nhập

Vui lòng khai báo chính xác tên truy cập và mật khẩu!

Quên mật khẩu?

Đăng Ký

Bạn phải điền đầy đủ thông tin đăng ký!

  

FORUMOTION BACKUP TEMPLATES

Shanks

Support

Support


Bài viết : 340

Danh vọng : 15840

Uy tín : 5069

Huy hiệu : like,top,vip

#1

 Sun Oct 26, 2014 11:41 pm 

FORUMOTION BACKUP TEMPLATES


Userscript này sẽ giúp bạn lưu trữ tất các template (đã chỉnh sửa) của diễn đàn một cách dễ dàng.
Tất cả template được chọn sẽ được lưu trữ trong một tập tin nén để phục hồi khi cần thiết.


[You must be registered and logged in to see this link.]DEMO




[You must be registered and logged in to see this link.]HƯỚNG DẪN


[You must be registered and logged in to see this link.]CÀI EXTENSION / ADD-ON

Sử dụng trình duyệt [You must be registered and logged in to see this link.] hoặc [You must be registered and logged in to see this link.] phiên bản mới nhất. 
Cài đặt tiện ích hỗ trợ userscript trước khi sử dụng:



[You must be registered and logged in to see this link.]CÀI SCRIPT BACKUP

Cài đặt userscript Forumotion backup templates.
Nhấn vào liên kết sau: [You must be registered and logged in to see this link.]
Sau khi hiện ra bảng xác nhận thì nhấn Install (Cài đặt).

[You must be registered and logged in to see this link.]SỬ DỤNG

Truy cập ACP >> Display >> Skins >> Themes management để sử dụng.
Rê chuột vào dấu ? để xem hướng dẫn.


[You must be registered and logged in to see this link.]MÃ NGUỒN

Code:
// ==UserScript==
// @name         Forumotion backup templates
// @namespace    http://www.devs.cf/
// @version      0.6.1
// @description  Export & Import forumotion Templates
// @copyright    2014+, Zzbaivong
// @icon         https://cdn.rawgit.com/baivong/Userscript/master/fm-backup-temp/zip-icon.png
// @match        http://*/admin/index.forum?mode=export*
// @match        http://*/admin/index.forum?*&mode=export*
// @resource     jszip https://cdn.rawgit.com/baivong/Userscript/master/fm-backup-temp/jszip.min.js
// @resource     jsziputils https://cdn.rawgit.com/baivong/Userscript/master/fm-backup-temp/jszip-utils.js
// @resource     filesaver https://cdn.rawgit.com/baivong/Userscript/master/fm-backup-temp/FileSaver.min.js
// @resource     zzFmBackup https://cdn.rawgit.com/baivong/Userscript/master/fm-backup-temp/chrome.user.js
// @require      http://code.jquery.com/jquery-1.10.2.min.js
// @downloadURL  https://cdn.rawgit.com/baivong/Userscript/master/fm-backup-temp/forumotion-backup-templates.user.js
// @updateURL    https://cdn.rawgit.com/baivong/Userscript/master/fm-backup-temp/forumotion-backup-templates.meta.js
// @run-at       document-end
// @grant        GM_getResourceText
// ==/UserScript==

/**
 * jsZip (v2.3.0) By Stuart Knightley <http://stuartk.com/jszip>
 * jszip-utils (v0.0.2) By Stuart Knightley, David Duponchel <http://stuk.github.io/jszip-utils>
 * FileSaver (2014-05-27) By Eli Grey <http://eligrey.com>
 * zzFmBackup By Zzbaivong <http://www.devs.cf>
 */

function addscript(source) {
    $("<script>", {
        type: "text/javascript",
        text: source
    }).appendTo("head");
}
addscript(GM_getResourceText("jszip"));
addscript(GM_getResourceText("jsziputils"));
addscript(GM_getResourceText("filesaver"));
addscript(GM_getResourceText("zzFmBackup"));



ZZFMBACKUP:

Code:
/**
 * jsZip (v2.3.0) By Stuart Knightley <http://stuartk.com/jszip>
 * jszip-utils (v0.0.2) By Stuart Knightley, David Duponchel <http://stuk.github.io/jszip-utils>
 * FileSaver (2014-05-27) By Eli Grey <http://eligrey.com>
 * zzFmBackup By Zzbaivong <http://www.devs.cf>
 */

var zzFmBackup = {
    lang: {
        vi: {
            ex: {
                title: "Xuất Template",
                tooltip: 'Trong bảng này, bạn có thể xuất tất cả "template đã được thay đổi" của bạn vào một tập tin nén (.zip) và tải nó về máy.<br />Để bắt đầu, bạn nhấn vào nút <span style="color:green">Kiểm tra</span> để lấy thông tin phiên bản và danh sách template cần xuất. Sau đó nhấn <span style="color:green">Xác nhận</span> và chờ tiến trình hoàn thành.',
                checkall: "Chọn tất cả",
                option: "Template chưa công khai",
                firsttip: 'Chọn các mục chứa template cần lưu trữ và nhấn <span style="color:#444">Kiểm tra</span>.',
                download: "Tập tin đang được tải xuống. Nhấn vào đây nếu bạn đợi quá lâu.",
                notemplate: "Không có template cần lưu trữ.",
                sumtemplate: "Tổng số template cần lưu trữ là",
                presssubmit: 'Nhấn <span style="color:#444">Xác nhận</span> để bắt đầu!',
                pressrefresh: 'Nhấn <span style="color:#444">Làm lại</span> để chọn mục khác!',
                loading: "Đang tạo tập tin lưu trữ..."

            },
            im: {
                title: "Nhập Template",
                tooltip: 'Trong bảng này, bạn có thể nhập template từ tập tin nén (.zip) đã lưu trữ trước đó. Lưu ý rằng: diễn đàn phải được chạy cùng phiên bản với bản lưu trữ.<br />Để bắt đầu, bạn nhấn <span style="color:green">Chọn tệp</span> (Import) và tìm đến vị trí tập tin lưu trữ. Sau đó nhấn <span style="color:green">Xác nhận</span> và chờ tiến trình hoàn thành.',
                choose: "Chọn tập tin lưu trữ",
                option: "Không công khai template",
                firsttip: 'Chọn tập tin đã lưu trữ và nhấn <span style="color:#444">Xác nhận</span>.',
                notversion: "Lỗi không tương thích!<br />Tập tin này lưu trữ Template cho phiên bản",
                source: "Nguồn",
                version: "Phiên bản",
                time: "Lưu lúc",
                count: "Số template",
                updateAll: "Tất cả template đã được cập nhật.",
                loading: "Đang cập nhật template..."
            },
            wail: "Vui lòng chờ trong giây lát...",
            notsupport: "Trình duyệt của bạn không hỗ trợ ứng dụng này!",
            requestlimit: "Lỗi máy chủ từ chối truy cập!<br />Tiến trình sẽ bắt đầu lại sau",
            reloadtemplate: "Tải lại template ",
            errortemplate: "Lỗi template ",
            second: "giây.",
            filtering: "Đang kiểm tra...",
            checkone: "Bạn phải chọn ít nhất 1 mục!",
            bt: {
                filter: "Kiểm tra",
                refresh: "Làm lại",
                submit: "Xác nhận"
            },
            icon: {
                load: "http://i.imgur.com/m3NXDa6.gif",
                info: "http://i.imgur.com/Tuv2aWf.png",
                error: "http://i.imgur.com/ffXpTVP.gif",
                success: "http://i.imgur.com/R7Y7JtX.gif",
                disable: "http://i.imgur.com/06GXmA1.png"
            }
        },
        en: {
            ex: {
                title: "Export Template",
                tooltip: 'In this table, you can also export "changed template" to a *.zip file and save it to your computer.<br />To start, click <span style="color:green">Check</span> button to get version information and the list of templates that you want to export. Then click <span style="color:green">Ok</span>, wait for few seconds and you are good to go.',
                checkall: "Pick all",
                option: "Unpublish Templates (Waiting Templates)",
                firsttip: 'Pick categories you need then click <span style="color:#444">Check</span>.',
                download: "Downloading your templates. Click here if its take too long!",
                notemplate: "There's no template archive needed",
                sumtemplate: "The number of template archive needed it's",
                presssubmit: 'Click <span style="color:#444">Ok</span> to start!',
                pressrefresh: 'Click <span style="color:#444">Start over</span> to change your options!',
                loading: "Creating Zip file..."

            },
            im: {
                title: "Import Template",
                tooltip: 'In this table, you can also import template from a *.zip file. Attention: your version must match with the version of the template you are going to import.<br />To start, click <span style="color:green">Open file</span> (Import) pick your template zipped file (*.zip). Then click <span style="color:green">Ok</span>, wait for few seconds and you are good to go.',
                choose: "Open zipped file",
                option: "Not publish Template",
                firsttip: 'Pick your zipped file then click <span style="color:#444">Ok</span>.',
                notversion: "Opps!<br />This template require ",
                source: "Source",
                version: "Version",
                time: "Last update",
                count: "Template(s)",
                updateAll: "All done!",
                loading: "Updating template..."
            },
            wail: "Please hold on a second...",
            notsupport: "Your browser does not support this application!",
            requestlimit: "Access denied!<br />Progress will start over in a while",
            reloadtemplate: "Reload template ",
            errortemplate: "Bad template ",
            second: "s.",
            filtering: "Template filtering...",
            checkone: "Pick at least 1 item",
            bt: {
                filter: "Check",
                refresh: "Start over",
                submit: "Ok"
            },
            icon: {
                load: "http://i.imgur.com/m3NXDa6.gif",
                info: "http://i.imgur.com/Tuv2aWf.png",
                error: "http://i.imgur.com/ffXpTVP.gif",
                success: "http://i.imgur.com/R7Y7JtX.gif",
                disable: "http://i.imgur.com/06GXmA1.png"
            }
        }
    },
    trans: function() {
        var x = "en";
        if ($("#user_connected .txt_blue:last").text() == "Thoát") {
            x = "vi";
        }
        return x;
    },
    list: {
        main: "General",
        portal: "Portal",
        gallery: "Gallery",
        calendar: "Calendar",
        group: "Usergroups",
        post: "Post & Private Messages",
        moderation: "Moderation",
        profil: "Profile"
    },
    viTime: function(time) {
        var a = (new Date(time)).toString().split(/\s/);
        return a[2] + "/" + {
            Jan: "01",
            Feb: "02",
            Mar: "03",
            Apr: "04",
            May: "05",
            Jun: "06",
            Jul: "07",
            Aug: "08",
            Sep: "09",
            Oct: "10",
            Nov: "11",
            Dec: "12"
        }[a[1]] + "/" + a[3] + " " + a[4];
    },
    tid: GetParam("tid"),
    noti: function(mess, icon, imp) {
        var showIcon = '<img src="' + zzFmBackup.lang[zzFmBackup.trans()].icon[icon] + '" alt="" style="height: 13px; width: 13px; vertical-align: middle; margin-top: -3px;" /> ';
        if (!icon) {
            showIcon = "";
        }
        var se = "#exportNoti";
        if (imp) {
            se = "#importNoti";
        }
        $(se).html(showIcon + mess);
        window.console && console.log(mess);
    },
    scrollGoto: function(Id) {
        $("body, html").animate({
            scrollTop: $("#" + Id).offset().top
        });
    },
    item: [],
    ver: "",
    verName: {
        subsilver: "PhpBB2",
        prosilver: "PhpBB3",
        punbb: "PunBB",
        invision: "Invision"
    },
    zip: new JSZip(),
    prevZip: "",
    replaceIcon: function(se, icon) {
        var img = $(se).next("img");
        if (img.length) {
            img.attr({
                "class": "icon_" + icon,
                src: zzFmBackup.lang[zzFmBackup.trans()].icon[icon]
            });
        } else {
            $(se).hide().after('<img class="icon_' + icon + '" src="' + zzFmBackup.lang[zzFmBackup.trans()].icon[icon] + '" alt="" style="height: 13px; width: 13px;" />');
        }
    },
    requestLimit: function(exim, time, se, temp, Id, callback) {
        var noti = "zzExport";
        if (exim) {
            noti = "zzImport";
        }
        zzFmBackup.scrollGoto(noti);
        zzFmBackup.replaceIcon(se, "error");
        zzFmBackup.noti(zzFmBackup.lang[zzFmBackup.trans()].errortemplate + temp + "!", "error", exim);
        zzFmBackup.noti(zzFmBackup.lang[zzFmBackup.trans()].requestlimit + ' <span id="' + Id + '" style="color:#FF0080">' + time + '</span> ' + zzFmBackup.lang[zzFmBackup.trans()].second, "error", exim);
        var count = time - 1;
        var resum = setInterval(function() {
            var result = count--;
            $("#" + Id).html(result);
            if (result <= 0) {
                clearInterval(resum);
                zzFmBackup.replaceIcon(se, "load");
                zzFmBackup.noti(zzFmBackup.lang[zzFmBackup.trans()].reloadtemplate + temp + "!", "info", exim);
                callback();
            }
        }, 1000);
    },
    exportTemp: function(n) {
        zip = zzFmBackup.zip;
        var item = zzFmBackup.item[n];
        var bkLeg = zzFmBackup.item.length;
        var m = n + 1;
        zzFmBackup.replaceIcon(".cusTemp[value='" + item[1] + "']", "load");
        $.get("/admin/index.forum?part=themes&sub=templates&mode=edit_" + item[0] + "&t=" + item[1] + "&l=" + item[0] + "&extended_admin=1&tid=" + zzFmBackup.tid).done(function(data) {
            zip.file(item[0] + "/" + item[1] + "." + item[2] + ".txt", $(data).find("#template").val());
            zzFmBackup.noti("(" + m + "/" + bkLeg + ") " + zzFmBackup.lang[zzFmBackup.trans()].ex.loading, "load");
            zzFmBackup.replaceIcon(".cusTemp[value='" + item[1] + "']", "success");
            if (m < bkLeg) {
                setTimeout(function() {
                    zzFmBackup.exportTemp(m);
                }, 1000);
            } else {
                var zipName = zzFmBackup.ver + "." + timestamp() + "." + location.host + ".zip";
                var blob = zip.generate({
                    type: "blob"
                });
                saveAs(blob, zipName);
                window.URL = window.webkitURL || window.URL;
                if (zzFmBackup.prevZip) {
                    window.URL.revokeObjectURL(zzFmBackup.prevZip);
                }
                zzFmBackup.prevZip = blob;
                zzFmBackup.noti('<a href="' + window.URL.createObjectURL(blob) + '" download="' + zipName + '">' + zzFmBackup.lang[zzFmBackup.trans()].ex.download + '</a>', "success");
                zzFmBackup.scrollGoto("zzExport");
            }
        }).fail(function() {
            zzFmBackup.requestLimit(false, 60, ".cusTemp[value='" + item[1] + "']", item[2], "exportResume", function() {
                zzFmBackup.exportTemp(n);
            });
        });
    },
    zipTemp: [],
    importSuccess: function(m, bkLeg, tempId) {
        zzFmBackup.replaceIcon(".cusTemp2[value='" + tempId + "']", "success");
        zzFmBackup.noti("(" + $(".hasTemp2 li .icon_success").length + "/" + $(".cusTemp2:checked").length + ") " + zzFmBackup.lang[zzFmBackup.trans()].im.loading, "load", true);
    },
    importEnd: function(m, bkLeg, nopick) {
        if (m < bkLeg) {
            if (nopick) {
                zzFmBackup.importTemp(m);
            } else {
                setTimeout(function() {
                    zzFmBackup.importTemp(m);
                }, 2000);
            }
        } else {
            zzFmBackup.noti(zzFmBackup.lang[zzFmBackup.trans()].im.updateAll, "success", true);
            zzFmBackup.scrollGoto("zzImport");
        }
    },
    importPublish: function(se, m, bkLeg, tempId, tempName, link) {
        zzFmBackup.replaceIcon(se, "load");
        $.post(link).done(function(data) {
            zzFmBackup.importSuccess(m, bkLeg, tempId);
            zzFmBackup.importEnd(m, bkLeg);
        }).fail(function() {
            zzFmBackup.requestLimit(true, 120, se, tempName, "importResume", function() {
                zzFmBackup.importPublish(se, m, bkLeg, tempId, tempName, link);
            });
        });
    },
    importTemp: function(n) {
        var temp = zzFmBackup.zipTemp[n];
        var bkLeg = zzFmBackup.zipTemp.length;
        var m = n + 1;
        var tempId = temp.t;
        var tempMode = temp.l;
        var tempName = temp.tpl_name;
        var se = '.cusTemp2[value="' + tempId + '"]';
        if ($(se).is(":checked")) {
            zzFmBackup.replaceIcon(se, "load");
            $.post("/admin/index.forum?part=themes&sub=templates&mode=edit_" + tempMode + "&extended_admin=1&tid=" + zzFmBackup.tid, {
                t: tempId,
                l: tempMode,
                tpl_name: tempName,
                template: temp.template,
                submit: "Save"
            }).done(function(data) {
                if (temp.wail && !$("#importPublish").is(":checked")) {
                    setTimeout(function() {
                        zzFmBackup.importPublish(se, m, bkLeg, tempId, tempName, "/admin/index.forum?part=themes&sub=templates&mode=edit_" + tempMode + "&t=" + tempId + "&l=" + tempMode + "&main_mode=edit&extended_admin=1&pub=1&tid=" + zzFmBackup.tid);
                    }, 2000);
                } else {
                    zzFmBackup.importSuccess(m, bkLeg, tempId);
                    zzFmBackup.importEnd(m, bkLeg);
                }
            }).fail(function() {
                zzFmBackup.requestLimit(true, 120, se, tempName, "importResume", function() {
                    zzFmBackup.importTemp(n);
                });
            });
        } else {
            zzFmBackup.importEnd(m, bkLeg, true);
        }
    },
    arrTest: [],
    testTemp: function(n) {
        var cat = zzFmBackup.arrTest[n];
        var se = ".catTemp[value='" + cat + "']";
        var $this = $(se);
        var catWrap = $this.parent().parent();
        var m = n + 1;
        var bkLeg = zzFmBackup.arrTest.length;
        zzFmBackup.replaceIcon(se, "load");
        $.get("/admin/index.forum?mode=" + cat + "&part=themes&sub=templates&tid=" + zzFmBackup.tid).done(function(data) {
            var tempWait = "";
            if ($("#exportWait").is(":checked")) {
                tempWait = ', td.row1 span[style="color:red"]';
            }
            var customTemp = $(data).find('td.row1 span[style="color:#7CBA2C"]' + tempWait).parent();
            var showResult = "";
            var status = "noTemp";
            if (customTemp.length) {
                customTemp.each(function(index, el) {
                    var markWail = "";
                    if ($(this).find('span[style="color:red"]').length) {
                        markWail = "x";
                    }
                    var customTempId = this.search.match(/&t=(\d+)&/)[1];
                    showResult += '<li><label><input class="cusTemp" type="checkbox" value="' + customTempId + markWail + '" checked /> ' + $(this).html() + '</label></li>';
                });
                status = "hasTemp";
            } else {
                $this.prop("checked", false);
                showResult = '<li><img src="' + zzFmBackup.lang[zzFmBackup.trans()].icon.disable + '" alt="" style="height: 13px; width: 13px;" /> <em>' + zzFmBackup.lang[zzFmBackup.trans()].ex.notemplate + '</em></li>';
            }
            catWrap.attr("class", status);
            $("#listTemp ." + cat).html(showResult);
            zzFmBackup.replaceIcon(se, "success");
            zzFmBackup.noti("(" + m + "/" + bkLeg + ") " + zzFmBackup.lang[zzFmBackup.trans()].filtering, "load");
            if (m < bkLeg) {
                setTimeout(function() {
                    zzFmBackup.testTemp(m);
                }, 500);
            } else {
                var sumTemp = $(".cusTemp").length;
                var mess = zzFmBackup.lang[zzFmBackup.trans()].ex.presssubmit;
                if (sumTemp === 0) {
                    mess = zzFmBackup.lang[zzFmBackup.trans()].ex.pressrefresh;
                    $("#exportTemp").hide();
                }
                zzFmBackup.noti(zzFmBackup.lang[zzFmBackup.trans()].ex.sumtemplate + ': <span style="color:#FF0080">' + sumTemp + '</span>.<br />' + mess, "info");
            }
        }).fail(function() {
            zzFmBackup.requestLimit(false, 60, se, cat, "testResume", function() {
                zzFmBackup.testTemp(n);
            });
        });
    },
    menuTemp: function() {
        var listTemp = $("#listTemp");
        listTemp.empty();
        $.each(zzFmBackup.list, function(key, val) {
            listTemp.append('<div><label><input class="catTemp" type="checkbox" value="' + key + '" /> <strong style="color: #0014FF">' + val + '</strong></label><ol class="' + key + '"></ol></div>');
        });
    },
    start: function() {
        $("<style>", {
            type: "text/css",
            html: '#importNoti strong{color:#DA4FB8}#zzBackup ol{margin:5px 0 15px;list-style:none outside none}#zzBackup fieldset{counter-reset:section}#zzBackup li:before{counter-increment:section;content:counter(section) ".";width:30px;display:inline-block;text-align:right;margin-right:5px}'
        }).appendTo("head");
        var lag = zzFmBackup.lang[zzFmBackup.trans()];
        bubble["export_tooltip"] = lag.ex.tooltip;
        bubble["import_tooltip"] = lag.im.tooltip;
        $.get("/admin/index.forum?part=themes&sub=styles&mode=version&extended_admin=1&tid=" + zzFmBackup.tid, function(data) {
            zzFmBackup.ver = $(data).find('dd:first > input:checked', '[name="form_version"]').val();
        });
        $("blockquote").after('<div id="zzBackup"><fieldset id="zzExport" class="style-theme-export"><legend>' + lag.ex.title + '</legend><p id="exportNoti" class="messagebox"></p><dl class="clearfix"><dt><label for="exportAll"><input id="exportAll" type="checkbox" value="" style="display: none;" /><img src="http://2img.net/i/fa/admin/icones/question2.png" onmouseover="show_tooltip2(this, \'export_tooltip\');" align="absmiddle" title=""> ' + lag.ex.checkall + '</label><br /><label for="exportWait"><input id="exportWait" type="checkbox" value="" /> ' + lag.ex.option + '</label></dt><dd><div id="listTemp"></div><div class="div_btns"><input type="button" id="testTemp" name="testTemp" value="' + lag.bt.filter + '" class="icon_search" /><input type="button" id="refreshTemp" name="refreshTemp" value="' + lag.bt.refresh + '" class="icon_refresh" style="display: none;" /><input type="button" id="exportTemp" name="exportTemp" value="' + lag.bt.submit + '" class="icon_ok" style="display: none;" /></div></dd></dl></fieldset><fieldset id="zzImport" class="style-theme-export"><legend>' + lag.im.title + '</legend><p id="importNoti" class="messagebox"></p><dl class="clearfix"><dt><label for="importZip"><img src="http://2img.net/i/fa/admin/icones/question2.png" onmouseover="show_tooltip2(this, \'import_tooltip\');" align="absmiddle"> ' + lag.im.choose + '</label><br /><label for="importPublish"><input id="importPublish" type="checkbox" value="" /> ' + lag.im.option + '</label></dt><dd><input type="file" id="importZip" name="importZip" /><div id="readerTemp" style="margin-top: 20px;"></div><div class="div_btns"><input type="button" id="importTemp" name="importTemp" value="' + lag.bt.submit + '" class="icon_ok" /></div></dd></dl></fieldset></div>');
        zzFmBackup.noti(lag.ex.firsttip, "info");
        zzFmBackup.noti(lag.im.firsttip, "info", true);

        // EXPORT TEMPLATE
        $("#exportAll").change(function() {
            $(".catTemp").prop("checked", $(this).prop("checked"));
        });
        $(":button", "#zzBackup").click(function() {
            zzFmBackup.scrollGoto($(this).closest("fieldset").attr("id"));
        });
        zzFmBackup.menuTemp();
        $("#testTemp").click(function() {
            zzFmBackup.arrTest = [];
            if ($(".catTemp:checked").length) {
                $(this).hide();
                $("#refreshTemp, #exportTemp").show();
                zzFmBackup.replaceIcon(".catTemp:not(:checked)", "disable");
                zzFmBackup.noti(lag.wail, "load");
                $(".catTemp:checked").each(function() {
                    zzFmBackup.arrTest.push($(this).val())
                });
                zzFmBackup.testTemp(0);
            } else {
                zzFmBackup.noti(lag.checkone, "error");
            }
        });
        $("#refreshTemp").click(function() {
            zzFmBackup.item = [];
            zzFmBackup.zip = new JSZip();
            $(this).add("#exportTemp").hide();
            $("#testTemp").show();
            zzFmBackup.menuTemp();
            $("#exportAll").prop("checked", false);
            zzFmBackup.noti(lag.ex.firsttip, "info");
        });
        $("#exportTemp").click(function() {
            if (!$(".cusTemp:checked").length) {
                zzFmBackup.noti(lag.checkone, "error");
            } else {
                $(this).hide();
                zzFmBackup.noti(lag.wail, "load");
                zzFmBackup.replaceIcon(".cusTemp:not(:checked)", "disable");
                $(".cusTemp:checked").each(function() {
                    var cus = [];
                    var $this = $(this);
                    cus[0] = $this.closest("ol").attr("class"); // Folder
                    cus[1] = $this.val(); // Temp Id
                    cus[2] = $this.next().text(); // Temp name
                    zzFmBackup.item.push(cus);
                });
                $(".cusTemp").prop("disabled", true);
                zzFmBackup.exportTemp(0);
            }
        });

        // IMPORT TEMPLATE
        var $result = $("#readerTemp");
        $("#zzImport").on("change", "#importZip", function(evt) {
            $result.empty();
            var files = evt.target.files[0];
            var reader = new FileReader();
            reader.onload = (function(theFile) {
                return function(e) {
                    var backup = theFile.name.split(".");
                    var forum = theFile.name.match(/^\w+\.\d+\.(.+)\.zip$/)[1];
                    try {
                        if (backup[0] !== zzFmBackup.ver) {
                            zzFmBackup.noti(lag.im.notversion + " <strong>" + zzFmBackup.verName[backup[0]] + "</strong>.", "error", true);
                        } else {
                            var zip = new JSZip(e.target.result);
                            zzFmBackup.noti('<strong>' + lag.im.source + '</strong>: <a href="http://' + forum + '" target="_blank">' + forum + "</a><br /><strong>" + lag.im.version + "</strong>: " + zzFmBackup.verName[backup[0]] + "<br /><strong>" + lag.im.time + "</strong>: " + zzFmBackup.viTime(1E3 * parseInt(backup[1], 10)) + "<br /><strong>" + lag.im.count + "</strong>: " + Object.keys(zip.files).length, false, true);
                            zzFmBackup.zipTemp = [];
                            $.each(zip.files, function(index, zipEntry) {
                                var arrName = zipEntry.name.split(/\/|\./);
                                if (!$('.catTemp2[value="' + arrName[0] + '"]').length) {
                                    $result.append('<div class="hasTemp2"><label><input class="catTemp2" type="checkbox" value="' + arrName[0] + '" checked /> <strong style="color: #0014FF">' + zzFmBackup.list[arrName[0]] + '</strong></label><ol class="' + arrName[0] + '"></ol></div>');
                                }
                                var wailTemp = arrName[1].split("x");
                                var colorName = "#7CBA2C";
                                wailStatus = true;
                                if (wailTemp.length === 2) {
                                    colorName = "red";
                                    wailStatus = false;
                                }
                                $('<li><label><input class="cusTemp2" type="checkbox" value="' + wailTemp[0] + '" checked />&nbsp;<span style="color:' + colorName + '">' + arrName[2] + '</span></label></li>').appendTo(".hasTemp2 ." + arrName[0]);
                                zzFmBackup.zipTemp.push({
                                    wail: wailStatus,
                                    l: arrName[0],
                                    t: wailTemp[0],
                                    tpl_name: arrName[2],
                                    template: zipEntry.asText()
                                });
                            });
                        }
                    } catch (e) {
                        zzFmBackup.noti(lag.notsupport, "error", true);
                        window.console && console.log(e.message);
                    }
                };
            })(files);
            reader.readAsArrayBuffer(files);
            $("#importZip").replaceWith($("#importZip").clone());
        });
        $("#importTemp").click(function() {
            if (!$(".cusTemp2:checked").length) {
                zzFmBackup.noti(lag.checkone, "error", true);
            } else {
                zzFmBackup.noti(lag.wail, "load", true);
                zzFmBackup.replaceIcon(".cusTemp2:not(:checked), .catTemp2:not(:checked)", "disable");
                zzFmBackup.replaceIcon(".catTemp2:checked", "success");
                $(".cusTemp2").prop("disabled", true);
                zzFmBackup.importTemp(0);
            }
        });
        $("#zzBackup").on("change", ".catTemp, .catTemp2", function() {
            var $this = $(this);
            $(":checkbox", "." + $this.val()).prop("checked", $this.prop("checked"));
        });
    }
};
zzFmBackup.start();



Nguồn: Zzbaivong Devs

Bạn không có quyền trả lời bài viết