Advertisement
andrewb

ll_client1.r

Sep 17th, 2015
1,129
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. rebol [
  2.     Title: "Lady Lawful Client"
  3.     Version: 0.1
  4.     Purpose: [To learn a bit more about REBOL.]
  5. ]
  6.  
  7. prtz: []
  8.  
  9. get-ll-json: func [jurl] [
  10.   json: read jurl
  11.   parts: parse json {[{" "} "," ":"]}
  12.   clear prtz
  13.   foreach [p] parts [
  14.     if not zero? length? p [ append prtz p ]
  15.   ]
  16.   prtz
  17. ]
  18.  
  19. getPic: func [gurl] [ to-image (load-image (load to-string gurl)) ]
  20.  
  21. getPrev: func [] [ get-ll-json http://ladylawful.com/prev ]
  22.  
  23. getNext: func [] [ get-ll-json http://ladylawful.com/next ]
  24.  
  25. getCurrent: func [] [ get-ll-json http://ladylawful.com/img ]
  26.  
  27. picFull: func [ json ] [ json/2 ]
  28.  
  29. picSmall: func [ json ] [ json/4 ]
  30.  
  31. picThumb: func [ json ] [ json/6 ]
  32.  
  33. setSize: func[ pic ] [
  34.     tx: pic/size/x + 20
  35.     ty: pic/size/y + 20
  36.     to-pair (as-pair tx ty)
  37. ]
  38.  
  39. refreshPic: func [w i n] [
  40.     i /clear
  41.     i/size: n/size
  42.     set-face i n
  43.     w/size: setSize n
  44.     show w
  45. ]
  46.  
  47. v1: layout [
  48.   at 10x10 b: image getPic picSmall getCurrent
  49.   at 10x10 btn "PREV" [
  50.     refreshPic v1 b getPic picSmall getPrev
  51.   ]
  52.   at 60x10 btn "NEXT" [
  53.     refreshPic v1 b getPic picSmall getNext
  54.   ]
  55.   at 110x10 btn "QUIT" [quit]
  56. ]
  57.  
  58. view v1
Advertisement
RAW Paste Data Copied
Advertisement