Commits

Tomoya Chiba  committed 4f7016e

URL setting

  • Participants
  • Parent commits 0aee2a2

Comments (0)

Files changed (3)

 
 # all environments
 app.set "port", process.env.PORT or 3000
+app.set "url", process.env.SERVER_URL or "http://localhost:3000"
 app.set "views", __dirname + "/views"
 app.set "view engine", "ejs"
 app.use express.favicon()
 app.use express.errorHandler()  if "development" is app.get("env")
 
 app.get "/", (req, res) ->
-  res.render "index"
+  res.render "index", {url: app.get("url")}
 
 server.listen app.get("port"), ->
   console.log "Express server listening on port " + app.get("port")

File client/reversi-client.coffee

 
-socketURL = "http://27.120.104.78:3000"
-
 ReversiRule =
   white : -1
   black : 1
     interfaceId = "##{@_interface.id}"
     $(interfaceId).off 'click'
 
-$ ->
+window.clientStandby = (socketURL) ->
+  socketURL = socketURL || "http://localhost:3000"
+
   socket = io.connect socketURL
   revClient = null
 

File views/index.ejs

     <script src="/javascripts/canvasquery.min.js"></script>
     <!--<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>-->
     <script src="/javascripts/reversi-client.js"></script>
+    <script>
+        $(function() {clientStandby("<%= url %>");});
+    </script>
     <title>Welcome</title>
   </head>
   <body>