Basically redo theme importing.

This commit is contained in:
Zixaphir 2013-05-28 05:15:58 -07:00
parent 1a2b663658
commit 7809ca0fe3
9 changed files with 418 additions and 714 deletions

View File

@ -1,5 +1,5 @@
/* /*
* appchan x - Version 2.0.4 - 2013-05-27 * appchan x - Version 2.0.4 - 2013-05-28
* *
* Licensed under the MIT license. * Licensed under the MIT license.
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE * https://github.com/zixaphir/appchan-x/blob/master/LICENSE

View File

@ -20,7 +20,7 @@
// ==/UserScript== // ==/UserScript==
/* /*
* appchan x - Version 2.0.4 - 2013-05-27 * appchan x - Version 2.0.4 - 2013-05-28
* *
* Licensed under the MIT license. * Licensed under the MIT license.
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE * https://github.com/zixaphir/appchan-x/blob/master/LICENSE
@ -11707,7 +11707,7 @@
editTheme["Author"] = "Author"; editTheme["Author"] = "Author";
editTheme["Author Tripcode"] = "Unknown"; editTheme["Author Tripcode"] = "Unknown";
} }
layout = ["Background Image", "Background Attachment", "Background Position", "Background Repeat", "Background Color", "Thread Wrapper Background", "Thread Wrapper Border", "Dialog Background", "Dialog Border", "Reply Background", "Reply Border", "Highlighted Reply Background", "Highlighted Reply Border", "Backlinked Reply Outline", "Input Background", "Input Border", "Hovered Input Background", "Hovered Input Border", "Focused Input Background", "Focused Input Border", "Checkbox Background", "Checkbox Border", "Checkbox Checked Background", "Buttons Background", "Buttons Border", "Navigation Background", "Navigation Border", "Links", "Hovered Links", "Quotelinks", "Backlinks", "Navigation Links", "Hovered Navigation Links", "Names", "Tripcodes", "Emails", "Subjects", "Text", "Inputs", "Post Numbers", "Greentext", "Sage", "Board Title", "Timestamps", "Warnings", "Shadow Color"]; layout = ["Background Image", "Background Attachment", "Background Position", "Background Repeat", "Background Color", "Thread Wrapper Background", "Thread Wrapper Border", "Dialog Background", "Dialog Border", "Reply Background", "Reply Border", "Highlighted Reply Background", "Highlighted Reply Border", "Backlinked Reply Outline", "Input Background", "Input Border", "Hovered Input Background", "Hovered Input Border", "Focused Input Background", "Focused Input Border", "Checkbox Background", "Checkbox Border", "Buttons Background", "Buttons Border", "Navigation Background", "Navigation Border", "Links", "Hovered Links", "Quotelinks", "Backlinks", "Navigation Links", "Hovered Navigation Links", "Names", "Tripcodes", "Emails", "Subjects", "Text", "Inputs", "Post Numbers", "Greentext", "Sage", "Board Title", "Timestamps", "Warnings", "Shadow Color"];
ThemeTools.dialog = $.el("div", { ThemeTools.dialog = $.el("div", {
id: "themeConf", id: "themeConf",
className: "reply dialog", className: "reply dialog",
@ -11843,173 +11843,123 @@
}; };
return reader.readAsDataURL(file); return reader.readAsDataURL(file);
}, },
importtheme: function(origin, evt) { importtheme: function(evt) {
var file, reader; var file, reader;
file = evt.target.files[0]; file = evt.target.files[0];
reader = new FileReader(); reader = new FileReader();
reader.onload = function(e) { reader.onload = function(e) {
var bgColor, bgRPA, blinkColor, brderColor, err, imported, inputColor, inputbColor, jlinkColor, linkColor, linkHColor, mainColor, name, nameColor, quoteColor, sageColor, textColor, timeColor, titleColor, tripColor, userThemes; var bgColor, bgRPA, blinkColor, brderColor, color, err, imported, inputColor, inputbColor, jlinkColor, linkColor, linkHColor, mainColor, name, nameColor, quoteColor, sageColor, textColor, timeColor, titleColor, tripColor;
try { try {
imported = JSON.parse(e.target.result); imported = JSON.parse(e.target.result);
if (!imported) {
throw "Cannot parse file";
}
} catch (_error) { } catch (_error) {
err = _error; err = _error;
alert(err); alert(err);
return; return;
} }
if (!((origin !== 'appchan' && imported.mainColor) || (origin === 'appchan' && imported["Author Tripcode"]))) { name = imported.name || imported['Theme'];
if (!name) {
alert("Theme file is invalid."); alert("Theme file is invalid.");
return; return;
} }
name = imported.name || imported["Theme"]; delete imported.name || imported['Theme'];
delete imported.name;
if (Themes[name] && !Themes[name]["Deleted"]) { if (Themes[name] && !Themes[name]["Deleted"]) {
if (confirm("A theme with this name already exists. Would you like to over-write?")) { if (confirm('A theme with this name already exists. Would you like to over-write?')) {
delete Themes[name]; delete Themes[name];
} else { } else {
return; return;
} }
} }
if (origin === "oneechan" || origin === "SS") { if (imported.bgColor) {
bgColor = new Style.color(imported.bgColor); if (!imported.replyOp) {
mainColor = new Style.color(imported.mainColor); imported.replyOp = "0.9";
brderColor = new Style.color(imported.brderColor);
inputColor = new Style.color(imported.inputColor);
inputbColor = new Style.color(imported.inputbColor);
blinkColor = new Style.color(imported.blinkColor);
jlinkColor = new Style.color(imported.jlinkColor);
linkColor = new Style.color(imported.linkColor);
linkHColor = new Style.color(imported.linkHColor);
nameColor = new Style.color(imported.nameColor);
quoteColor = new Style.color(imported.quoteColor);
sageColor = new Style.color(imported.sageColor);
textColor = new Style.color(imported.textColor);
titleColor = new Style.color(imported.titleColor);
tripColor = new Style.color(imported.tripColor);
timeColor = new Style.color(imported.timeColor || imported.textColor);
if (imported.bgRPA) {
bgRPA = imported.bgRPA.split(' ');
} else {
bgRPA = ['no-repeat', 'bottom', 'left', 'fixed'];
} }
if (origin === "oneechan") { bgRPA = imported.bgRPA ? imported.bgRPA.split(' ') : ['no-repeat', 'bottom', 'left', 'fixed'];
Themes[name] = { color = Style.color;
'Author': "Anonymous", bgColor = new color(imported.bgColor);
'Author Tripcode': "!POMF.9waa", mainColor = new color(imported.mainColor);
'Background Image': "url('" + (imported.bgImg || '') + "')", brderColor = new color(imported.brderColor);
'Background Attachment': "" + (bgRPA[3] || ''), inputColor = new color(imported.inputColor);
'Background Position': "" + (bgRPA[1] || '') + " " + (bgRPA[2] || ''), inputbColor = new color(imported.inputbColor);
'Background Repeat': "" + (bgRPA[0] || ''), blinkColor = new color(imported.blinkColor);
'Background Color': "rgb(" + bgColor.rgb + ")", jlinkColor = new color(imported.jlinkColor);
'Dialog Background': "rgba(" + mainColor.rgb + ",.98)", linkColor = new color(imported.linkColor);
'Dialog Border': "rgb(" + brderColor.rgb + ")", linkHColor = new color(imported.linkHColor);
'Thread Wrapper Background': "rgba(0,0,0,0)", nameColor = new color(imported.nameColor);
'Thread Wrapper Border': "rgba(0,0,0,0)", quoteColor = new color(imported.quoteColor);
'Reply Background': "rgba(" + mainColor.rgb + "," + imported.replyOp + ")", sageColor = new color(imported.sageColor);
'Reply Border': "rgb(" + brderColor.rgb + ")", textColor = new color(imported.textColor);
'Highlighted Reply Background': "rgba(" + (mainColor.shiftRGB(4, true)) + ", " + imported.replyOp + ")", titleColor = new color(imported.titleColor);
'Highlighted Reply Border': "rgb(" + linkColor.rgb + ")", tripColor = new color(imported.tripColor);
'Backlinked Reply Outline': "rgb(" + linkColor.rgb + ")", timeColor = new color(imported.timeColor || imported.textColor);
'Checkbox Background': "rgba(" + inputColor.rgb + ", " + imported.replyOp + ")", Themes[name] = {
'Checkbox Border': "rgb(" + inputbColor.rgb + ")", 'Author': "Anonymous",
'Checkbox Checked Background': "rgb(" + inputColor.rgb + ")", 'Author Tripcode': "!POMF.9waa",
'Input Background': "rgba(" + inputColor.rgb + ", " + imported.replyOp + ")", 'Background Image': "url('" + (imported.bgImg || '') + "')",
'Input Border': "rgb(" + inputbColor.rgb + ")", 'Background Attachment': "" + (bgRPA[3] || ''),
'Hovered Input Background': "rgba(" + inputColor.hover + ", " + imported.replyOp + ")", 'Background Position': "" + (bgRPA[1] || '') + " " + (bgRPA[2] || ''),
'Hovered Input Border': "rgb(" + inputbColor.rgb + ")", 'Background Repeat': "" + (bgRPA[0] || ''),
'Focused Input Background': "rgba(" + inputColor.hover + ", " + imported.replyOp + ")", 'Background Color': "rgb(" + bgColor.rgb + ")",
'Focused Input Border': "rgb(" + inputbColor.rgb + ")", 'Dialog Background': "rgba(" + mainColor.rgb + ",.98)",
'Buttons Background': "rgba(" + inputColor.rgb + ", " + imported.replyOp + ")", 'Dialog Border': "rgb(" + brderColor.rgb + ")",
'Buttons Border': "rgb(" + inputbColor.rgb + ")", 'Thread Wrapper Background': "rgba(0,0,0,0)",
'Navigation Background': "rgba(" + bgColor.rgb + ", 0.8)", 'Thread Wrapper Border': "rgba(0,0,0,0)",
'Navigation Border': "rgb(" + mainColor.rgb + ")", 'Reply Background': "rgba(" + mainColor.rgb + "," + imported.replyOp + ")",
'Quotelinks': "rgb(" + linkColor.rgb + ")", 'Reply Border': "rgb(" + brderColor.rgb + ")",
'Links': "rgb(" + linkColor.rgb + ")", 'Highlighted Reply Background': "rgba(" + (mainColor.shiftRGB(4, true)) + "," + imported.replyOp + ")",
'Hovered Links': "rgb(" + linkHColor.rgb + ")", 'Highlighted Reply Border': "rgb(" + linkColor.rgb + ")",
'Navigation Links': "rgb(" + textColor.rgb + ")", 'Backlinked Reply Outline': "rgb(" + linkColor.rgb + ")",
'Hovered Navigation Links': "rgb(" + linkHColor.rgb + ")", 'Checkbox Background': "rgba(" + inputColor.rgb + "," + imported.replyOp + ")",
'Subjects': "rgb(" + titleColor.rgb + ")", 'Checkbox Border': "rgb(" + inputbColor.rgb + ")",
'Names': "rgb(" + nameColor.rgb + ")", 'Input Background': "rgba(" + inputColor.rgb + "," + imported.replyOp + ")",
'Sage': "rgb(" + sageColor.rgb + ")", 'Input Border': "rgb(" + inputbColor.rgb + ")",
'Tripcodes': "rgb(" + tripColor.rgb + ")", 'Hovered Input Background': "rgba(" + inputColor.hover + "," + imported.replyOp + ")",
'Emails': "rgb(" + linkColor.rgb + ")", 'Hovered Input Border': "rgb(" + inputbColor.rgb + ")",
'Post Numbers': "rgb(" + linkColor.rgb + ")", 'Focused Input Background': "rgba(" + inputColor.hover + "," + imported.replyOp + ")",
'Text': "rgb(" + textColor.rgb + ")", 'Focused Input Border': "rgb(" + inputbColor.rgb + ")",
'Backlinks': "rgb(" + linkColor.rgb + ")", 'Buttons Background': "rgba(" + inputColor.rgb + "," + imported.replyOp + ")",
'Greentext': "rgb(" + quoteColor.rgb + ")", 'Buttons Border': "rgb(" + inputbColor.rgb + ")",
'Board Title': "rgb(" + textColor.rgb + ")", 'Navigation Background': "rgba(" + bgColor.rgb + ",0.8)",
'Timestamps': "rgb(" + timeColor.rgb + ")", 'Navigation Border': "rgb(" + mainColor.rgb + ")",
'Inputs': "rgb(" + textColor.rgb + ")", 'Quotelinks': "rgb(" + linkColor.rgb + ")",
'Warnings': "rgb(" + sageColor.rgb + ")", 'Links': "rgb(" + linkColor.rgb + ")",
'Shadow Color': "rgba(0,0,0,0.1)", 'Hovered Links': "rgb(" + linkHColor.rgb + ")",
'Custom CSS': ".rice {\nbox-shadow:rgba(" + mainColor.shiftRGB(32) + (",.3) 0 1px;\n}\ninput[type=password]:hover,\ninput[type=text]:not([disabled]):hover,\ninput#fs_search:hover,\ninput.field:hover,\n.webkit select:hover,\ntextarea:hover,\n#options input:not([type=checkbox]):hover {\n box-shadow:inset rgba(0,0,0,.2) 0 1px 2px;\n}\ninput[type=password]:focus,\ninput[type=text]:focus,\ninput#fs_search:focus,\ninput.field:focus,\n.webkit select:focus,\ntextarea:focus,\n#options input:focus {\n box-shadow:inset rgba(0,0,0,.2) 0 1px 2px;\n}\nbutton,\ninput,\ntextarea,\n.rice {\n transition:background .2s,box-shadow .2s;\n}\n " + (imported.customCSS || '')) 'Navigation Links': "rgb(" + textColor.rgb + ")",
}; 'Hovered Navigation Links': "rgb(" + linkHColor.rgb + ")",
} else if (origin === "SS") { 'Subjects': "rgb(" + titleColor.rgb + ")",
Themes[name] = { 'Names': "rgb(" + nameColor.rgb + ")",
'Author': "Anonymous", 'Sage': "rgb(" + sageColor.rgb + ")",
'Author Tripcode': "!.pC/AHOKAg", 'Tripcodes': "rgb(" + tripColor.rgb + ")",
'Background Image': "url('" + (imported.bgImg || '') + "')", 'Emails': "rgb(" + linkColor.rgb + ")",
'Background Attachment': "" + (bgRPA[3] || ''), 'Post Numbers': "rgb(" + linkColor.rgb + ")",
'Background Position': "" + (bgRPA[1] || '') + " " + (bgRPA[2] || ''), 'Text': "rgb(" + textColor.rgb + ")",
'Background Repeat': "" + (bgRPA[0] || ''), 'Backlinks': "rgb(" + linkColor.rgb + ")",
'Background Color': "rgb(" + bgColor.rgb + ")", 'Greentext': "rgb(" + quoteColor.rgb + ")",
'Dialog Background': "rgba(" + mainColor.rgb + ", .98)", 'Board Title': "rgb(" + textColor.rgb + ")",
'Dialog Border': "rgb(" + brderColor.rgb + ")", 'Timestamps': "rgb(" + timeColor.rgb + ")",
'Thread Wrapper Background': "rgba(" + mainColor.rgb + ", .5)", 'Inputs': "rgb(" + textColor.rgb + ")",
'Thread Wrapper Border': "rgba(" + brderColor.rgb + ", .9)", 'Warnings': "rgb(" + sageColor.rgb + ")",
'Reply Background': "rgba(" + mainColor.rgb + ", .9)", 'Shadow Color': "rbga(0,0,0,0.1)",
'Reply Border': "rgb(" + brderColor.rgb + ")", 'Custom CSS': ".board {\npadding: 1px 2px;\n}\n.rice {\nbox-shadow:rgba(" + mainColor.shiftRGB(32) + (",.3) 0 1px;\n}\ninput[type=password]:hover,\ninput[type=text]:not([disabled]):hover,\ninput#fs_search:hover,\ninput.field:hover,\n.webkit select:hover,\ntextarea:hover,\n#options input:not([type=checkbox]):hover {\n box-shadow:inset rgba(0,0,0,.2) 0 1px 2px;\n}\ninput[type=password]:focus,\ninput[type=text]:focus,\ninput#fs_search:focus,\ninput.field:focus,\n.webkit select:focus,\ntextarea:focus,\n#options input:focus {\n box-shadow:inset rgba(0,0,0,.2) 0 1px 2px;\n}\nbutton,\ninput,\ntextarea,\n.rice {\n transition:background .2s,box-shadow .2s;\n}\n " + (imported.customCSS || ''))
'Highlighted Reply Background': "rgba(" + (mainColor.shiftRGB(4, true)) + ", .9)", };
'Highlighted Reply Border': "rgb(" + linkColor.rgb + ")", } else {
'Backlinked Reply Outline': "rgb(" + linkColor.rgb + ")",
'Checkbox Background': "rgba(" + inputColor.rgb + ", .9)",
'Checkbox Border': "rgb(" + inputbColor.rgb + ")",
'Checkbox Checked Background': "rgb(" + inputColor.rgb + ")",
'Input Background': "rgba(" + inputColor.rgb + ", .9)",
'Input Border': "rgb(" + inputbColor.rgb + ")",
'Hovered Input Background': "rgba(" + inputColor.hover + ", .9)",
'Hovered Input Border': "rgb(" + inputbColor.rgb + ")",
'Focused Input Background': "rgba(" + inputColor.hover + ", .9)",
'Focused Input Border': "rgb(" + inputbColor.rgb + ")",
'Buttons Background': "rgba(" + inputColor.rgb + ", .9)",
'Buttons Border': "rgb(" + inputbColor.rgb + ")",
'Navigation Background': "rgba(" + bgColor.rgb + "', 0.8)",
'Navigation Border': "rgb(" + mainColor.rgb + ")",
'Quotelinks': "rgb(" + linkColor.rgb + ")",
'Links': "rgb(" + linkColor.rgb + ")",
'Hovered Links': "rgb(" + linkHColor.rgb + ")",
'Navigation Links': "rgb(" + textColor.rgb + ")",
'Hovered Navigation Links': "rgb(" + linkHColor.rgb + ")",
'Subjects': "rgb(" + titleColor.rgb + ")",
'Names': "rgb(" + nameColor.rgb + ")",
'Sage': "rgb(" + sageColor.rgb + ")",
'Tripcodes': "rgb(" + tripColor.rgb + ")",
'Emails': "rgb(" + linkColor.rgb + ")",
'Post Numbers': "rgb(" + linkColor.rgb + ")",
'Text': "rgb(" + textColor.rgb + ")",
'Backlinks': "rgb(" + linkColor.rgb + ")",
'Greentext': "rgb(" + quoteColor.rgb + ")",
'Board Title': "rgb(" + textColor.rgb + ")",
'Timestamps': "rgb(" + timeColor.rgb + ")",
'Inputs': "rgb(" + textColor.rgb + ")",
'Warnings': "rgb(" + sageColor.rgb + ")",
'Shadow Color': "rgba(0,0,0,0.1)",
'Custom CSS': ".board {\npadding: 1px 2px;\n}\n.rice {\nbox-shadow:rgba(" + mainColor.shiftRGB(32) + (",.3) 0 1px;\n}\ninput[type=password]:hover,\ninput[type=text]:not([disabled]):hover,\ninput#fs_search:hover,\ninput.field:hover,\n.webkit select:hover,\ntextarea:hover,\n#options input:not([type=checkbox]):hover {\n box-shadow:inset rgba(0,0,0,.2) 0 1px 2px;\n}\ninput[type=password]:focus,\ninput[type=text]:focus,\ninput#fs_search:focus,\ninput.field:focus,\n.webkit select:focus,\ntextarea:focus,\n#options input:focus {\n box-shadow:inset rgba(0,0,0,.2) 0 1px 2px;\n}\nbutton,\ninput,\ntextarea,\n.rice {\n transition:background .2s,box-shadow .2s;\n}\n " + (imported.customCSS || ''))
};
}
} else if (origin === 'appchan') {
Themes[name] = imported; Themes[name] = imported;
} }
return userThemes = $.get("userThemes", {}, function(_arg) { return $.get("userThemes", {}, function(_arg) {
var userThemes; var userThemes;
userThemes = _arg.userThemes; userThemes = _arg.userThemes;
userThemes[name] = Themes[name]; userThemes[name] = Themes[name];
$.set('userThemes', userThemes); $.set('userThemes', userThemes);
alert("Theme \"" + name + "\" imported!"); alert("Theme \"" + name + "\" imported!");
$.rm($("#themes", d.body)); return Settings.openSection.call({
return Settings.open('themes'); open: Settings.themes,
hyphenatedTitle: 'themes'
});
}); });
}; };
return reader.readAsText(file); return reader.readAsText(file);
@ -13652,7 +13602,7 @@
return $.after($('input[name="Stubs"]', section).parentNode.parentNode, div); return $.after($('input[name="Stubs"]', section).parentNode.parentNode, div);
}, },
"export": function(now, data) { "export": function(now, data) {
var a, db, span, _i, _len; var a, db, _i, _len;
if (typeof now !== 'number') { if (typeof now !== 'number') {
now = Date.now(); now = Date.now();
@ -13681,11 +13631,7 @@
href: "data:application/json;base64," + (btoa(unescape(encodeURIComponent(JSON.stringify(data, null, 2))))), href: "data:application/json;base64," + (btoa(unescape(encodeURIComponent(JSON.stringify(data, null, 2))))),
target: '_blank' target: '_blank'
}); });
a.click(); return a.click();
return;
span = $('.imp-exp-result', Settings.dialog);
$.rmAll(span);
return $.add(span, a);
}, },
"import": function() { "import": function() {
return this.nextElementSibling.click(); return this.nextElementSibling.click();
@ -14150,7 +14096,7 @@
} }
div = $.el('div', { div = $.el('div', {
id: 'addthemes', id: 'addthemes',
innerHTML: "<a id=newtheme href='javascript:;'>New Theme</a>\n/\n<a id=import href='javascript:;'>Import Theme</a><input id=importbutton type=file hidden>\n/\n<a id=SSimport href='javascript:;'>Import from 4chan SS</a><input id=SSimportbutton type=file hidden>\n/\n<a id=OCimport href='javascript:;'>Import from Oneechan</a><input id=OCimportbutton type=file hidden>\n/\n<a id=tUndelete href='javascript:;'>Undelete Theme</a>" innerHTML: "<a id=newtheme href='javascript:;'>New Theme</a>\n/\n<a id=import href='javascript:;' title='From Appchan X, Oneechan, or 4chan SS'>Import Theme</a><input id=importbutton type=file hidden>\n/\n<a id=tUndelete href='javascript:;'>Undelete Theme</a>"
}); });
$.on($("#newtheme", div), 'click', function() { $.on($("#newtheme", div), 'click', function() {
ThemeTools.init("untitled"); ThemeTools.init("untitled");
@ -14159,21 +14105,7 @@
$.on($("#import", div), 'click', function() { $.on($("#import", div), 'click', function() {
return this.nextSibling.click(); return this.nextSibling.click();
}); });
$.on($("#importbutton", div), 'change', function(e) { $.on($("#importbutton", div), 'change', ThemeTools.importtheme);
return ThemeTools.importtheme("appchan", e);
});
$.on($("#OCimport", div), 'click', function() {
return this.nextSibling.click();
});
$.on($("#OCimportbutton", div), 'change', function(e) {
return ThemeTools.importtheme("oneechan", e);
});
$.on($("#SSimportbutton", div), 'change', function(e) {
return ThemeTools.importtheme("SS", e);
});
$.on($("#SSimport", div), 'click', function() {
return this.nextSibling.click();
});
$.on($('#tUndelete', div), 'click', function() { $.on($('#tUndelete', div), 'click', function() {
var themes; var themes;
@ -14468,12 +14400,7 @@
name = this.parentElement.parentElement.id; name = this.parentElement.parentElement.id;
exportMascot = Mascots[name]; exportMascot = Mascots[name];
exportMascot['Mascot'] = name; exportMascot['Mascot'] = name;
exportedMascot = "data:application/json," + encodeURIComponent(JSON.stringify(exportMascot)); return exportedMascot = "data:application/json," + encodeURIComponent(JSON.stringify(exportMascot));
if (window.open(exportedMascot, "_blank")) {
} else if (confirm("Your popup blocker is preventing Appchan X from exporting this theme. Would you like to open the exported theme in this window?")) {
return window.location(exportedMascot);
}
}, },
restore: function() { restore: function() {
if (confirm("Are you sure you want to restore \"" + this.id + "\"?")) { if (confirm("Are you sure you want to restore \"" + this.id + "\"?")) {
@ -14518,18 +14445,19 @@
return Settings.close(); return Settings.close();
}, },
"export": function(e) { "export": function(e) {
var exportTheme, exportedTheme; var a, data;
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
exportTheme = Themes[this.name]; data = Themes[this.name];
exportTheme['Theme'] = this.name; data['Theme'] = this.name;
exportedTheme = "data:application/json," + encodeURIComponent(JSON.stringify(exportTheme)); a = $.el('a', {
if (window.open(exportedTheme, "_blank")) { textContent: '>>Save me!',
download: "" + this.name + "-" + (Date.now()) + ".json",
} else if (confirm("Your popup blocker is preventing Appchan X from exporting this theme. Would you like to open the exported theme in this window?")) { href: "data:application/json;base64," + (btoa(unescape(encodeURIComponent(JSON.stringify(data, null, 2))))),
return window.location(exportedTheme); target: '_blank'
} });
return a.click();
}, },
"delete": function(e) { "delete": function(e) {
var container, settheme, var container, settheme,

View File

@ -20,7 +20,7 @@
// ==/UserScript== // ==/UserScript==
/* /*
* appchan x - Version 2.0.4 - 2013-05-27 * appchan x - Version 2.0.4 - 2013-05-28
* *
* Licensed under the MIT license. * Licensed under the MIT license.
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE * https://github.com/zixaphir/appchan-x/blob/master/LICENSE
@ -11701,7 +11701,7 @@
editTheme["Author"] = "Author"; editTheme["Author"] = "Author";
editTheme["Author Tripcode"] = "Unknown"; editTheme["Author Tripcode"] = "Unknown";
} }
layout = ["Background Image", "Background Attachment", "Background Position", "Background Repeat", "Background Color", "Thread Wrapper Background", "Thread Wrapper Border", "Dialog Background", "Dialog Border", "Reply Background", "Reply Border", "Highlighted Reply Background", "Highlighted Reply Border", "Backlinked Reply Outline", "Input Background", "Input Border", "Hovered Input Background", "Hovered Input Border", "Focused Input Background", "Focused Input Border", "Checkbox Background", "Checkbox Border", "Checkbox Checked Background", "Buttons Background", "Buttons Border", "Navigation Background", "Navigation Border", "Links", "Hovered Links", "Quotelinks", "Backlinks", "Navigation Links", "Hovered Navigation Links", "Names", "Tripcodes", "Emails", "Subjects", "Text", "Inputs", "Post Numbers", "Greentext", "Sage", "Board Title", "Timestamps", "Warnings", "Shadow Color"]; layout = ["Background Image", "Background Attachment", "Background Position", "Background Repeat", "Background Color", "Thread Wrapper Background", "Thread Wrapper Border", "Dialog Background", "Dialog Border", "Reply Background", "Reply Border", "Highlighted Reply Background", "Highlighted Reply Border", "Backlinked Reply Outline", "Input Background", "Input Border", "Hovered Input Background", "Hovered Input Border", "Focused Input Background", "Focused Input Border", "Checkbox Background", "Checkbox Border", "Buttons Background", "Buttons Border", "Navigation Background", "Navigation Border", "Links", "Hovered Links", "Quotelinks", "Backlinks", "Navigation Links", "Hovered Navigation Links", "Names", "Tripcodes", "Emails", "Subjects", "Text", "Inputs", "Post Numbers", "Greentext", "Sage", "Board Title", "Timestamps", "Warnings", "Shadow Color"];
ThemeTools.dialog = $.el("div", { ThemeTools.dialog = $.el("div", {
id: "themeConf", id: "themeConf",
className: "reply dialog", className: "reply dialog",
@ -11837,173 +11837,123 @@
}; };
return reader.readAsDataURL(file); return reader.readAsDataURL(file);
}, },
importtheme: function(origin, evt) { importtheme: function(evt) {
var file, reader; var file, reader;
file = evt.target.files[0]; file = evt.target.files[0];
reader = new FileReader(); reader = new FileReader();
reader.onload = function(e) { reader.onload = function(e) {
var bgColor, bgRPA, blinkColor, brderColor, err, imported, inputColor, inputbColor, jlinkColor, linkColor, linkHColor, mainColor, name, nameColor, quoteColor, sageColor, textColor, timeColor, titleColor, tripColor, userThemes; var bgColor, bgRPA, blinkColor, brderColor, color, err, imported, inputColor, inputbColor, jlinkColor, linkColor, linkHColor, mainColor, name, nameColor, quoteColor, sageColor, textColor, timeColor, titleColor, tripColor;
try { try {
imported = JSON.parse(e.target.result); imported = JSON.parse(e.target.result);
if (!imported) {
throw "Cannot parse file";
}
} catch (_error) { } catch (_error) {
err = _error; err = _error;
alert(err); alert(err);
return; return;
} }
if (!((origin !== 'appchan' && imported.mainColor) || (origin === 'appchan' && imported["Author Tripcode"]))) { name = imported.name || imported['Theme'];
if (!name) {
alert("Theme file is invalid."); alert("Theme file is invalid.");
return; return;
} }
name = imported.name || imported["Theme"]; delete imported.name || imported['Theme'];
delete imported.name;
if (Themes[name] && !Themes[name]["Deleted"]) { if (Themes[name] && !Themes[name]["Deleted"]) {
if (confirm("A theme with this name already exists. Would you like to over-write?")) { if (confirm('A theme with this name already exists. Would you like to over-write?')) {
delete Themes[name]; delete Themes[name];
} else { } else {
return; return;
} }
} }
if (origin === "oneechan" || origin === "SS") { if (imported.bgColor) {
bgColor = new Style.color(imported.bgColor); if (!imported.replyOp) {
mainColor = new Style.color(imported.mainColor); imported.replyOp = "0.9";
brderColor = new Style.color(imported.brderColor);
inputColor = new Style.color(imported.inputColor);
inputbColor = new Style.color(imported.inputbColor);
blinkColor = new Style.color(imported.blinkColor);
jlinkColor = new Style.color(imported.jlinkColor);
linkColor = new Style.color(imported.linkColor);
linkHColor = new Style.color(imported.linkHColor);
nameColor = new Style.color(imported.nameColor);
quoteColor = new Style.color(imported.quoteColor);
sageColor = new Style.color(imported.sageColor);
textColor = new Style.color(imported.textColor);
titleColor = new Style.color(imported.titleColor);
tripColor = new Style.color(imported.tripColor);
timeColor = new Style.color(imported.timeColor || imported.textColor);
if (imported.bgRPA) {
bgRPA = imported.bgRPA.split(' ');
} else {
bgRPA = ['no-repeat', 'bottom', 'left', 'fixed'];
} }
if (origin === "oneechan") { bgRPA = imported.bgRPA ? imported.bgRPA.split(' ') : ['no-repeat', 'bottom', 'left', 'fixed'];
Themes[name] = { color = Style.color;
'Author': "Anonymous", bgColor = new color(imported.bgColor);
'Author Tripcode': "!POMF.9waa", mainColor = new color(imported.mainColor);
'Background Image': "url('" + (imported.bgImg || '') + "')", brderColor = new color(imported.brderColor);
'Background Attachment': "" + (bgRPA[3] || ''), inputColor = new color(imported.inputColor);
'Background Position': "" + (bgRPA[1] || '') + " " + (bgRPA[2] || ''), inputbColor = new color(imported.inputbColor);
'Background Repeat': "" + (bgRPA[0] || ''), blinkColor = new color(imported.blinkColor);
'Background Color': "rgb(" + bgColor.rgb + ")", jlinkColor = new color(imported.jlinkColor);
'Dialog Background': "rgba(" + mainColor.rgb + ",.98)", linkColor = new color(imported.linkColor);
'Dialog Border': "rgb(" + brderColor.rgb + ")", linkHColor = new color(imported.linkHColor);
'Thread Wrapper Background': "rgba(0,0,0,0)", nameColor = new color(imported.nameColor);
'Thread Wrapper Border': "rgba(0,0,0,0)", quoteColor = new color(imported.quoteColor);
'Reply Background': "rgba(" + mainColor.rgb + "," + imported.replyOp + ")", sageColor = new color(imported.sageColor);
'Reply Border': "rgb(" + brderColor.rgb + ")", textColor = new color(imported.textColor);
'Highlighted Reply Background': "rgba(" + (mainColor.shiftRGB(4, true)) + ", " + imported.replyOp + ")", titleColor = new color(imported.titleColor);
'Highlighted Reply Border': "rgb(" + linkColor.rgb + ")", tripColor = new color(imported.tripColor);
'Backlinked Reply Outline': "rgb(" + linkColor.rgb + ")", timeColor = new color(imported.timeColor || imported.textColor);
'Checkbox Background': "rgba(" + inputColor.rgb + ", " + imported.replyOp + ")", Themes[name] = {
'Checkbox Border': "rgb(" + inputbColor.rgb + ")", 'Author': "Anonymous",
'Checkbox Checked Background': "rgb(" + inputColor.rgb + ")", 'Author Tripcode': "!POMF.9waa",
'Input Background': "rgba(" + inputColor.rgb + ", " + imported.replyOp + ")", 'Background Image': "url('" + (imported.bgImg || '') + "')",
'Input Border': "rgb(" + inputbColor.rgb + ")", 'Background Attachment': "" + (bgRPA[3] || ''),
'Hovered Input Background': "rgba(" + inputColor.hover + ", " + imported.replyOp + ")", 'Background Position': "" + (bgRPA[1] || '') + " " + (bgRPA[2] || ''),
'Hovered Input Border': "rgb(" + inputbColor.rgb + ")", 'Background Repeat': "" + (bgRPA[0] || ''),
'Focused Input Background': "rgba(" + inputColor.hover + ", " + imported.replyOp + ")", 'Background Color': "rgb(" + bgColor.rgb + ")",
'Focused Input Border': "rgb(" + inputbColor.rgb + ")", 'Dialog Background': "rgba(" + mainColor.rgb + ",.98)",
'Buttons Background': "rgba(" + inputColor.rgb + ", " + imported.replyOp + ")", 'Dialog Border': "rgb(" + brderColor.rgb + ")",
'Buttons Border': "rgb(" + inputbColor.rgb + ")", 'Thread Wrapper Background': "rgba(0,0,0,0)",
'Navigation Background': "rgba(" + bgColor.rgb + ", 0.8)", 'Thread Wrapper Border': "rgba(0,0,0,0)",
'Navigation Border': "rgb(" + mainColor.rgb + ")", 'Reply Background': "rgba(" + mainColor.rgb + "," + imported.replyOp + ")",
'Quotelinks': "rgb(" + linkColor.rgb + ")", 'Reply Border': "rgb(" + brderColor.rgb + ")",
'Links': "rgb(" + linkColor.rgb + ")", 'Highlighted Reply Background': "rgba(" + (mainColor.shiftRGB(4, true)) + "," + imported.replyOp + ")",
'Hovered Links': "rgb(" + linkHColor.rgb + ")", 'Highlighted Reply Border': "rgb(" + linkColor.rgb + ")",
'Navigation Links': "rgb(" + textColor.rgb + ")", 'Backlinked Reply Outline': "rgb(" + linkColor.rgb + ")",
'Hovered Navigation Links': "rgb(" + linkHColor.rgb + ")", 'Checkbox Background': "rgba(" + inputColor.rgb + "," + imported.replyOp + ")",
'Subjects': "rgb(" + titleColor.rgb + ")", 'Checkbox Border': "rgb(" + inputbColor.rgb + ")",
'Names': "rgb(" + nameColor.rgb + ")", 'Input Background': "rgba(" + inputColor.rgb + "," + imported.replyOp + ")",
'Sage': "rgb(" + sageColor.rgb + ")", 'Input Border': "rgb(" + inputbColor.rgb + ")",
'Tripcodes': "rgb(" + tripColor.rgb + ")", 'Hovered Input Background': "rgba(" + inputColor.hover + "," + imported.replyOp + ")",
'Emails': "rgb(" + linkColor.rgb + ")", 'Hovered Input Border': "rgb(" + inputbColor.rgb + ")",
'Post Numbers': "rgb(" + linkColor.rgb + ")", 'Focused Input Background': "rgba(" + inputColor.hover + "," + imported.replyOp + ")",
'Text': "rgb(" + textColor.rgb + ")", 'Focused Input Border': "rgb(" + inputbColor.rgb + ")",
'Backlinks': "rgb(" + linkColor.rgb + ")", 'Buttons Background': "rgba(" + inputColor.rgb + "," + imported.replyOp + ")",
'Greentext': "rgb(" + quoteColor.rgb + ")", 'Buttons Border': "rgb(" + inputbColor.rgb + ")",
'Board Title': "rgb(" + textColor.rgb + ")", 'Navigation Background': "rgba(" + bgColor.rgb + ",0.8)",
'Timestamps': "rgb(" + timeColor.rgb + ")", 'Navigation Border': "rgb(" + mainColor.rgb + ")",
'Inputs': "rgb(" + textColor.rgb + ")", 'Quotelinks': "rgb(" + linkColor.rgb + ")",
'Warnings': "rgb(" + sageColor.rgb + ")", 'Links': "rgb(" + linkColor.rgb + ")",
'Shadow Color': "rgba(0,0,0,0.1)", 'Hovered Links': "rgb(" + linkHColor.rgb + ")",
'Custom CSS': ".rice {\nbox-shadow:rgba(" + mainColor.shiftRGB(32) + (",.3) 0 1px;\n}\ninput[type=password]:hover,\ninput[type=text]:not([disabled]):hover,\ninput#fs_search:hover,\ninput.field:hover,\n.webkit select:hover,\ntextarea:hover,\n#options input:not([type=checkbox]):hover {\n box-shadow:inset rgba(0,0,0,.2) 0 1px 2px;\n}\ninput[type=password]:focus,\ninput[type=text]:focus,\ninput#fs_search:focus,\ninput.field:focus,\n.webkit select:focus,\ntextarea:focus,\n#options input:focus {\n box-shadow:inset rgba(0,0,0,.2) 0 1px 2px;\n}\nbutton,\ninput,\ntextarea,\n.rice {\n transition:background .2s,box-shadow .2s;\n}\n " + (imported.customCSS || '')) 'Navigation Links': "rgb(" + textColor.rgb + ")",
}; 'Hovered Navigation Links': "rgb(" + linkHColor.rgb + ")",
} else if (origin === "SS") { 'Subjects': "rgb(" + titleColor.rgb + ")",
Themes[name] = { 'Names': "rgb(" + nameColor.rgb + ")",
'Author': "Anonymous", 'Sage': "rgb(" + sageColor.rgb + ")",
'Author Tripcode': "!.pC/AHOKAg", 'Tripcodes': "rgb(" + tripColor.rgb + ")",
'Background Image': "url('" + (imported.bgImg || '') + "')", 'Emails': "rgb(" + linkColor.rgb + ")",
'Background Attachment': "" + (bgRPA[3] || ''), 'Post Numbers': "rgb(" + linkColor.rgb + ")",
'Background Position': "" + (bgRPA[1] || '') + " " + (bgRPA[2] || ''), 'Text': "rgb(" + textColor.rgb + ")",
'Background Repeat': "" + (bgRPA[0] || ''), 'Backlinks': "rgb(" + linkColor.rgb + ")",
'Background Color': "rgb(" + bgColor.rgb + ")", 'Greentext': "rgb(" + quoteColor.rgb + ")",
'Dialog Background': "rgba(" + mainColor.rgb + ", .98)", 'Board Title': "rgb(" + textColor.rgb + ")",
'Dialog Border': "rgb(" + brderColor.rgb + ")", 'Timestamps': "rgb(" + timeColor.rgb + ")",
'Thread Wrapper Background': "rgba(" + mainColor.rgb + ", .5)", 'Inputs': "rgb(" + textColor.rgb + ")",
'Thread Wrapper Border': "rgba(" + brderColor.rgb + ", .9)", 'Warnings': "rgb(" + sageColor.rgb + ")",
'Reply Background': "rgba(" + mainColor.rgb + ", .9)", 'Shadow Color': "rbga(0,0,0,0.1)",
'Reply Border': "rgb(" + brderColor.rgb + ")", 'Custom CSS': ".board {\npadding: 1px 2px;\n}\n.rice {\nbox-shadow:rgba(" + mainColor.shiftRGB(32) + (",.3) 0 1px;\n}\ninput[type=password]:hover,\ninput[type=text]:not([disabled]):hover,\ninput#fs_search:hover,\ninput.field:hover,\n.webkit select:hover,\ntextarea:hover,\n#options input:not([type=checkbox]):hover {\n box-shadow:inset rgba(0,0,0,.2) 0 1px 2px;\n}\ninput[type=password]:focus,\ninput[type=text]:focus,\ninput#fs_search:focus,\ninput.field:focus,\n.webkit select:focus,\ntextarea:focus,\n#options input:focus {\n box-shadow:inset rgba(0,0,0,.2) 0 1px 2px;\n}\nbutton,\ninput,\ntextarea,\n.rice {\n transition:background .2s,box-shadow .2s;\n}\n " + (imported.customCSS || ''))
'Highlighted Reply Background': "rgba(" + (mainColor.shiftRGB(4, true)) + ", .9)", };
'Highlighted Reply Border': "rgb(" + linkColor.rgb + ")", } else {
'Backlinked Reply Outline': "rgb(" + linkColor.rgb + ")",
'Checkbox Background': "rgba(" + inputColor.rgb + ", .9)",
'Checkbox Border': "rgb(" + inputbColor.rgb + ")",
'Checkbox Checked Background': "rgb(" + inputColor.rgb + ")",
'Input Background': "rgba(" + inputColor.rgb + ", .9)",
'Input Border': "rgb(" + inputbColor.rgb + ")",
'Hovered Input Background': "rgba(" + inputColor.hover + ", .9)",
'Hovered Input Border': "rgb(" + inputbColor.rgb + ")",
'Focused Input Background': "rgba(" + inputColor.hover + ", .9)",
'Focused Input Border': "rgb(" + inputbColor.rgb + ")",
'Buttons Background': "rgba(" + inputColor.rgb + ", .9)",
'Buttons Border': "rgb(" + inputbColor.rgb + ")",
'Navigation Background': "rgba(" + bgColor.rgb + "', 0.8)",
'Navigation Border': "rgb(" + mainColor.rgb + ")",
'Quotelinks': "rgb(" + linkColor.rgb + ")",
'Links': "rgb(" + linkColor.rgb + ")",
'Hovered Links': "rgb(" + linkHColor.rgb + ")",
'Navigation Links': "rgb(" + textColor.rgb + ")",
'Hovered Navigation Links': "rgb(" + linkHColor.rgb + ")",
'Subjects': "rgb(" + titleColor.rgb + ")",
'Names': "rgb(" + nameColor.rgb + ")",
'Sage': "rgb(" + sageColor.rgb + ")",
'Tripcodes': "rgb(" + tripColor.rgb + ")",
'Emails': "rgb(" + linkColor.rgb + ")",
'Post Numbers': "rgb(" + linkColor.rgb + ")",
'Text': "rgb(" + textColor.rgb + ")",
'Backlinks': "rgb(" + linkColor.rgb + ")",
'Greentext': "rgb(" + quoteColor.rgb + ")",
'Board Title': "rgb(" + textColor.rgb + ")",
'Timestamps': "rgb(" + timeColor.rgb + ")",
'Inputs': "rgb(" + textColor.rgb + ")",
'Warnings': "rgb(" + sageColor.rgb + ")",
'Shadow Color': "rgba(0,0,0,0.1)",
'Custom CSS': ".board {\npadding: 1px 2px;\n}\n.rice {\nbox-shadow:rgba(" + mainColor.shiftRGB(32) + (",.3) 0 1px;\n}\ninput[type=password]:hover,\ninput[type=text]:not([disabled]):hover,\ninput#fs_search:hover,\ninput.field:hover,\n.webkit select:hover,\ntextarea:hover,\n#options input:not([type=checkbox]):hover {\n box-shadow:inset rgba(0,0,0,.2) 0 1px 2px;\n}\ninput[type=password]:focus,\ninput[type=text]:focus,\ninput#fs_search:focus,\ninput.field:focus,\n.webkit select:focus,\ntextarea:focus,\n#options input:focus {\n box-shadow:inset rgba(0,0,0,.2) 0 1px 2px;\n}\nbutton,\ninput,\ntextarea,\n.rice {\n transition:background .2s,box-shadow .2s;\n}\n " + (imported.customCSS || ''))
};
}
} else if (origin === 'appchan') {
Themes[name] = imported; Themes[name] = imported;
} }
return userThemes = $.get("userThemes", {}, function(_arg) { return $.get("userThemes", {}, function(_arg) {
var userThemes; var userThemes;
userThemes = _arg.userThemes; userThemes = _arg.userThemes;
userThemes[name] = Themes[name]; userThemes[name] = Themes[name];
$.set('userThemes', userThemes); $.set('userThemes', userThemes);
alert("Theme \"" + name + "\" imported!"); alert("Theme \"" + name + "\" imported!");
$.rm($("#themes", d.body)); return Settings.openSection.call({
return Settings.open('themes'); open: Settings.themes,
hyphenatedTitle: 'themes'
});
}); });
}; };
return reader.readAsText(file); return reader.readAsText(file);
@ -14142,7 +14092,7 @@
} }
div = $.el('div', { div = $.el('div', {
id: 'addthemes', id: 'addthemes',
innerHTML: "<a id=newtheme href='javascript:;'>New Theme</a>\n/\n<a id=import href='javascript:;'>Import Theme</a><input id=importbutton type=file hidden>\n/\n<a id=SSimport href='javascript:;'>Import from 4chan SS</a><input id=SSimportbutton type=file hidden>\n/\n<a id=OCimport href='javascript:;'>Import from Oneechan</a><input id=OCimportbutton type=file hidden>\n/\n<a id=tUndelete href='javascript:;'>Undelete Theme</a>" innerHTML: "<a id=newtheme href='javascript:;'>New Theme</a>\n/\n<a id=import href='javascript:;' title='From Appchan X, Oneechan, or 4chan SS'>Import Theme</a><input id=importbutton type=file hidden>\n/\n<a id=tUndelete href='javascript:;'>Undelete Theme</a>"
}); });
$.on($("#newtheme", div), 'click', function() { $.on($("#newtheme", div), 'click', function() {
ThemeTools.init("untitled"); ThemeTools.init("untitled");
@ -14151,21 +14101,7 @@
$.on($("#import", div), 'click', function() { $.on($("#import", div), 'click', function() {
return this.nextSibling.click(); return this.nextSibling.click();
}); });
$.on($("#importbutton", div), 'change', function(e) { $.on($("#importbutton", div), 'change', ThemeTools.importtheme);
return ThemeTools.importtheme("appchan", e);
});
$.on($("#OCimport", div), 'click', function() {
return this.nextSibling.click();
});
$.on($("#OCimportbutton", div), 'change', function(e) {
return ThemeTools.importtheme("oneechan", e);
});
$.on($("#SSimportbutton", div), 'change', function(e) {
return ThemeTools.importtheme("SS", e);
});
$.on($("#SSimport", div), 'click', function() {
return this.nextSibling.click();
});
$.on($('#tUndelete', div), 'click', function() { $.on($('#tUndelete', div), 'click', function() {
var themes; var themes;
@ -14460,12 +14396,7 @@
name = this.parentElement.parentElement.id; name = this.parentElement.parentElement.id;
exportMascot = Mascots[name]; exportMascot = Mascots[name];
exportMascot['Mascot'] = name; exportMascot['Mascot'] = name;
exportedMascot = "data:application/json," + encodeURIComponent(JSON.stringify(exportMascot)); return exportedMascot = "data:application/json," + encodeURIComponent(JSON.stringify(exportMascot));
if (window.open(exportedMascot, "_blank")) {
} else if (confirm("Your popup blocker is preventing Appchan X from exporting this theme. Would you like to open the exported theme in this window?")) {
return window.location(exportedMascot);
}
}, },
restore: function() { restore: function() {
if (confirm("Are you sure you want to restore \"" + this.id + "\"?")) { if (confirm("Are you sure you want to restore \"" + this.id + "\"?")) {
@ -14510,18 +14441,22 @@
return Settings.close(); return Settings.close();
}, },
"export": function(e) { "export": function(e) {
var exportTheme, exportedTheme; var a, data;
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
exportTheme = Themes[this.name]; data = Themes[this.name];
exportTheme['Theme'] = this.name; data['Theme'] = this.name;
exportedTheme = "data:application/json," + encodeURIComponent(JSON.stringify(exportTheme)); a = $.el('a', {
if (window.open(exportedTheme, "_blank")) { textContent: '>>Save me!',
download: "" + this.name + "-" + (Date.now()) + ".json",
} else if (confirm("Your popup blocker is preventing Appchan X from exporting this theme. Would you like to open the exported theme in this window?")) { href: "data:application/json;base64," + (btoa(unescape(encodeURIComponent(JSON.stringify(data, null, 2))))),
return window.location(exportedTheme); target: '_blank'
} });
$.on(a, 'click', function(e) {
return e.stopPropagation();
});
return $.replace(this, a);
}, },
"delete": function(e) { "delete": function(e) {
var container, settheme, var container, settheme,

View File

@ -1,6 +1,6 @@
// Generated by CoffeeScript // Generated by CoffeeScript
/* /*
* appchan x - Version 2.0.4 - 2013-05-27 * appchan x - Version 2.0.4 - 2013-05-28
* *
* Licensed under the MIT license. * Licensed under the MIT license.
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE * https://github.com/zixaphir/appchan-x/blob/master/LICENSE
@ -11684,7 +11684,7 @@
editTheme["Author"] = "Author"; editTheme["Author"] = "Author";
editTheme["Author Tripcode"] = "Unknown"; editTheme["Author Tripcode"] = "Unknown";
} }
layout = ["Background Image", "Background Attachment", "Background Position", "Background Repeat", "Background Color", "Thread Wrapper Background", "Thread Wrapper Border", "Dialog Background", "Dialog Border", "Reply Background", "Reply Border", "Highlighted Reply Background", "Highlighted Reply Border", "Backlinked Reply Outline", "Input Background", "Input Border", "Hovered Input Background", "Hovered Input Border", "Focused Input Background", "Focused Input Border", "Checkbox Background", "Checkbox Border", "Checkbox Checked Background", "Buttons Background", "Buttons Border", "Navigation Background", "Navigation Border", "Links", "Hovered Links", "Quotelinks", "Backlinks", "Navigation Links", "Hovered Navigation Links", "Names", "Tripcodes", "Emails", "Subjects", "Text", "Inputs", "Post Numbers", "Greentext", "Sage", "Board Title", "Timestamps", "Warnings", "Shadow Color"]; layout = ["Background Image", "Background Attachment", "Background Position", "Background Repeat", "Background Color", "Thread Wrapper Background", "Thread Wrapper Border", "Dialog Background", "Dialog Border", "Reply Background", "Reply Border", "Highlighted Reply Background", "Highlighted Reply Border", "Backlinked Reply Outline", "Input Background", "Input Border", "Hovered Input Background", "Hovered Input Border", "Focused Input Background", "Focused Input Border", "Checkbox Background", "Checkbox Border", "Buttons Background", "Buttons Border", "Navigation Background", "Navigation Border", "Links", "Hovered Links", "Quotelinks", "Backlinks", "Navigation Links", "Hovered Navigation Links", "Names", "Tripcodes", "Emails", "Subjects", "Text", "Inputs", "Post Numbers", "Greentext", "Sage", "Board Title", "Timestamps", "Warnings", "Shadow Color"];
ThemeTools.dialog = $.el("div", { ThemeTools.dialog = $.el("div", {
id: "themeConf", id: "themeConf",
className: "reply dialog", className: "reply dialog",
@ -11820,173 +11820,123 @@
}; };
return reader.readAsDataURL(file); return reader.readAsDataURL(file);
}, },
importtheme: function(origin, evt) { importtheme: function(evt) {
var file, reader; var file, reader;
file = evt.target.files[0]; file = evt.target.files[0];
reader = new FileReader(); reader = new FileReader();
reader.onload = function(e) { reader.onload = function(e) {
var bgColor, bgRPA, blinkColor, brderColor, err, imported, inputColor, inputbColor, jlinkColor, linkColor, linkHColor, mainColor, name, nameColor, quoteColor, sageColor, textColor, timeColor, titleColor, tripColor, userThemes; var bgColor, bgRPA, blinkColor, brderColor, color, err, imported, inputColor, inputbColor, jlinkColor, linkColor, linkHColor, mainColor, name, nameColor, quoteColor, sageColor, textColor, timeColor, titleColor, tripColor;
try { try {
imported = JSON.parse(e.target.result); imported = JSON.parse(e.target.result);
if (!imported) {
throw "Cannot parse file";
}
} catch (_error) { } catch (_error) {
err = _error; err = _error;
alert(err); alert(err);
return; return;
} }
if (!((origin !== 'appchan' && imported.mainColor) || (origin === 'appchan' && imported["Author Tripcode"]))) { name = imported.name || imported['Theme'];
if (!name) {
alert("Theme file is invalid."); alert("Theme file is invalid.");
return; return;
} }
name = imported.name || imported["Theme"]; delete imported.name || imported['Theme'];
delete imported.name;
if (Themes[name] && !Themes[name]["Deleted"]) { if (Themes[name] && !Themes[name]["Deleted"]) {
if (confirm("A theme with this name already exists. Would you like to over-write?")) { if (confirm('A theme with this name already exists. Would you like to over-write?')) {
delete Themes[name]; delete Themes[name];
} else { } else {
return; return;
} }
} }
if (origin === "oneechan" || origin === "SS") { if (imported.bgColor) {
bgColor = new Style.color(imported.bgColor); if (!imported.replyOp) {
mainColor = new Style.color(imported.mainColor); imported.replyOp = "0.9";
brderColor = new Style.color(imported.brderColor);
inputColor = new Style.color(imported.inputColor);
inputbColor = new Style.color(imported.inputbColor);
blinkColor = new Style.color(imported.blinkColor);
jlinkColor = new Style.color(imported.jlinkColor);
linkColor = new Style.color(imported.linkColor);
linkHColor = new Style.color(imported.linkHColor);
nameColor = new Style.color(imported.nameColor);
quoteColor = new Style.color(imported.quoteColor);
sageColor = new Style.color(imported.sageColor);
textColor = new Style.color(imported.textColor);
titleColor = new Style.color(imported.titleColor);
tripColor = new Style.color(imported.tripColor);
timeColor = new Style.color(imported.timeColor || imported.textColor);
if (imported.bgRPA) {
bgRPA = imported.bgRPA.split(' ');
} else {
bgRPA = ['no-repeat', 'bottom', 'left', 'fixed'];
} }
if (origin === "oneechan") { bgRPA = imported.bgRPA ? imported.bgRPA.split(' ') : ['no-repeat', 'bottom', 'left', 'fixed'];
Themes[name] = { color = Style.color;
'Author': "Anonymous", bgColor = new color(imported.bgColor);
'Author Tripcode': "!POMF.9waa", mainColor = new color(imported.mainColor);
'Background Image': "url('" + (imported.bgImg || '') + "')", brderColor = new color(imported.brderColor);
'Background Attachment': "" + (bgRPA[3] || ''), inputColor = new color(imported.inputColor);
'Background Position': "" + (bgRPA[1] || '') + " " + (bgRPA[2] || ''), inputbColor = new color(imported.inputbColor);
'Background Repeat': "" + (bgRPA[0] || ''), blinkColor = new color(imported.blinkColor);
'Background Color': "rgb(" + bgColor.rgb + ")", jlinkColor = new color(imported.jlinkColor);
'Dialog Background': "rgba(" + mainColor.rgb + ",.98)", linkColor = new color(imported.linkColor);
'Dialog Border': "rgb(" + brderColor.rgb + ")", linkHColor = new color(imported.linkHColor);
'Thread Wrapper Background': "rgba(0,0,0,0)", nameColor = new color(imported.nameColor);
'Thread Wrapper Border': "rgba(0,0,0,0)", quoteColor = new color(imported.quoteColor);
'Reply Background': "rgba(" + mainColor.rgb + "," + imported.replyOp + ")", sageColor = new color(imported.sageColor);
'Reply Border': "rgb(" + brderColor.rgb + ")", textColor = new color(imported.textColor);
'Highlighted Reply Background': "rgba(" + (mainColor.shiftRGB(4, true)) + ", " + imported.replyOp + ")", titleColor = new color(imported.titleColor);
'Highlighted Reply Border': "rgb(" + linkColor.rgb + ")", tripColor = new color(imported.tripColor);
'Backlinked Reply Outline': "rgb(" + linkColor.rgb + ")", timeColor = new color(imported.timeColor || imported.textColor);
'Checkbox Background': "rgba(" + inputColor.rgb + ", " + imported.replyOp + ")", Themes[name] = {
'Checkbox Border': "rgb(" + inputbColor.rgb + ")", 'Author': "Anonymous",
'Checkbox Checked Background': "rgb(" + inputColor.rgb + ")", 'Author Tripcode': "!POMF.9waa",
'Input Background': "rgba(" + inputColor.rgb + ", " + imported.replyOp + ")", 'Background Image': "url('" + (imported.bgImg || '') + "')",
'Input Border': "rgb(" + inputbColor.rgb + ")", 'Background Attachment': "" + (bgRPA[3] || ''),
'Hovered Input Background': "rgba(" + inputColor.hover + ", " + imported.replyOp + ")", 'Background Position': "" + (bgRPA[1] || '') + " " + (bgRPA[2] || ''),
'Hovered Input Border': "rgb(" + inputbColor.rgb + ")", 'Background Repeat': "" + (bgRPA[0] || ''),
'Focused Input Background': "rgba(" + inputColor.hover + ", " + imported.replyOp + ")", 'Background Color': "rgb(" + bgColor.rgb + ")",
'Focused Input Border': "rgb(" + inputbColor.rgb + ")", 'Dialog Background': "rgba(" + mainColor.rgb + ",.98)",
'Buttons Background': "rgba(" + inputColor.rgb + ", " + imported.replyOp + ")", 'Dialog Border': "rgb(" + brderColor.rgb + ")",
'Buttons Border': "rgb(" + inputbColor.rgb + ")", 'Thread Wrapper Background': "rgba(0,0,0,0)",
'Navigation Background': "rgba(" + bgColor.rgb + ", 0.8)", 'Thread Wrapper Border': "rgba(0,0,0,0)",
'Navigation Border': "rgb(" + mainColor.rgb + ")", 'Reply Background': "rgba(" + mainColor.rgb + "," + imported.replyOp + ")",
'Quotelinks': "rgb(" + linkColor.rgb + ")", 'Reply Border': "rgb(" + brderColor.rgb + ")",
'Links': "rgb(" + linkColor.rgb + ")", 'Highlighted Reply Background': "rgba(" + (mainColor.shiftRGB(4, true)) + "," + imported.replyOp + ")",
'Hovered Links': "rgb(" + linkHColor.rgb + ")", 'Highlighted Reply Border': "rgb(" + linkColor.rgb + ")",
'Navigation Links': "rgb(" + textColor.rgb + ")", 'Backlinked Reply Outline': "rgb(" + linkColor.rgb + ")",
'Hovered Navigation Links': "rgb(" + linkHColor.rgb + ")", 'Checkbox Background': "rgba(" + inputColor.rgb + "," + imported.replyOp + ")",
'Subjects': "rgb(" + titleColor.rgb + ")", 'Checkbox Border': "rgb(" + inputbColor.rgb + ")",
'Names': "rgb(" + nameColor.rgb + ")", 'Input Background': "rgba(" + inputColor.rgb + "," + imported.replyOp + ")",
'Sage': "rgb(" + sageColor.rgb + ")", 'Input Border': "rgb(" + inputbColor.rgb + ")",
'Tripcodes': "rgb(" + tripColor.rgb + ")", 'Hovered Input Background': "rgba(" + inputColor.hover + "," + imported.replyOp + ")",
'Emails': "rgb(" + linkColor.rgb + ")", 'Hovered Input Border': "rgb(" + inputbColor.rgb + ")",
'Post Numbers': "rgb(" + linkColor.rgb + ")", 'Focused Input Background': "rgba(" + inputColor.hover + "," + imported.replyOp + ")",
'Text': "rgb(" + textColor.rgb + ")", 'Focused Input Border': "rgb(" + inputbColor.rgb + ")",
'Backlinks': "rgb(" + linkColor.rgb + ")", 'Buttons Background': "rgba(" + inputColor.rgb + "," + imported.replyOp + ")",
'Greentext': "rgb(" + quoteColor.rgb + ")", 'Buttons Border': "rgb(" + inputbColor.rgb + ")",
'Board Title': "rgb(" + textColor.rgb + ")", 'Navigation Background': "rgba(" + bgColor.rgb + ",0.8)",
'Timestamps': "rgb(" + timeColor.rgb + ")", 'Navigation Border': "rgb(" + mainColor.rgb + ")",
'Inputs': "rgb(" + textColor.rgb + ")", 'Quotelinks': "rgb(" + linkColor.rgb + ")",
'Warnings': "rgb(" + sageColor.rgb + ")", 'Links': "rgb(" + linkColor.rgb + ")",
'Shadow Color': "rgba(0,0,0,0.1)", 'Hovered Links': "rgb(" + linkHColor.rgb + ")",
'Custom CSS': ".rice {\nbox-shadow:rgba(" + mainColor.shiftRGB(32) + (",.3) 0 1px;\n}\ninput[type=password]:hover,\ninput[type=text]:not([disabled]):hover,\ninput#fs_search:hover,\ninput.field:hover,\n.webkit select:hover,\ntextarea:hover,\n#options input:not([type=checkbox]):hover {\n box-shadow:inset rgba(0,0,0,.2) 0 1px 2px;\n}\ninput[type=password]:focus,\ninput[type=text]:focus,\ninput#fs_search:focus,\ninput.field:focus,\n.webkit select:focus,\ntextarea:focus,\n#options input:focus {\n box-shadow:inset rgba(0,0,0,.2) 0 1px 2px;\n}\nbutton,\ninput,\ntextarea,\n.rice {\n transition:background .2s,box-shadow .2s;\n}\n " + (imported.customCSS || '')) 'Navigation Links': "rgb(" + textColor.rgb + ")",
}; 'Hovered Navigation Links': "rgb(" + linkHColor.rgb + ")",
} else if (origin === "SS") { 'Subjects': "rgb(" + titleColor.rgb + ")",
Themes[name] = { 'Names': "rgb(" + nameColor.rgb + ")",
'Author': "Anonymous", 'Sage': "rgb(" + sageColor.rgb + ")",
'Author Tripcode': "!.pC/AHOKAg", 'Tripcodes': "rgb(" + tripColor.rgb + ")",
'Background Image': "url('" + (imported.bgImg || '') + "')", 'Emails': "rgb(" + linkColor.rgb + ")",
'Background Attachment': "" + (bgRPA[3] || ''), 'Post Numbers': "rgb(" + linkColor.rgb + ")",
'Background Position': "" + (bgRPA[1] || '') + " " + (bgRPA[2] || ''), 'Text': "rgb(" + textColor.rgb + ")",
'Background Repeat': "" + (bgRPA[0] || ''), 'Backlinks': "rgb(" + linkColor.rgb + ")",
'Background Color': "rgb(" + bgColor.rgb + ")", 'Greentext': "rgb(" + quoteColor.rgb + ")",
'Dialog Background': "rgba(" + mainColor.rgb + ", .98)", 'Board Title': "rgb(" + textColor.rgb + ")",
'Dialog Border': "rgb(" + brderColor.rgb + ")", 'Timestamps': "rgb(" + timeColor.rgb + ")",
'Thread Wrapper Background': "rgba(" + mainColor.rgb + ", .5)", 'Inputs': "rgb(" + textColor.rgb + ")",
'Thread Wrapper Border': "rgba(" + brderColor.rgb + ", .9)", 'Warnings': "rgb(" + sageColor.rgb + ")",
'Reply Background': "rgba(" + mainColor.rgb + ", .9)", 'Shadow Color': "rbga(0,0,0,0.1)",
'Reply Border': "rgb(" + brderColor.rgb + ")", 'Custom CSS': ".board {\npadding: 1px 2px;\n}\n.rice {\nbox-shadow:rgba(" + mainColor.shiftRGB(32) + (",.3) 0 1px;\n}\ninput[type=password]:hover,\ninput[type=text]:not([disabled]):hover,\ninput#fs_search:hover,\ninput.field:hover,\n.webkit select:hover,\ntextarea:hover,\n#options input:not([type=checkbox]):hover {\n box-shadow:inset rgba(0,0,0,.2) 0 1px 2px;\n}\ninput[type=password]:focus,\ninput[type=text]:focus,\ninput#fs_search:focus,\ninput.field:focus,\n.webkit select:focus,\ntextarea:focus,\n#options input:focus {\n box-shadow:inset rgba(0,0,0,.2) 0 1px 2px;\n}\nbutton,\ninput,\ntextarea,\n.rice {\n transition:background .2s,box-shadow .2s;\n}\n " + (imported.customCSS || ''))
'Highlighted Reply Background': "rgba(" + (mainColor.shiftRGB(4, true)) + ", .9)", };
'Highlighted Reply Border': "rgb(" + linkColor.rgb + ")", } else {
'Backlinked Reply Outline': "rgb(" + linkColor.rgb + ")",
'Checkbox Background': "rgba(" + inputColor.rgb + ", .9)",
'Checkbox Border': "rgb(" + inputbColor.rgb + ")",
'Checkbox Checked Background': "rgb(" + inputColor.rgb + ")",
'Input Background': "rgba(" + inputColor.rgb + ", .9)",
'Input Border': "rgb(" + inputbColor.rgb + ")",
'Hovered Input Background': "rgba(" + inputColor.hover + ", .9)",
'Hovered Input Border': "rgb(" + inputbColor.rgb + ")",
'Focused Input Background': "rgba(" + inputColor.hover + ", .9)",
'Focused Input Border': "rgb(" + inputbColor.rgb + ")",
'Buttons Background': "rgba(" + inputColor.rgb + ", .9)",
'Buttons Border': "rgb(" + inputbColor.rgb + ")",
'Navigation Background': "rgba(" + bgColor.rgb + "', 0.8)",
'Navigation Border': "rgb(" + mainColor.rgb + ")",
'Quotelinks': "rgb(" + linkColor.rgb + ")",
'Links': "rgb(" + linkColor.rgb + ")",
'Hovered Links': "rgb(" + linkHColor.rgb + ")",
'Navigation Links': "rgb(" + textColor.rgb + ")",
'Hovered Navigation Links': "rgb(" + linkHColor.rgb + ")",
'Subjects': "rgb(" + titleColor.rgb + ")",
'Names': "rgb(" + nameColor.rgb + ")",
'Sage': "rgb(" + sageColor.rgb + ")",
'Tripcodes': "rgb(" + tripColor.rgb + ")",
'Emails': "rgb(" + linkColor.rgb + ")",
'Post Numbers': "rgb(" + linkColor.rgb + ")",
'Text': "rgb(" + textColor.rgb + ")",
'Backlinks': "rgb(" + linkColor.rgb + ")",
'Greentext': "rgb(" + quoteColor.rgb + ")",
'Board Title': "rgb(" + textColor.rgb + ")",
'Timestamps': "rgb(" + timeColor.rgb + ")",
'Inputs': "rgb(" + textColor.rgb + ")",
'Warnings': "rgb(" + sageColor.rgb + ")",
'Shadow Color': "rgba(0,0,0,0.1)",
'Custom CSS': ".board {\npadding: 1px 2px;\n}\n.rice {\nbox-shadow:rgba(" + mainColor.shiftRGB(32) + (",.3) 0 1px;\n}\ninput[type=password]:hover,\ninput[type=text]:not([disabled]):hover,\ninput#fs_search:hover,\ninput.field:hover,\n.webkit select:hover,\ntextarea:hover,\n#options input:not([type=checkbox]):hover {\n box-shadow:inset rgba(0,0,0,.2) 0 1px 2px;\n}\ninput[type=password]:focus,\ninput[type=text]:focus,\ninput#fs_search:focus,\ninput.field:focus,\n.webkit select:focus,\ntextarea:focus,\n#options input:focus {\n box-shadow:inset rgba(0,0,0,.2) 0 1px 2px;\n}\nbutton,\ninput,\ntextarea,\n.rice {\n transition:background .2s,box-shadow .2s;\n}\n " + (imported.customCSS || ''))
};
}
} else if (origin === 'appchan') {
Themes[name] = imported; Themes[name] = imported;
} }
return userThemes = $.get("userThemes", {}, function(_arg) { return $.get("userThemes", {}, function(_arg) {
var userThemes; var userThemes;
userThemes = _arg.userThemes; userThemes = _arg.userThemes;
userThemes[name] = Themes[name]; userThemes[name] = Themes[name];
$.set('userThemes', userThemes); $.set('userThemes', userThemes);
alert("Theme \"" + name + "\" imported!"); alert("Theme \"" + name + "\" imported!");
$.rm($("#themes", d.body)); return Settings.openSection.call({
return Settings.open('themes'); open: Settings.themes,
hyphenatedTitle: 'themes'
});
}); });
}; };
return reader.readAsText(file); return reader.readAsText(file);
@ -13629,7 +13579,7 @@
return $.after($('input[name="Stubs"]', section).parentNode.parentNode, div); return $.after($('input[name="Stubs"]', section).parentNode.parentNode, div);
}, },
"export": function(now, data) { "export": function(now, data) {
var a, db, span, _i, _len; var a, db, _i, _len;
if (typeof now !== 'number') { if (typeof now !== 'number') {
now = Date.now(); now = Date.now();
@ -13658,11 +13608,7 @@
href: "data:application/json;base64," + (btoa(unescape(encodeURIComponent(JSON.stringify(data, null, 2))))), href: "data:application/json;base64," + (btoa(unescape(encodeURIComponent(JSON.stringify(data, null, 2))))),
target: '_blank' target: '_blank'
}); });
a.click(); return a.click();
return;
span = $('.imp-exp-result', Settings.dialog);
$.rmAll(span);
return $.add(span, a);
}, },
"import": function() { "import": function() {
return this.nextElementSibling.click(); return this.nextElementSibling.click();
@ -14127,7 +14073,7 @@
} }
div = $.el('div', { div = $.el('div', {
id: 'addthemes', id: 'addthemes',
innerHTML: "<a id=newtheme href='javascript:;'>New Theme</a>\n/\n<a id=import href='javascript:;'>Import Theme</a><input id=importbutton type=file hidden>\n/\n<a id=SSimport href='javascript:;'>Import from 4chan SS</a><input id=SSimportbutton type=file hidden>\n/\n<a id=OCimport href='javascript:;'>Import from Oneechan</a><input id=OCimportbutton type=file hidden>\n/\n<a id=tUndelete href='javascript:;'>Undelete Theme</a>" innerHTML: "<a id=newtheme href='javascript:;'>New Theme</a>\n/\n<a id=import href='javascript:;' title='From Appchan X, Oneechan, or 4chan SS'>Import Theme</a><input id=importbutton type=file hidden>\n/\n<a id=tUndelete href='javascript:;'>Undelete Theme</a>"
}); });
$.on($("#newtheme", div), 'click', function() { $.on($("#newtheme", div), 'click', function() {
ThemeTools.init("untitled"); ThemeTools.init("untitled");
@ -14136,21 +14082,7 @@
$.on($("#import", div), 'click', function() { $.on($("#import", div), 'click', function() {
return this.nextSibling.click(); return this.nextSibling.click();
}); });
$.on($("#importbutton", div), 'change', function(e) { $.on($("#importbutton", div), 'change', ThemeTools.importtheme);
return ThemeTools.importtheme("appchan", e);
});
$.on($("#OCimport", div), 'click', function() {
return this.nextSibling.click();
});
$.on($("#OCimportbutton", div), 'change', function(e) {
return ThemeTools.importtheme("oneechan", e);
});
$.on($("#SSimportbutton", div), 'change', function(e) {
return ThemeTools.importtheme("SS", e);
});
$.on($("#SSimport", div), 'click', function() {
return this.nextSibling.click();
});
$.on($('#tUndelete', div), 'click', function() { $.on($('#tUndelete', div), 'click', function() {
var themes; var themes;
@ -14445,12 +14377,7 @@
name = this.parentElement.parentElement.id; name = this.parentElement.parentElement.id;
exportMascot = Mascots[name]; exportMascot = Mascots[name];
exportMascot['Mascot'] = name; exportMascot['Mascot'] = name;
exportedMascot = "data:application/json," + encodeURIComponent(JSON.stringify(exportMascot)); return exportedMascot = "data:application/json," + encodeURIComponent(JSON.stringify(exportMascot));
if (window.open(exportedMascot, "_blank")) {
} else if (confirm("Your popup blocker is preventing Appchan X from exporting this theme. Would you like to open the exported theme in this window?")) {
return window.location(exportedMascot);
}
}, },
restore: function() { restore: function() {
if (confirm("Are you sure you want to restore \"" + this.id + "\"?")) { if (confirm("Are you sure you want to restore \"" + this.id + "\"?")) {
@ -14495,18 +14422,19 @@
return Settings.close(); return Settings.close();
}, },
"export": function(e) { "export": function(e) {
var exportTheme, exportedTheme; var a, data;
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
exportTheme = Themes[this.name]; data = Themes[this.name];
exportTheme['Theme'] = this.name; data['Theme'] = this.name;
exportedTheme = "data:application/json," + encodeURIComponent(JSON.stringify(exportTheme)); a = $.el('a', {
if (window.open(exportedTheme, "_blank")) { textContent: '>>Save me!',
download: "" + this.name + "-" + (Date.now()) + ".json",
} else if (confirm("Your popup blocker is preventing Appchan X from exporting this theme. Would you like to open the exported theme in this window?")) { href: "data:application/json;base64," + (btoa(unescape(encodeURIComponent(JSON.stringify(data, null, 2))))),
return window.location(exportedTheme); target: '_blank'
} });
return a.click();
}, },
"delete": function(e) { "delete": function(e) {
var container, settheme, var container, settheme,

View File

@ -192,12 +192,12 @@ Settings =
target: '_blank' target: '_blank'
<% if (type !== 'userscript') { %> <% if (type !== 'userscript') { %>
a.click() a.click()
return <% } else { %>
<% } %>
# XXX Firefox won't let us download automatically. # XXX Firefox won't let us download automatically.
span = $ '.imp-exp-result', Settings.dialog span = $ '.imp-exp-result', Settings.dialog
$.rmAll span $.rmAll span
$.add span, a $.add span, a
<% } %>
import: -> import: ->
@nextElementSibling.click() @nextElementSibling.click()
@ -589,19 +589,8 @@ Settings =
$.on $("#import", div), 'click', -> $.on $("#import", div), 'click', ->
@nextSibling.click() @nextSibling.click()
$.on $("#importbutton", div), 'change', (e) ->
ThemeTools.importtheme "appchan", e
$.on $("#OCimport", div), 'click', -> $.on $("#importbutton", div), 'change', ThemeTools.importtheme
@nextSibling.click()
$.on $("#OCimportbutton", div), 'change', (e) ->
ThemeTools.importtheme "oneechan", e
$.on $("#SSimportbutton", div), 'change', (e) ->
ThemeTools.importtheme "SS", e
$.on $("#SSimport", div), 'click', ->
@nextSibling.click()
$.on $('#tUndelete', div), 'click', -> $.on $('#tUndelete', div), 'click', ->
$.rm $.id "themeContainer" $.rm $.id "themeContainer"
@ -862,11 +851,6 @@ Settings =
exportMascot['Mascot'] = name exportMascot['Mascot'] = name
exportedMascot = "data:application/json," + encodeURIComponent(JSON.stringify(exportMascot)) exportedMascot = "data:application/json," + encodeURIComponent(JSON.stringify(exportMascot))
if window.open exportedMascot, "_blank"
return
else if confirm "Your popup blocker is preventing Appchan X from exporting this theme. Would you like to open the exported theme in this window?"
window.location exportedMascot
restore: -> restore: ->
if confirm "Are you sure you want to restore \"#{@id}\"?" if confirm "Are you sure you want to restore \"#{@id}\"?"
Conf["Deleted Mascots"].remove @id Conf["Deleted Mascots"].remove @id
@ -906,14 +890,22 @@ Settings =
export: (e) -> export: (e) ->
e.preventDefault() e.preventDefault()
e.stopPropagation() e.stopPropagation()
exportTheme = Themes[@name] data = Themes[@name]
exportTheme['Theme'] = @name data['Theme'] = @name
exportedTheme = "data:application/json," + encodeURIComponent(JSON.stringify(exportTheme))
if window.open exportedTheme, "_blank" a = $.el 'a',
return textContent: '>>Save me!'
else if confirm "Your popup blocker is preventing Appchan X from exporting this theme. Would you like to open the exported theme in this window?" download: "#{@name}-#{Date.now()}.json"
window.location exportedTheme href: "data:application/json;base64,#{btoa unescape encodeURIComponent JSON.stringify data, null, 2}"
target: '_blank'
<% if (type !== 'userscript') { %>
a.click()
<% } else { %>
# XXX Firefox won't let us download automatically.
$.on a, 'click', (e) ->
e.stopPropagation()
$.replace @, a
<% } %>
delete: (e) -> delete: (e) ->
e.preventDefault() e.preventDefault()

View File

@ -1,27 +0,0 @@
.rice {
box-shadow:rgba(""" + mainColor.shiftRGB(32) + """,.3) 0 1px;
}
input[type=password]:hover,
input[type=text]:not([disabled]):hover,
input#fs_search:hover,
input.field:hover,
.webkit select:hover,
textarea:hover,
#options input:not([type=checkbox]):hover {
box-shadow:inset rgba(0,0,0,.2) 0 1px 2px;
}
input[type=password]:focus,
input[type=text]:focus,
input#fs_search:focus,
input.field:focus,
.webkit select:focus,
textarea:focus,
#options input:focus {
box-shadow:inset rgba(0,0,0,.2) 0 1px 2px;
}
button,
input,
textarea,
.rice {
transition:background .2s,box-shadow .2s;
}

View File

@ -1,12 +1,6 @@
<a id=newtheme href='javascript:;'>New Theme</a> <a id=newtheme href='javascript:;'>New Theme</a>
/ /
<a id=import href='javascript:;'>Import Theme</a> <a id=import href='javascript:;' title='From Appchan X, Oneechan, or 4chan SS'>Import Theme</a>
<input id=importbutton type=file hidden> <input id=importbutton type=file hidden>
/ /
<a id=SSimport href='javascript:;'>Import from 4chan SS</a>
<input id=SSimportbutton type=file hidden>
/
<a id=OCimport href='javascript:;'>Import from Oneechan</a>
<input id=OCimportbutton type=file hidden>
/
<a id=tUndelete href='javascript:;'>Undelete Theme</a> <a id=tUndelete href='javascript:;'>Undelete Theme</a>

View File

@ -44,7 +44,6 @@ ThemeTools =
"Focused Input Border" "Focused Input Border"
"Checkbox Background" "Checkbox Background"
"Checkbox Border" "Checkbox Border"
"Checkbox Checked Background"
"Buttons Background" "Buttons Background"
"Buttons Border" "Buttons Border"
"Navigation Background" "Navigation Background"
@ -111,7 +110,7 @@ ThemeTools =
div = $.el "div", div = $.el "div",
className: "themevar" className: "themevar"
innerHTML: "<div class=optionname><b>#{item}</b></div><div class=option><input name='#{item}' placeholder='#{if item == "Background Image" then "Shift+Click to upload image" else item}'>" innerHTML: "<div class=optionname><b>#{item}</b></div><div class=option><input name='#{item}' placeholder='#{if item is "Background Image" then "Shift+Click to upload image" else item}'>"
input = $('input', div) input = $('input', div)
@ -167,7 +166,7 @@ ThemeTools =
if (depth isnt 0) or toggle1 or toggle2 if (depth isnt 0) or toggle1 or toggle2
return alert "Syntax error on #{@name}." return alert "Syntax error on #{@name}."
if @className == "colorfield" if @className is "colorfield"
@nextSibling.value = "##{Style.colorToHex(@value) or 'aaaaaa'}" @nextSibling.value = "##{Style.colorToHex(@value) or 'aaaaaa'}"
@nextSibling.color.importColor() @nextSibling.color.importColor()
@ -214,7 +213,7 @@ ThemeTools =
reader.readAsDataURL file reader.readAsDataURL file
importtheme: (origin, evt) -> importtheme: (evt) ->
file = evt.target.files[0] file = evt.target.files[0]
reader = new FileReader() reader = new FileReader()
@ -222,158 +221,113 @@ ThemeTools =
try try
imported = JSON.parse e.target.result imported = JSON.parse e.target.result
unless imported
throw "Cannot parse file"
catch err catch err
alert err alert err
return return
unless (origin != 'appchan' and imported.mainColor) or (origin == 'appchan' and imported["Author Tripcode"]) name = imported.name or imported['Theme']
unless name
alert "Theme file is invalid." alert "Theme file is invalid."
return return
name = imported.name or imported["Theme"]
delete imported.name delete imported.name or imported['Theme']
if Themes[name] and not Themes[name]["Deleted"] if Themes[name] and not Themes[name]["Deleted"]
if confirm "A theme with this name already exists. Would you like to over-write?" if confirm 'A theme with this name already exists. Would you like to over-write?'
delete Themes[name] delete Themes[name]
else else
return return
if origin == "oneechan" or origin == "SS" # 4chan SS / Oneechan
bgColor = new Style.color(imported.bgColor); if imported.bgColor
mainColor = new Style.color(imported.mainColor); unless imported.replyOp
brderColor = new Style.color(imported.brderColor); imported.replyOp = "0.9"
inputColor = new Style.color(imported.inputColor);
inputbColor = new Style.color(imported.inputbColor);
blinkColor = new Style.color(imported.blinkColor);
jlinkColor = new Style.color(imported.jlinkColor);
linkColor = new Style.color(imported.linkColor);
linkHColor = new Style.color(imported.linkHColor);
nameColor = new Style.color(imported.nameColor);
quoteColor = new Style.color(imported.quoteColor);
sageColor = new Style.color(imported.sageColor);
textColor = new Style.color(imported.textColor);
titleColor = new Style.color(imported.titleColor);
tripColor = new Style.color(imported.tripColor);
timeColor = new Style.color(imported.timeColor || imported.textColor);
if imported.bgRPA bgRPA = if imported.bgRPA
bgRPA = imported.bgRPA.split(' ') imported.bgRPA.split ' '
else else
bgRPA = ['no-repeat', 'bottom', 'left', 'fixed'] ['no-repeat', 'bottom', 'left', 'fixed']
if origin == "oneechan" color = Style.color
Themes[name] =
'Author' : "Anonymous"
'Author Tripcode' : "!POMF.9waa"
'Background Image' : "url('#{imported.bgImg or ''}')"
'Background Attachment' : "#{bgRPA[3] or ''}"
'Background Position' : "#{bgRPA[1] or ''} #{bgRPA[2] or ''}"
'Background Repeat' : "#{bgRPA[0] or ''}"
'Background Color' : "rgb(#{bgColor.rgb})"
'Dialog Background' : "rgba(#{mainColor.rgb},.98)"
'Dialog Border' : "rgb(#{brderColor.rgb})"
'Thread Wrapper Background' : "rgba(0,0,0,0)"
'Thread Wrapper Border' : "rgba(0,0,0,0)"
'Reply Background' : "rgba(#{mainColor.rgb},#{imported.replyOp})"
'Reply Border' : "rgb(#{brderColor.rgb})"
'Highlighted Reply Background': "rgba(#{mainColor.shiftRGB(4, true)}, #{imported.replyOp})"
'Highlighted Reply Border' : "rgb(#{linkColor.rgb})"
'Backlinked Reply Outline' : "rgb(#{linkColor.rgb})"
'Checkbox Background' : "rgba(#{inputColor.rgb}, #{imported.replyOp})"
'Checkbox Border' : "rgb(#{inputbColor.rgb})"
'Checkbox Checked Background' : "rgb(#{inputColor.rgb})"
'Input Background' : "rgba(#{inputColor.rgb}, #{imported.replyOp})"
'Input Border' : "rgb(#{inputbColor.rgb})"
'Hovered Input Background' : "rgba(#{inputColor.hover}, #{imported.replyOp})"
'Hovered Input Border' : "rgb(#{inputbColor.rgb})"
'Focused Input Background' : "rgba(#{inputColor.hover}, #{imported.replyOp})"
'Focused Input Border' : "rgb(#{inputbColor.rgb})"
'Buttons Background' : "rgba(#{inputColor.rgb}, #{imported.replyOp})"
'Buttons Border' : "rgb(#{inputbColor.rgb})"
'Navigation Background' : "rgba(#{bgColor.rgb}, 0.8)"
'Navigation Border' : "rgb(#{mainColor.rgb})"
'Quotelinks' : "rgb(#{linkColor.rgb})"
'Links' : "rgb(#{linkColor.rgb})"
'Hovered Links' : "rgb(#{linkHColor.rgb})"
'Navigation Links' : "rgb(#{textColor.rgb})"
'Hovered Navigation Links' : "rgb(#{linkHColor.rgb})"
'Subjects' : "rgb(#{titleColor.rgb})"
'Names' : "rgb(#{nameColor.rgb})"
'Sage' : "rgb(#{sageColor.rgb})"
'Tripcodes' : "rgb(#{tripColor.rgb})"
'Emails' : "rgb(#{linkColor.rgb})"
'Post Numbers' : "rgb(#{linkColor.rgb})"
'Text' : "rgb(#{textColor.rgb})"
'Backlinks' : "rgb(#{linkColor.rgb})"
'Greentext' : "rgb(#{quoteColor.rgb})"
'Board Title' : "rgb(#{textColor.rgb})"
'Timestamps' : "rgb(#{timeColor.rgb})"
'Inputs' : "rgb(#{textColor.rgb})"
'Warnings' : "rgb(#{sageColor.rgb})"
'Shadow Color' : "rgba(0,0,0,0.1)"
'Custom CSS' : """<%= grunt.file.read('src/General/css/theme.oneechan.css') %> #{imported.customCSS or ''}"""
else if origin == "SS" bgColor = new color imported.bgColor
Themes[name] = mainColor = new color imported.mainColor
'Author' : "Anonymous" brderColor = new color imported.brderColor
'Author Tripcode' : "!.pC/AHOKAg" inputColor = new color imported.inputColor
'Background Image' : "url('#{imported.bgImg or ''}')" inputbColor = new color imported.inputbColor
'Background Attachment' : "#{bgRPA[3] or ''}" blinkColor = new color imported.blinkColor
'Background Position' : "#{bgRPA[1] or ''} #{bgRPA[2] or ''}" jlinkColor = new color imported.jlinkColor
'Background Repeat' : "#{bgRPA[0] or ''}" linkColor = new color imported.linkColor
'Background Color' : "rgb(#{bgColor.rgb})" linkHColor = new color imported.linkHColor
'Dialog Background' : "rgba(#{mainColor.rgb}, .98)" nameColor = new color imported.nameColor
'Dialog Border' : "rgb(#{brderColor.rgb})" quoteColor = new color imported.quoteColor
'Thread Wrapper Background' : "rgba(#{mainColor.rgb}, .5)" sageColor = new color imported.sageColor
'Thread Wrapper Border' : "rgba(#{brderColor.rgb}, .9)" textColor = new color imported.textColor
'Reply Background' : "rgba(#{mainColor.rgb}, .9)" titleColor = new color imported.titleColor
'Reply Border' : "rgb(#{brderColor.rgb})" tripColor = new color imported.tripColor
'Highlighted Reply Background': "rgba(#{mainColor.shiftRGB(4, true)}, .9)" timeColor = new color imported.timeColor or imported.textColor
'Highlighted Reply Border' : "rgb(#{linkColor.rgb})"
'Backlinked Reply Outline' : "rgb(#{linkColor.rgb})"
'Checkbox Background' : "rgba(#{inputColor.rgb}, .9)"
'Checkbox Border' : "rgb(#{inputbColor.rgb})"
'Checkbox Checked Background' : "rgb(#{inputColor.rgb})"
'Input Background' : "rgba(#{inputColor.rgb}, .9)"
'Input Border' : "rgb(#{inputbColor.rgb})"
'Hovered Input Background' : "rgba(#{inputColor.hover}, .9)"
'Hovered Input Border' : "rgb(#{inputbColor.rgb})"
'Focused Input Background' : "rgba(#{inputColor.hover}, .9)"
'Focused Input Border' : "rgb(#{inputbColor.rgb})"
'Buttons Background' : "rgba(#{inputColor.rgb}, .9)"
'Buttons Border' : "rgb(#{inputbColor.rgb})"
'Navigation Background' : "rgba(#{bgColor.rgb}', 0.8)"
'Navigation Border' : "rgb(#{mainColor.rgb})"
'Quotelinks' : "rgb(#{linkColor.rgb})"
'Links' : "rgb(#{linkColor.rgb})"
'Hovered Links' : "rgb(#{linkHColor.rgb})"
'Navigation Links' : "rgb(#{textColor.rgb})"
'Hovered Navigation Links' : "rgb(#{linkHColor.rgb})"
'Subjects' : "rgb(#{titleColor.rgb})"
'Names' : "rgb(#{nameColor.rgb})"
'Sage' : "rgb(#{sageColor.rgb})"
'Tripcodes' : "rgb(#{tripColor.rgb})"
'Emails' : "rgb(#{linkColor.rgb})"
'Post Numbers' : "rgb(#{linkColor.rgb})"
'Text' : "rgb(#{textColor.rgb})"
'Backlinks' : "rgb(#{linkColor.rgb})"
'Greentext' : "rgb(#{quoteColor.rgb})"
'Board Title' : "rgb(#{textColor.rgb})"
'Timestamps' : "rgb(#{timeColor.rgb})"
'Inputs' : "rgb(#{textColor.rgb})"
'Warnings' : "rgb(#{sageColor.rgb})"
'Shadow Color' : "rgba(0,0,0,0.1)"
'Custom CSS' : """<%= grunt.file.read('src/General/css/theme.4chanss.css') %> #{imported.customCSS or ''}"""
else if origin == 'appchan' Themes[name] =
'Author': "Anonymous"
'Author Tripcode': "!POMF.9waa"
'Background Image': "url('#{imported.bgImg or ''}')"
'Background Attachment': "#{bgRPA[3] or ''}"
'Background Position': "#{bgRPA[1] or ''} #{bgRPA[2] or ''}"
'Background Repeat': "#{bgRPA[0] or ''}"
'Background Color': "rgb(#{bgColor.rgb})"
'Dialog Background': "rgba(#{mainColor.rgb},.98)"
'Dialog Border': "rgb(#{brderColor.rgb})"
'Thread Wrapper Background': "rgba(0,0,0,0)"
'Thread Wrapper Border': "rgba(0,0,0,0)"
'Reply Background': "rgba(#{mainColor.rgb},#{imported.replyOp})"
'Reply Border': "rgb(#{brderColor.rgb})"
'Highlighted Reply Background': "rgba(#{mainColor.shiftRGB(4, true)},#{imported.replyOp})"
'Highlighted Reply Border': "rgb(#{linkColor.rgb})"
'Backlinked Reply Outline': "rgb(#{linkColor.rgb})"
'Checkbox Background': "rgba(#{inputColor.rgb},#{imported.replyOp})"
'Checkbox Border': "rgb(#{inputbColor.rgb})"
'Input Background': "rgba(#{inputColor.rgb},#{imported.replyOp})"
'Input Border': "rgb(#{inputbColor.rgb})"
'Hovered Input Background': "rgba(#{inputColor.hover},#{imported.replyOp})"
'Hovered Input Border': "rgb(#{inputbColor.rgb})"
'Focused Input Background': "rgba(#{inputColor.hover},#{imported.replyOp})"
'Focused Input Border': "rgb(#{inputbColor.rgb})"
'Buttons Background': "rgba(#{inputColor.rgb},#{imported.replyOp})"
'Buttons Border': "rgb(#{inputbColor.rgb})"
'Navigation Background': "rgba(#{bgColor.rgb},0.8)"
'Navigation Border': "rgb(#{mainColor.rgb})"
'Quotelinks': "rgb(#{linkColor.rgb})"
'Links': "rgb(#{linkColor.rgb})"
'Hovered Links': "rgb(#{linkHColor.rgb})"
'Navigation Links': "rgb(#{textColor.rgb})"
'Hovered Navigation Links': "rgb(#{linkHColor.rgb})"
'Subjects': "rgb(#{titleColor.rgb})"
'Names': "rgb(#{nameColor.rgb})"
'Sage': "rgb(#{sageColor.rgb})"
'Tripcodes': "rgb(#{tripColor.rgb})"
'Emails': "rgb(#{linkColor.rgb})"
'Post Numbers': "rgb(#{linkColor.rgb})"
'Text': "rgb(#{textColor.rgb})"
'Backlinks': "rgb(#{linkColor.rgb})"
'Greentext': "rgb(#{quoteColor.rgb})"
'Board Title': "rgb(#{textColor.rgb})"
'Timestamps': "rgb(#{timeColor.rgb})"
'Inputs': "rgb(#{textColor.rgb})"
'Warnings': "rgb(#{sageColor.rgb})"
'Shadow Color': "rbga(0,0,0,0.1)"
'Custom CSS': """<%= grunt.file.read('src/General/css/theme.import.css') %> #{imported.customCSS or ''}"""
else
Themes[name] = imported Themes[name] = imported
userThemes = $.get "userThemes", {}, ({userThemes})-> $.get "userThemes", {}, ({userThemes}) ->
userThemes[name] = Themes[name] userThemes[name] = Themes[name]
$.set 'userThemes', userThemes $.set 'userThemes', userThemes
alert "Theme \"#{name}\" imported!" alert "Theme \"#{name}\" imported!"
$.rm $("#themes", d.body)
Settings.open 'themes' Settings.openSection.call {open: Settings.themes, hyphenatedTitle: 'themes'}
reader.readAsText(file) reader.readAsText(file)