-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUpdate_.txt
93 lines (78 loc) · 2.71 KB
/
Update_.txt
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
current_version = 1.1;
url = "http://code.google.com/p/quickpalm/downloads/list";
prefix = "QuickPALM%20";
jarname = "QuickPALM_.jar";
///// FUNCTIONS - START
function findFileRecursive(dir, fname, patharr)
{
list = getFileList(dir);
for (i=0; i<list.length; i++)
{
if (endsWith(list[i], "/"))
findFileRecursive(""+dir+list[i], fname, patharr);
else if (indexOf(list[i], fname)!=-1)
patharr[0]=dir+list[i];
}
}
///// FUNCTIONS - END
showStatus("Searching for "+jarname);
jpath = newArray(1);
findFileRecursive(getDirectory("plugins"), jarname, jpath);
jpath = jpath[0];
if (jpath==0) exit("Could not find '"+jarname+"' path.");
showStatus("Looking in "+url);
urltxt = File.openUrlAsString(url);
urltxtlines = split(urltxt, "\n");
showStatus("Parsing versions");
fnames = newArray(100);
links = newArray(100);
versions = newArray(100);
versions_major = newArray(100);
versions_minor = newArray(100);
versions_beta = newArray(100);
counter = 0;
for (l=0;l<lengthOf(urltxtlines);l++)
{
line = urltxtlines[l];
if (indexOf(line, "title=\"Download\"")!=-1 && indexOf(line, "Laser")==-1)
{
start = indexOf(line, "location.href='")+15;
stop = indexOf(line, "'\"");
links[counter] = substring(line, start, stop);
start = indexOf(line, "name=\"")+6;
stop = indexOf(line, "\" title");
fnames[counter] = replace(substring(line, start, stop), "%20", " ");
start = indexOf(fnames[counter], "QuickPALM%20")+11;
stop = indexOf(fnames[counter], ".zip");
versions[counter] = substring(fnames[counter], start, stop);
versions_major = substring(versions[counter], 0, indexOf(versions[counter], "."));
if (indexOf(versions[counter], "b")==-1)
{
versions_minor = substring(versions[counter], indexOf(versions[counter], ".")+1, lengthOf(versions[counter]));
versions_beta[counter] = "final";
}
else
{
versions_minor = substring(versions[counter], indexOf(versions[counter], ".")+1, indexOf(versions[counter], "b"));
versions_beta[counter] = substring(versions[counter], indexOf(versions[counter], "b")+1, lengthOf(versions[counter]));
}
counter++;
}
}
showStatus("Found "+counter+" diferent versions");
versions = Array.trim(versions, counter);
Dialog.create("Update QuickPALM...");
Dialog.addMessage("Current version: "+ current_version);
Dialog.addChoice("Get version", versions);
Dialog.show();
choice = Dialog.getChoice();
furl = "";
for (n=0;n<counter;n++)
{
if (choice == versions[n]) furl = links[n];
}
showStatus("Downloading...");
exec("open", furl);
print("Downloading: "+furl+"\nPlease extract and copy: "+jarname+"\nReplace: "+jpath);
//File.saveString(File.openUrlAsString(furl), jpath);
//showStatus("Done... please restart ImageJ.");