Mercurial > repos > tabletprog
view editor.tp @ 21:6c8ae6b47ab5
Small improvements to property support and elimination of setP and getP functions as they are no longer needed
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 25 Mar 2012 21:11:10 -0700 |
parents | 4dd99fde5f63 |
children | 068d63627b16 |
line wrap: on
line source
#{ //mquery functions q <- foreign: :query {} qall <- foreign: :query {} each <- foreign: :iterable fun {} addClass <- foreign: :node className {} removeClass <- foreign: :node className {} get <- foreign: :url onSuccess onFail onOther {} //TP Parser parser <- foreign: #{ parse <- foreign: :str {} } //js builtins console <- foreign: #{ log <- foreign: #{} } window <- #{} //kernel definitions true <- #{ if:else <- :self trueblock :elseblock { trueblock: } } false <- #{ if:else <- :self trueblock :elseblock { elseblock: } } editFile <- :path { get: path :request { addClass: (q: "body") "editorMode" src <- request responseText console log: src ast <- parser parse: src console log: ast ast toHTML: (q: "#src") } } //editor code main <- { //bind handlers for file browser links each: (qall: "a") :idx el { el onclick!: :event { link <- foreign: this path <- link href path <- path substr: (path indexOf: "/edit/") + 5 console log: path editFile: path foreign: false } } //bind handlers for editor buttons each: (qall: ".controls li") :idx el { el onclick!: :event { srcel <- (q: "#src") srcel textContent!: (srcel textContent) + (el textContent) } } (q: "#ops_button") onclick!: :event { addClass: (q: ".controls") "showops" } (q: "#builtin_button") onclick!: :event { removeClass: (q: ".controls") "showops" } path <- (window location) pathname if: (path indexOf: "/edit/") = 0 { editFile: (path substr: 5) } else: {} } }