Maxim Sokhatsky 11 лет назад
Родитель
Сommit
67d46cf063
4 измененных файлов с 9 добавлено и 72 удалено
  1. 9 40
      apps/face/src/index.erl
  2. 0 25
      apps/face/src/login.erl
  3. 0 6
      apps/face/src/n2o_game.erl
  4. 0 1
      apps/face/src/routes.erl

+ 9 - 40
apps/face/src/index.erl

@@ -7,14 +7,15 @@
 -jsmacro([take/2]).
 
 take(GameId,Place) ->
-    ws:send(bert:encodebuf(bert:tuple(bert:atom('client'),
-        bert:tuple(bert:atom("game_action"),GameId,bert:atom("okey_take"),[{pile,Place}])))).
+    ws:send(bert:encodebuf(bert:tuple(
+        bert:atom('client'),
+        bert:tuple(
+            bert:atom("game_action"),
+            GameId,
+            bert:atom("okey_take"),
+            [{pile,Place}])))).
 
-main() -> 
-    case wf:user() of
-         undefined -> wf:redirect("/login"), #dtl{file="index",app=n2o_sample,bindings=[{title,""},{body,""}]};
-         _ -> #dtl{file = "index", app=n2o_sample,bindings=[{title,<<"N2O">>},{body,body()}]}
-     end.
+main() -> #dtl{file="index", bindings=[{title,<<"N2O">>},{body,body()}]}.
 
 body() ->
     [ #panel{ id=history },
@@ -44,39 +45,7 @@ event(join) ->
     Msg = "ws.send(Bert.encodebuf(Bert.tuple(Bert.atom('client'), Bert.tuple(Bert.atom('join_game'), 1000001))));",
     wf:wire(Msg);
 
-
-
-
-%%-record(game_action, {
-%%          game      :: 'GameId'(),
-%%          action    :: string(),
-%%          args = [] :: proplist()
-%%         }).
-
-%%-record(okey_take, {
-%%          pile :: integer() %% 0 or 1
-%%         }).
-
-
-
-event(take) ->
-    Msg = "ws.send(Bert.encodebuf(Bert.tuple(Bert.atom('client'),"
-        " Bert.tuple(Bert.atom('game_action'), 1000001, Bert.atom('okey_take'), {pile: 0} ) )));",
-    wf:wire(take("1000001","0"));
-
-%%-record('OkeyPiece', {
-%%          color = -1 :: integer(),           %% 1..4
-%%          value = -1 :: integer()            %% 1..13
-%%          %% color set to 1 and value set to zero mean that this is false okey
-%%         }).
-
-
-%%-record(okey_discard, {
-%%          tile :: #'OkeyPiece'{}
-%%         }).
-
-
-
+event(take) -> wf:wire(take("1000001","0"));
 
 event(Event) -> wf:info("Event: ~p", [Event]).
 

+ 0 - 25
apps/face/src/login.erl

@@ -1,25 +0,0 @@
--module(login).
--compile(export_all).
--include_lib("n2o/include/wf.hrl").
-
-title() -> [ <<"Login">> ].
-main() -> #dtl{file = "login", app=n2o_sample,bindings=[{title,title()},{body,body()}]}.
-
-body() ->
- [ #span{id=display}, #br{},
-            #span{body="Login: "}, #textbox{id=user}, #br{},
-            #span{body="Password: "}, #password{id=pass},
-            #button{id=login,body="Login",postback=login,source=[user,pass]} ].
-%    react:x().
-
-event(init) -> [];
-event(login) ->
-    User = wf:q(user),
-    wf:update(display,User),
-    wf:user(User),
-    <<"/ws/",X/binary>> = wf:path(?REQ),
-    case X of
-        <<>> -> wf:redirect("/index");
-        <<"login">> -> wf:redirect("/index");
-         _ -> wf:redirect("/static/spa/index.htm") end;
-event(_) -> [].

+ 0 - 6
apps/face/src/n2o_game.erl

@@ -23,12 +23,6 @@ init(_Transport, Req, _Opts, _Active) ->
     Req1 = wf:header(<<"Access-Control-Allow-Origin">>, <<"*">>, NewCtx#context.req),
     {ok, Req1, NewCtx}.
 
-%% {'KamfMessage',23,game_event,[{game,undefined},{event,okey_tile_taken},{args,[{player,<<"dusler">>},{pile,0},{revealed,null},{pile_height,43}]}]}
-
-is_proplist([]) -> true;
-is_proplist([{K,_}|L]) when is_atom(K) -> is_proplist(L);
-is_proplist(_) -> false.
-
 stream(<<"ping">>, Req, State) ->
     wf:info("ping received~n"),
     {reply, <<"pong">>, Req, State};

+ 0 - 1
apps/face/src/routes.erl

@@ -15,6 +15,5 @@ route_prefix(P) -> route(P).
 
 route(<<>>)              -> index;
 route(<<"index">>)       -> index;
-route(<<"login">>)       -> login;
 route(<<"favicon.ico">>) -> static_file;
 route(_) -> index.