Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodeacross.js
More file actions
Latest commit
136 lines (112 loc) · 3.48 KB
/
Copy pathcodeacross.js
File metadata and controls
136 lines (112 loc) · 3.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
Events=newMongo.Collection('events');
Accounts.config({
forbidClientAccountCreation : true,
})
if(Meteor.isClient){
Accounts.ui.config({
passwordSignupFields: 'USERNAME_ONLY',
});
$.cloudinary.config({
cloud_name: "lets"
});
Template.body.helpers({
events: function(){
returnEvents.find({});
}
});
Template.body.events({
"click .seja-parceiro": function(event){
alert('Bela iniciativa! Entre em contato conosco para conversar sobre parceiria [<o>] ')
},
"click .buy-drink": function(event){
alert('Obrigado! Olha nossos próximos eventos no Meetup e vêm compartilhar este drink conosco :D !')
},
"submit .new-event": function(event){
// Prevent default browser form submit
event.preventDefault();
// Get value from form element
varname=event.target.name.value;
vardatetime=event.target.datetime.value;
varwebsite=event.target.website.value;
varimages=event.target.image.files;
vardescription=event.target.description.value;
varcity=event.target.city.value;
varplace=event.target.place.value;
varaddress=event.target.address.value;
varcontato=event.target.contato.value;
varemail=event.target.email.value;
if(name&&datetime&&contato&&email&&description&&images){
// Insert an event into the collection
event_id=Events.insert({
name: name,
datetime: datetime,
website: website,
description: description,
city: city,
place: place,
address: address,
contato: contato,
email: email,
createdAt: newDate()// current time
});
Cloudinary.upload(images,{},function(err,res){
if(err){
alert("A imagem não foi carregada.");
}else{
if(res.public_id){
Events.update(event_id,{
$set: {image: res.public_id}
});
console.log('Image '+res.public_id+' saved');
}
}
});
// Clear form
event.target.name.value="";
event.target.datetime.value="";
event.target.website.value="";
event.target.imagepath.value="";
event.target.description.value="";
event.target.city.value="";
event.target.place.value="";
event.target.address.value="";
event.target.contato.value="";
event.target.email.value="";
alert('Demais! O seu evento foi inserido. Confere a lista dos eventos acima.')
}else{
alert("Por favor preencher todos os campos requiridos");
}
}
});
Template.event.helpers({
isAdmin: function(){
returnMeteor.user();
},
descriptionHtml: function(){
returnthis.description.replace(/\r?\n/g,"<br>");
},
});
Template.event.events({
"click .delete": function(){
if(confirm('Tem certeza que deseja deletar "'+this.name+'"')){
Events.remove(this._id);
}
}
});
}
if(Meteor.isServer){
Cloudinary.config({
cloud_name: 'lets',
api_key: '924521254223698',
api_secret: 's2GiPJ4TVqUzvDXCSxUY6oPTunY'
});
Meteor.startup(function(){
// code to run on server at startup
if(Accounts.findUserByUsername("admin")==null){
Accounts.createUser({
"username": "admin",
"password": "CC2017"
});
}
});
}