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.
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE

View File

@ -20,7 +20,7 @@
// ==/UserScript==
/*
* appchan x - Version 2.0.4 - 2013-05-27
* appchan x - Version 2.0.4 - 2013-05-28
*
* Licensed under the MIT license.
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE
@ -11707,7 +11707,7 @@
editTheme["Author"] = "Author";
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", {
id: "themeConf",
className: "reply dialog",
@ -11843,173 +11843,123 @@
};
return reader.readAsDataURL(file);
},
importtheme: function(origin, evt) {
importtheme: function(evt) {
var file, reader;
file = evt.target.files[0];
reader = new FileReader();
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 {
imported = JSON.parse(e.target.result);
if (!imported) {
throw "Cannot parse file";
}
} catch (_error) {
err = _error;
alert(err);
return;
}
if (!((origin !== 'appchan' && imported.mainColor) || (origin === 'appchan' && imported["Author Tripcode"]))) {
name = imported.name || imported['Theme'];
if (!name) {
alert("Theme file is invalid.");
return;
}
name = imported.name || imported["Theme"];
delete imported.name;
delete imported.name || imported['Theme'];
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];
} else {
return;
}
}
if (origin === "oneechan" || origin === "SS") {
bgColor = new Style.color(imported.bgColor);
mainColor = new Style.color(imported.mainColor);
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 (imported.bgColor) {
if (!imported.replyOp) {
imported.replyOp = "0.9";
}
if (origin === "oneechan") {
Themes[name] = {
'Author': "Anonymous",
'Author Tripcode': "!POMF.9waa",
'Background Image': "url('" + (imported.bgImg || '') + "')",
'Background Attachment': "" + (bgRPA[3] || ''),
'Background Position': "" + (bgRPA[1] || '') + " " + (bgRPA[2] || ''),
'Background Repeat': "" + (bgRPA[0] || ''),
'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': ".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 === "SS") {
Themes[name] = {
'Author': "Anonymous",
'Author Tripcode': "!.pC/AHOKAg",
'Background Image': "url('" + (imported.bgImg || '') + "')",
'Background Attachment': "" + (bgRPA[3] || ''),
'Background Position': "" + (bgRPA[1] || '') + " " + (bgRPA[2] || ''),
'Background Repeat': "" + (bgRPA[0] || ''),
'Background Color': "rgb(" + bgColor.rgb + ")",
'Dialog Background': "rgba(" + mainColor.rgb + ", .98)",
'Dialog Border': "rgb(" + brderColor.rgb + ")",
'Thread Wrapper Background': "rgba(" + mainColor.rgb + ", .5)",
'Thread Wrapper Border': "rgba(" + brderColor.rgb + ", .9)",
'Reply Background': "rgba(" + mainColor.rgb + ", .9)",
'Reply Border': "rgb(" + brderColor.rgb + ")",
'Highlighted Reply Background': "rgba(" + (mainColor.shiftRGB(4, true)) + ", .9)",
'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': ".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') {
bgRPA = imported.bgRPA ? imported.bgRPA.split(' ') : ['no-repeat', 'bottom', 'left', 'fixed'];
color = Style.color;
bgColor = new color(imported.bgColor);
mainColor = new color(imported.mainColor);
brderColor = new color(imported.brderColor);
inputColor = new color(imported.inputColor);
inputbColor = new color(imported.inputbColor);
blinkColor = new color(imported.blinkColor);
jlinkColor = new color(imported.jlinkColor);
linkColor = new color(imported.linkColor);
linkHColor = new color(imported.linkHColor);
nameColor = new color(imported.nameColor);
quoteColor = new color(imported.quoteColor);
sageColor = new color(imported.sageColor);
textColor = new color(imported.textColor);
titleColor = new color(imported.titleColor);
tripColor = new color(imported.tripColor);
timeColor = new color(imported.timeColor || imported.textColor);
Themes[name] = {
'Author': "Anonymous",
'Author Tripcode': "!POMF.9waa",
'Background Image': "url('" + (imported.bgImg || '') + "')",
'Background Attachment': "" + (bgRPA[3] || ''),
'Background Position': "" + (bgRPA[1] || '') + " " + (bgRPA[2] || ''),
'Background Repeat': "" + (bgRPA[0] || ''),
'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': ".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 {
Themes[name] = imported;
}
return userThemes = $.get("userThemes", {}, function(_arg) {
return $.get("userThemes", {}, function(_arg) {
var userThemes;
userThemes = _arg.userThemes;
userThemes[name] = Themes[name];
$.set('userThemes', userThemes);
alert("Theme \"" + name + "\" imported!");
$.rm($("#themes", d.body));
return Settings.open('themes');
return Settings.openSection.call({
open: Settings.themes,
hyphenatedTitle: 'themes'
});
});
};
return reader.readAsText(file);
@ -13652,7 +13602,7 @@
return $.after($('input[name="Stubs"]', section).parentNode.parentNode, div);
},
"export": function(now, data) {
var a, db, span, _i, _len;
var a, db, _i, _len;
if (typeof now !== 'number') {
now = Date.now();
@ -13681,11 +13631,7 @@
href: "data:application/json;base64," + (btoa(unescape(encodeURIComponent(JSON.stringify(data, null, 2))))),
target: '_blank'
});
a.click();
return;
span = $('.imp-exp-result', Settings.dialog);
$.rmAll(span);
return $.add(span, a);
return a.click();
},
"import": function() {
return this.nextElementSibling.click();
@ -14150,7 +14096,7 @@
}
div = $.el('div', {
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() {
ThemeTools.init("untitled");
@ -14159,21 +14105,7 @@
$.on($("#import", div), 'click', function() {
return this.nextSibling.click();
});
$.on($("#importbutton", div), 'change', function(e) {
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($("#importbutton", div), 'change', ThemeTools.importtheme);
$.on($('#tUndelete', div), 'click', function() {
var themes;
@ -14468,12 +14400,7 @@
name = this.parentElement.parentElement.id;
exportMascot = Mascots[name];
exportMascot['Mascot'] = name;
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);
}
return exportedMascot = "data:application/json," + encodeURIComponent(JSON.stringify(exportMascot));
},
restore: function() {
if (confirm("Are you sure you want to restore \"" + this.id + "\"?")) {
@ -14518,18 +14445,19 @@
return Settings.close();
},
"export": function(e) {
var exportTheme, exportedTheme;
var a, data;
e.preventDefault();
e.stopPropagation();
exportTheme = Themes[this.name];
exportTheme['Theme'] = this.name;
exportedTheme = "data:application/json," + encodeURIComponent(JSON.stringify(exportTheme));
if (window.open(exportedTheme, "_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(exportedTheme);
}
data = Themes[this.name];
data['Theme'] = this.name;
a = $.el('a', {
textContent: '>>Save me!',
download: "" + this.name + "-" + (Date.now()) + ".json",
href: "data:application/json;base64," + (btoa(unescape(encodeURIComponent(JSON.stringify(data, null, 2))))),
target: '_blank'
});
return a.click();
},
"delete": function(e) {
var container, settheme,

View File

@ -20,7 +20,7 @@
// ==/UserScript==
/*
* appchan x - Version 2.0.4 - 2013-05-27
* appchan x - Version 2.0.4 - 2013-05-28
*
* Licensed under the MIT license.
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE
@ -11701,7 +11701,7 @@
editTheme["Author"] = "Author";
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", {
id: "themeConf",
className: "reply dialog",
@ -11837,173 +11837,123 @@
};
return reader.readAsDataURL(file);
},
importtheme: function(origin, evt) {
importtheme: function(evt) {
var file, reader;
file = evt.target.files[0];
reader = new FileReader();
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 {
imported = JSON.parse(e.target.result);
if (!imported) {
throw "Cannot parse file";
}
} catch (_error) {
err = _error;
alert(err);
return;
}
if (!((origin !== 'appchan' && imported.mainColor) || (origin === 'appchan' && imported["Author Tripcode"]))) {
name = imported.name || imported['Theme'];
if (!name) {
alert("Theme file is invalid.");
return;
}
name = imported.name || imported["Theme"];
delete imported.name;
delete imported.name || imported['Theme'];
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];
} else {
return;
}
}
if (origin === "oneechan" || origin === "SS") {
bgColor = new Style.color(imported.bgColor);
mainColor = new Style.color(imported.mainColor);
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 (imported.bgColor) {
if (!imported.replyOp) {
imported.replyOp = "0.9";
}
if (origin === "oneechan") {
Themes[name] = {
'Author': "Anonymous",
'Author Tripcode': "!POMF.9waa",
'Background Image': "url('" + (imported.bgImg || '') + "')",
'Background Attachment': "" + (bgRPA[3] || ''),
'Background Position': "" + (bgRPA[1] || '') + " " + (bgRPA[2] || ''),
'Background Repeat': "" + (bgRPA[0] || ''),
'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': ".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 === "SS") {
Themes[name] = {
'Author': "Anonymous",
'Author Tripcode': "!.pC/AHOKAg",
'Background Image': "url('" + (imported.bgImg || '') + "')",
'Background Attachment': "" + (bgRPA[3] || ''),
'Background Position': "" + (bgRPA[1] || '') + " " + (bgRPA[2] || ''),
'Background Repeat': "" + (bgRPA[0] || ''),
'Background Color': "rgb(" + bgColor.rgb + ")",
'Dialog Background': "rgba(" + mainColor.rgb + ", .98)",
'Dialog Border': "rgb(" + brderColor.rgb + ")",
'Thread Wrapper Background': "rgba(" + mainColor.rgb + ", .5)",
'Thread Wrapper Border': "rgba(" + brderColor.rgb + ", .9)",
'Reply Background': "rgba(" + mainColor.rgb + ", .9)",
'Reply Border': "rgb(" + brderColor.rgb + ")",
'Highlighted Reply Background': "rgba(" + (mainColor.shiftRGB(4, true)) + ", .9)",
'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': ".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') {
bgRPA = imported.bgRPA ? imported.bgRPA.split(' ') : ['no-repeat', 'bottom', 'left', 'fixed'];
color = Style.color;
bgColor = new color(imported.bgColor);
mainColor = new color(imported.mainColor);
brderColor = new color(imported.brderColor);
inputColor = new color(imported.inputColor);
inputbColor = new color(imported.inputbColor);
blinkColor = new color(imported.blinkColor);
jlinkColor = new color(imported.jlinkColor);
linkColor = new color(imported.linkColor);
linkHColor = new color(imported.linkHColor);
nameColor = new color(imported.nameColor);
quoteColor = new color(imported.quoteColor);
sageColor = new color(imported.sageColor);
textColor = new color(imported.textColor);
titleColor = new color(imported.titleColor);
tripColor = new color(imported.tripColor);
timeColor = new color(imported.timeColor || imported.textColor);
Themes[name] = {
'Author': "Anonymous",
'Author Tripcode': "!POMF.9waa",
'Background Image': "url('" + (imported.bgImg || '') + "')",
'Background Attachment': "" + (bgRPA[3] || ''),
'Background Position': "" + (bgRPA[1] || '') + " " + (bgRPA[2] || ''),
'Background Repeat': "" + (bgRPA[0] || ''),
'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': ".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 {
Themes[name] = imported;
}
return userThemes = $.get("userThemes", {}, function(_arg) {
return $.get("userThemes", {}, function(_arg) {
var userThemes;
userThemes = _arg.userThemes;
userThemes[name] = Themes[name];
$.set('userThemes', userThemes);
alert("Theme \"" + name + "\" imported!");
$.rm($("#themes", d.body));
return Settings.open('themes');
return Settings.openSection.call({
open: Settings.themes,
hyphenatedTitle: 'themes'
});
});
};
return reader.readAsText(file);
@ -14142,7 +14092,7 @@
}
div = $.el('div', {
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() {
ThemeTools.init("untitled");
@ -14151,21 +14101,7 @@
$.on($("#import", div), 'click', function() {
return this.nextSibling.click();
});
$.on($("#importbutton", div), 'change', function(e) {
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($("#importbutton", div), 'change', ThemeTools.importtheme);
$.on($('#tUndelete', div), 'click', function() {
var themes;
@ -14460,12 +14396,7 @@
name = this.parentElement.parentElement.id;
exportMascot = Mascots[name];
exportMascot['Mascot'] = name;
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);
}
return exportedMascot = "data:application/json," + encodeURIComponent(JSON.stringify(exportMascot));
},
restore: function() {
if (confirm("Are you sure you want to restore \"" + this.id + "\"?")) {
@ -14510,18 +14441,22 @@
return Settings.close();
},
"export": function(e) {
var exportTheme, exportedTheme;
var a, data;
e.preventDefault();
e.stopPropagation();
exportTheme = Themes[this.name];
exportTheme['Theme'] = this.name;
exportedTheme = "data:application/json," + encodeURIComponent(JSON.stringify(exportTheme));
if (window.open(exportedTheme, "_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(exportedTheme);
}
data = Themes[this.name];
data['Theme'] = this.name;
a = $.el('a', {
textContent: '>>Save me!',
download: "" + this.name + "-" + (Date.now()) + ".json",
href: "data:application/json;base64," + (btoa(unescape(encodeURIComponent(JSON.stringify(data, null, 2))))),
target: '_blank'
});
$.on(a, 'click', function(e) {
return e.stopPropagation();
});
return $.replace(this, a);
},
"delete": function(e) {
var container, settheme,

View File

@ -1,6 +1,6 @@
// 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.
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE
@ -11684,7 +11684,7 @@
editTheme["Author"] = "Author";
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", {
id: "themeConf",
className: "reply dialog",
@ -11820,173 +11820,123 @@
};
return reader.readAsDataURL(file);
},
importtheme: function(origin, evt) {
importtheme: function(evt) {
var file, reader;
file = evt.target.files[0];
reader = new FileReader();
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 {
imported = JSON.parse(e.target.result);
if (!imported) {
throw "Cannot parse file";
}
} catch (_error) {
err = _error;
alert(err);
return;
}
if (!((origin !== 'appchan' && imported.mainColor) || (origin === 'appchan' && imported["Author Tripcode"]))) {
name = imported.name || imported['Theme'];
if (!name) {
alert("Theme file is invalid.");
return;
}
name = imported.name || imported["Theme"];
delete imported.name;
delete imported.name || imported['Theme'];
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];
} else {
return;
}
}
if (origin === "oneechan" || origin === "SS") {
bgColor = new Style.color(imported.bgColor);
mainColor = new Style.color(imported.mainColor);
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 (imported.bgColor) {
if (!imported.replyOp) {
imported.replyOp = "0.9";
}
if (origin === "oneechan") {
Themes[name] = {
'Author': "Anonymous",
'Author Tripcode': "!POMF.9waa",
'Background Image': "url('" + (imported.bgImg || '') + "')",
'Background Attachment': "" + (bgRPA[3] || ''),
'Background Position': "" + (bgRPA[1] || '') + " " + (bgRPA[2] || ''),
'Background Repeat': "" + (bgRPA[0] || ''),
'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': ".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 === "SS") {
Themes[name] = {
'Author': "Anonymous",
'Author Tripcode': "!.pC/AHOKAg",
'Background Image': "url('" + (imported.bgImg || '') + "')",
'Background Attachment': "" + (bgRPA[3] || ''),
'Background Position': "" + (bgRPA[1] || '') + " " + (bgRPA[2] || ''),
'Background Repeat': "" + (bgRPA[0] || ''),
'Background Color': "rgb(" + bgColor.rgb + ")",
'Dialog Background': "rgba(" + mainColor.rgb + ", .98)",
'Dialog Border': "rgb(" + brderColor.rgb + ")",
'Thread Wrapper Background': "rgba(" + mainColor.rgb + ", .5)",
'Thread Wrapper Border': "rgba(" + brderColor.rgb + ", .9)",
'Reply Background': "rgba(" + mainColor.rgb + ", .9)",
'Reply Border': "rgb(" + brderColor.rgb + ")",
'Highlighted Reply Background': "rgba(" + (mainColor.shiftRGB(4, true)) + ", .9)",
'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': ".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') {
bgRPA = imported.bgRPA ? imported.bgRPA.split(' ') : ['no-repeat', 'bottom', 'left', 'fixed'];
color = Style.color;
bgColor = new color(imported.bgColor);
mainColor = new color(imported.mainColor);
brderColor = new color(imported.brderColor);
inputColor = new color(imported.inputColor);
inputbColor = new color(imported.inputbColor);
blinkColor = new color(imported.blinkColor);
jlinkColor = new color(imported.jlinkColor);
linkColor = new color(imported.linkColor);
linkHColor = new color(imported.linkHColor);
nameColor = new color(imported.nameColor);
quoteColor = new color(imported.quoteColor);
sageColor = new color(imported.sageColor);
textColor = new color(imported.textColor);
titleColor = new color(imported.titleColor);
tripColor = new color(imported.tripColor);
timeColor = new color(imported.timeColor || imported.textColor);
Themes[name] = {
'Author': "Anonymous",
'Author Tripcode': "!POMF.9waa",
'Background Image': "url('" + (imported.bgImg || '') + "')",
'Background Attachment': "" + (bgRPA[3] || ''),
'Background Position': "" + (bgRPA[1] || '') + " " + (bgRPA[2] || ''),
'Background Repeat': "" + (bgRPA[0] || ''),
'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': ".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 {
Themes[name] = imported;
}
return userThemes = $.get("userThemes", {}, function(_arg) {
return $.get("userThemes", {}, function(_arg) {
var userThemes;
userThemes = _arg.userThemes;
userThemes[name] = Themes[name];
$.set('userThemes', userThemes);
alert("Theme \"" + name + "\" imported!");
$.rm($("#themes", d.body));
return Settings.open('themes');
return Settings.openSection.call({
open: Settings.themes,
hyphenatedTitle: 'themes'
});
});
};
return reader.readAsText(file);
@ -13629,7 +13579,7 @@
return $.after($('input[name="Stubs"]', section).parentNode.parentNode, div);
},
"export": function(now, data) {
var a, db, span, _i, _len;
var a, db, _i, _len;
if (typeof now !== 'number') {
now = Date.now();
@ -13658,11 +13608,7 @@
href: "data:application/json;base64," + (btoa(unescape(encodeURIComponent(JSON.stringify(data, null, 2))))),
target: '_blank'
});
a.click();
return;
span = $('.imp-exp-result', Settings.dialog);
$.rmAll(span);
return $.add(span, a);
return a.click();
},
"import": function() {
return this.nextElementSibling.click();
@ -14127,7 +14073,7 @@
}
div = $.el('div', {
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() {
ThemeTools.init("untitled");
@ -14136,21 +14082,7 @@
$.on($("#import", div), 'click', function() {
return this.nextSibling.click();
});
$.on($("#importbutton", div), 'change', function(e) {
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($("#importbutton", div), 'change', ThemeTools.importtheme);
$.on($('#tUndelete', div), 'click', function() {
var themes;
@ -14445,12 +14377,7 @@
name = this.parentElement.parentElement.id;
exportMascot = Mascots[name];
exportMascot['Mascot'] = name;
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);
}
return exportedMascot = "data:application/json," + encodeURIComponent(JSON.stringify(exportMascot));
},
restore: function() {
if (confirm("Are you sure you want to restore \"" + this.id + "\"?")) {
@ -14495,18 +14422,19 @@
return Settings.close();
},
"export": function(e) {
var exportTheme, exportedTheme;
var a, data;
e.preventDefault();
e.stopPropagation();
exportTheme = Themes[this.name];
exportTheme['Theme'] = this.name;
exportedTheme = "data:application/json," + encodeURIComponent(JSON.stringify(exportTheme));
if (window.open(exportedTheme, "_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(exportedTheme);
}
data = Themes[this.name];
data['Theme'] = this.name;
a = $.el('a', {
textContent: '>>Save me!',
download: "" + this.name + "-" + (Date.now()) + ".json",
href: "data:application/json;base64," + (btoa(unescape(encodeURIComponent(JSON.stringify(data, null, 2))))),
target: '_blank'
});
return a.click();
},
"delete": function(e) {
var container, settheme,

View File

@ -192,12 +192,12 @@ Settings =
target: '_blank'
<% if (type !== 'userscript') { %>
a.click()
return
<% } %>
<% } else { %>
# XXX Firefox won't let us download automatically.
span = $ '.imp-exp-result', Settings.dialog
$.rmAll span
$.add span, a
<% } %>
import: ->
@nextElementSibling.click()
@ -589,19 +589,8 @@ Settings =
$.on $("#import", div), 'click', ->
@nextSibling.click()
$.on $("#importbutton", div), 'change', (e) ->
ThemeTools.importtheme "appchan", e
$.on $("#OCimport", div), 'click', ->
@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 $("#importbutton", div), 'change', ThemeTools.importtheme
$.on $('#tUndelete', div), 'click', ->
$.rm $.id "themeContainer"
@ -862,11 +851,6 @@ Settings =
exportMascot['Mascot'] = name
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: ->
if confirm "Are you sure you want to restore \"#{@id}\"?"
Conf["Deleted Mascots"].remove @id
@ -906,14 +890,22 @@ Settings =
export: (e) ->
e.preventDefault()
e.stopPropagation()
exportTheme = Themes[@name]
exportTheme['Theme'] = @name
exportedTheme = "data:application/json," + encodeURIComponent(JSON.stringify(exportTheme))
data = Themes[@name]
data['Theme'] = @name
if window.open exportedTheme, "_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 exportedTheme
a = $.el 'a',
textContent: '>>Save me!'
download: "#{@name}-#{Date.now()}.json"
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) ->
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=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>
/
<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>

View File

@ -44,7 +44,6 @@ ThemeTools =
"Focused Input Border"
"Checkbox Background"
"Checkbox Border"
"Checkbox Checked Background"
"Buttons Background"
"Buttons Border"
"Navigation Background"
@ -111,7 +110,7 @@ ThemeTools =
div = $.el "div",
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)
@ -167,7 +166,7 @@ ThemeTools =
if (depth isnt 0) or toggle1 or toggle2
return alert "Syntax error on #{@name}."
if @className == "colorfield"
if @className is "colorfield"
@nextSibling.value = "##{Style.colorToHex(@value) or 'aaaaaa'}"
@nextSibling.color.importColor()
@ -214,7 +213,7 @@ ThemeTools =
reader.readAsDataURL file
importtheme: (origin, evt) ->
importtheme: (evt) ->
file = evt.target.files[0]
reader = new FileReader()
@ -222,158 +221,113 @@ ThemeTools =
try
imported = JSON.parse e.target.result
unless imported
throw "Cannot parse file"
catch err
alert err
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."
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 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]
else
return
if origin == "oneechan" or origin == "SS"
bgColor = new Style.color(imported.bgColor);
mainColor = new Style.color(imported.mainColor);
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);
# 4chan SS / Oneechan
if imported.bgColor
unless imported.replyOp
imported.replyOp = "0.9"
if imported.bgRPA
bgRPA = imported.bgRPA.split(' ')
bgRPA = if imported.bgRPA
imported.bgRPA.split ' '
else
bgRPA = ['no-repeat', 'bottom', 'left', 'fixed']
['no-repeat', 'bottom', 'left', 'fixed']
if origin == "oneechan"
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 ''}"""
color = Style.color
else if origin == "SS"
Themes[name] =
'Author' : "Anonymous"
'Author Tripcode' : "!.pC/AHOKAg"
'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(#{mainColor.rgb}, .5)"
'Thread Wrapper Border' : "rgba(#{brderColor.rgb}, .9)"
'Reply Background' : "rgba(#{mainColor.rgb}, .9)"
'Reply Border' : "rgb(#{brderColor.rgb})"
'Highlighted Reply Background': "rgba(#{mainColor.shiftRGB(4, true)}, .9)"
'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 ''}"""
bgColor = new color imported.bgColor
mainColor = new color imported.mainColor
brderColor = new color imported.brderColor
inputColor = new color imported.inputColor
inputbColor = new color imported.inputbColor
blinkColor = new color imported.blinkColor
jlinkColor = new color imported.jlinkColor
linkColor = new color imported.linkColor
linkHColor = new color imported.linkHColor
nameColor = new color imported.nameColor
quoteColor = new color imported.quoteColor
sageColor = new color imported.sageColor
textColor = new color imported.textColor
titleColor = new color imported.titleColor
tripColor = new color imported.tripColor
timeColor = new color imported.timeColor or imported.textColor
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
userThemes = $.get "userThemes", {}, ({userThemes})->
$.get "userThemes", {}, ({userThemes}) ->
userThemes[name] = Themes[name]
$.set 'userThemes', userThemes
alert "Theme \"#{name}\" imported!"
$.rm $("#themes", d.body)
Settings.open 'themes'
Settings.openSection.call {open: Settings.themes, hyphenatedTitle: 'themes'}
reader.readAsText(file)