rendered paste bodydialog urban {
title "Urban Dictionary"
size -1 -1 211 143
option dbu
edit "", 1, 5 15 67 13, autohs
text "Text to look up", 2, 6 4 39 8
text "Match 2", 3, 112 33 25 8
edit "", 4, 6 44 95 41, read multi autovs vsbar
edit "", 5, 111 44 95 41, read multi autovs vsbar
text "Match 1", 6, 6 33 25 8
edit "", 7, 6 99 94 41, read multi autovs vsbar
text "Match 3", 8, 7 88 25 8
edit "", 9, 111 99 95 41, read multi autovs vsbar
text "Match 4", 10, 111 88 25 8
button "Look Up", 11, 79 16 33 11
list 12, 186 7 15 30, size
button "Copy", 13, 149 14 32 11
button "Goto Link", 14, 116 15 29 10, disabled
}
on *:DIALOG:urban:sclick:14: { url -n %link }
alias urbid {
if ($1) { return $iif($did(urban,12).seltext == 1,4,$iif($did(urban,12).seltext == 2,5,$iif($did(urban,12).seltext == 3,7,9))) }
else { return $iif(%matches == 1,4,$iif(%matches == 2,5,$iif(%matches == 3,7,9))) }
}
on *:DIALOG:urban:sclick:13: {
clipboard [URBAN] $did(urban,1) $+ : $regsubex($str(-,$did(urban,$urbid(c)).lines),/-/g,$did(urban,$urbid(c),\n))
}
on *:DIALOG:urban:sclick:11: {
set %urbname $replace($did(urban,1),$chr(32),+)
did -b urban 11,1
sockopen urban www.urbandictionary.com 80
set %link www.urbandictionary.com/define.php?term= $+ %urbname
set %matches 1
}
on *:SOCKOPEN:urban: {
sockwrite -nt $sockname GET /define.php?term= $+ %urbname HTTP/1.1
sockwrite -nt $sockname HOST: www.urbandictionary.com
sockwrite -nt $sockname $crlf
}
on *:SOCKREAD:urban: {
if ($sockerr) { did -a urban 4,5,7,9 $sockerr | halt }
else {
var %urb
sockread %urb
if (*<p>* iswm %urb && %matches <= 4) {
did -ra urban $urbid $replace($htmlfree(%urb),",")
did -c urban $urbid 1
inc %matches
}
elseif (%matches == 5) {
unset %matches
unset %urbname
sockclose urban
did -e urban 1,11-14
did -c urban 12 1
}
elseif (*isn't defined* iswm %urb) {
did -ra urban 4,5,7,9 $did(urban,1) isn't defined.
unset %matches
unset %urbname
sockclose urban
did -e urban 1,11-14
did -c urban 12 1
}
elseif (*</html>* iswm %urb) {
if (%matches == 2) { did -ra urban 5,7,9 N/A }
elseif (%matches == 3) { did -ra urban 7,9 N/A }
elseif (%matches == 4) { did -ra urban 9 N/A }
unset %matches
unset %urbname
sockclose urban
did -e urban 1,11-14
did -c urban 12 1
}
}
}
on *:DIALOG:urban:init:0: {
did -b urban 12,13
did -a urban 12 1
did -a urban 12 2
did -a urban 12 3
did -a urban 12 4
did -t urban 11
}