comparison src/monoize.sml @ 899:25a038a9194b

dtable example and demos both working
author Adam Chlipala <adamc@hcoop.net>
date Thu, 06 Aug 2009 11:54:28 -0400
parents ae9e22822ec5
children f17638dd3080
comparison
equal deleted inserted replaced
898:d1d0b18afd3d 899:25a038a9194b
2644 end 2644 end
2645 2645
2646 | "dyn" => 2646 | "dyn" =>
2647 (case attrs of 2647 (case attrs of
2648 [("Signal", e, _)] => 2648 [("Signal", e, _)] =>
2649 let 2649 ((L'.EStrcat
2650 val inTable = case targs of 2650 ((L'.EPrim (Prim.String ("<script type=\"text/javascript\">dyn(")), loc),
2651 (L.CRecord (_, ctx), _) :: _ => 2651 (L'.EStrcat ((L'.EJavaScript (L'.Script, e), loc),
2652 List.exists (fn ((L.CName "Table", _), _) => true 2652 (L'.EPrim (Prim.String (")</script>")), loc)), loc)), loc),
2653 | _ => false) ctx 2653 fm)
2654 | _ => false
2655
2656 val tag = if inTable then
2657 "tbody"
2658 else
2659 "span"
2660 in
2661 ((L'.EStrcat
2662 ((L'.EPrim (Prim.String ("<" ^ tag ^ "><script type=\"text/javascript\">dyn(")), loc),
2663 (L'.EStrcat ((L'.EJavaScript (L'.Script, e), loc),
2664 (L'.EPrim (Prim.String (")</script></" ^ tag ^ ">")), loc)), loc)), loc),
2665 fm)
2666 end
2667 | _ => raise Fail "Monoize: Bad dyn attributes") 2654 | _ => raise Fail "Monoize: Bad dyn attributes")
2668 2655
2669 | "submit" => normal ("input type=\"submit\"", NONE, NONE) 2656 | "submit" => normal ("input type=\"submit\"", NONE, NONE)
2670 | "button" => normal ("input type=\"submit\"", NONE, NONE) 2657 | "button" => normal ("input type=\"submit\"", NONE, NONE)
2671 | "hidden" => input "hidden" 2658 | "hidden" => input "hidden"
2681 ((L'.EStrcat (ts, 2668 ((L'.EStrcat (ts,
2682 (L'.EPrim (Prim.String (" name=\"" ^ name ^ "\" />")), 2669 (L'.EPrim (Prim.String (" name=\"" ^ name ^ "\" />")),
2683 loc)), loc), fm) 2670 loc)), loc), fm)
2684 end 2671 end
2685 | SOME (_, src, _) => 2672 | SOME (_, src, _) =>
2686 (strcat [str "<span><script type=\"text/javascript\">inp(", 2673 (strcat [str "<script type=\"text/javascript\">inp(",
2687 (L'.EJavaScript (L'.Script, src), loc), 2674 (L'.EJavaScript (L'.Script, src), loc),
2688 str ")</script></span>"], 2675 str ")</script>"],
2689 fm)) 2676 fm))
2690 | _ => (Print.prefaces "Targs" (map (fn t => ("T", CorePrint.p_con env t)) targs); 2677 | _ => (Print.prefaces "Targs" (map (fn t => ("T", CorePrint.p_con env t)) targs);
2691 raise Fail "No name passed to textbox tag")) 2678 raise Fail "No name passed to textbox tag"))
2692 | "password" => input "password" 2679 | "password" => input "password"
2693 | "textarea" => 2680 | "textarea" =>
2758 val sc = strcat [str "inp(", 2745 val sc = strcat [str "inp(",
2759 (L'.EJavaScript (L'.Script, src), loc), 2746 (L'.EJavaScript (L'.Script, src), loc),
2760 str ")"] 2747 str ")"]
2761 val sc = setAttrs sc 2748 val sc = setAttrs sc
2762 in 2749 in
2763 (strcat [str "<span><script type=\"text/javascript\">", 2750 (strcat [str "<script type=\"text/javascript\">",
2764 sc, 2751 sc,
2765 str "</script></span>"], 2752 str "</script>"],
2766 fm) 2753 fm)
2767 end) 2754 end)
2768 2755
2769 | "ccheckbox" => 2756 | "ccheckbox" =>
2770 (case List.find (fn ("Source", _, _) => true | _ => false) attrs of 2757 (case List.find (fn ("Source", _, _) => true | _ => false) attrs of
2781 val sc = strcat [str "chk(", 2768 val sc = strcat [str "chk(",
2782 (L'.EJavaScript (L'.Script, src), loc), 2769 (L'.EJavaScript (L'.Script, src), loc),
2783 str ")"] 2770 str ")"]
2784 val sc = setAttrs sc 2771 val sc = setAttrs sc
2785 in 2772 in
2786 (strcat [str "<span><script type=\"text/javascript\">", 2773 (strcat [str "<script type=\"text/javascript\">",
2787 sc, 2774 sc,
2788 str "</script></span>"], 2775 str "</script>"],
2789 fm) 2776 fm)
2790 end) 2777 end)
2791 2778
2792 | "cselect" => 2779 | "cselect" =>
2793 (case List.find (fn ("Source", _, _) => true | _ => false) attrs of 2780 (case List.find (fn ("Source", _, _) => true | _ => false) attrs of
2811 str ",", 2798 str ",",
2812 (L'.EJavaScript (L'.Script, xml), loc), 2799 (L'.EJavaScript (L'.Script, xml), loc),
2813 str ")"] 2800 str ")"]
2814 val sc = setAttrs sc 2801 val sc = setAttrs sc
2815 in 2802 in
2816 (strcat [str "<span><script type=\"text/javascript\">", 2803 (strcat [str "<script type=\"text/javascript\">",
2817 sc, 2804 sc,
2818 str "</script></span>"], 2805 str "</script>"],
2819 fm) 2806 fm)
2820 end) 2807 end)
2821 2808
2822 | "coption" => normal ("option", NONE, NONE) 2809 | "coption" => normal ("option", NONE, NONE)
2823 2810