[You must be registered and logged in to see this link.] Zzbaivong wrote:
- Check your network connection.
- Check your backup file.
- Code:
version.timestamp.domain.zip (Invision.1470528770.devs.forumvi.com.zip)
|__main
|__101.agreement.txt
|__105.buy_credits.txt
where I have to look ? this and my userscript
- userscript:
- Code:
// ==UserScript==
// @name Forumotion backup templates
// @namespace http://devs.forumvi.com/
// @version 2.0.1
// @description Export & Import forumotion Templates
// @copyright 2014+, Zzbaivong
// @icon http://i19.servimg.com/u/f19/18/83/32/63/icon-610.png
// @match http://*/admin/index.forum?mode=export*
// @match http://*/admin/index.forum?*&mode=export*
// @resource jszip https://openuserjs.org/src/libs/baivong/jszip.js
// @resource jsziputils https://openuserjs.org/src/libs/baivong/jszip-utils.js
// @resource filesaver https://openuserjs.org/src/libs/baivong/FileSaver.js
// @resource zzFmBackup
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @run-at document-end
// @grant GM_addStyle
// @grant GM_getResourceText
// ==/UserScript==
/**
* jsZip (v2.5.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 (2015-05-07) By Eli Grey <http://eligrey.com>
* zzFmBackup (v2.0.1) By Zzbaivong <http://devs.forumvi.com>
*/
function addscript(source) {
$("<script>", {
type: "text/javascript",
text: source
}).appendTo("head");
}
GM_addStyle("#zzBackup fieldset{counter-reset:section;border:1px solid #07f}#zzBackup legend{color:#e000a2}#zzBackup ol{margin:5px 0 15px;list-style:none outside none}#zzBackup li:before{counter-increment:section;content:counter(section) '.';width:30px;display:inline-block;text-align:right;margin-right:5px}.backupOption{font-size:18px;color:#00a8a1}#importNoti strong{color:#DA4FB8}#zzBackup dt label{display:block;margin-top:10px;color:#777}#zzBackup dt label:hover{color:#111}#zzBackup label input:checked ~ span{color:#0094CA}.buttonOne{display:none;margin-top:10px;padding:7px 20px;background:#f90e5e;color:#FFF;font-weight:700;border:3px solid #DDD}.buttonOne:hover{border-color:#444;cursor:pointer}.buttonOne:active{background:#444}#zzBackup :disabled,#zzBackup :disabled ~ span{color:#999;cursor:not-allowed}");
addscript(GM_getResourceText("jszip"));
addscript(GM_getResourceText("jsziputils"));
addscript(GM_getResourceText("filesaver"));
addscript(GM_getResourceText("zzFmBackup"));/**
/**
* zzFmBackup
* ForumotionBackupTemplates
* v2.0.1
* Zzbaivong <http://devs.forumvi.com> *
*/
var goodIcon = "http://i.imgur.com/YNQGXWY.png",
badIcon = "http://i.imgur.com/cf2Pe8g.png",
disableIcon = "http://i.imgur.com/06GXmA1.png",
errorIcon = "http://i.imgur.com/ffXpTVP.gif",
infoIcon = "http://i.imgur.com/Tuv2aWf.png",
loadIcon = "http://i.imgur.com/m3NXDa6.gif",
successIcon = "http://i.imgur.com/R7Y7JtX.gif";
var allowNotification = true;
Notification.requestPermission(function (result) {
if (result === "denied") {
allowNotification = false;
// console.log("Permission wasn't granted. Allow a retry.");
return;
} else if (result === "default") {
allowNotification = false;
// console.log("The permission request was dismissed.");
return;
}
allowNotification = true;
});
/**
* Yêu c?u c?p phép b?t thông báo n?u chua du?c b?t
*/
if (Notification.permission !== "denied") {
Notification.requestPermission();
}
/**
* L?y th?i gian hi?n t?i
* @return {Number} Th?i gian hi?n t?i, không tính giây
*/
function timestamp() {
return Math.floor((new Date()).getTime() / 1000);
}
/**
* H? tr? ngôn ng? Anh và Vi?t
* @type {Object}
*/
var lang = {
vi: {
ex: {
title: "Xu?t Template",
tooltip: "Trong b?ng này, b?n có th? xu?t t?t c? [[template dã du?c thay d?i]] c?a b?n vào m?t t?p tin nén (.zip) và t?i nó v? máy.\nÐ? b?t d?u, b?n nh?n vào nút {{Ki?m tra}} d? l?y thông tin phiên b?n và danh sách template c?n xu?t. Sau dó nh?n {{Xác nh?n}} và ch? ti?n trình hoàn thành.",
checkall: "Ch?n t?t c?",
unpublish: "Template chua công khai",
firsttip: "Ch?n các m?c ch?a template c?n luu tr? và nh?n {{Ki?m tra}}.",
download: "T?p tin dang du?c t?i xu?ng. Nh?n vào dây n?u b?n d?i quá lâu.",
download2: "Template c?a b?n dã du?c t?i xong.",
notemplate: "Không có template c?n luu tr?.",
sumtemplate: "T?ng s? template c?n luu tr? là",
presssubmit: "Nh?n {{Xác nh?n}} d? b?t d?u!",
pressrefresh: "Nh?n {{Làm l?i}} d? ch?n m?c khác!",
loading: "Ðang t?o t?p tin luu 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) dã luu tr? tru?c dó. Luu ý r?ng: di?n dàn ph?i du?c ch?y cùng phiên b?n v?i b?n luu tr?.\nÐ? b?t d?u, b?n nh?n [[Ch?n t?p]] (Browse...) và tìm d?n v? trí t?p tin luu tr?. Sau dó nh?n {{Xác nh?n}} và ch? ti?n trình hoàn thành.",
choose: "Ch?n t?p tin luu tr?",
notpublish: "Không công khai template",
firsttip: "Ch?n t?p tin dã luu tr? và nh?n {{Xác nh?n}}.",
notname: "L?i không tuong thích! Tên t?p tin <<không h?p l?>>.",
notversion: "L?i không tuong thích! T?p tin này luu tr? Template cho phiên b?n",
source: "Ngu?n",
version: "Phiên b?n",
time: "Luu lúc",
count: "S? template",
updateAll: "T?t c? template dã du?c c?p nh?t.",
loading: "Ðang c?p nh?t template..."
},
option: "Tùy ch?n",
simpleclick: "Ch? d? 1-Click",
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! Ti?n trình s? b?t d?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",
start: "B?T Ð?U"
}
},
en: {
ex: {
title: "Exporta Template",
tooltip: "In questa tabella puoi esportare un template [[dopo la modifica]] in un files forumato *.zip direttamente sul tuo computer.\per iniziare clicca su {{Check}} il bottone per ottenere le informazioni sulla versione e l'elenco dei template che si desidera esportare. Clicca su {{Ok}}, attendi qualche secondo e puoi cominciare.",
checkall: "Scegli tutto",
unpublish: "Template in attesa",
firsttip: "E neccessario scegliere le categorie e clicca su {{Check}}.",
download: "Se il download e' troppo lungo per scaricare il template clicca qui!",
download2: "I template sono stati scaricati,con successo.",
notemplate: "Non ci sono template modificati da salvare",
sumtemplate: "E necessario inserire il numero dei template's",
presssubmit: "Clicca su {{Ok}} per cominciare!",
pressrefresh: "Clicca su {{Start over}} per modificare le opzioni!",
loading: "Creazione si un files zip..."
},
im: {
title: "Importa Template",
tooltip: "In questa tabella, è possibile importare il template il file * .zip. Attenzione: la versione deve corrispondere con la versione del template che si sta per importare.\per iniziare clicca su [[Apri file]] (Sfoglia...) seleziona il file del template sippato (*.zip). clicca su {{Ok}}, attendi il caricamento.",
choose: "Aprire il file zippato",
notpublish: "Non istallare il template...solo anteprima",
firsttip: "Scegli il tuo file zippato e clicca su {{Ok}}.",
notname: "Opps!Questo template <<non e' valido>>.",
notversion: "Opps!Questo template richiede ",
source: "Fonte",
version: "Versione",
time: "Ultimo aggiornamento",
count: "Template(s)",
updateAll: "Ripristino eseguito con successo!",
loading: "Modello in aggiornamento..."
},
option: "Opzioni",
simpleclick: "Controlla tutti",
wail: "Attendere...",
notsupport: "Il tuo browser non supporta questa applicazione!",
requestlimit: "Accesso negato ! ",
reloadtemplate: "Ricaricare template ",
errortemplate: "template con bug ",
second: "s.",
filtering: "Filtraggio template...",
checkone: "Scegliere almeno 1 template",
bt: {
filter: "Check",
refresh: "Start over",
submit: "Ok",
start: "Start",
}
}
};
var icons = {
load: loadIcon,
info: infoIcon,
error: errorIcon,
success: successIcon,
disable: disableIcon
};
var langCode = "en",
trans;
if ($("#user_connected .txt_blue:last").text() === "Thoát") {
langCode = "vi";
}
trans = lang[langCode]; // Ch?n gói ngôn ng?
if (allowNotification) {
new Notification("Backup templates", {
body: trans.bt.start,
icon: goodIcon
});
}
/**
* Chuy?n các ký hi?u trong gói ngôn ng? sang 2 d?ng html và text
* @param {String} txt N?i dung ghi chú
* @return {Object} html, text
*/
function showTip(txt) {
return {
html: txt.replace(/{{([^\}\}]+)}}/g, "<span style="color:green">$1</span>").replace(/\[\[([^\]\]]+)\]\]/g, "<span style="color:#444">$1</span>").replace(/<<([^>>]+)>>/g, "<strong>$1</strong>").replace(/\n/g, "<br />"),
text: txt.replace(/{{([^\}\}]+)}}/g, "$1").replace(/\[\[([^\]\]]+)\]\]/g, "$1").replace(/<<([^>>]+)>>/g, "$1")
};
}
/**
* Ð?nh d?ng th?i gian
* @param {Number} time Thông s? th?i gian
* @return {String} Th?i gian dã d?nh d?ng
*/
function timeFormat(time) {
var a = (new Date(time)).toString().split(/\s/),
dd = a[2],
mm = {
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]],
yyyy = a[3],
showTime = mm + "/" + dd + "/" + yyyy + " " + a[4];
if (langCode === "vi") {
showTime = dd + "-" + mm + "-" + yyyy + " " + a[4];
}
return showTime;
}
var tId = $("a", "#activetab").attr("href").match(/&tid=([^&?]+)/)[1]; // Mã truy c?p ACP
var progressIsRun = true;
function progressIsRunning(e) {
var message = "Programma in esecuzione.";
e.returnValue = message;
return message;
}
function alertUnload() {
if (progressIsRun) {
$(window).on("beforeunload", progressIsRunning);
}
progressIsRun = false;
}
function alertUnloadOff() {
if (!progressIsRun) {
$(window).off("beforeunload", progressIsRunning);
}
progressIsRun = true;
}
/**
* Hi?n th? ghi chú kèm bi?u tu?ng
* @param {htmlString} mess N?i dung ghi chú
* @param {String} icon Lo?i hi?u tu?ng: load/info/error/success/disabled
* @param {Selector} imp V? trí hi?n th? ghi chú
*/
function noti(mess, icon, imp) {
var showIcon = "<img src="" + icons[icon] + "" alt="icon" style="height: 13px; width: 13px; vertical-align: middle; margin-top: -3px;" > ";
if (!icon) {
showIcon = "";
}
var se = "#exportNoti";
if (imp) {
se = "#importNoti";
}
$(se).html(showIcon + showTip(mess).html);
// console.log(showTip(mess).text);
}
/**
* Cu?n d?n d?i tu?ng
* @param {Selector} Id Ð?i tu?ng c?n cu?n d?n
*/
function scrollGoto(Id) {
$("body, html").animate({
scrollTop: $("#" + Id).offset().top
});
}
var arrTempExport = []; // Danh sách các Template du?c chon d? luu tr?
var zip = new JSZip(); // T?o d? li?u zip m?i
var prevZip = ""; // D? li?u t?p zip tru?c dó
var forumVersion = ""; // Phiên b?n Forumotion dang s? d?ng
/**
* Thay th? bi?u tu?ng
* @param {Selector} se Ð?i tu?ng có bi?u tu?ng c?n thay
* @param {String} icon Lo?i bi?u tu?ng: load/info/error/success/disabled
*/
function replaceIcon(se, icon) {
var img = $(se).next("img");
if (img.length) {
img.attr({
"class": "icon_" + icon,
src: icons[icon]
});
} else {
$(se).hide().after("<img class="icon_" + icon + "" src="" + icons[icon] + "" alt="icon" style="height: 13px; width: 13px;" />");
}
}
/**
* X? lý khi b? t? ch?i truy c?p
* @param {Boolean} exim Khu v?c x?y ra l?i {true:Import, false:Export}
* @param {Number} time Th?i gian ch?
* @param {Selector} se V? trí x?y ra l?i
* @param {String} temp Template b? l?i
* @param {Selector} Id V? trí hi?n th? d?m ngu?c tuong ?ng v?i khu v?c
* @param {Function} callback X? lý khi h?t th?i gian ch?
*/
function requestLimit(exim, time, se, temp, Id, callback) {
var place = "zzExport";
if (exim) {
place = "zzImport";
}
scrollGoto(place); // Cu?n d?n m?c b? l?i
replaceIcon(se, "errore"); // Ð?i tr?ng thái
noti(trans.errortemplate + temp + "!", "errore", exim);
noti(trans.requestlimit + " <span id="" + Id + "" style="color:#FF0080">" + time + "</span> " + trans.second, "errore", exim);
if (allowNotification) {
new Notification("Errore", {
body: trans.requestlimit + " " + time + " " + trans.second,
icon: badIcon
});
}
// B?t d?u d?m ngu?c
var count = time - 1,
resum = setInterval(function () {
var result = count--;
$("#" + Id).html(result);
if (result <= 0) {
clearInterval(resum);
replaceIcon(se, "load"); // Ð?i tr?ng thái
noti(trans.reloadtemplate + temp + "!", "info", exim);
callback(); // X? lý khi h?t th?i gian ch?
}
}, 1000);
}
/**
* Xu?t template ra và t?i v? máy
* @param {Number} n V? trí template dang x? lý trong danh sách
*/
function exportTemp(n) {
var item = arrTempExport[n];
/**
* item là m?t m?ng ch?a thông tin c?a Template dang xét nhu sau
* [0] Folder
* [1] Temp Id
* [2] Temp name
*/
var bkLeg = arrTempExport.length; // Ki?m tra s? lu?ng Templates s? xu?t
var m = n + 1; // V? trí Temp k? ti?p trong danh sách
replaceIcon(".cusTemp[value='" + item[1] + "']", "load");
// T?i Temp dang xét
$.get("/admin/index.forum?part=themes&sub=templates&mode=edit_" + item[0] + "&t=" + item[1] + "&l=" + item[0] + "&extended_admin=1&tid=" + tId).done(function (data) { // X? lý khi t?i thành công
zip.file(item[0] + "/" + item[1] + "." + item[2] + ".txt", $(data).find("#template").val()); // Luu thông tin Temp dã t?i vào t?p zip
noti("(" + m + "/" + bkLeg + ") " + trans.ex.loading, "load");
replaceIcon(".cusTemp[value='" + item[1] + "']", "successo");
if (m < bkLeg) { // N?u v?n còn Temp trong danh sách
// T?i Temp ti?p theo sau 1 giây (th?i gian ch? này là d? tránh l?i t? ch?i truy c?p)
setTimeout(function () {
exportTemp(m);
}, 1000);
} else { // Khi t?t c? Temp dã t?i xong
var zipName = forumVersion + "." + timestamp() + "." + location.host + ".zip";
var blob = zip.generate({
type: "blob"
});
saveAs(blob, zipName); // T?o t?p zip
if (prevZip) { // Ki?m tra xem d? li?u t?p zip cu còn luu trong trình duy?t không
window.URL.revokeObjectURL(prevZip); // Xóa t?p zip cu n?u còn
}
prevZip = blob; // Luu t?p zip hi?n t?i thành d? li?u zip cu d? dùng khi t?i xu?ng b? l?i
$("#exportWait, #exportOne, #exportStart").prop("disabled", false);
noti("<a href="" + window.URL.createObjectURL(blob) + "" download="" + zipName + "">" + trans.ex.download + "</a>", "successo");
scrollGoto("zzExport");
$("#refreshTemp").show();
if (allowNotification) {
new Notification("Complimenti", {
body: trans.ex.download2,
icon: goodIcon
});
}
alertUnloadOff();
}
}).fail(function () { // X? lý khi t?i b? l?i
// G?i phuong th?c x? lý khi b? t? ch?i truy c?p, ch? 60 giây tru?c khi ti?p t?i
requestLimit(false, 60, ".cusTemp[value='" + item[1] + "']", item[2], "exportResume", function () {
exportTemp(n);
});
});
}
/**
* T?i lên thành công m?t Temp
* @param {Number} m V? trí Temp t?i lên k? ti?p
* @param {Number} bkLeg T?ng s? lu?ng Temp t?i lên
* @param {[type]} tempId Temp Id
*/
function importSuccess(m, bkLeg, tempId) {
replaceIcon(".cusTemp2[value='" + tempId + "']", "successo");
noti("(" + $(".hasTemp2 li .icon_success").length + "/" + $(".cusTemp2:checked").length + ") " + trans.im.loading, "load", true);
}
/**
* Ti?n trình sau khi k?t thúc t?i lên m?t Temp
* @param {Number} m V? trí Temp t?i lên k? ti?p
* @param {Number} bkLeg T?ng s? lu?ng Temp t?i lên
* @param {Boolean} nopick Tùy ch?n xu?t b?n Temp
*/
function importEnd(m, bkLeg, nopick) {
if (m < bkLeg) { // N?u còn Temp trong danh sách
if (nopick) { // Tru?ng h?p Temp không du?c ch?n d? xu?t b?n
importTemp(m); // Ti?p t?c ngay v?i Temp k? ti?p trong danh sách
} else {
// Ch? 2 giây m?i ti?p t?c d? tránh l?i t? ch?i truy c?p
setTimeout(function () {
importTemp(m);
}, 2000);
}
} else { // Khi dã t?i lên t?t c? Temp
$("#importPublish, #importZip, #importOne, #importStart").prop("disabled", false);
noti(trans.im.updateAll, "Complimenti", true);
scrollGoto("zzImport");
if (allowNotification) {
new Notification("Complimenti", {
body: trans.im.updateAll,
icon: goodIcon
});
}
alertUnloadOff();
}
}
/**
* Xu?t b?n m?t Temp sau khi t?i lên
* @param {Selector} se V? trí bi?u tu?ng
* @param {Number} m V? trí Temp trong danh sách t?i lên
* @param {Number} bkLeg T?ng s? lu?ng Temp t?i lên
* @param {String} tempId Temp Id
* @param {String} tempName Temp Name
* @param {URL} link Liên k?t truy v?n d? xu?t b?n Temp sau khi t?i lên
*/
function importPublish(se, m, bkLeg, tempId, tempName, link) {
replaceIcon(se, "load");
$.post(link).done(function () {
importSuccess(m, bkLeg, tempId);
importEnd(m, bkLeg);
}).fail(function () {
requestLimit(true, 120, se, tempName, "importResume", function () {
importPublish(se, m, bkLeg, tempId, tempName, link);
});
});
}
var zipTemp = []; // Danh sách các Temp trong t?p zip t?i lên
/**
* T?i lên m?t Temp
* @param {Number} n V? trí Temp trong danh sách t?i lên
*/
function importTemp(n) {
var temp = zipTemp[n];
/**
* Thông s? c?a m?t Temp
* [wail] Temp dã s?a nhung không du?c xu?t b?n
* [l] Temp Mode
* [t] Temp Id
* [tpl_name] Temp Name
* [template] N?i dung Temp
*/
var bkLeg = 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")) { // N?u temp du?c ngu?i dùng ch?n
// B?t d?u t?i lên
replaceIcon(se, "load");
$.post("/admin/index.forum?part=themes&sub=templates&mode=edit_" + tempMode + "&extended_admin=1&tid=" + tId, {
t: tempId,
l: tempMode,
tpl_name: tempName,
template: temp.template,
submit: "Save"
}).done(function () {
if (temp.wail && !$("#importPublish").is(":checked")) { // Xu?t b?n Temp
// Ch? 2 giây d? tránh l?i t? ch?i truy c?p
setTimeout(function () {
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=" + tId);
}, 2000);
} else { // N?u Temp không cho phép xu?t b?n thì ti?p t?c v?i Temp k? ti?p
importSuccess(m, bkLeg, tempId);
importEnd(m, bkLeg);
}
}).fail(function () {
// X? lý l?i t? ch?i truy c?p, ch? 120 giây tru?c khi b?t d?u l?i
requestLimit(true, 120, se, tempName, "importResume", function () {
importTemp(n);
});
});
} else { // N?u không du?c ch?n
importEnd(m, bkLeg, true); // K?t thúc ti?n trình và ti?p t?c v?i Temp k? ti?p
}
}
var arrTest = [];
/**
* L?p danh sách template dã du?c thay d?i
* @param {Number} n V? trí nhóm Temp trong danh sách
*/
function testTemp(n) {
var cat = arrTest[n];
var se = ".catTemp[value='" + cat + "']";
var $this = $(se);
var catWrap = $this.parent().parent();
var m = n + 1;
var bkLeg = arrTest.length;
replaceIcon(se, "load");
$.get("/admin/index.forum?mode=" + cat + "&part=themes&sub=templates&tid=" + tId).done(function (data) {
// Ki?m tra Temp dã ch?nh s?a mà chua luu
var tempWait = "";
if ($("#exportWait").is(":checked")) {
tempWait = ", td.row1 span[style="color:red"]";
}
// T?p h?p danh sách các Temp dã s?a (bao g?m Temp chua luu n?u du?c ch?n)
var $customTemp = $(data).find("td.row1 span[style="color:#7CBA2C"]" + tempWait).parent();
var showResult = "";
var status = "noTemp";
if ($customTemp.length) { // Có Temp dã ch?nh s?a
$customTemp.each(function () {
// Ðánh d?u x vào tên c?a Temp chua luu
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 { // Không có tem ch?nh s?a
$this.prop("checked", false);
showResult = "<li><img src="" + icons.disable + "" alt="icon" style="height: 13px; width: 13px;" /> <em>" + trans.ex.notemplate + "</em></li>";
}
catWrap.attr("class", status);
$("#listTemp ." + cat).html(showResult);
replaceIcon(se, "success");
noti("(" + m + "/" + bkLeg + ") " + trans.filtering, "load");
if (m < bkLeg) { // N?u còn nhóm Temp trong danh sách
setTimeout(function () {
testTemp(m);
}, 500); // Ch? 0.5 giây và ki?m tra nhóm k? ti?p
} else { // Khi dã ki?m tra toàn b? nhóm temp
// Ð?m t?ng s? Temp và thông báo
var sumTemp = $(".cusTemp").length;
var mess = trans.ex.presssubmit;
if (sumTemp === 0) {
mess = trans.ex.pressrefresh;
$("#exportTemp").hide();
}
noti(trans.ex.sumtemplate + ": <span style="color:#FF0080">" + sumTemp + "</span>.\n" + mess, "info");
if ($("#exportOne").prop("checked")) {
$("#exportTemp").click();
}
}
}).fail(function () {
requestLimit(false, 60, se, cat, "testResume", function () {
testTemp(n);
});
});
}
var listTempGroup = {
main: "Generale",
portal: "Portale",
gallery: "Galleria",
calendar: "Calendario",
group: "Gruppi",
post: "Post & Messaggi Privati",
moderation: "Moderazione",
profil: "Profilo",
mobile: "Versione mobile"
}; // Danh sách các nhóm Templates
/**
* T?o danh sách các nhóm Templates d? ngu?i dùng ch?n
*/
function menuTemp() {
var listTemp = $("#listTemp");
listTemp.empty();
$.each(listTempGroup, 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>");
});
}
// C?p nh?t thông tin phiên b?n Forumotion
$.get("/admin/index.forum?part=themes&sub=styles&mode=version&extended_admin=1&tid=" + tId, function (data) {
forumVersion = $(data).find("dd:first > input:checked", "[name="form_version"]").val();
});
// Thêm Forumotion Backup Templates vào B?ng qu?n tr? giao di?n
$("blockquote").after("<div id="zzBackup"><fieldset id="zzExport" class="style-theme-export"><legend>" + trans.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" title="" + showTip(trans.ex.tooltip).text + "" class="show_tooltips" align="absmiddle"><span> " + trans.ex.checkall + "</span></label><br /><br /><span class="backupOption">" + trans.option + "</span><br /><label for="exportWait"><input id="exportWait" type="checkbox" value=""><span> " + trans.ex.unpublish + "</span></label><label for="exportOne"><input id="exportOne" class="oneMode" type="checkbox" value=""><span> " + trans.simpleclick + "</span></label><button id="exportStart" class="buttonOne">" + trans.bt.start + "</button></dt><dd><div id="listTemp"></div><div class="div_btns"><input type="button" id="testTemp" name="testTemp" value="" + trans.bt.filter + "" class="icon_search" /><input type="button" id="refreshTemp" name="refreshTemp" value="" + trans.bt.refresh + "" class="icon_refresh" style="display: none;" /><input type="button" id="exportTemp" name="exportTemp" value="" + trans.bt.submit + "" class="icon_ok" style="display: none;" /></div></dd></dl></fieldset><fieldset id="zzImport" class="style-theme-export"><legend>" + trans.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" title="" + showTip(trans.im.tooltip).text + "" class="show_tooltips" align="absmiddle"> " + trans.im.choose + "</label><br /><br /><span class="backupOption">" + trans.option + "</span><br /><label for="importPublish"><input id="importPublish" type="checkbox" value="" /><span> " + trans.im.notpublish + "</span></label><label for="importOne"><input id="importOne" class="oneMode" type="checkbox" value=""><span> " + trans.simpleclick + "</span></label><button id="importStart" class="buttonOne">" + trans.bt.start + "</button></dt><dd><input type="file" id="importZip" name="importZip" accept="application/zip" /><div id="readerTemp" style="margin-top: 20px;"></div><div class="div_btns"><input type="button" id="importTemp" name="importTemp" value="" + trans.bt.submit + "" class="icon_ok" /></div></dd></dl></fieldset></div>");
// T?o danh sách các nhóm Temp trong khu v?c T?i xu?ng
menuTemp();
noti(trans.ex.firsttip, "info");
// EXPORT TEMPLATE
// Ch?n/b? ch?n Toàn b? Temp s? T?i xu?ng
$("#exportAll").change(function () {
$(".catTemp").prop("checked", $(this).prop("checked"));
});
// Cu?n d?n khu v?c dang thao tác (Ð? xem ghi chú ti?n trình)
$(":button", "#zzBackup").click(function () {
scrollGoto($(this).closest("fieldset").attr("id"));
});
// L?y danh sách các Temp dã ch?nh s?a
$("#testTemp").click(function () {
$("#exportWait, #exportOne, #exportStart").prop("disabled", true);
arrTest = [];
if ($(".catTemp:checked").length) { // N?u dã ch?n nhóm Temp c?n ki?m tra
alertUnload();
$(this).hide();
$("#refreshTemp, #exportTemp").show();
replaceIcon(".catTemp:not(:checked)", "disable");
noti(trans.wail, "load");
$(".catTemp:checked").each(function () {
arrTest.push($(this).val());
});
testTemp(0);
} else { // N?u chua ch?n nhóm Temp c?n ki?m tra
noti(trans.checkone, "errore");
alertUnloadOff();
}
});
// Làm m?i các thông s?
$("#refreshTemp").click(function () {
arrTempExport = [];
zip = new JSZip();
$(this).add("#exportTemp").hide();
$("#testTemp").show();
menuTemp();
$("#exportAll, #exportWait").prop("checked", false);
$("#exportWait, #exportOne, #exportStart").prop("disabled", false);
noti(trans.ex.firsttip, "info");
alertUnloadOff();
});
// B?t d?u t?i xu?ng
$("#exportTemp").click(function () {
if (!$(".cusTemp:checked").length) { // N?u không có Temp ch?n t?i xu?ng
$("#exportWait, #exportOne, #exportStart").prop("disabled", false);
noti(trans.checkone, "errore");
alertUnloadOff();
} else {
alertUnload();
$(".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
arrTempExport.push(cus);
});
$(this).hide();
$("#refreshTemp").hide();
$(".cusTemp").prop("disabled", true);
exportTemp(0);
noti(trans.wail, "load");
replaceIcon(".cusTemp:not(:checked)", "disable");
}
});
// IMPORT TEMPLATE
var verName = {
subsilver: "PhpBB2",
prosilver: "PhpBB3",
punbb: "PunBB",
invision: "Invision"
}; // Tên phiên b?n forumotion
noti(trans.im.firsttip, "info", true);
// B?t d?u T?i lên
$("#importTemp").click(function () {
if (!$(".cusTemp2:checked").length) {
noti(trans.checkone, "errore", true);
alertUnloadOff();
} else {
alertUnload();
$(this).hide();
noti(trans.wail, "load", true);
replaceIcon(".cusTemp2:not(:checked), .catTemp2:not(:checked)", "disable");
replaceIcon(".catTemp2:checked", "success");
$(".cusTemp2, #importPublish, #importZip, #importOne, #importStart").prop("disabled", true);
importTemp(0);
}
});
var $result = $("#readerTemp"),
vaild = true;
/**
* Th?c hi?n khi phát hi?n tên t?p tin không h?p l?
*/
function notVaildName() {
vaild = false;
scrollGoto("zzImport");
$("#importTemp").hide();
noti(trans.im.notname, "errore", true);
if (allowNotification) {
new Notification("Errore", {
body: showTip(trans.im.notname).text,
icon: badIcon
});
}
alertUnloadOff();
}
// T?i lên t?p zip t? máy tính
$("#zzImport").on("change", "#importZip", function (evt) {
alertUnload();
$("#importTemp").show();
scrollGoto("zzImport");
$result.empty();
var files = evt.target.files[0];
var reader = new FileReader();
reader.onload = (function (theFile) {
return function (e) {
// Phân tích tên file d? l?y ra thông s? c?n thi?t
// invision.1432416686.devs.forumvi.com.zip
var matchZip = /^(invision|punbb|prosilver|subsilver)\.(\d{10})\.(([\w\d\-]+\.)?([\w\d\-]+\.)\w{2,4})\.zip$/;
var nameZip = theFile.name;
if (!matchZip.test(nameZip)) { // N?u t?p không h?p l?
notVaildName();
} else {
var backup = nameZip.match(matchZip);
try {
// Ki?m tra phiên b?n Forumotion
if (backup[1] !== forumVersion) {
noti(trans.im.notversion + " <<" + verName[backup[1]] + ">>.", "errore", true);
if (allowNotification) {
new Notification("Errore", {
body: trans.im.notversion + " " + verName[backup[1]],
icon: badIcon
});
}
alertUnloadOff();
} else {
var zipImport = new JSZip(e.target.result); // Phân tích t?p zip
noti("<<" + trans.im.source + ">>: <a href="http://" + backup[3] + "" target="_blank">" + backup[3] + "</a>\n<<" + trans.im.version + ">>: " + verName[backup[1]] + "\n<<" + trans.im.time + ">>: " + timeFormat(1E3 * parseInt(backup[2], 10)) + "\n<<" + trans.im.count + ">>: " + Object.keys(zipImport.files).length, false, true);
zipTemp = [];
$.each(zipImport.files, function (index, zipEntry) { // L?y d? li?u các t?p bên trong
// Phân tích tên file d? l?y ra thông s? c?n thi?t
// main/110.index_body.txt
var nameFile = zipEntry.name;
if (!/^(main|portal|gallery|calendar|group|post|moderation|profil|mobile)\/\d{3,4}x?\.\w+\.txt$/.test(nameFile)) { // N?u t?p không h?p l?
$("#readerTemp").empty();
notVaildName();
return false;
}
// T?o nhóm Temp
var arrName = nameFile.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">" + listTempGroup[arrName[0]] + "</strong></label><ol class="" + arrName[0] + ""></ol></div>");
}
// Ðánh d?u Temp không du?c xu?t b?n
var wailTemp = arrName[1].split("x");
var colorName = "#7CBA2C";
var wailStatus = true;
if (wailTemp.length === 2) {
colorName = "red";
wailStatus = false;
}
// Thêm Temp vào nhóm tuong ?ng
$("<li><label><input class="cusTemp2" type="checkbox" value="" + wailTemp[0] + "" checked /> <span style="color:" + colorName + "">" + arrName[2] + "</span></label></li>").appendTo(".hasTemp2 ." + arrName[0]);
// T?o danh sách d? li?u các Temp
zipTemp.push({
wail: wailStatus,
l: arrName[0],
t: wailTemp[0],
tpl_name: arrName[2],
template: zipEntry.asText()
});
});
if ($("#importOne").prop("checked") && vaild) {
$("#importTemp").click();
}
}
} catch (es) { // L?i trình duy?t không h? tr?
noti(trans.notsupport, "errore", true);
// console.log(es.message);
}
}
};
})(files);
reader.readAsArrayBuffer(files);
$("#importZip").replaceWith($("#importZip").clone());
});
// Ch?n/B? ch?n t?t c? Temp trong nhóm
$("#zzBackup").on("change", ".catTemp, .catTemp2", function () {
var $this = $(this);
$(":checkbox", "." + $this.val()).prop("checked", $this.prop("checked"));
});
// ONE-CLICK MODE
$(".oneMode").on("change", function () {
var $parent = $(this).closest("dl"),
$start = $parent.find(".buttonOne"),
$groupBtn = $parent.find(".div_btns");
if ($(this).prop("checked")) {
$start.show();
$groupBtn.hide();
} else {
$start.hide();
$groupBtn.show();
}
});
$("#importStart").click(function () {
alertUnload();
$("#importZip").click();
});
$("#exportStart").click(function () {
alertUnload();
$("#refreshTemp").click();
$("#exportAll, #exportWait, .catTemp").prop("checked", true);
$("#testTemp").click();
});
Questions: I tried this http://help.forumotion.com/t141441-
backup-and-recovery-templates
backup : ok works
Skin : it does not work properly
fmbackup.page_id = "207"; Prewier
[You must be registered and logged in to see this image.]validation :
[You must be registered and logged in to see this image.]you can only do
Backup and recovery templates with the language translation page? ..no skin no version
thank you