Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions OGV/client/lib/OrbitControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ THREE.OrbitControls = function ( object, domElement ) {
this.zoomSpeed = 1.0;

// Limits to how far you can dolly in and out
this.minDistance = 0;
this.maxDistance = Infinity;
this.minDistance = 20;
this.maxDistance = 10000;

// Set to true to disable this control
this.noRotate = false;
Expand Down Expand Up @@ -257,7 +257,7 @@ THREE.OrbitControls = function ( object, domElement ) {
// restrict phi to be between desired limits
phi = Math.max( this.minPolarAngle, Math.min( this.maxPolarAngle, phi ) );

// restrict phi to be betwee EPS and PI-EPS
// restrict phi to be between EPS and PI-EPS
phi = Math.max( EPS, Math.min( Math.PI - EPS, phi ) );

var radius = offset.length() * scale;
Expand Down
106 changes: 83 additions & 23 deletions OGV/client/views/model_meta.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* M O D E L _ M E T A . J S
/** M O D E L _ M E T A . J S
* BRL-CAD
*
* Copyright (c) 1995-2013 United States Government as represented by
Expand Down Expand Up @@ -36,32 +36,92 @@ Template.modelMeta.events({
'submit #uploader-form': function(e, t)
{
e.preventDefault();

a = e;
var modelMetaForm = $(e.currentTarget),
filename = modelMetaForm.find('#desc-filename').val().toLowerCase(),
description = modelMetaForm.find('#desc-about').val(),
thumbnail,
modelId = modelMetaForm.find('#model-id').val();
modelId = modelMetaForm.find('#model-id').val(),
audience = modelMetaForm.find('#desc-audience').val(),
currentUser = Meteor.user();

file = $('#desc-model-thumb')

var fsFile = new FS.File(e.target[2].files[0]);
fsFile.gFile = modelId;

ThumbFiles.insert(fsFile,function(err,thumbFile) {
if (err) {
throwError(err.reason);
/**
* Adding the checked boxes to an array named category
*/
var category = Array();
$("input:checkbox[name=category]:checked").each(function(){
category.push($(this).val());
});

var currentModel = ModelFiles.findOne(modelId);

ModelFiles.update(modelId, {$set: {name: filename, about: description, audience: audience}}, function(error, res) {
if (error) {
sAlert.error(error.reason);
} else {
throwNotification("Image has been Uploaded" );
ModelFiles.update(modelId, {$set: {name: filename, about: description, thumbnail:thumbFile._id}}, function(error, res) {
if (error) {
throwError(error.reason);
} else {
throwNotification("Data about model has been saved");
}
});

sAlert.success("Data about model has been saved");
}
});
}
});
Posts.insert({
postType: "posted",
postedAt: currentModel.timeUploaded,
postId: modelId,
postedBy: currentUser._id,
audience: audience
});
if(category.length > 0){
ModelFiles.update(modelId, {$set: {categories: category}}, function(error, res) {
if (error) {
sAlert.error(error.reason);
} else {
sAlert.success("Data about model has been saved");
}
});
}
/*cPercent = Meteor.call('convertPercent');
console.log("######");
console.log(cPercent);
console.log("######");*/

var uploadedModel = ModelFiles.findOne(modelId);
if( uploadedModel.converted ){
Router.go('/models/'+uploadedModel._id);
sAlert.success("Data about model has been saved");
} else {
ModelFiles.remove(uploadedModel._id);
Router.go('/upload');
sAlert.success("There was some error in converting your uploaded file");
}



}
});

Template.modelMeta.helpers({
'progressValue': function(){
var id = $('#model-id').val(),
modelObj = ModelFiles.findOne({_id: id});
var value = modelObj.conversion;
value = parseInt(value, 10);
if(value == null) value = 0;
if(value >= 70) {
$('progress[value]').css('display', 'none');
$('.progress-label').css('display', 'none');
$('#save-btn').css('display', 'block');
return value;
} else {
return value;
}
}
});

/**
* helper to display already present categories in the model
* Displayed every time when the /description/:_id page is viewed
* Displays nothing if categories is empty.
*/
Template.modelMeta.modelCategory = function()
{
var id = Session.get('modelId');
return ModelFiles.findOne({_id: id});
};
38 changes: 29 additions & 9 deletions OGV/client/views/social.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* Comments and its backend implementation
*/
Template.comment.helpers({
submittedText: function() {
return new Date(this.submitted).toString();
Expand All @@ -9,26 +12,35 @@ Template.commentSubmit.events({
'submit form': function(e, template) {
e.preventDefault();
var $body = $(e.target).find('[name=body]');
if(this.converted){
postId = this._id;
} else {
postId = this.postId;
}
var comment = {
body: $body.val(),
postId: this._id
postId: postId
};

Meteor.call('comment', comment, function(error, commentId) {
if (error){
throwError(error.reason);
sAlert.error(error.reason);
} else {
$body.val('');
var commentOnModel = Comments.findOne(commentId);
ModelFiles.update(commentOnModel.postId, {$inc: {commentsCount: 1}});
}

});

}
});


Template.commentBody.helpers({
comments: function()
{
var commentList = Comments.find({postId:this._id});
var commentList = Comments.find({postId:this.postId});
if (!commentList) commentList = Comments.find({postId:this.data._id});
return commentList
}
Expand All @@ -50,23 +62,31 @@ Template.comments.events({
}
});



/**
* Likes and its backend implementation
*/
Template.lovemeter.events({
'click .lovemeter-wrapper':function(){
var love = {
postId: this._id
postId: this.postId
};
Meteor.call('love', love, function(error, loveId) {
Meteor.call('love', love, function(error, loveId) {
if (error){
throwError(error.reason);
sAlert.error(error.reason);
}
});
});
}
});

Template.lovemeter.helpers({
lovers: function(){
loversObj = Lovers.findOne({postId: this._id});
if(this.postId){
id = this.postId;
} else {
id = this._id;
}
loversObj = Lovers.findOne({postId: id});
if(loversObj){
loversArray = loversObj.lovers;
return loversArray.length;
Expand Down
Loading