Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

prototype2

  • Loading branch information...
commit 520ec351ec1ceb57907798be3297b17cdf911294 1 parent 3173a1a
motsat authored
56 hoge.js
... ... @@ -0,0 +1,56 @@
  1 +// MongoDB
  2 +// MongoDBサーバーの設定
  3 +var mongoose = require('mongoose');
  4 +var Schema = mongoose.Schema;
  5 +
  6 +// ModelのSchema Class定義する
  7 +var CommentsSchema = new Schema({
  8 + title: String,
  9 + body: String,
  10 + date: Date
  11 +});
  12 +
  13 +// ModelのSchema Class定義する
  14 +var RoomSchema = new Schema({
  15 + title: String,
  16 + password: String,
  17 + body: String,
  18 + date: Date,
  19 + comments: [CommentsSchema], // 1対多を埋め込み型で定義できる
  20 + metadata: {
  21 + votes: Number,
  22 + favs: Number
  23 + }
  24 +});
  25 +
  26 +mongoose.model('Room', RoomSchema); // モデル化。model('モデル名', '定義したスキーマクラス')
  27 +mongoose.connect('mongodb://localhost/chatroom'); // mongodb://[hostname]/[dbname]
  28 +
  29 +var Room = mongoose.model('Room'); // 定義したときの登録名で呼び出し
  30 +
  31 +// インスタンス生成
  32 +var room = new Room();
  33 +room.title = 'test title';
  34 +room.body = 'this is a pen';
  35 +
  36 +// 埋め込み型カラムはpush()を使う
  37 +room.comments.push(
  38 + {title: 'comment title1',
  39 + body: 'comment body1',
  40 + password: 'your password'});
  41 +
  42 +// pre-hookを定義しているとsave時に定義した関数が走る
  43 +room.save(function(err) {
  44 + if(!err) console.log('saved!')
  45 +});
  46 +//
  47 +// データの取得
  48 +Room.find({}, function(err, docs) {
  49 + docs.forEach(function(doc){
  50 + console.log(doc);
  51 + });
  52 +});
  53 +
  54 +// Room.findOne({}, function(err, doc) {
  55 +// console.log(doc);
  56 +// });
BIN  public/images/pencil.gif
BIN  public/images/plus.png
BIN  public/images/trash.jpg
9 public/js/objectMediator.js
@@ -13,6 +13,15 @@ ObjectMediator.prototype.onObjectDragEnd = function(id, attr){
13 13 ObjectMediator.prototype.setUp = function() {
14 14 var collection = new ObjectCollection();
15 15 socket = new io.Socket('motoki.local',{port:8000}),
  16 + raphael = Raphael(document.getElementById('main_boad'), 500, 500);
  17 +
  18 +
  19 +
  20 +
  21 + return;
  22 +
  23 + var collection = new ObjectCollection();
  24 + socket = new io.Socket('motoki.local',{port:8000}),
16 25 raphael = Raphael(document.getElementById('svg_campus'), 500, 500);
17 26
18 27 socket.connect();
51 views/index.ejs
@@ -15,24 +15,26 @@
15 15 <script type='text/javascript'>
16 16 var start_rect;
17 17 var v = {
18   - 'campus' :{'w':1000, 'h':500,'margin':{'w':30,'h':10}},
19   - 'pathL' :{'attr':{"stroke":"royalblue", "stroke-width":10}},
  18 + 'campus' :{'w':1000, 'h':250,'margin':{'w':30,'h':10}},
  19 + 'pathL' :{'attr':{"stroke":"royalblue", "stroke-width":10, opacity:0.5}},
20 20 'pathM' :{},
21 21 'rectStart':{'w':100, 'h':40,
22   - 'attr':{"stroke":"gray", "stroke-width":1, "fill-opacity":0, "gradient":'100-#FFFF93-#F5FF93'}},
  22 + 'attr':{"stroke":"gray", "stroke-width":1, "gradient":'100-#FFFF93-#D1DA93'}},
23 23 'circle' :{'r':7,
24 24 'attr':{"stroke":"darkblue", "stroke-width":2, "fill":'red'}},
25 25 'rectL' :{'w':100, 'h':40,
26   - 'attr':{"stroke":"white", "stroke-width":1, "fill-opacity":0, "gradient":'100-#40E0D0-#7FFFD4'}},
27   - 'rectM' :{'attr':{"stroke":"darkblue", "stroke-width":1, "fill-opacity":0, "gradient":'100-#40E0D0-#7FFFD4'}},
  26 + 'attr':{"stroke":"white", "stroke-width":1, "gradient":'100-#40E0D0-#7FFFD4'}},
  27 + 'rectM' :{'attr':{"stroke":"darkblue", "stroke-width":1, "gradient":'100-#40E0D0-#7FFFD4'}},
28 28 'rectEnd' :{'w':100, 'h':40,
29   - 'attr':{"stroke":"gray", "stroke-width":1, "fill-opacity":0, "gradient":'100-#FF82AB-#FFAEB9'}},
  29 + 'attr':{"stroke":"gray", "stroke-width":1, "gradient":'100-#FF82AB-#FFAEB9'}},
30 30 'rectMOn' :{'attr':{"stroke":"crimson" , "scale":1.5}},
31 31 'font_m' :{'attr':{"fill":"100-blue-darkblue", 'font-size':17, 'font-family':'MS UI Gothic'}},
  32 + 'icon' :{"w":20,"h":20},
32 33 'taskInterval':70,
33   - 'taskR' :10,
34   -}
  34 + 'taskR' :10};
  35 +
35 36 $ (function() {
  37 +
36 38 // mediator = new ObjectMediator();
37 39 // mediator.setUp();
38 40
@@ -52,26 +54,28 @@ $ (function() {
52 54 start_rect.click(function(ev) {log(this.attr())});
53 55
54 56 nextX += (v.rectStart.w + v.taskInterval);
55   - var obj = objects();
56 57
  58 + var objects = getObjects();
57 59 // tasks描画
58   - for (var i=0; i < obj.tasks.length; i++) {
  60 + for (var i=0; i < objects.tasks.length; i++) {
59 61
60 62 var rc = raphael.rect(x = nextX, y= v.campus.margin.h, w = v.rectL.w, h=v.rectL.h, v.taskR)
61 63 .attr($.extend(v.rectL.attr, {'scale':0.1}))
62 64 .animate({'scale':1}, 700, 'bounce');
63 65
64   - // rc.click(function(){log(this.getBBox())});
65   -
66 66 var circle = raphael.circle(x + v.circle.r, y = v.campus.margin.h + v.circle.r, v.circle.r)
67 67 .attr($.extend(v.circle.attr,{'scale':0.1}))
68 68 .animate({'scale':1}, 700, 'bounce');
69 69
70 70 // sets click handler on task's group
71   - var e = raphael.set()
72   - .push(rc)
73   - .push(circle);
74   - e.click(function(){log(e.attr({'stroke':'darkgray','fill':'gray'}))});
  71 + im = raphael.image('/images/pencil.gif', x = nextX, y = v.campus.margin.h, w = v.icon.w, h = v.icon.h)
  72 + .hide();
  73 + rc.mouseover(function(){im.show()});
  74 + rc.mouseout(function(){im.hide()});
  75 +
  76 + im.mouseover(function(){im.show()});
  77 + im.mouseout(function(){im.hide()});
  78 + im.click(function(){log('click image')});
75 79
76 80 nextX += (v.rectL.w + v.taskInterval);
77 81 }
@@ -87,6 +91,7 @@ $ (function() {
87 91 .attr($.extend(v.pathL.attr,{'scale':0.1}))
88 92 .animate({'scale':1}, 800)
89 93 .toBack();
  94 + log(a);
90 95 });
91 96
92 97 function log(msg)
@@ -95,7 +100,7 @@ function log(msg)
95 100 console.log(msg);
96 101 }
97 102 }
98   -function objects(){
  103 +function getObjects(){
99 104 return {
100 105 'title' :'このアプリ完成まで',
101 106 'tasks' : [
@@ -105,16 +110,20 @@ function objects(){
105 110 'tasks':[{'title':'中項目1'},{'title':'中項目2'}]},
106 111 {'title':'大項目3',
107 112 'tasks':[{'title':'中項目3'},{'title':'中項目4'}]},
108   - ],
  113 + ]
109 114 };
110 115 }
111 116 </script>
112 117 </head>
113   -<h2></h2>
  118 +<body>
  119 +<h2>Gridder</h2>
  120 +
  121 +<img width='20' height='20' src='/images/pencil.gif'/>
  122 +<img width='20' height='20' src='/images/plus.png'/>
  123 +<img width='20' height='20' src='/images/trash.jpg'/>
  124 +
114 125 <hr/>
115 126 <div class='campus' id='main_boad'>
116 127 </div>
117   -<body>
118   -
119 128
120 129 </body>

0 comments on commit 520ec35

Please sign in to comment.
Something went wrong with that request. Please try again.