All pastes #293807 Raw Edit

Miscellany

public text v1 · immutable
#293807 ·published 2006-12-27 22:21 UTC
rendered paste body
alias shopitem /dialog -ma shop shop
dialog shop {
  title "Items"
  size -1 -1 300 100
  option dbu
  button "OK" 1, 2 84 46 12
  list 2, 4 2 285 82
  edit "" 3, 80 84 80 9
  edit "" 4, 170 84 46 9, read
}
menu channel {
  shop:/shopitem
}
on *:dialog:shop:sclick:1: {
  $shops($did(3))
}
alias Shops { 
  did -r Shop 2
  did -a Shop 1 Please wait...
  inc %n 
  set $+(%,shop.style.,%n) did -a shop 2
  set $+(%,shop.word.,%n) $replace($1-,$chr(32),+) 
  did -a Shop 2 Looking for $iif($1,$qt($1-),All items)
  sockopen $+(shops.,%n) www.runehq.com 80 
} 
on *:SOCKOPEN:shops.*:{ 
  var %id = $gettok($sockname,2,46) 
  sockwrite -n $sockname GET /RHQItemDB.php HTTP/1.1 
  sockwrite -n $sockname Host: www.runehq.com
  sockwrite -n $sockname $+($crlf,$crlf) 
} 
on *:SOCKREAD:shops.*:{
  var %x = 0, %y = 0, $&
    %id = $gettok($sockname,2,46), $&
    %style = $($+(%,shop.style.,%id),2), $& 
    %word = $($+(%,shop.word.,%id),2)
  if ($sockerr) { 
    did -a shop 2 An error occured while connecting 
    unset $+(%,shop.*) 
  } 
  else { 
    var %read 
    sockread %read 
    inc %x
    if (*There are currently* iswm %read && *items* iswm %read) {
      set %item.number $remove(%read,</b> items,<p class="text">There are currently <b>)
    }
    elseif (*RHQItemView.php?id=* !iswm %read) halt
    elseif (*menuitem* !iswm %read) halt
    elseif (%x == %item.number) {
      did -a shop 1 Ok
    }
    elseif (%x == %item.number) {
      unset %item.number
      unset $+(%,shop.*) 
    }
    elseif (%word isin %read) {
      var %item = $remove(%read,<td align="left"><a class=,"menuitem",s=, href=",</a>,</td>,a class="menuItem" href=",align=left",>,><,</,lign=left", a clas )
      did -a shop 2 $replace(%item,",$chr(64))
      inc %y
      did -r Shop 4
      did -a Shop 4 $+(%y,/,%item.number) Items
    }
  }
}
alias htmlstrip { var %x,%y = $regsub($1-,/(<[^>]+>)/g,$null,%x) | return %x }