home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AmigActive 4
/
AACD04.ISO
/
AACD
/
Online
/
AWebScripts
/
AddHL.awebrx
next >
Wrap
Text File
|
1999-11-25
|
4KB
|
260 lines
/* $VER: AddHL.awebrx 1.2 (17.11.1999) by Jorma Oksanen <tenu@sci.fi>
Adds URL to hotlist, first checking for duplicate entries
Usage:
Add Adds an unassigned entry
Add to Group Adds entry to a specified group
Edit name Allows editing the entry name
Update Updates old entry with the new name
Delete Deletes old entries
Cancel Cancels hotlist operation
'Add to group' can create a new group, just enter
the name of the new group into the text field.
Example:
foo/bar/baz will add foo/bar/baz/entry, creating all
necessary groups.
'Update' can't be performed on multiple entries, because
AWeb deletes identical entries.
'Edit name' and 'Delete' loop back to the requester.
Setup:
GUI/Popup/Link
AddHL RUN AWeb3:Plugins/AddHL.awebrx %u
GUI/Keys
[key] RUN AWeb3:Plugins/AddHL.awebrx
If you want to replace the navigation button:
GUI/Navigation/Add to hotlist
RUN AWeb3:Plugins/AddHL.awebrx
*/
options results
parse arg '"' u '"'
if u~='' then t=u
else do
'get title var t'
'get url var u'
end
if right(u,1)='/' then u2=left(u,length(u)-1)
else u2=u'/'
'get hotlist stem hl'
/* duplicate check and group scan */
d=0; g=0
do i=1 to hl.0
if (hl.i.url=u)|(hl.i.url=u2) then do
d=d+1
dup.d=i
end
if hl.i.group then do
g=g+1
grp.g=i
end
end
g.0=g
loop:
if d=0 then body2=''
else do
body2="URL already in hotlist as*N *N"
do i=1 to d
j=dup.i
k=hl.j.owner
n=hl.j.title'*N'
if k=0 then n='unassigned/'n
else do
do until k=0
n=hl.k.title'/'n
k=hl.k.owner
end
end
body2=body2||n
end
end
upd=99
del=99
ggs='_Add|Add to _Group|_Edit name'
select
when d=1 then do
ggs=ggs'|_Update|_Delete'
upd=4
del=5
end
when d>1 then do
ggs=ggs'|_Delete'
del=4
end
otherwise nop
end
ggs=ggs'|_Cancel'
do forever
body1='Name: 't'*NURL: 'u'*N *N'
'request "AddHotlist" "'body1||body2'" "'ggs'"'
if rc=5 then exit 0 /* Cancel */
select
when result=1 then do /* Add */
'addhotlist "'u'" "'t'"'
exit 0
end
when result=2 then do /* Add to Group */
body='A) unassigned*N'
do i=1 to min(g,25)
j=grp.i
k=hl.j.owner
n=hl.j.title'*N'
do while k>0
n=hl.k.title'/'n
k=hl.k.owner
end
body=body||d2c(i+65)')' n
end
'requeststring "Select group" "'body'" "Ok|Cancel"'
if (rc=5)|(result='') then exit 0
grpname=result
i=upper(result)
if i='A' then do
'addhotlist "'u'" "'t'"'
exit 0
end
if length(i)=1 then do
i=c2d(i)-65; if i>min(g,25) then exit 0
i=grp.i
end
else i=creategrp(grpname)
j=hl.0+1
hl.j.group=0
hl.j.title=t
hl.j.url=u
hl.j.owner=i
hl.0=j
'hotlist set hl'
exit 0
end
when result=3 then do /* Edit name */
'requeststring "AddHotList" "Enter new name for URL" "Ok|Cancel" "'t'"'
if rc=5 then exit
t=result
end
when result=upd then do /* Update */
i=dup.1
hl.i.title=t
'hotlist set hl'
exit 0
end
when result=del then do /* Delete */
k=hl.0
do i=d to 1 by -1
j=dup.i
if i~=k then do
hl.j.group=hl.k.group
hl.j.title=hl.k.title
hl.j.url=hl.k.url
hl.j.owner=hl.k.owner
end
k=k-1
end
hl.0=k
'hotlist set hl'
d=0
signal loop
end
end
end
exit 0
creategrp: procedure expose hl. grp.
parse arg grpname
p=0; g=grp.0
do until grpname=''
parse var grpname t '/' grpname
i=searchgrp(t,p)
if i=0 then do
i=hl.0+1
hl.i.group=1
hl.i.title=t
hl.i.url=''
hl.i.owner=p
hl.0=i
g=g+1
grp.g=i
end
p=i
end
grp.0=g
return i
searchgrp: procedure expose hl. grp.
if grp.0=0 then return 0
do i=1 to grp.0
j=grp.i
if hl.j.title=arg(1) then if hl.j.owner=arg(2) then return j
end
return 0