<commit_before>{-# LANGUAGE NoImplicitPrelude #-}

import Prelude
import FFI

-- TODO copy-pasted from Event.hs for now...
-- still problems: date and string/text
data Event = Event
	{
		pluginName :: String,
		eventDate :: String,
		desc :: String,
		extraInfo :: String, 
		fullContents :: String -- removed the Maybe
	}

main :: Fay ()
main = --ready $ do
		ajax "/timesheet/2013-07-01" processResults

processResults :: [Event] -> Fay ()
processResults events = do
		mapM_ processResult events
		nodes "#pleasehold" >>= hide
		return ()
	where
		eventsTable = nodes "table#eventsTable"
		processResult event = eventsTable >>= (append $ makeEventRow event)

makeEventRow :: Event -> String
makeEventRow event = makeTableRow $ map ($ event)
			[formatTime . eventDate, pluginName, desc, extraInfo]

makeTableRow :: [String] -> String
makeTableRow cols = "<tr><td>" ++ intercalate "</td><td>" cols ++ "</td></tr>"

data JQuery

formatTime :: String -> String
formatTime = ffi "formatTime(%1)"

ajax :: String -> (Automatic b -> Fay ()) -> Fay ()
ajax = ffi "jQuery.ajax(%1, {'type': 'GET', contentType: 'text/json', processData: false, 'success' : %2 })"

nodes :: String -> Fay JQuery
nodes = ffi "jQuery(%1)"

append :: String -> JQuery -> Fay JQuery
append = ffi "%2.append(%1)"

hide :: JQuery -> Fay JQuery
hide = ffi "%1.hide()"<commit_msg>use fay jquery lib, little improvements<commit_after>{-# LANGUAGE NoImplicitPrelude #-}

import Prelude
import FFI
import JQuery

-- TODO copy-pasted from Main.Event.hs for now...
-- still problems: date and string/text
data Event = Event
	{
		pluginName :: String,
		eventDate :: String,
		desc :: String,
		extraInfo :: String, 
		fullContents :: String -- removed the Maybe
	}

main :: Fay ()
main = --ready $ do
		myajax "/timesheet/2013-07-01" processResults

processResults :: [Main.Event] -> Fay ()
processResults events = do
		mapM_ addEventRow events
		select "#pleasehold" >>= hide Instantly
		return ()

addEventRow :: Main.Event -> Fay JQuery
addEventRow event = select "table#eventsTable" >>=
	(appendStr $ makeEventRow event) -- >>=
--	onClick (\x -> do
--		putStrLn $ "click"
--		return False
--	)

makeEventRow :: Main.Event -> String
makeEventRow event = makeTableRow $ map ($ event)
			[formatTime . eventDate, pluginName, desc, extraInfo]

makeTableRow :: [String] -> String
makeTableRow cols = "<tr><td>" ++ intercalate "</td><td>" cols ++ "</td></tr>"

formatTime :: String -> String
formatTime = ffi "formatTime(%1)"

myajax :: String -> (Automatic b -> Fay ()) -> Fay ()
myajax = ffi "jQuery.ajax(%1, {'type': 'GET', contentType: 'text/json', processData: false, 'success' : %2 })"

appendStr :: String -> JQuery -> Fay JQuery
appendStr = ffi "%2.append(%1)"
{'fraction_non_alphanumeric': 0.1598240469208211, 'fraction_numerical': 0.010263929618768328, 'mean_word_length': 3.864527629233512, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1024936', 'n_tokens_mistral': 935, 'n_tokens_neox': 894, 'n_words': 269}