illustrator是矢量编辑软件,画板是绘制处理的重要容器,在印刷方面的一个重要功能就是正则编辑文本,开发一个正则编辑文本功能,以下功能仅用于学习交流,请勿用于非法用途和商业用途,源代码如下所示:
var toZENKAKU = function(chara) {
return String.fromCharCode(chara.charCodeAt(0) + 65248);
};
var toHANKAKU = function(chara) {
return String.fromCharCode(chara.charCodeAt(0) - 65248);
};
var findreplacePattern = {
"半角英数を全角英数へ": ["/[a-zA-Z0-9]/g", toZENKAKU],
"全角英数を半角英数へ": ["/[a-zA-Z0-9]/g", toZENKAKU]
};
function textReplacePatterns(textFrame, pattern) {
if (textFrame.constructor.name !== "TextFrame") {
return false;
}
for (var i = 0; i < pattern.length; i += 1) {
textFrame.contents.replace(eval(pattern[i][0]), function() {
var spot = arguments[arguments.length - 2];
var TR = textFrame.textRanges[spot];
TR.length = arguments[0].length;
var getReplaceString = function(PT, FT) {
var ReplaceString = "";
switch (typeof PT) {
case "object":
ReplaceString = PT.hasOwnProperty(FT) ? PT[FT]:
FT;
break;
case "function":
ReplaceString = PT(FT);
break;
case "string":
ReplaceString = PT;
break;
default:
ReplaceString = PT.toString();
break;
}
return ReplaceString;
};
var RS = getReplaceString(pattern[i][1], arguments[0]);
switch (typeof RS) {
case "function":
RS(TR);
break;
default:
TR.contents = RS.toString();
break;
}
return TR.contents;
});
}
}
var debug = false;
if (typeof doEx !== "function" || debug == true) {
var _doEx = doEx;
Function.prototype.curry = function() {
var slice = Array.prototype.slice;
var args = slice.apply(arguments);
var that = this;
return function() {
return that.apply(this, args.concat(slice.apply(arguments)));
};
};
function() {
doEx = function() {
return new doEx.prototype.init(Array.prototype.slice.apply(arguments));
};
doEx.prototype = {
init: function() {
this.log = [];
this.length = 0;
var arg = Array.prototype.slice.apply(arguments)[0];
this.log.push("doEX_init : " + arg.toString());
for (var i = 0,
var l = arg.length >>> 0; i < l; i++) {
var s = arg[i];
try {
switch (s.constructor.name) {
case "Object":
try {
for (var x in s) {
this[x](s[x]);
}
} catch (e) {
this.error.push("init_Object_error : " + e);
}
break;
case "Function":
return doEx(s());
break;
case "String":
try {
if (typeof this.objectShortName[s] == "string") {
s = this.objectShortName[s];
}
s = app.activeDocument[s];
this.add(s);
} catch (e) {
this.error.push("objectShortName_error : " + e);
}
break;
case "Array":
this.add(s);
break;
default:
this.add(s);
}
} catch (e) {
this.add(s);
}
}
return this;
},
position: 0,
constructor: {
name: "DocumentObjectsExtract"
},
add: function(s) {
this.log.push("doEX_add : " + s.toString());
var len = this.length >>> 0;
try {
if (typeof s === "string") {
s = doEx(s)
}
if ((s.length >>> 0) !== 0) {
s = Array.prototype.slice.call(s, 0);
for (var i = 0; i < s.length >>> 0; i += 1) {
this[len + i] = s[i];
}
this.length = len + s.length;
} else {
this[len] = s;
this.length = len + 1;
}
} catch (e) {
this[len] = s;
this.length++;
this.error.push("add_error : " + e);
}
this.log.push("length:" + this.length);
return this;
},
toArray: function() {
return Array.prototype.slice.call(this, 0);
},
saveDoc: function(path) {
this.each(function() {
if (this.constructor.name == "Document") {
this.saveAs(File(path));
}
});
return this;
},
get: function(num) {
if (typeof num == "number" && num < this.length && num >= 0) {
return this[num];
}
return false;
},
now: function() {
return this.get(this.position);
},
next: function() {
return this.get(this.position++);
},
prev: function() {
return this.get(--this.position);
},
loop: function() {
if (this.position >= this.length) {
this.position = 0
}
return this.get(this.position++);
},
dofunc: function(func, arg) {
if (func == undefined) {
return this;
}
var res = true;
if (func.constructor.name == "Function") {
res = func.call(this)
}
if (res) {
return this;
} else {
return {
each: function() {
}
};
}
},
each: function(fnc, arg) {
var l = this.length >>> 0;
var i = -1;
this.log.push("each : " + this.toArray().toString());
var res = [];
if (typeof fnc == "function") {
while (++i < l) {
if (i in this) {
ret = fnc.call(this[i], this[i], arg, i);
typeof ret != "undefined" && res.push(ret);
}
}
}
return res.length > 0 ? doEx(res) : this;
},
eachReverse: function(fnc, arg) {
var l = this.length;
var res = [];
if (typeof fnc == "function") {
for (var i = l; i > 0; i--) {
ret = fnc.call(this[i - 1], this[i - 1], arg);
typeof ret != "undefined" && res.push(ret);
}
}
if (res.length > 0) {
return doEx(res);
} else {
return this;
}
},
eachR: function(fnc, arg) {
return this.eachReverse(fnc, arg);
},
filter: function() {
this.log.push("filter : " + Array.prototype.slice.apply(arguments).toString());
if ((arguments.length >>> 0) == 0) {
return this;
}
var s = {
TRUE: [],
FALSE: []
};
var caseBy = {
function: function(arg) {
while (x = this.next()) {
arg(x) ? s.TRUE.push(this) : s.FALSE.push(this);
}
},
string: function(arg) {
if (typeof this.objectShortName[arg] == "string") {
arg = this.objectShortName[arg]
}
if (typeof this.filters[arg] == "function") {
this.filters[arg].call(this, s);
} else {
var fd = this.attr(arg).toArray();
s.TRUE = s.TRUE.concat(fd);
}
}
};
var extractarg = function(args) {
for (var i = 0; i < args.length; i += 1) {
var arg = args[i];
switch (arg.constructor.name) {
case "Function":
caseBy.
function.call(this, arg);
break;
case "String":
var ARG = arg.split(">");
for (var j = 0; j < ARG.length; j += 1) {
caseBy.string.call(this, ARG[j]);
}
}
}
};
extractarg.call(this, arguments);
try {
if (s.TRUE.length > 0) {
return doEx(s.TRUE);
} else {
var x = doEx();
for (var i in x) {
x[i] = false
}
x.length = 0;
return x;
}
} catch (e) {
this.error.push("filter_error : " + e);
return false;
}
},
find: function(text) {
this.log.push("doEX_find : " + text.toString());
try {
var ARG = text.split(">");
var that = this;
for (var i = 0; i < ARG.length; i += 1) {
var SP = ARG[i].split(",");
var it = doEx();
for (var j = 0; j < SP.length; j += 1) {
it.add(that.attr(SP[j]));
}
that = it;
}
this.log.push("doEX_find_return : " + that.toArray().toString());
return that;
} catch (e) {
this.error.push("find_command_error : " + text);
return this;
}
},
attr: function(x, y) {
var that = this;
var it = doEx(that.each(function() {
try {
if (typeof x == "string" && y !== undefined) {
try {
if (typeof y == "string") {
return this[x] = y;
}
if (typeof y == "function") {
this[x] = y.call(this, this);
}
if (typeof y == "boolean") {
return this[x] = y;
}
} catch (e) {
that.error.push("attr_value_set_error " + e);
}
}
if (typeof x == "object") {
for (var i in x) {
if (this.hasOwnProperty(i)) {
try {
switch (typeof x[i]) {
case "function":
this[i] = x[i].call(this, this);
break;
default:
this[i] = x[i];
}
} catch (e) {
that.error.push("attr_value_error : " + e);
}
}
}
}
if (typeof x == "string") {
var gx = this[x];
try {
if (gx.toString() == "") {
return "";
}
switch (typeof gx) {
case "string":
return gx;
case "number":
return gx;
case "function":
return x + " is function";
case "undefind":
return undefined;
}
if (gx.length) {
return app.name.match(/InDe/) ? Array.prototype.slice.call(gx, 0) : Array.prototype.slice.call(gx, 0);
} else {
return gx;
}
} catch (e) {
that.error("attr_value_error_x : " + e);
return false;
}
}
if (!x && !y) {
for (var i in this) {
try {
this.hasOwnProperty(i) && $.writeln(i + " : " + this[i]);
} catch (e) {
that.error.push("attr_value_error : " + e);
}
}
}
} catch (e) {
that.error.push("attr_error_ :" + e);
return false;
}
})).toArray();
var rt = [];
while (r = it.shift()) {
rt = rt.concat(r)
}
return doEx(rt);
},
search: function(x, y) {
return doEx(this.each(function() {
if (this.hasOwnProperty(x)) {
if (typeof this[x] == "string") {
if (this[x] == y) {
return this;
}
}
if (typeof this[x] == "object") {
try {
if (this[x].constructor.name == y) {
return this;
}
} catch (e) {
}
}
if (typeof this[x] == "boolean") {
if (this[x] === y) {
return this;
}
}
}
}));
},
has: function(x, y) {
return this.each(function() {
if (this[x].toString().match(y)) {
return this;
}
});
},
select: function(x, t) {
var wD = new Window("dialog", "SELECT", [200, 100, 410, 170]);
wD.add("statictext", [10, 13, 55, 30], t || "Select", {});
var ActionDDList = wD.add("dropdownlist", [60, 10, 190, 30], {});
wD.add("button", [40, 40, 100, 60], "OK");
this.each(function() {
if (this.constructor.name !== "String") {
ActionDDList.add("item", this[x].toString());
return;
} else {
ActionDDList.add("item", this.toString());
return;
}
});
ActionDDList.selection = ActionDDList.items[0];
var result = wD.show();
if (result == 2) {
return doEx(false);
}
return doEx([this[ActionDDList.selection.index]]);
},
random: function() {
return this[Math.round(Math.random() * (this.length - 1))];
},
filters: {},
error: [],
temp: [],
log: [],
duplicate: function(x, y) {
return this.each(function() {
return this.duplicate(x, y);
});
},
translate: function(x, y) {
return this.each(function() {
this.translate(x, y);
});
},
type: function() {
return this.each(function() {
return this.constructor.name;
});
},
debug: function() {
this.each(function() {
$.bp();
});
},
remove: function() {
this.eachReverse(function() {
this.remove();
});
},
test: function(x, fnc, arg) {
typeof fnc == "function" && fnc.call(this[x], this[x], arg);
},
first: function(fnc, arg) {
typeof fnc == "function" && fnc.call(this[0], this[0], arg);
},
last: function(fnc, arg) {
typeof fnc == "function" && fnc.call(this[this.length - 1], this[this.length - 1], arg);
},
saveLog: function() {
},
alertLog: function() {
alert(this.log.join("\n"));
this.log = [];
return this;
},
alertError: function() {
alert(this.error.join("\n"));
this.log = [];
return this;
},
selector: function() {
},
view: function() {
var i = 0;
var that = this;
var O = {};
while (O = that.next()) {
var D = myDialogMaker({
type: "dialog",
title: "DataBrowse",
opt: {},
pos: [0, 0, 400, 400],
layout: [{
type: "group",
name: "Group",
label: "Group",
pos: [0, 0, 398, 398],
option: {},
items: [{
type: "edittext",
name: "T",
label: "",
option: {},
pos: [16, 13, 386, 35]
}, {
type: "listbox",
name: "L",
label: "ListBox",
pos: [15, 46, 384, 354],
option: {
onChange: function() {
this.selection && this.parent.items.T.text = this.selection.key + " : " + this.selection.value;
},
onDoubleClick: function() {
if (this.selection) {
doEx(O[this.selection.key]).view();
}
}
}
}, {
type: "statictext",
name: "OT",
label: "",
pos: [16, 363, 200, 387],
option: {}
}, {
type: "button",
name: "E",
label: "Next",
pos: [250, 363, 300, 387],
option: {
onClick: function() {
this.parent.parent.close();
}
}
}, {
type: "button",
name: "E",
label: "Close",
pos: [320, 363, 387, 387],
option: {
onClick: function() {
this.parent.parent.close(2);
}
}
}, {
type: "button",
name: "E",
label: "Load",
pos: [200, 363, 250, 387],
option: {
onDraw: function() {
this.parent.items.OT.text = O.toString() + "[" + i.toString() + "] of " + that.length;
var L = this.parent.items.L;
L.removeAll();
switch (typeof O) {
case "object":
for (var v in O) {
try {
var x = L.add("item", v + " : " + O[v].toString().slice(0, 40));
x.key = v;
x.value = O[v].toString();
} catch (e) {
var x = L.add("item", v + " : " + e);
x.key = v;
}
}
break;
case "string":
var x = L.add("item", O);
x.key = "string";
x.value = O;
break;
}
}
}
}]
}]
});
D.wD.center();
if (D.wD.show() == 2) {
break;
}
i++;
}
return this;
},
domselect: function() {
var i = 0;
var that = this;
var O = {};
var sel = [];
while (O = that.next()) {
var D = myDialogMaker({
type: "dialog",
title: "DataBrowse",
opt: {},
pos: [0, 0, 400, 400],
layout: [{
type: "group",
name: "Group",
label: "Group",
pos: [0, 0, 398, 398],
option: {},
items: [{
type: "edittext",
name: "T",
label: "",
option: {},
pos: [16, 13, 386, 35]
}, {
type: "listbox",
name: "L",
label: "ListBox",
pos: [15, 46, 384, 354],
option: {
onChange: function() {
this.selection && this.parent.items.T.text = this.selection.key + " : " + this.selection.value;
},
onDoubleClick: function() {
if (this.selection) {
sel = sel.concat(Array.prototype.slice.call(O[this.selection.key], 0));
this.parent.parent.close();
}
}
}
}, {
type: "statictext",
name: "OT",
label: "",
pos: [16, 363, 200, 387],
option: {}
}, {
type: "button",
name: "E",
label: "Next",
pos: [250, 363, 300, 387],
option: {
onClick: function() {
if (this.selection) {
sel = sel.concat(Array.prototype.slice.call(O[this.selection.key], 0));
}
this.parent.parent.close();
}
}
}, {
type: "button",
name: "E",
label: "Close",
pos: [320, 363, 387, 387],
option: {
onClick: function() {
this.parent.parent.close(2);
}
}
}, {
type: "button",
name: "E",
label: "Load",
pos: [200, 363, 250, 387],
option: {
onDraw: function() {
this.parent.items.OT.text = O.toString() + "[" + i.toString() + "] of " + that.length;
var L = this.parent.items.L;
L.removeAll();
switch (typeof O) {
case "object":
for (var v in O) {
try {
var x = L.add("item", v + " : " + O[v].toString().slice(0, 40));
x.key = v;
x.value = O[v].toString();
} catch (e) {
var x = L.add("item", v + " : " + e);
x.key = v;
}
}
break;
case "string":
var x = L.add("item", O);
x.key = "string";
x.value = O;
break;
}
}
}
}]
}]
});
D.wD.center();
if (D.wD.show() == 2) {
break;
}
i++;
}
return doEx(sel).view();
},
hvg: function(Sc) {
if (!Sc) {
Sc = 1;
} else {
Sc = Sc * 1;
}
if (app.name == "Adobe Illustrator") {
var rulerOrigin_Original = app.activeDocument.rulerOrigin;
app.activeDocument.rulerOrigin = [-9600, -9600];
}
var hvgObject = {
group: [],
p_x: 0,
p_y: 0,
getItem: function(y, x) {
try {
return this.group[y][x];
} catch (e) {
return false;
}
},
loop: function() {
var N = this.next();
if (N === false) {
this.p_x = 0;
this.p_y = 0;
N = this.next();
}
return N;
},
next: function() {
if (this.group[this.p_y].length > this.p_x) {
var get = this.getItem(this.p_y, this.p_x);
this.p_x++;
} else {
this.p_y++;
this.p_x = 0;
if (this.group.length > this.p_y) {
var get = this.getItem(this.p_y, this.p_x);
this.p_x++;
} else {
return false;
}
}
if (get.toString() == "[object Object]") {
get = this.next()
}
return get;
},
rotate: function() {
var temp = [];
for (var i = 0; i < hvgObject.group.length; i += 1) {
hvgObject.group[i].reverse();
for (var j = 0; j < hvgObject.group[i].length; j += 1) {
if (!temp[j]) {
temp.push([]);
}
temp[j].push(hvgObject.group[i][j]);
}
}
hvgObject.group = temp;
return this;
},
reverse: function() {
var temp = [];
for (var i = 0; i < hvgObject.group.length; i += 1) {
hvgObject.group[i].reverse();
}
return this;
},
order: function(A) {
var temp = [];
if (A == undefined) {
A = function() {
var o = "Z";
var r = "1";
var D = myDialogMaker({
type: "dialog",
title: "取得する順番の選択",
opt: {},
pos: [0, 0, 200, 150],
layout: [{
pos: [0, 0, 200, 150],
type: "group",
name: "Group",
option: {},
items: [{
pos: [7, 8, 192, 55],
type: "panel",
name: "X",
option: {},
items: [{
type: "radiobutton",
name: "N",
label: "N",
option: {},
pos: [9, 20, 91, 33]
}, {
type: "radiobutton",
name: "Z",
label: "Z",
option: {
value: true
},
pos: [95, 20, 177, 33]
}],
label: "処理方向"
}, {
pos: [7, 62, 192, 141],
type: "panel",
name: "Y",
option: {},
items: [{
type: "radiobutton",
name: "LT",
label: "左上",
option: {
value: true
},
pos: [7, 21, 89, 34]
}, {
type: "radiobutton",
name: "RT",
label: "右上",
option: {},
pos: [95, 21, 177, 34]
}, {
type: "radiobutton",
name: "LB",
label: "左下",
option: {},
pos: [7, 53, 89, 66]
}, {
type: "radiobutton",
name: "RB",
label: "右下",
option: {},
pos: [95, 53, 177, 66]
}],
label: "開始位置"
}],
label: "Group"
}]
});
D.wD.center();
D.wD.show();
if (D.items.Group.items.X.items.N.value) {
o = "N";
}
if (D.items.Group.items.Y.items.LT.value) {
r = "1"
}
if (D.items.Group.items.Y.items.RT.value) {
r = "2"
}
if (D.items.Group.items.Y.items.RB.value) {
r = "3"
}
if (D.items.Group.items.Y.items.LB.value) {
r = "4"
}
return o + r;
}()
}
var that = this;
var doing = {
N2: function() {
return that.rotate();
},
N3: function() {
return that.rotate().reverse();
},
N1: function() {
return that.reverse().rotate();
},
N4: function() {
return that.reverse().rotate().reverse();
},
Z1: function() {
return that;
},
Z2: function() {
return that.reverse();
},
Z3: function() {
return that.rotate().rotate();
},
Z4: function() {
return that.rotate().rotate().reverse();
}
};
return doing[A]();
},
each: function(fnc, args) {
if (typeof fnc == "function") {
while (i = this.next()) {
fnc.call(i, i, args)
}
}
this.p_x = 0;
this.p_y = 0;
return this;
},
getRows: function() {
return doEx(this.group);
},
getAll: function() {
var o = [];
while (i = this.next()) {
o.push(i)
}
return o;
},
doEx: function() {
this.p_x = 0;
this.p_y = 0;
return doEx(this.getAll());
},
toArray: function() {
return this.getAll();
},
view: function() {
var x = this.group;
var p = [];
for (var i = 0; i < x.length; i += 1) {
var v = [];
for (var j = 0; j < x[i].length; j += 1) {
v.push(x[i][j].toString() !== "[object Object]" ? "■" : "□");
}
p.push(v.join(""));
}
alert("認識した配列の形状\n" + p.join("\n"));
return this;
},
console: function() {
var x = this.group;
var p = [];
for (var i = 0; i < x.length; i += 1) {
var v = [];
for (var j = 0; j < x[i].length; j += 1) {
v.push(x[i][j].toString() !== "[object Object]" ? "■" : "□");
}
p.push(v.join(""));
}
$.writeln("認識した配列の形状\n" + p.join("\n"));
return this;
}
};
var orderFunc = {
o: function(a, b) {
return a.geometricBounds[0] - b.geometricBounds[0];
},
g: function(a, b) {
return b.n - a.n;
},
h: function(x) {
return Math.abs(x.geometricBounds[1] - x.geometricBounds[3]);
},
c: function(x) {
var z = (x.visibleBounds[3] + x.visibleBounds[1]) / 2;
return z;
}
};
var hl = 0;
this.each(function() {
try {
if (this.hasOwnProperty("geometricBounds")) {
var h = orderFunc.h(this);
if (h == 0) {
h = 0.1
}
hl += h;
}
} catch (e) {
}
});
hl = hl / this.length;
var group = [];
this.each(function() {
try {
if (!this.hasOwnProperty("geometricBounds")) {
return;
}
var ic = orderFunc.c(this);
for (var i = 0; i < group.length; i += 1) {
if (Math.abs(ic - group[i].n) < (hl * Sc)) {
group[i].item.push(this);
return;
}
}
group.push({
n: ic,
item: [this]
});
return;
} catch (e) {
return e;
}
});
var temp = [];
group = group.sort(orderFunc.g);
for (var i = 0; i < group.length; i += 1) {
temp.push(group[i].item.sort(orderFunc.o));
}
var getCol = function() {
var temp2 = [];
var col = [];
for (var i = 0; i < temp.length; i += 1) {
var wl = {};
try {
wl = temp[i].shift();
col.push(wl);
} catch (e) {
col.push(wl);
}
}
var cl = 0;
var ml = undefined;
for (var i = 0; i < col.length; i += 1) {
try {
if (!ml) {
ml = col[i].visibleBounds[0];
cl = Math.abs((col[i].visibleBounds[2] + col[i].visibleBounds[0]) / 2);
}
if (col[i].visibleBounds[0] < ml) {
ml = col[i].visibleBounds[0];
cl = Math.abs((col[i].visibleBounds[2] + col[i].visibleBounds[0]) / 2);
}
} catch (e) {
}
}
for (var i = 0; i < col.length; i += 1) {
try {
if (Math.abs(((col[i].visibleBounds[2] + col[i].visibleBounds[0]) / 2) - cl) < Math.abs(col[i].visibleBounds[2] - col[i].visibleBounds[0])) {
temp2.push(col[i]);
} else {
if (col[i].visibleBounds[2] == col[i].visibleBounds[0]) {
temp2.push(col[i]);
} else {
temp2.push({});
temp[i].unshift(col[i]);
}
}
} catch (e) {
temp2.push({});
}
}
return temp2;
};
var getL = function() {
var l = 0;
try {
for (var i = 0; i < temp.length; i += 1) {
l += temp[i].length;
}
} catch (e) {
}
return l;
};
var temp3 = [];
while (getL()) {
temp3.push(getCol());
}
var temp4 = [];
for (var i = 0; i < temp3.length; i += 1) {
for (var j = 0; j < temp3[i].length; j += 1) {
if (!temp4[j]) {
temp4.push([])
}
temp4[j].push(temp3[i][j]);
}
}
hvgObject.group = temp4;
if (app.name == "Adobe InDesign") {
hvgObject = hvgObject.rotate().rotate().rotate()
}
if (app.name == "Adobe Illustrator") {
app.activeDocument.rulerOrigin = rulerOrigin_Original
}
return hvgObject;
},
isPlural: function() {
var pluralWords = ["ArtStyles", "Artboards", "Brushes", "CharacterStyles", "Characters", "CompoundPathItems", "DataSets", "Documents", "GradientStops", "GraphItems", "GroupItems", "InsertionPoints", "Layers", "LegacyTextItems", "Lines", "MashItems", "NonNativeItems", "PageItems", "ParagraphStyles", "PathItems", "PathPoints", "Patterns", "PlacedItems", "PluginItems", "RasterItems", "Spots", "Stories", "Swatches", "SymbolItems", "Symbols", "Tags", "TextFonts", "TextFrameItems", "TextRanges", "Variables", "Views", "Words"];
}
};
doEx.extend = function(target, source) {
for (var property in source) {
try {
target.prototype[property] = source[property];
} catch (e) {
target[property] = source[property];
}
}
return target;
};
doEx.prototype.init.prototype = doEx.prototype;
function getObjextX(objectType) {
var X = [];
for (var x = 0; x < app.activeDocument.layers.length; x += 1) {
X.concat(Array.prototype.slice.call(app.activeDocument.layers[x][objectType], 0));
}
return doEx(X);
}
doEx.extend(doEx, {
concat: Array.prototype.concat
});
doEx.view = function() {
doEx(app.activeDocument).view();
};
doEx.selector = function() {
var select = prompt("What", "selection");
return doEx(select);
};
if (app.name == "Adobe Illustrator") {
var config_for_illustrator = {
selected: function() {
this.each(function() {
"selected" in this && this.selected = true;
});
return this;
},
deselected: function() {
this.each(function() {
"selected" in this && this.selected = false;
});
return this;
},
filters: {
ParentisLayer: function(s) {
this.each(function() {
if (this.parent.constructor.name == "Layer") {
s.TRUE.push(this)
}
});
return s;
},
layers: function(s) {
this.each(function() {
this.constructor.name.match(/Document|Layer/) && doEx(this.layers).each(function() {
s.TRUE.push(this);
});
});
return s;
},
placedItems: function(s) {
this.each(function(a) {
a.constructor.name == "PlacedItem" ? s.TRUE.push(a) : (a.constructor.name == "GroupItem" ? doEx(a.pageItems).each(arguments.callee) : s.FALSE.push(a));
});
return s;
},
rasterItems: function(s) {
this.each(function(a) {
a.constructor.name == "RasterItem" ? s.TRUE.push(a) : (a.constructor.name == "GroupItem" ? doEx(a.pageItems).each(arguments.callee) : s.FALSE.push(a));
});
return s;
},
pathItems: function(s) {
this.each(function(a) {
a.constructor.name == "PathItem" ? s.TRUE.push(a) : (a.constructor.name.match(/CompoundPathItem|GroupItem/) ? doEx(a.constructor.name == "GroupItem" ? a.pageItems : a.pathItems).each(arguments.callee) : s.FALSE.push(a));
});
return s;
},
compoundPathItems: function(s) {
this.each(function(a) {
a.constructor.name == "CompoundPathItem" ? s.TRUE.push(a) : (a.constructor.name == "GroupItem" ? doEx(a.pageItems).each(arguments.callee) : s.FALSE.push(a));
});
return s;
},
pathPoints: function(s) {
this.filter("pathItems").each(function() {
s.TRUE = s.TRUE.concat(Array.prototype.slice.call(this.pathPoints, 0));
});
return s;
},
groupItems: function(s) {
this.each(function() {
if (this.constructor.name == "GroupItem") {
s.TRUE.push(this);
} else {
if (this.constructor.name.match(/Document|Layer/)) {
doEx(this.groupItems).each(function() {
if (this.parent.constructor.name == "Layer") {
s.TRUE.push(this)
}
});
}
}
});
return s;
},
textFrames: function(s) {
this.each(function(a) {
a.constructor.name == "TextFrame" ? s.TRUE.push(a) : (a.constructor.name == "GroupItem" ? doEx(a.pageItems).each(arguments.callee) : s.FALSE.push(a));
});
return s;
},
textRanges: function(s) {
this.each(function() {
if (this.constructor.name == "TextRange") {
s.TRUE.push(this);
return;
}
this.constructor.name.match(/TextFrame|Story/) && doEx(this.textRanges).each(function(tr) {
s.TRUE.push(tr);
});
});
return s;
},
selection: function(s) {
this.each(function() {
this.selected == true || this.selected == "PathPointSelection.ANCHORPOINT" ? s.TRUE.push(this) : s.FALSE.push(this);
});
return s;
}
},
objectShortName: {
I: "allPageItems",
T: "textFrames",
G: "groupItems",
P: "pathItems",
PP: "pathPoints",
S: "selection",
PL: "placedItems",
L: "layers",
R: "rasterItems"
}
};
doEx.extend(doEx, config_for_illustrator);
for (var i in config_for_illustrator.filters) {
doEx.prototype[i] = doEx.prototype.filter.curry(i);
}
}
if (app.name == "Adobe InDesign") {
var config_for_indesign = {
filters: {
selection: function(s) {
},
allPageItems: function(s) {
this.each(function() {
doEx(this.allPageItems).each(function() {
s.TRUE.push(this);
});
});
return s;
},
groupItems: function(s) {
this.each(function() {
this.constructor.name == "Group" ? s.TRUE.push(this) : s.FALSE.push(this);
});
return s;
},
textFrames: function(s) {
if (this.constructor.name !== "DocumentObjectsExtract") {
return s;
}
this.each(function() {
try {
this.constructor.name == "TextFrame" ? s.TRUE.push(this) : (this.constructor.name == "Group" ? doEx(this.textFrames).each(function() {
s.TRUE.push(this);
}) : s.FALSE.push(this));
} catch (e) {
}
});
return s;
},
paragraphs: function(s) {
var textFrames = this.filters.textFrames.call(this, {
TRUE: [],
FALSE: []
});
doEx(textFrames.FALSE).each(function() {
this.constructor.name == "Text" || this.constructor.name == "TextColumn" || this.constructor.name == "Paragraph" || this.constructor.name == "Cell" && textFrames.TRUE.push(this);
this.constructor.name == "Table" && doEx(this.cells).each(function() {
textFrames.TRUE.push(this);
});
});
doEx(textFrames.TRUE).each(function() {
doEx(this.paragraphs).each(function() {
s.TRUE.push(this);
});
});
return s;
},
words: function(s) {
var textFrames = this.filters.textFrames.call(this, {
TRUE: [],
FALSE: []
});
doEx(textFrames.FALSE).each(function() {
this.constructor.name == "Text" || this.constructor.name == "TextColumn" || this.constructor.name == "Paragraph" || this.constructor.name == "Cell" && textFrames.TRUE.push(this);
this.constructor.name == "Table" && doEx(this.cells).each(function() {
textFrames.TRUE.push(this);
});
});
doEx(textFrames.TRUE).each(function() {
doEx(this.words).each(function() {
s.TRUE.push(this);
});
});
return s;
},
characters: function(s) {
var textFrames = this.filters.textFrames.call(this, {
TRUE: [],
FALSE: []
});
doEx(textFrames.FALSE).each(function() {
this.constructor.name == "Text" || this.constructor.name == "TextColumn" || this.constructor.name == "Paragraph" || this.constructor.name == "Cell" && textFrames.TRUE.push(this);
this.constructor.name == "Table" && doEx(this.cells).each(function() {
textFrames.TRUE.push(this);
});
});
doEx(textFrames.TRUE).each(function() {
doEx(this.characters).each(function() {
s.TRUE.push(this);
});
});
return s;
},
tables: function(s) {
var textFrames = doEx(this).filters.textFrames.call(this, {
TRUE: [],
FALSE: []
});
doEx(textFrames.FALSE).each(function() {
if (this.constructor.name == "Table" || this.constructor.name == "Cell") {
this.constructor.name == "Cell" && this.tables.length > 0 && textFrames.TRUE.push(this);
s.TRUE.push(this);
}
});
doEx(textFrames.TRUE).each(function() {
doEx(this.tables).each(function() {
var innertable = doEx(this).filters.tables.call(this.cells, {
TRUE: [],
FALSE: []
});
doEx(innertable.TRUE).each(function() {
this.constructor.name == "Table" && s.TRUE.push(this);
});
s.TRUE.push(this);
});
});
return s;
},
cells: function(s) {
var tables = this.filters.tables.call(this, {
TRUE: [],
FALSE: []
});
doEx(tables.TRUE).each(function() {
doEx(this.cells).each(function() {
s.TRUE.push(this);
});
});
return s;
},
rows: function(s) {
var tables = this.filters.tables.call(this, {
TRUE: [],
FALSE: []
});
doEx(tables.TRUE).each(function() {
doEx(this.rows).each(function() {
s.TRUE.push(this);
});
});
return s;
}
},
objectShortName: {
I: "pageItems",
T: "textFrames",
G: "groupItems",
P: "pathItems",
PP: "pathPoints",
S: "selection",
PL: "placedItems",
L: "layers",
R: "rasterItems"
}
};
doEx.extend(doEx, config_for_indesign);
for (var i in config_for_indesign.filters) {
doEx.prototype[i] = doEx.prototype.filter.curry(i);
}
}
}();
function() {
var setPosition = function(a, b) {
return [a[0] + b[0], a[1] + b[1], a[2] + b[2], a[3] + b[3]];
};
extend = function(target, source) {
try {
for (var property in source) {
try {
target.prototype[property] = source[property];
} catch (e) {
target[property] = source[property];
}
}
} catch (e) {
}
return target;
};
myDialogMaker = function(option) {
return new myDialogMaker.prototype.init(option);
};
myDialogMaker.prototype = {
init: function(option) {
if (!option) {
var F = File.openDialog();
F.open("r");
eval("option = " + F.read());
F.close();
}
if (File(option).exists) {
var F = File(option);
F.open("r");
eval("option =" + F.read());
F.close();
}
this.wD = new Window(option.type, option.title, option.pos, option.properties);
extend(this.wD, option.option);
option.layout.length > 0 && this.items = this.buildLayout(this.wD, option.layout);
return this;
},
dialog: function(wD, pos, Config) {
var D = new Window("dialog", Config.label, Config.pos, Config.option);
try {
Config.layout.length > 0 && D.items = this.buildLayout(D, Config.layout);
} catch (e) {
}
D.parents = wD;
return D;
},
statictext: function(wD, pos, Config) {
var sT = wD.add("statictext", pos, Config.label, {});
return sT;
},
edittext: function(wD, pos, Config) {
if (Config.width && Config.height && Config.size) {
if (Config.label) {
var sT = this.statictext(wD, setPosition([0, 3, Config.width - (Config.size * 10), 20], pos), Config)
}
var sET = wD.add(Config.type, setPosition([Config.width - (Config.size * 10), 0, Config.width, Config.height], pos), Config.
default, {
name: Config.name
});
} else {
var Size = 0;
if (Config.label) {
Size = Config.label.length;
var sT = this.statictext(wD, [pos[0], pos[1], (pos[0] * 1) + (Size * 10), pos[3]], Config);
}
var sET = wD.add(Config.type, [(pos[0] * 1) + (Size * 10), pos[1], pos[2], pos[3]], Config.
default, Config.option);
}
extend(sET, Config.option);
return sET;
},
checkbox: function(wD, pos, Config) {
var cB = wD.add("checkbox", [pos[0], pos[1], (pos[2] * 1) + (Config.label.length * 10), pos[3]], Config.label);
extend(cB, Config.option);
return cB;
},
checkboxies: function(wD, pos, Config) {
var GP = wD.add("group", pos, Config.label);
switch (typeof Config.list) {
case "object":
for (var x in Config.list) {
this.checkbox(GP, checkpos, Config.list[x]);
}
break;
}
return GP;
},
radiobutton: function(wD, pos, Config) {
var RB = wD.add("radiobutton", pos, Config.label);
extend(RB, Config.option);
return RB;
},
button: function(wD, pos, Config) {
var bT = wD.add("button", pos, Config.label, {
name: Config.name
});
extend(bT, Config.option);
return bT;
},
iconbutton: function(wD, pos, Config) {
try {
var SI = ScriptUI.newImage(Config.label);
var iB = wD.add("iconbutton", pos, SI);
extend(iB, Config.option);
return iB;
} catch (e) {
return this.button(wD, pos, Config);
}
},
dropdownlist: function(wD, pos, Config) {
var ddl = wD.add("dropdownlist", pos);
Config.list && this.addListItems(ddl, Config.list);
ddl.selection = ddl.items[0];
extend(ddl, Config.option);
return ddl;
},
treeview: function(wD, pos, Config) {
var TB = wD.add("treeview", pos, "");
Config.list && this.addListItems(TB, Config.list);
extend(TB, Config.option);
return TB;
},
listbox: function(wD, pos, Config) {
var TB = wD.add("listbox", pos, "", Config.option);
Config.list && this.addListItems(TB, Config.list);
extend(TB, Config.option);
return TB;
},
flashplayer: function(wD, pos, Config) {
var FP = wD.add("flashplayer", pos);
extend(FP, Config.option);
return FP;
},
progressbar: function(wD, pos, Config) {
var PB = wD.add("progressbar", pos);
extend(PB, Config.option);
return PB;
},
addListItems: function(TG, LIST) {
switch (LIST.constructor.name) {
case "Function":
LIST(TG);
break;
case "Array":
for (var x in LIST) {
TG.add("item", LIST[x]);
}
break;
case "Object":
for (var x in LIST) {
TG.add("item", x);
}
break;
}
},
slider: function(wD, pos, Config) {
var SL = wD.add("slider", pos, "");
extend(SL, Config.option);
return SL;
},
group: function(wD, pos, Config) {
var GP = wD.add("group", pos, Config.label);
GP.items = this.buildLayout(GP, Config.items);
extend(GP, Config.option);
return GP;
},
panel: function(wD, pos, Config) {
var GP = wD.add("panel", pos, Config.label);
GP.items = this.buildLayout(GP, Config.items);
extend(GP, Config.option);
return GP;
},
save: function() {
},
items: {},
getItem: function(name) {
return this.items.hasOwnProperty(name) ? this.items[name] : false;
},
temp: {},
buildLayout: function(wD, layout) {
var layout_L = layout.length;
var myitems = {};
for (var xi = 0; xi < layout_L; xi += 1) {
var ret = myDialogMaker.prototype[layout[xi].type](wD, layout[xi].pos, layout[xi]);
layout[xi].hasOwnProperty("name") && typeof layout[xi].name == "string" && myitems[layout[xi].name] = ret;
}
return myitems;
},
showLayout: function() {
var m = function(i) {
var z = [];
for (var x in i) {
try {
z.push(x);
if (i[x]) {
x = m(i[x].items)
}
} catch (e) {
}
z.push(x);
}
return z;
};
alert(m(this.items).toSource());
}
};
myDialogMaker.prototype.init.prototype = myDialogMaker.prototype;
}();
var buildDialogLayout = myDialogMaker.prototype.buildLayout;
var addListItems = myDialogMaker.prototype.addListItems;
var MDM = myDialogMaker;
var MDME = function(skin, event) {
var ui = MDM(skin);
if (!event) {
var F = File.openDialog();
F.open("r");
eval("event = " + F.read());
F.close();
}
if (File(event).exists) {
var F = File(event);
F.open("r");
eval("event =" + F.read());
F.close();
}
for (var i in event) {
doEx.extend(ui.items.Group.items[i], event[i]);
}
return ui;
};
function setFont(o, f, t, s) {
var g = o.graphics;
var FontStyle = {
REGULAR: ScriptUI.FontStyle.REGULAR,
BOLD: ScriptUI.FontStyle.BOLD,
ITALIC: ScriptUI.FontStyle.ITALIC,
BOLDITALIC: ScriptUI.FontStyle.BOLDITALIC
};
g.font = ScriptUI.newFont(f, FontStyle[t] || ScriptUI.FontStyle.REGULAR, s);
}
function setFontStyle(o, f, t, s, pt, c, w) {
setFont(o, f, t, s);
setFGC(o, pt, c, w);
}
function setFGC(o, t, c, w) {
try {
var g = o.graphics;
g.foregroundColor = g.newPen(g.PenType.SOLID_COLOR, c, w || 1);
} catch (e) {
}
}
function setBGC(o, t, c) {
try {
var g = o.graphics;
g.backgroundColor = g.newBrush(g.BrushType.SOLID_COLOR, c);
} catch (e) {
}
}
function drawRact(target, rac) {
var x = 0;
var y = 0;
var z = {};
try {
target.graphics.newPath();
target.graphics.rectPath(rac[0], rac[1], rac[2], rac[3]);
z = target.graphics.newBrush(target.graphics.BrushType.SOLID_COLOR, [rac[4][0], rac[4][1], rac[4][2], 1]);
target.graphics.fillPath(z);
} catch (e) {
$.writeln("drawRact : " + e);
}
}
function drawRactData(target, racdata) {
var x = 0;
var y = 0;
var z = {};
var rac = {};
try {
for (var i = 0; i < racdata.length; i += 1) {
rac = racdata[i];
target.graphics.newPath();
target.graphics.rectPath(rac[0], rac[1], rac[2], rac[3]);
z = target.graphics.newBrush(target.graphics.BrushType.SOLID_COLOR, [rac[4][0], rac[4][1], rac[4][2], 1]);
target.graphics.fillPath(z);
}
} catch (e) {
$.writeln("drawRact : " + e);
}
}
function drawText(target, t, point) {
var x = 0;
var y = 0;
try {
x = typeof point[0] == "number" ? point[0] : 0;
y = typeof point[1] == "number" ? point[1] : 0;
} catch (e) {
$.writeln(e);
}
try {
target.graphics.drawString(t.text, target.graphics.newPen(target.graphics.PenType.SOLID_COLOR, [t.color[0], t.color[1], t.color[2], t.color[3]], 1), x, y, target.graphics.font);
} catch (e) {
$.writeln(e);
}
}
function drawMosaicPict(target, picData, point) {
var decodeFromCharCode = function(s) {
var z = [];
for (var i = 0,
var l = s.length; i < l;) {
z.push((s.slice(i, ++i).charCodeAt(0) - 255) / 100);
}
return z;
};
var px = 0;
var py = 0;
try {
px = typeof point[0] == "number" ? point[0] : 0;
py = typeof point[1] == "number" ? point[1] : 0;
} catch (e) {
}
try {
var r = g = b = 0;
var z = {};
if (typeof picData.data == "string") {
picData.data = decodeFromCharCode(picData.data);
}
for (var i = 0; i < picData.height; i += 1) {
for (var j = 0; j < picData.width; j += 1) {
target.graphics.newPath();
target.graphics.rectPath((j * picData.pictsize) + px, (i * picData.pictsize) + py, picData.pictsize, picData.pictsize);
if (picData.type == "mono") {
r = g = b = picData.data[(i * picData.width) + j];
} else {
r = picData.data.r[(i * picData.width) + j];
g = picData.data.g[(i * picData.width) + j];
b = picData.data.b[(i * picData.width) + j];
}
z = target.graphics.newBrush(target.graphics.BrushType.SOLID_COLOR, [r, g, b, 1]);
target.graphics.fillPath(z);
}
}
} catch (ex) {
$.writeln("xxx : " + ex);
}
}
function MosaicButton(targetButtom, mozpic) {
targetButtom.onDraw = function() {
drawMosaicPict(this, mozpic.normal, mozpic.point);
};
try {
if (mozpic.mouseover) {
targetButtom.addEventListener("mouseover", function(e) {
e.target.onDraw = function() {
drawMosaicPict(this, mozpic.mouseover, mozpic.point);
};
e.target.notify("onDraw");
}, false);
targetButtom.addEventListener("mouseout", function(e) {
e.target.onDraw = function() {
drawMosaicPict(this, mozpic.normal, mozpic.point);
};
e.target.notify("onDraw");
}, false);
}
} catch (e) {
}
}
}
function() {
$.localize = true;
var D = MDM(LAYOUT());
var undoCounter = 0;
var History = [];
var FFLtemp = {};
var FontFamilyList = [];
for (var i = 0; i < app.textFonts.length; i += 1) {
if (!FFLtemp.hasOwnProperty(app.textFonts[i].family)) {
FFLtemp[app.textFonts[i].family] = [app.textFonts[i].style];
FontFamilyList.push(app.textFonts[i].family);
} else {
FFLtemp[app.textFonts[i].family].push(app.textFonts[i].style);
}
}
var SWATCHIES = doEx(app.activeDocument.swatches).attr("name").toArray();
var Pstyle = doEx(app.activeDocument.paragraphStyles).attr("name").toArray();
var Wstyle = doEx(app.activeDocument.characterStyles).attr("name").toArray();
var LISTS = {
regexlist: {
"ひらがな": "[ぁ-ん]+",
"カタカナ": "[ァ-ン]+",
"ひらカタ": "[ぁ-んァ-ン]+",
"半角数字": "[0-9]+",
"半角英字": "[a-zA-Z]+",
"半角英数": "[a-zA-Z0-9]+",
"漢字": "[一-龠]+"
},
akiLeft: {
"ベタ": "0",
"自動": "-1",
"八分": "0.125",
"四分": "0.25",
"二分": "0.5",
"全角": "1"
},
akiRight: {
"ベタ": "0",
"自動": "-1",
"八分": "0.125",
"四分": "0.25",
"二分": "0.5",
"全角": "1"
},
fontName: FontFamilyList,
fc: SWATCHIES,
sc: SWATCHIES,
Pstyle: Pstyle,
Wstyle: Wstyle
};
for (var i in LISTS) {
additem(D.items.Group.items[i], LISTS[i]);
}
for (var i in LISTS) {
D.items.Group.items[i].selection = D.items.Group.items[i].items[0];
}
with(D.items.Group) {
items.Group.items.selection.value = true;
items.regexlist.onChange = function() {
D.items.Group.items.regex.text = LISTS.regexlist[D.items.Group.items.regexlist.selection.text];
};
items.fontName.onChange = function() {
var S = D.items.Group.items.style;
S.removeAll();
var L = FFLtemp[this.selection.text];
additem(S, L);
S.selection = S.items[0];
};
items.undo.onClick = function() {
if (undoCounter > 0) {
app.undo();
app.redraw();
undoCounter--;
History.pop();
} else {
alert("これ以上アンドゥは出来ません。");
}
};
items.close.onClick = function() {
D.wD.close();
};
items.exec.onClick = function() {
if (D.items.Group.items.regex.text.length == 0) {
alert("正規表現が入力されていません。\n");
return;
}
var VAL = {};
var Hist = {
regex: D.items.Group.items.regex.text,
target: D.items.Group.items.Group.items.selection.value ? "selection" : "document"
};
var replaceCount = 0;
for (var i in ITEMS) {
if (D.items.Group.items[i].enabled) {
switch (D.items.Group.items[i].type) {
case "edittext":
Hist[i] = VAL[i] = D.items.Group.items[i].text;
break;
case "dropdownlist":
VAL[ITEMS[i].pname] = ITEMS[i].convertValue(D.items.Group.items[i].selection.text);
Hist[i] = D.items.Group.items[i].selection.text;
break;
}
}
}
try {
Hist.style = D.items.Group.items.style.selection.text;
} catch (e) {
}
var Target = D.items.Group.items.Group.items.selection.value ? doEx("selection").filter("textFrames") : doEx(app.activeDocument.stories).find("textFrames");
Target.each(textReplacePatterns, [
["/" + D.items.Group.items.regex.text + "/mg", function() {
return function cz(tr) {
try {
VAL.characterStyle.applyTo(tr, true);
} catch (e) {
}
try {
VAL.paragraphStyle.applyTo(tr, true);
} catch (e) {
}
replaceCount++;
doEx.extend(tr, VAL);
return tr;
};
}]
]);
app.redraw();
History.push(Hist);
undoCounter++;
alert("処理が終わりました。\n該当した変更箇所は:" + replaceCount + "箇所でした。");
};
}
var ITEMS = {
fontName: {
text: localize({
ja: "書体",
en: "Font"
}),
pname: "textFont",
convertValue: function(v) {
return doEx(app.textFonts).search("family", v).search("style", D.items.Group.items.style.selection.text)[0];
}
},
size: {
text: "サイズ"
},
verticalScale: {
text: "垂直比率",
defaultValue: "100",
test: ["number", "renge:[1~10000]"]
},
horizontalScale: {
text: "水平比率",
defaultValue: "100",
test: ["number", "range:[1~10000]"]
},
Tsume: {
text: "ツメ",
test: ["number"]
},
kerning: {
text: "カーニング",
test: ["number"]
},
tracking: {
text: "トラッキング",
test: ["number"]
},
akiLeft: {
text: "アキ左",
pname: "akiLeft",
convertValue: function(v) {
return LISTS.akiLeft[v];
},
test: ["number"]
},
akiRight: {
text: "アキ右",
pname: "akiRight",
convertValue: function(v) {
return LISTS.akiRight[v];
},
test: ["number"]
},
baselineShift: {
text: "ベースラインシフト",
test: ["number"]
},
rotation: {
text: "文字回転",
test: ["number", "range:[-180~180]"]
},
fc: {
text: "塗りの色",
pname: "fillColor",
convertValue: function(v) {
return doEx(app.activeDocument.swatches).search("name", v)[0].color;
}
},
sc: {
text: "線の色",
pname: "strokeColor",
convertValue: function(v) {
return doEx(app.activeDocument.swatches).search("name", v)[0].color;
}
},
Wstyle: {
text: "文字スタイル",
pname: "characterStyle",
convertValue: function(v) {
return doEx(app.activeDocument.characterStyles).search("name", v)[0];
}
},
Pstyle: {
text: "段落スタイル",
pname: "paragraphStyle",
convertValue: function(v) {
return doEx(app.activeDocument.paragraphStyles).search("name", v)[0];
}
}
};
var check = function(x) {
D.items.Group.items[x].enabled = this.value ? true : false;
};
for (var i in ITEMS) {
D.items.Group.items[i + "_c"].value = false;
D.items.Group.items[i + "_c"].text = ITEMS[i].text;
D.items.Group.items[i + "_c"].onClick = check.curry(i);
$.os.match("Win") && D.items.Group.items[i + "_c"].size = [75, 15];
try {
D.items.Group.items[i].enabled = false;
if (ITEMS[i].defaultValue !== false && ITEMS[i].defaultValue) {
D.items.Group.items[i].text = ITEMS[i].defaultValue;
}
} catch (e) {
}
}
D.items.Group.items.regexT.text = localize({
ja: "正規表現",
en: "Regex"
});
D.items.Group.items.targetT.text = localize({
ja: "処理対象",
en: "Target"
});
D.items.Group.items.close.text = localize({
ja: "閉じる",
en: "Close"
});
D.items.Group.items.exec.text = localize({
ja: "実行",
en: "Execute"
});
D.wD.center();
D.wD.show();
function getValues() {
return VAL;
}
function additem(t, list) {
if (list === undefined) {
return;
}
if (list instanceof Array) {
for (var i = 0; i < list.length; i += 1) {
t.add("item", list[i])
}
} else {
for (var i in list) {
var r = t.add("item", i);
r.value = list[i];
}
}
}
function uniq(arr) {
for (var i = 0,
var l = arr.length; i < l; i++) {
for (var j = 0; j < i; j += 1) {
if (arr[i] === arr[j]) {
arr.splice(i--, l-- && 1);
}
}
}
return arr;
}
function LAYOUT() {
return {
type: "dialog",
title: "正規表現を使ってテキスト属性の操作",
opt: {},
pos: [0, 0, 300, 400],
layout: [{
pos: [7, 5, 293, 394],
type: "group",
name: "Group",
option: {},
items: [{
type: "edittext",
name: "regex",
label: "",
option: {},
pos: [70, 12, 223, 30]
}, {
type: "dropdownlist",
name: "regexlist",
label: "DropDownList",
option: {},
pos: [229, 12, 276, 29]
}, {
type: "statictext",
name: "regexT",
label: "Regex",
option: {},
pos: [14, 15, 65, 30]
}, {
type: "statictext",
name: "targetT",
label: "Target",
option: {},
pos: [47, 38, 92, 51]
}, {
pos: [92, 34, 279, 55],
type: "group",
name: "Group",
option: {},
items: [{
type: "radiobutton",
name: "doc",
label: "Document",
option: {},
pos: [6, 4, 88, 17]
}, {
type: "radiobutton",
name: "selection",
label: "SELECTION",
option: {},
pos: [99, 4, 181, 17]
}],
label: "Group"
}, {
type: "checkbox",
name: "fontName_c",
label: "FontName",
option: {},
pos: [7, 72, 75, 83]
}, {
type: "dropdownlist",
name: "fontName",
label: "DropDownList",
option: {},
pos: [97, 69, 278, 84]
}, {
type: "dropdownlist",
name: "style",
label: "DropDownList",
option: {},
pos: [97, 91, 278, 106]
}, {
type: "checkbox",
name: "size_c",
label: "Size",
option: {},
pos: [6, 119, 74, 130]
}, {
type: "edittext",
name: "size",
label: "",
option: {},
pos: [80, 116, 124, 133]
}, {
type: "statictext",
name: "StaticText",
label: "pt",
option: {},
pos: [128, 117, 140, 132]
}, {
type: "checkbox",
name: "verticalScale_c",
label: "VertivalScale",
option: {},
pos: [6, 144, 74, 155]
}, {
type: "edittext",
name: "verticalScale",
label: "",
option: {},
pos: [80, 141, 124, 158]
}, {
type: "statictext",
name: "StaticText",
label: "%",
option: {},
pos: [128, 143, 138, 158]
}, {
type: "checkbox",
name: "horizontalScale_c",
label: "HorizontalScale",
option: {},
pos: [144, 144, 223, 155]
}, {
type: "edittext",
name: "horizontalScale",
label: "",
option: {},
pos: [227, 141, 271, 158]
}, {
type: "statictext",
name: "StaticText",
label: "%",
option: {},
pos: [273, 143, 283, 158]
}, {
type: "edittext",
name: "kerning",
label: "",
option: {},
pos: [80, 167, 124, 184]
}, {
type: "checkbox",
name: "kerning_c",
label: "Kerning",
option: {},
pos: [6, 170, 74, 181]
}, {
type: "statictext",
name: "StaticText",
label: "%",
option: {},
pos: [128, 194, 138, 205]
}, {
type: "checkbox",
name: "tracking_c",
label: "Tracking",
option: {},
pos: [144, 170, 223, 181]
}, {
type: "edittext",
name: "tracking",
label: "",
option: {},
pos: [226, 167, 279, 184]
}, {
type: "checkbox",
name: "Tsume_c",
label: "Tsume",
option: {},
pos: [6, 194, 74, 205]
}, {
type: "edittext",
name: "Tsume",
label: "",
option: {},
pos: [80, 191, 124, 208]
}, {
type: "checkbox",
name: "akiLeft_c",
label: "AkiLeft",
option: {},
pos: [6, 217, 74, 228]
}, {
type: "dropdownlist",
name: "akiLeft",
label: "DropDownList",
option: {},
pos: [79, 215, 136, 231]
}, {
type: "checkbox",
name: "akiRight_c",
label: "AkiRight",
option: {},
pos: [144, 217, 223, 228]
}, {
type: "dropdownlist",
name: "akiRight",
label: "DropDownList",
option: {},
pos: [225, 215, 280, 231]
}, {
type: "checkbox",
name: "baselineShift_c",
label: "BL",
option: {},
pos: [6, 242, 74, 253]
}, {
type: "edittext",
name: "baselineShift",
label: "",
option: {},
pos: [80, 239, 124, 256]
}, {
type: "checkbox",
name: "rotation_c",
label: "R",
option: {},
pos: [144, 242, 223, 253]
}, {
type: "edittext",
name: "rotation",
label: "",
option: {},
pos: [226, 239, 279, 256]
}, {
type: "checkbox",
name: "fc_c",
label: "FillColor",
option: {},
pos: [6, 271, 74, 282]
}, {
type: "dropdownlist",
name: "fc",
label: "DropDownList",
option: {},
pos: [79, 269, 134, 285]
}, {
type: "checkbox",
name: "sc_c",
label: "StrokeColor",
option: {},
pos: [144, 271, 223, 282]
}, {
type: "dropdownlist",
name: "sc",
label: "DropDownList",
option: {},
pos: [226, 269, 279, 285]
}, {
type: "checkbox",
name: "Wstyle_c",
label: "charactorStyle",
option: {},
pos: [7, 303, 75, 314]
}, {
type: "dropdownlist",
name: "Wstyle",
label: "DropDownList",
option: {},
pos: [96, 301, 276, 316]
}, {
type: "checkbox",
name: "Pstyle_c",
label: "paragraphStyle",
option: {},
pos: [7, 328, 75, 339]
}, {
type: "dropdownlist",
name: "Pstyle",
label: "DropDownList",
option: {},
pos: [96, 326, 276, 341]
}, {
type: "button",
name: "exec",
label: "Execute",
option: {},
pos: [7, 362, 69, 379]
}, {
type: "button",
name: "undo",
label: "UNDO",
option: {},
pos: [72, 362, 122, 379]
}, {
type: "button",
name: "close",
label: "CLOSE",
option: {},
pos: [203, 362, 279, 379]
}],
label: "Group"
}]
};
}
}();
合理的脚本代码可以有效的提高工作效率,减少重复劳动。
文章引用至 作者知了-联系方式1
文章引用至 作者知了-联系方式2