-
Notifications
You must be signed in to change notification settings - Fork 0
/
goto_last_view_page.js
89 lines (79 loc) · 1.84 KB
/
goto_last_view_page.js
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
var data = new Array();
var timeout = null;
var liveBookmark = false;
function ClearBookmarks() {
data = new Array();
}
function Bookmarks() {
return data;
}
function LiveBookmarks(interval) {
interval = interval || 100;
liveBookmark = true;
timeout = app.setInterval("AddBookmark()", interval);
timeout.count = 0;
}
function AddBookmark() {
try {
if (Bookmarks().length > 0) {
var lastBookmark = Bookmarks().pop();
if (parseInt(lastBookmark) == parseInt(this.pageNum)) {
Bookmarks().push(this.pageNum);
} else {
Bookmarks().push(lastBookmark);
Bookmarks().push(this.pageNum);
}
} else {
Bookmarks().push(this.pageNum);
}
}
catch (ex) {
app.alert(ex);
}
}
function GotoLastBookmark() {
try {
if (Bookmarks().length > 0) {
if (timeout) {
app.clearInterval(timeout);
}
var pageNo = Bookmarks().pop();
this.pageNum = parseInt(pageNo);
if (liveBookmark) {
LiveBookmarks(2000);
}
}
}
catch (ex) {
app.alert(ex);
}
}
app.addMenuItem({
cName: "-",
cParent: "View",
cExec: "void(0);"
});
app.addMenuItem({
cName: "Bookmark &+",
cParent: "View",
cExec: "AddBookmark();",
cEnable: "event.rc= (event.target != null);"
});
app.addMenuItem({
cName: "Last Bookmark &-",
cParent: "View",
cExec: "GotoLastBookmark();",
cEnable: "event.rc= true;"
});
app.addMenuItem({
cName: "Clear Bookmark(s) &*",
cParent: "View",
cExec: "ClearBookmarks();",
cEnable: "event.rc= true;"
});
app.addMenuItem({
cName: "Live Bookmark",
cParent: "View",
cExec: "LiveBookmarks();",
cEnable: "event.rc= true;"
});