;-=-=-=-=-=-
; DeadLy Script - NEWS
;-=-=-=-=-=-
dialog news {
  title On-Line Jokes / News - $sc
  icon $icons(online)
  size -1 -1 400 220
  box "", 1, 10 1 260 190
  text Select Jokes / News, 2, 280 10 100 14
  text Click here to retrieve, 3, 290 65 100 14
  edit "", 101, 20 15 240 170, multi read vsbar
  combo 201, 280 25 110 100, drop 
  list 301, 305 80 63 52, size
  button visit sites, 401, 300 140 70 18
  button stop, 403, 300 160 70 18
  button exit, 404, 300 200 70 18, cancel 
  button send sms msg, 405, 200 200 95 18
  check Open on Connect, 402, 10 197 150 18
}
on 1:DIALOG:news:*:*: {
  if $devent = init { 
    $dll1
    dll $dl SetControlMDX $dname 301 ToolBar list flat nodivider > $bars
    dll $dl SetBorderStyle 301
    did -i $dname 301 1 bmpsize 40 40
    did -i $dname 301 1 setimage icon large $icons(news)
    did -a $dname 301 +a 1 $chr(32) $+ $chr(9) $+ Get / Read News NOW!
    did -a news 201 pinoyjokes
    did -a news 201 abs-cbn
    did -a news 201 cooltext
    did -c news 201 $didwm(news,201,$hget(var,news.jokes))
    did $replace($hget(setup,news),on,-c,off,-u) news 402 
    hadd -m events server.news $did(news,201)
    getnews 
  }
  if $devent = sclick { 
    if $did = 201 { hadd -m events server.news $did(news,201) | hadd var news.jokes $did(news,201) }
    if $did = 301 { getnews }
    if $did = 401 { 
      if ($hget(events,server.news) = pinoyjokes) url -n www.pinoyjokes.net 
      if ($hget(events,server.news) = abs-cbn) url -n www.abs-cbnnews.com
    }
    if $did = 402 { hadd setup news $iif($did(402).state = 1,on,off) }
    if $did = 403 { sockclose getnews | news.ena | did -r news 101 | did -a news 101 Closing Link . . . }
    if $did = 405 { _icq.dlg_sendsms }
  }
  if $devent = close { .remove xlate.txt | unloads news }
  if $devent = edit { hadd -m events dic $did(102) }
}

alias getnews {
  sockclose getnews | did -a news 101 Finding Sites . . . | did -b news 201,301,401 | did -r news 101 | did -f news 401 
  if ($hget(events,server.news) = pinoyjokes) sockopen getnews www.pinoyjokes.net 80
  if ($hget(events,server.news) = abs-cbn) sockopen getnews www.abs-cbnnews.com 80
  if ($hget(events,server.news) = cooltext) sockopen getnews www.cooltext.org 80
}
on 1:SOCKOPEN:getnews: { did -a news 101 Connecting . . . 
  if ($sockerr != 0) && ($dialog(news) != $null) { did -r news 101 | did -a news 101 $sock($sockname).wsmsg . . . Can't open sockets, try again later . . . | news.ena | return }  
  if ($hget(events,server.news) = pinoyjokes) sockwrite -tn $sockname GET http://www.pinoyjokes.net 
  if ($hget(events,server.news) = abs-cbn) sockwrite -tn $sockname GET http://www.abs-cbnnews.com 
  if ($hget(events,server.news) = cooltext) sockwrite -tn $sockname GET http://www.cooltext.org 
}
alias news.ena did -e news 201,301,401 

on 1:SOCKREAD:getnews: { 
  sockread -n %new 
  if ($hget(events,server.news) = pinoyjokes) {
    if (*<!-- PJBEST END -->* iswm %new) { set %0k off }
    if (%0k = on) { 
      if (%new = $null) did -a news 101 $crlf
      set %wen $remove(%new,<CENTER>,<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=5>,<TR>,<TD>,<STRONG>,</STRONG>,</TD>,</TR>,</TABLE>,</CENTER>,more of these jokes at)
      did -a news 101 $gettok($gettok($replace(%wen,<P>,$crlf,</P>,$crlf,&quot;,"),1,64),1,60)
    }
    if (*<!-- PJBEST START -->* iswm %new) { set %0k on | did -r news 101 }
  }
  if ($hget(events,server.news) = abs-cbn) {
    if (*newsmain* iswm %new) { did -r news 101 
      if (%new = $null) did -a news 101 $crlf
      set %wen Headlines: $replace($remove($gettok(%new,11-,62),</A>,<B><I>TODAY</I></B></TD></TR></TABLE),<br>,$crlf $crlf,€,l,™,',â,a,Ã±,ñ)
      did -a news 101 %wen
    }
  }
  if ($hget(events,server.news) = cooltext) {
    if (*<!--End SMS of the day -->* iswm %new) { set %0k off }
    if (%0k = on) { 
      if (%new = $null) did -a news 101 $crlf
      set %wen $remove(%new,<CENTER>,<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=5>,<TR>,<TD>,</P>,<STRONG>,</STRONG>,</TD>,</TR>,</TABLE>,</CENTER>)
      did -a news 101 $replace(%wen,<P>,$crlf $crlf)
    }
    if (*<!--Start SMS of the day -->* iswm %new) { set %0k on | did -r news 101 }
  }
  if (*<html>* iswm %new) did -a news 101 Retrieving Data . . .
  if (*</html>* iswm %new) { unset %new %wen %0k | news.ena | did -a news 101 $crlf $crlf Click "visit sites" for MORE. . . }
}

on *:EXIT: unset %new %wen %0k | unloads news
on *:UNLOAD: unset %new %wen %0k 
on *:LOAD: dialog $iif($dialog(news),-v,-m) news news | s.open
;-=-=-=-=-=-
;-=-=-=-=-=-
