Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
SRCT-chat
Commits
05b8b43a
Commit
05b8b43a
authored
Nov 22, 2014
by
Ivan Diaz
Browse files
First push making createChannels
parent
948c3d97
Changes
3
Hide whitespace changes
Inline
Side-by-side
client/views/channel/create.html
View file @
05b8b43a
<template
name=
"createChannel"
>
<!-- we need a forum in here -->
<form
id=
"createChannels"
>
Created By: {{username}}
<input
type=
"submit"
id=
"userName"
value=
"{{username}}"
name=
"username"
/>
Channel:
<br>
<input
type=
"submit"
id=
"channelName"
name=
"channel"
/>
Date:
<br>
<input
type=
"submit"
id=
"channelDate"
name=
"date"
/>
</form>
<br>
<input
type=
"submit"
value=
"Submit"
/>
</template>
client/views/channel/createChannel.js
0 → 100644
View file @
05b8b43a
Template
.
createChannel
.
helpers
({
channels
:
function
()
{
return
Channels
.
find
().
fetch
();
},
channelName
:
function
(
channelId
)
{
var
channelObj
=
Channels
.
findOne
(
channelId
);
return
channelObj
.
name
;
},
username
:
function
()
{
return
Meteor
.
user
().
profile
.
name
;
}
});
Template
.
createChannel
.
events
({
'
submit #channelName
'
:
function
(
e
,
t
)
{
var
insUsername
=
$
(
"
#userName
"
).
val
()
//grab data from userName field
var
channelName
=
$
(
"
#channelName
"
).
val
();
//Same but for Channel Name field
var
channelCheck
=
Channels
.
find
({
name
:
channelName
});
if
(
channelCheck
.
length
>
0
){
//Check to see if the channel length is greater than 0 and if its the same
alert
(
"
Channel exists, rename it
"
);
}
else
{
//Insert if it doesn't exist
Channels
.
insert
({
name
:
insUsername
}),
function
(
error
){
if
(
!
err
)
{
alert
(
"
SUCCESS!
"
);
}
else
{
alert
(
"
Its messed up!
"
);
alert
(
err
);
}
}
}
}
//});
});
client/views/channel/createChannel.js~
0 → 100644
View file @
05b8b43a
Template.createChannel.helpers({
channels: function() {
return Channels.find().fetch();
},
channelName: function(channelId) {
var channelObj = Channels.findOne(channelId);
return channelObj.name;
},
username: function() {
return Meteor.user().profile.name;
}
Template.createChannel.events(e,t) {
var insUsername = $("#userName").val() //grab data from userName field
var channelName=$("#channelName").val(); //Same but for Channel Name field
var channelCheck = Channels.find({name: channelName});
if(channelCheck.length>0) //Check to see if the channel length is greater than 0 and if its the same
alert("Channel exists, rename it");
} else { //Insert if it doesn't exist
Channels.insert{name: insUsername}, function(error){
if(!err) {
alert("SUCCESS!");
} else {
alert("Its messed up!");
alert(err);
}
}
}
}
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment