This file contains hidden or 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
function in_library (library_string, name) { | |
var my_reg_exp = new RegExp( "::" + remove_file_extension(name) + "::" ); // use separation symbol | |
var result = false; | |
if(my_reg_exp.test( library_string )) { | |
result = true; | |
}; | |
return result; | |
}; |
This file contains hidden or 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
function index_progress_bar(title) { | |
var w = new Window("palette", title, undefined); | |
w.orientation = "column"; | |
var text_group = w.add("group"); | |
text_group.orientation = "column"; | |
var file_name = text_group.add("statictext", [0,0,350,20], "calculating.."); | |
var remain = text_group.add("statictext", [0,0,350,20], "Remain: .."); | |
text_group.alignChildren = "left"; | |
var progressbar = w.add("progressbar", undefined, 0, 100); | |
progressbar.preferredSize = [350,20]; |
This file contains hidden or 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
function get_folder_files(file_type, title, param_path) { | |
// v.0.1.2 | |
var path = ""; | |
if(!param_path) { | |
var tmp_file = File.openDialog(title, file_type); | |
if(!tmp_file) {exit(); }; | |
path = tmp_file.path; | |
}else { path = param_path; }; | |
var my_folder = new Folder(path); |
This file contains hidden or 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
function filter_files (param_files, file_name_part) { | |
var all_files = param_files || []; | |
var selected_files = []; | |
var my_reg = new RegExp(file_name_part); | |
if(all_files.length === 0 ) {return [];} | |
for (var i = 0, len = all_files.length; i < len; i++) { | |
if(my_reg.test(all_files[i].name)) { | |
selected_files.push(all_files[i]); | |
}; | |
}; |
This file contains hidden or 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
function find_by_grep (grep_keyword, paragraph_style, app_document) { | |
var app_doc = app_document || app.activeDocument; | |
app.findChangeGrepOptions.includeLockedLayersForFind = false; | |
app.findChangeGrepOptions.includeLockedStoriesForFind = false; | |
app.findChangeGrepOptions.includeHiddenLayers = false; | |
app.findChangeGrepOptions.includeMasterPages = false; | |
app.findChangeGrepOptions.includeFootnotes = false; | |
// app.findChangeTextOptions.caseSensitive = true; | |
// app.findChangeTextOptions.wholeWord = true; |
This file contains hidden or 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
function remove_see_see_also ( text ) { | |
var tmp_str = ""; | |
var my_reg = new RegExp("(^see also )|(^see )|(\t000$)","g"); | |
tmp_str = text.replace(my_reg, ""); | |
// remove unvisible xml tag | |
var xml_tag_char = ""; | |
xml_tag_char = tmp_str.charCodeAt(0); | |
if(xml_tag_char === 65279){ | |
tmp_str = tmp_str.replace(tmp_str[0],""); | |
}; |
This file contains hidden or 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
function read_text_file (file) { | |
if(file !=null) { | |
var all_string = ""; | |
file.open("r"); | |
while(!file.eof) { | |
all_string += (file.readln() + "\n") ; | |
}; | |
file.close(); | |
}; |
This file contains hidden or 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
function read_name_page_file (name_page_file) { | |
var name_and_page = []; | |
var tmp_arr = []; | |
var tmp_str = ""; | |
if(name_page_file !=null) { | |
name_page_file.open("r"); | |
while(!name_page_file.eof){ | |
tmp_str = name_page_file.readln(); | |
tmp_arr = tmp_str.split("\t"); |
This file contains hidden or 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
function record_time(startTime) { | |
var secs = Math.round(((new Date()).getTime() - startTime)/1000); | |
if(secs === 0) return 1; | |
var str = "", | |
hr = Math.floor(secs / 3600), | |
min = Math.floor((secs - (hr * 3600))/60), | |
sec = secs - (hr * 3600) - (min * 60); | |
if(hr>0) { str += hr + "h:"; } | |
if(min>0) { str += min + "mn:"; } | |
if(sec>0) { str += sec + "s"; } |
This file contains hidden or 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
function remove_file_extension(name, extensions) { | |
var my_extensions = extensions || ["jpg","gif","png","psd","eps","indd","INDL","ai","txt","pdf"]; | |
var reg_string = "\.(" + my_extensions.join("|") + ")$"; | |
var my_reg = new RegExp( reg_string, "i" ); | |
name = name.replace(my_reg, ''); | |
return name; | |
}; |