Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updates to start page and templates.

  • Loading branch information...
commit 1e7e32c34013e8f2081257bf2077a5306c44778a 1 parent d16ba2a
@russelldb authored
Showing with 60 additions and 12 deletions.
  1. +49 −9 priv/www/index.html
  2. +11 −3 src/templates.erl
View
58 priv/www/index.html
@@ -1,18 +1,58 @@
<html>
<head>
<title>Work</title>
-<link type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.0/themes/cupertino/jquery-ui.css" rel="Stylesheet" />
+<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/dojo/1.4.1/dijit/themes/tundra/tundra.css">
<script type="text/javascript"
-src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
-<script type="text/javascript"
-src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.0/jquery-ui.min.js"></script>
+src="http://ajax.googleapis.com/ajax/libs/dojo/1.4.1/dojo/dojo.xd.js"></script>
+
<script>
-$(function() {
- $("#date").datepicker();
-});
+dojo.require("dijit.form.FilteringSelect");
+dojo.require("dojo.data.ItemFileReadStore");
+dojo.require("dijit.form.Button");
+function getClients() {
+ var xhrArgs = {
+ url:"/template",
+ headers: { "Accept": "application/json"},
+ handleAs: "json",
+ load: function(data){
+ var clientStore = new dojo.data.ItemFileReadStore({
+ data: data
+ });
+
+ var filteringSelect = new dijit.form.FilteringSelect({
+ id: "clients",
+ name: "client",
+ value: "CPP",
+ store: clientStore,
+ searchAttr: "name"
+ },
+ "clients");
+ var button = new dijit.form.Button({label: "hello world",
+ onClick: function(e) {alert(dijit.byId('clients').attr('value'))} }, "clicker");
+ }
+ };
+
+ var deffered = dojo.xhrGet(xhrArgs);
+}
+
+
+
+dojo.addOnLoad(getClients);
+
</script>
</head>
-<body>
-<input type="text" name="date" id="date" />
+<body class="tundra">
+<h1>Work work work</h1>
+<h2>Add work</h2>
+
+<label for="clients">Select Client</label>
+<input id="clients">
+<button id="clicker" />
+<button id="1465" dojoType="dijit.form.Button"
+ onClick='alert("clicked simple")'
+ iconClass="plusIcon">
+ Click Me!
+</button>
+
</body>
</html>
View
14 src/templates.erl
@@ -3,7 +3,7 @@
%% @doc Template resource
-module(templates).
--export([init/1, to_html/2, allowed_methods/2, content_types_accepted/2, templates/1]).
+-export([init/1, to_html/2, allowed_methods/2, content_types_provided/2, templates/1, to_json/2, get_json/1]).
-include_lib("webmachine/include/webmachine.hrl").
-include_lib("time/include/time.hrl").
@@ -17,10 +17,18 @@ to_html(ReqData, Context) ->
allowed_methods(ReqData, Context) ->
{['GET'], ReqData, Context}.
-content_types_accepted(ReqData, Context) ->
- {[{"text/html", to_html}], ReqData, Context}.
+content_types_provided(ReqData, Context) ->
+ {[{"text/html", to_html}, {"application/json", to_json}], ReqData, Context}.
+
+to_json(ReqData, Context) ->
+ L = time:list_templates(),
+ Ting = get_json( L),
+ {mochijson2:encode(Ting), ReqData, Context}.
%%View method called by mustache
templates(_Ctx) ->
L = time:list_templates(),
[dict:from_list([{template, binary_to_list(Template)}]) || Template <- L].
+
+get_json(L) ->
+ {struct, [{identifier, <<"id">>}, {label, <<"name">>}, {items, [{struct, [{id, T}, {name, T}]} || T <- L ]}]}.
Please sign in to comment.
Something went wrong with that request. Please try again.