-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtabs.js
More file actions
120 lines (108 loc) · 2.78 KB
/
tabs.js
File metadata and controls
120 lines (108 loc) · 2.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*
save tabs is a java script for Acrobat Reader
on Linux put it usually in ~/.adobe/Acrobat/9.0/JavaScripts
on Windows and Adobe DC -> C:\Program Files (x86)\Adobe\Acrobat DC\Acrobat\Javascripts
and in Acrobat Menu (Edit>Preferences>Javascript) ENABLE "Enable menu items JavaScript execution privileges"
see http://stackoverflow.com/questions/12689154/adobe-acrobat-reader-tabs-saving-and-autoloading for more info. NOT my script
*/
var delim= '|';
var parentMenu="View";
/*
Loading Saved Tabs
*/
function LoadTabs()
{
if( global.tabs_opened == null )
{
return;
}
var flat= global.tabs_opened.split( delim );
for( i= 0; i< flat.length; i+=2)
{
try
{
app.openDoc( flat[i] );
app.execMenuItem( "FirstPage" );
for( ii= 0; ii< flat[i+1]; ++ii )
{
app.execMenuItem( "NextPage" );
}
}
catch( ee )
{
app.alert("Error while opening the requested document.\n"+flat[i],3);
}
}
}
/*
Function with trusted section returning opened documents
*/
trustedActiveDocs = app.trustedFunction ( function()
{
app.beginPriv();
var d = app.activeDocs;
app.endPriv();
return d;
})
/*
Saving Tabs that are opened
*/
function SaveTabs()
{
var d = trustedActiveDocs();
var tabs = '';
for ( var i=0;i<d.length; i++)
{
if(i>0)
tabs+=delim;
//app.alert(d[i].path+"------"+d[i].pageNum,3);
tabs+= d[i].path;
tabs+= delim;
tabs+= d[i].pageNum;
}
global.tabs_opened = tabs;
global.setPersistent( "tabs_opened", true );
app.alert("Tabs Saved",3);
}
/*
Toggle auto load tabs
automatically loading tabs when reader starts
*/
function ToggleAuto()
{
if(global.tabs_auto == 0 || global.tabs_auto == null)
{
global.tabs_auto=1;
global.setPersistent( "tabs_auto", true );
app.alert("Tabs auto loading enabled",3);
}
else
{
global.tabs_auto=0;
global.setPersistent( "tabs_auto", true );
app.alert("Tabs auto loading disabled",3);
}
}
app.addMenuItem( {
cName: "-",
cParent: parentMenu,
cExec: "void(0);" } );
app.addMenuItem( {
cName: "&Save Tabs",
cParent: parentMenu,
cExec: "SaveTabs();"
} );
app.addMenuItem( {
cName: "&Load Tabs",
cParent: parentMenu,
cExec: "LoadTabs();"
} );
app.addMenuItem( {
cName: "Toggle auto load",
cParent: parentMenu,
cExec: "ToggleAuto();"
} );
if(global.tabs_auto==1)
{
LoadTabs();
}