Created
January 11, 2019 06:40
-
-
Save UskeS/b2bda815dc7c3338755bc9b963542f3f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var doc = app.activeDocument; | |
var pst = doc.allParagraphStyles; | |
pst.splice(0, 2); | |
var pstNameList = getNames(pst); | |
var result = {}; //エラー結果を入れる配列 | |
for (var i=0, ilen=pstNameList.length; i<ilen; i++) { | |
for (var k=0, klen=pstNameList.length; k<klen; k++) { | |
if (i === k) { | |
continue; | |
} | |
if (pstNameList[i] === pstNameList[k]) { | |
result[pstNameList[i]] = ""; //空の連想配列 | |
} | |
} | |
} | |
if (result.length !== 0) { | |
alert("以下の段落スタイル名が重複しています\r" + getKeys(result).join("\r")); | |
} else { | |
alert("直復した段落スタイル名は見つかりませんでした"); | |
} | |
function getNames(objAry) { | |
var result = []; | |
for (var i=0, len=objAry.length; i<len; i++) { | |
if (objAry[i].hasOwnProperty("name")) { | |
result.push(objAry[i].name); | |
} | |
} | |
return result; | |
}; | |
function getKeys(obj) { | |
var result = []; | |
for (var key in obj) { | |
result.push(key); | |
} | |
return result; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment