Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
zeroing-editor
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
劳工
zeroing-editor
Commits
e6493d3a
Commit
e6493d3a
authored
Nov 26, 2019
by
rockyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加埋点脚本
parent
e9c228b4
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
0 deletions
+47
-0
自动合并.jsx
自动合并.jsx
+47
-0
No files found.
自动合并.jsx
0 → 100644
View file @
e6493d3a
/**
* Created by rockyl on 2019-11-25.
*/
var
mergeFlagReg
=
/__m$/
;
var
oldDocument
=
app
.
activeDocument
;
var
mergeLayers
=
[];
var
document
=
oldDocument
.
duplicate
(
oldDocument
.
name
+
'-合并'
,
0
);
app
.
activeDocument
=
document
;
merge
(
document
);
function
merge
(
document
){
traverse
(
document
,
function
(
layer
){
return
layer
.
name
.
match
(
mergeFlagReg
);
},
function
(
layer
){
var
newName
=
layer
.
name
.
replace
(
mergeFlagReg
,
''
);
layer
.
name
=
newName
;
mergeLayers
.
push
(
newName
);
document
.
activeLayer
=
layer
;
layer
.
merge
();
});
if
(
mergeLayers
.
length
>
0
){
alert
(
'合并的图层有: '
+
mergeLayers
.
join
(
','
));
}
else
{
alert
(
'没有图层被合并'
);
}
}
function
traverse
(
layer
,
filter
,
callback
)
{
if
(
layer
.
layers
){
for
(
var
i
=
0
;
i
<
layer
.
layers
.
length
;
i
++
)
{
var
childLayer
=
layer
.
layers
[
i
];
if
(
filter
(
childLayer
))
{
callback
(
childLayer
);
}
else
{
traverse
(
childLayer
,
filter
,
callback
);
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment