Permalink
Browse files

Merge branch 'master' of github.com:spockz/JCU

Conflicts:
	resources/static/hjs/jcu.hs
  • Loading branch information...
2 parents fd8d56b + c94d627 commit 9b8388a53b7921ee6b4ed43c2e84ac03b2a63a74 @spockz spockz committed Dec 31, 2011
Showing with 24 additions and 6 deletions.
  1. +3 −0 resources/static/hjs/Models.hs
  2. +1 −0 resources/static/hjs/Templates.hs
  3. +20 −6 resources/static/hjs/jcu.hs
@@ -35,6 +35,9 @@ jsRule2Rule ptr = Rule {
proofTreeNode = Node "" "" [] ""
+foreign import jscript "%1.rule"
+ getRule :: JSRule -> JSString
+
-- class exports.ProofTreeNode extends Backbone.Model
-- # Available attributes:
-- # term :: String
@@ -5,6 +5,7 @@ home = "<div class=\"yui3-g\"> <div class=\"yui3-u-1-2\"> <div class=\"conte
proof_tree_item term treeLbl disabled =
"<div class=\"tree_item dropzone\"> " ++ treeLbl ++ ". <input type=\"text\" id=\"proof_" ++ treeLbl ++ "\" " ++ if disabled then " disabled=\"disabled\"" else "" ++ " class=\"droppable\" value=\"" ++ term ++ "\" /></div>"
+rules_list_item :: String -> String
rules_list_item rule =
let rule_replaced = rule -- replace /[^a-zA-Z0-9]+/g, ""
in "<div id=\"rule_" ++ rule_replaced ++ "\" class=\"draggable rule-list-item ui-widget-content\"> <span class=\"rule-text\">"++ rule ++ "</span> <span class=\"buttons\"><button class=\"btnDeleteList\" type=\"button\" value=\"X\" /></span</div>"
@@ -7,7 +7,7 @@ import Data.List
-import Language.UHC.JScript.Types (JS, toJS, fromJS)
+import Language.UHC.JScript.Types -- (JS, toJS, fromJS, FromJS)
import Language.UHC.JScript.Primitives
import Language.UHC.JScript.JQuery.JQuery
import Language.UHC.JScript.W3C.HTML5 as HTML5
@@ -28,6 +28,22 @@ import Array
import Templates
import Models
+
+foreign import jscript "typeof(%1)"
+ typeof :: a -> JSString
+
+class FromJS a b => FromJSPlus a b where
+ check :: a -> b -> String -> Bool
+--
+--
+--
+-- fromJSP :: (FromJSPlus a b) => a -> Maybe b
+-- fromJSP i | chck = Just ji
+-- | otherwise = Nothing
+-- where ji = (fromJS :: a -> b) i
+-- chck = True -- check i ji ((fromJS :: JSString -> String) $ typeof i)
+-- -- debug trace
+
ajaxQ :: JS r => String -> AjaxCallback r -> AjaxCallback r -> IO ()
ajaxQ url onSuccess onFail = do
AQ.ajaxQ "jcu_app"
@@ -82,8 +98,9 @@ addRules :: AjaxCallback (JSArray JSRule)
addRules obj str obj2 = do -- slet rules = (Data.List.map fromJS . elems . jsArrayToArray) obj
f <- mkEachIterator (\ idx e -> do let ruleElem = jsRule2Rule e
alertType (rule ruleElem)
+ alertType (getRule e)
+ alert (jsStringToString $ getRule e)
alert (jsStringToString $ rule ruleElem)
-
return ())
alert "rules!"
@@ -101,9 +118,6 @@ foreign import jscript "wrapper"
foreign import jscript "wrapper"
ioWrap :: IO () -> IO (JSFunPtr (IO ()))
-
-foreign import jscript "typeof(%1)"
- typeof :: a -> JSString
alertType :: a -> IO ()
-alertType = _alert . typeof
+alertType = _alert . typeof

0 comments on commit 9b8388a

Please sign in to comment.