Skip to content
Browse files

prototype2

  • Loading branch information...
1 parent 3173a1a commit 520ec351ec1ceb57907798be3297b17cdf911294 @motsat committed Jun 19, 2011
View
56 hoge.js
@@ -0,0 +1,56 @@
+// MongoDB
+// MongoDBサーバーの設定
+var mongoose = require('mongoose');
+var Schema = mongoose.Schema;
+
+// ModelのSchema Class定義する
+var CommentsSchema = new Schema({
+ title: String,
+ body: String,
+ date: Date
+});
+
+// ModelのSchema Class定義する
+var RoomSchema = new Schema({
+ title: String,
+ password: String,
+ body: String,
+ date: Date,
+ comments: [CommentsSchema], // 1対多を埋め込み型で定義できる
+ metadata: {
+ votes: Number,
+ favs: Number
+ }
+});
+
+mongoose.model('Room', RoomSchema); // モデル化。model('モデル名', '定義したスキーマクラス')
+mongoose.connect('mongodb://localhost/chatroom'); // mongodb://[hostname]/[dbname]
+
+var Room = mongoose.model('Room'); // 定義したときの登録名で呼び出し
+
+// インスタンス生成
+var room = new Room();
+room.title = 'test title';
+room.body = 'this is a pen';
+
+// 埋め込み型カラムはpush()を使う
+room.comments.push(
+ {title: 'comment title1',
+ body: 'comment body1',
+ password: 'your password'});
+
+// pre-hookを定義しているとsave時に定義した関数が走る
+room.save(function(err) {
+ if(!err) console.log('saved!')
+});
+//
+// データの取得
+Room.find({}, function(err, docs) {
+ docs.forEach(function(doc){
+ console.log(doc);
+ });
+});
+
+// Room.findOne({}, function(err, doc) {
+// console.log(doc);
+// });
View
BIN public/images/pencil.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN public/images/plus.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN public/images/trash.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
9 public/js/objectMediator.js
@@ -13,6 +13,15 @@ ObjectMediator.prototype.onObjectDragEnd = function(id, attr){
ObjectMediator.prototype.setUp = function() {
var collection = new ObjectCollection();
socket = new io.Socket('motoki.local',{port:8000}),
+ raphael = Raphael(document.getElementById('main_boad'), 500, 500);
+
+
+
+
+ return;
+
+ var collection = new ObjectCollection();
+ socket = new io.Socket('motoki.local',{port:8000}),
raphael = Raphael(document.getElementById('svg_campus'), 500, 500);
socket.connect();
View
51 views/index.ejs
@@ -15,24 +15,26 @@
<script type='text/javascript'>
var start_rect;
var v = {
- 'campus' :{'w':1000, 'h':500,'margin':{'w':30,'h':10}},
- 'pathL' :{'attr':{"stroke":"royalblue", "stroke-width":10}},
+ 'campus' :{'w':1000, 'h':250,'margin':{'w':30,'h':10}},
+ 'pathL' :{'attr':{"stroke":"royalblue", "stroke-width":10, opacity:0.5}},
'pathM' :{},
'rectStart':{'w':100, 'h':40,
- 'attr':{"stroke":"gray", "stroke-width":1, "fill-opacity":0, "gradient":'100-#FFFF93-#F5FF93'}},
+ 'attr':{"stroke":"gray", "stroke-width":1, "gradient":'100-#FFFF93-#D1DA93'}},
'circle' :{'r':7,
'attr':{"stroke":"darkblue", "stroke-width":2, "fill":'red'}},
'rectL' :{'w':100, 'h':40,
- 'attr':{"stroke":"white", "stroke-width":1, "fill-opacity":0, "gradient":'100-#40E0D0-#7FFFD4'}},
- 'rectM' :{'attr':{"stroke":"darkblue", "stroke-width":1, "fill-opacity":0, "gradient":'100-#40E0D0-#7FFFD4'}},
+ 'attr':{"stroke":"white", "stroke-width":1, "gradient":'100-#40E0D0-#7FFFD4'}},
+ 'rectM' :{'attr':{"stroke":"darkblue", "stroke-width":1, "gradient":'100-#40E0D0-#7FFFD4'}},
'rectEnd' :{'w':100, 'h':40,
- 'attr':{"stroke":"gray", "stroke-width":1, "fill-opacity":0, "gradient":'100-#FF82AB-#FFAEB9'}},
+ 'attr':{"stroke":"gray", "stroke-width":1, "gradient":'100-#FF82AB-#FFAEB9'}},
'rectMOn' :{'attr':{"stroke":"crimson" , "scale":1.5}},
'font_m' :{'attr':{"fill":"100-blue-darkblue", 'font-size':17, 'font-family':'MS UI Gothic'}},
+ 'icon' :{"w":20,"h":20},
'taskInterval':70,
- 'taskR' :10,
-}
+ 'taskR' :10};
+
$ (function() {
+
// mediator = new ObjectMediator();
// mediator.setUp();
@@ -52,26 +54,28 @@ $ (function() {
start_rect.click(function(ev) {log(this.attr())});
nextX += (v.rectStart.w + v.taskInterval);
- var obj = objects();
+ var objects = getObjects();
// tasks描画
- for (var i=0; i < obj.tasks.length; i++) {
+ for (var i=0; i < objects.tasks.length; i++) {
var rc = raphael.rect(x = nextX, y= v.campus.margin.h, w = v.rectL.w, h=v.rectL.h, v.taskR)
.attr($.extend(v.rectL.attr, {'scale':0.1}))
.animate({'scale':1}, 700, 'bounce');
- // rc.click(function(){log(this.getBBox())});
-
var circle = raphael.circle(x + v.circle.r, y = v.campus.margin.h + v.circle.r, v.circle.r)
.attr($.extend(v.circle.attr,{'scale':0.1}))
.animate({'scale':1}, 700, 'bounce');
// sets click handler on task's group
- var e = raphael.set()
- .push(rc)
- .push(circle);
- e.click(function(){log(e.attr({'stroke':'darkgray','fill':'gray'}))});
+ im = raphael.image('/images/pencil.gif', x = nextX, y = v.campus.margin.h, w = v.icon.w, h = v.icon.h)
+ .hide();
+ rc.mouseover(function(){im.show()});
+ rc.mouseout(function(){im.hide()});
+
+ im.mouseover(function(){im.show()});
+ im.mouseout(function(){im.hide()});
+ im.click(function(){log('click image')});
nextX += (v.rectL.w + v.taskInterval);
}
@@ -87,6 +91,7 @@ $ (function() {
.attr($.extend(v.pathL.attr,{'scale':0.1}))
.animate({'scale':1}, 800)
.toBack();
+ log(a);
});
function log(msg)
@@ -95,7 +100,7 @@ function log(msg)
console.log(msg);
}
}
-function objects(){
+function getObjects(){
return {
'title' :'このアプリ完成まで',
'tasks' : [
@@ -105,16 +110,20 @@ function objects(){
'tasks':[{'title':'中項目1'},{'title':'中項目2'}]},
{'title':'大項目3',
'tasks':[{'title':'中項目3'},{'title':'中項目4'}]},
- ],
+ ]
};
}
</script>
</head>
-<h2></h2>
+<body>
+<h2>Gridder</h2>
+
+<img width='20' height='20' src='/images/pencil.gif'/>
+<img width='20' height='20' src='/images/plus.png'/>
+<img width='20' height='20' src='/images/trash.jpg'/>
+
<hr/>
<div class='campus' id='main_boad'>
</div>
-<body>
-
</body>

0 comments on commit 520ec35

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