removed forum and related code, not sure it's all gone but it seems to be.
This commit is contained in:
parent
62b1cc8e0a
commit
5f757f758a
19
README.md
19
README.md
@ -1,7 +1,7 @@
|
||||
# README for inkletblot.com
|
||||
|
||||
This is an angularjs project, currently it is a total rebuild of inkletblot.com using the framework.
|
||||
In the future the forum will be separated from the gallery and 'things' pages.
|
||||
The forum has been separated from the gallery and 'things' pages. It is at https://github.com/Inkletblot/forum.com
|
||||
|
||||
> I know things is a stupid name, can you come up with a better one?
|
||||
|
||||
@ -13,23 +13,8 @@ In the future the forum will be separated from the gallery and 'things' pages.
|
||||
* Fix client catching of server errors.
|
||||
* Generally strengthen server API, especially once forum is separate.
|
||||
|
||||
### Forum:
|
||||
* ***Create Category, both client and server.***
|
||||
* ***Create Topic, both client and server.***
|
||||
* **Create Post/Reply, both client and server.**
|
||||
* ***Fix and test signup.***
|
||||
* Create edit post functionality.
|
||||
* Create delete post functionality.
|
||||
* Menu only shows applicable items based on user level.
|
||||
* Update server/client/cookie to include all user info.
|
||||
* implement correct session with server.
|
||||
* reduce clients reliance on cookie info to prevent security threats.
|
||||
|
||||
### Gallery/Things:
|
||||
*Deal with this once forum is totally complete, it is now main project*
|
||||
|
||||
## Interesting Ideas.
|
||||
* Implement a text editor for posts?
|
||||
* Add an account page for users to manage their accounts.
|
||||
* Add admin ability to remove topics and categories.
|
||||
* Figure out passing information down the line so that the post page shows the category as well as topic.
|
||||
* None as of yet x
|
||||
@ -15,12 +15,9 @@
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.7.2/angular.min.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.7.2/angular-route.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.7.2/angular-animate.min.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.7.2/angular-cookies.js"></script>
|
||||
<script src="./scripts/links.js"></script>
|
||||
<script src="./scripts/main.js"></script>
|
||||
<script src="./scripts/auth.controllers.js"></script>
|
||||
<script src="./scripts/gallery.controller.js"></script>
|
||||
<script src="./scripts/forum.controller.js"></script>
|
||||
</head>
|
||||
|
||||
<body ng-app="daddy" ng-controller="bodyCtrlr" ng-init="setThings()">
|
||||
|
||||
@ -12,5 +12,5 @@
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "Solomon Laing",
|
||||
"license": "ISC"
|
||||
"license": "MIT"
|
||||
}
|
||||
|
||||
@ -1,158 +0,0 @@
|
||||
daddy.controller("loginCtrlr", function($scope, $cookies, $location, $http, stateData){
|
||||
|
||||
let titles = {
|
||||
login : "Login!",
|
||||
signup : "Not a Member?"
|
||||
}
|
||||
$scope.titles = titles
|
||||
|
||||
let message = {
|
||||
start : "Feel free to",
|
||||
link : "Sign Up",
|
||||
end : "at any time!"
|
||||
}
|
||||
$scope.message = message
|
||||
|
||||
$scope.setSignup = () => {
|
||||
stateData.setPage("things")
|
||||
$location.path("/signup")
|
||||
}
|
||||
|
||||
$scope.login = () => {
|
||||
$scope.status = true
|
||||
$scope.loginStatus = "Logging you in..."
|
||||
console.log("logging in")
|
||||
console.log("requesting authentication from server")
|
||||
$http({
|
||||
url : server + "/auth/login?userName="+$scope.user.username+"&userPass="+$scope.user.password,
|
||||
method : "GET"
|
||||
}).then((res) => {
|
||||
console.log(res)
|
||||
if (res.status == 200) {
|
||||
console.log("request granted")
|
||||
let today = new Date()
|
||||
let expired = new Date(today)
|
||||
expired.setDate(today.getDate()+1)
|
||||
$cookies.putObject('user', res.data[0], {expires : expired})
|
||||
console.log("set cookie")
|
||||
stateData.setUser(res.data[0])
|
||||
console.log("set data")
|
||||
stateData.setPage("things")
|
||||
$location.path("/things")
|
||||
}
|
||||
}).catch((res) => {
|
||||
if (res.status == 400) {
|
||||
$scope.loginStatus = "Incorrect information!"
|
||||
console.log("request denied")
|
||||
} else if (res.status == 500) {
|
||||
console.log("something went wrong: " + res)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
daddy.controller("signupCtrlr", function($scope, $http, $location, stateData) {
|
||||
|
||||
let titles = {
|
||||
form : "Sign up here!",
|
||||
success : "Signup Success!"
|
||||
}
|
||||
$scope.titles = titles
|
||||
|
||||
let message = {
|
||||
start : "You account has been created!",
|
||||
line2 : "Feel free to",
|
||||
link : "Login",
|
||||
end : "whenever you like."
|
||||
}
|
||||
$scope.message = message
|
||||
|
||||
$scope.success = false
|
||||
$scope.exists = false
|
||||
$scope.status = false
|
||||
|
||||
$scope.setLogin = () => {
|
||||
stateData.setPage("things")
|
||||
$location.path("/login")
|
||||
}
|
||||
|
||||
$scope.signup = () => {
|
||||
$scope.userExists()
|
||||
$scope.passwordsMatch()
|
||||
$scope.emailGood()
|
||||
|
||||
if ($scope.match && !$scope.exists && $scope.goodemail) {
|
||||
$scope.status = false
|
||||
$scope.submit()
|
||||
} else {
|
||||
$scope.status = true
|
||||
$scope.signupStatus = "Please correct errors above."
|
||||
}
|
||||
}
|
||||
|
||||
$scope.emailGood = () => {
|
||||
if (validateEmail($scope.user.email)) {
|
||||
$scope.goodemail = true
|
||||
$scope.emailError = ""
|
||||
} else {
|
||||
$scope.goodemail = false
|
||||
$scope.emailError = "< invalid email."
|
||||
}
|
||||
}
|
||||
|
||||
$scope.passwordsMatch = () => {
|
||||
if ($scope.user.password != $scope.user.confirmPassword) {
|
||||
$scope.match = false
|
||||
$scope.passwordError = "< password does not match."
|
||||
} else {
|
||||
$scope.match = true
|
||||
$scope.passwordError = ""
|
||||
}
|
||||
}
|
||||
|
||||
$scope.submit = () => {
|
||||
$http({
|
||||
url : server + "/auth/signup?userName=" + $scope.user.username + "&userPass=" + $scope.user.password + "&userEmail=" + $scope.user.email,
|
||||
method : "POST"
|
||||
}).then((res) => {
|
||||
if (res.status == 200) {
|
||||
console.log("user created successfully")
|
||||
$scope.success = true
|
||||
$scope.signupForm.$setPristine()
|
||||
$scope.user.username = ""
|
||||
$scope.user.password = ""
|
||||
$scope.user.confirmPassword = ""
|
||||
$scope.user.email = ""
|
||||
}
|
||||
}).catch((res) => {
|
||||
if (res.status == 500) {
|
||||
console.log("whoops...")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
$scope.userExists = () => {
|
||||
console.log("checking username is used?")
|
||||
$http({
|
||||
url : server + "/auth/exists?userName=" + $scope.user.username,
|
||||
method : "POST"
|
||||
}).then((res) => {
|
||||
if (res.status == 200) {
|
||||
console.log(res.data)
|
||||
if (res.data == true) {
|
||||
$scope.exists = true
|
||||
$scope.usernameError= "< username already exists."
|
||||
} else {
|
||||
$scope.exists = false
|
||||
$scope.usernameError = ""
|
||||
}
|
||||
}
|
||||
}).catch((res) => {
|
||||
if (res.status == 500) {
|
||||
console.log ("something went wrong")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
})
|
||||
@ -1,469 +0,0 @@
|
||||
daddy.controller("forumCtrlr", function($scope, $http, $location) {
|
||||
|
||||
$scope.titles = {
|
||||
main : "Talking Points...",
|
||||
list : "Catergories",
|
||||
last : "Last Topic"
|
||||
}
|
||||
|
||||
$scope.errors = {
|
||||
topic : {
|
||||
show : false,
|
||||
text : "None yet!"
|
||||
},
|
||||
catagory : {
|
||||
show : false,
|
||||
text: "None yet!"
|
||||
}
|
||||
}
|
||||
|
||||
$scope.getCategories = () => {
|
||||
console.log("getting categories form server")
|
||||
$http({
|
||||
url : server + "/forum/category/all",
|
||||
method : "GET"
|
||||
}).then((res) => {
|
||||
if (res.status == 200) {
|
||||
if (res.data.length == 0) {
|
||||
$scope.errors.catagory.show = true
|
||||
} else {
|
||||
$scope.categories = res.data
|
||||
for (let i = 0; i < res.data.length; i++) {
|
||||
$http({
|
||||
url : server + "/forum/category/topic/last?cat=" + res.data[i].catNo,
|
||||
method : "GET"
|
||||
}).then((res) => {
|
||||
if (res.status == 200) {
|
||||
console.log("topicNo: " + res.data.topicNo)
|
||||
// if (res.data.topicNo == null) {
|
||||
// $scope.errors.topic.show = true
|
||||
// } else {
|
||||
res.data.topicDate = niceDate(res.data.topicDate)
|
||||
$scope.categories[i].lastTopic = res.data
|
||||
// }
|
||||
} else {
|
||||
console.log("server has encountered an error: " + res.status)
|
||||
}
|
||||
})
|
||||
}
|
||||
console.log(res)
|
||||
}
|
||||
}
|
||||
}).catch((res) => {
|
||||
console.log("server has encountered an error: " + res.status)
|
||||
})
|
||||
}
|
||||
|
||||
$scope.setCat = (catNo) => {
|
||||
$location.path("/forum/category/"+catNo)
|
||||
}
|
||||
|
||||
$scope.setTopic = (topicNo) => {
|
||||
$location.path("/forum/topic/"+topicNo)
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
daddy.controller("createTopicCtrlr", function($scope, $location, $http, stateData) {
|
||||
|
||||
$scope.titles = {
|
||||
form : "Create a topic!"
|
||||
}
|
||||
|
||||
$scope.status = {
|
||||
show : false,
|
||||
text : ""
|
||||
}
|
||||
|
||||
let error = {
|
||||
loggedIn : {
|
||||
show : false,
|
||||
text1 : "You must be",
|
||||
link1 : "Logged In",
|
||||
text2 : "to create a topic!"
|
||||
},
|
||||
userLevel : {
|
||||
show : false,
|
||||
text1 : "No categories have been created, please contact an administrator about creating some.",
|
||||
text2 : "Administrator contact: solomonlaing@inkletblot.com"
|
||||
},
|
||||
category : {
|
||||
show : false
|
||||
}
|
||||
}
|
||||
|
||||
$scope.error = error
|
||||
|
||||
$scope.start = () => {
|
||||
if (stateData.state.user.userName == null) {
|
||||
console.log("not logged in.")
|
||||
error.loggedIn.show = true
|
||||
}
|
||||
if (stateData.state.user.userLevel == 0) {
|
||||
console.log("user not an admin.")
|
||||
error.userLevel.show = true
|
||||
}
|
||||
$scope.getCategories()
|
||||
}
|
||||
|
||||
$scope.getCategories = () => {
|
||||
console.log("getting categories form server")
|
||||
$http({
|
||||
url : server + "/forum/category/all",
|
||||
method : "GET"
|
||||
}).then((res) => {
|
||||
if (res.status == 200) {
|
||||
if (res.data.length == 0) {
|
||||
$scope.errors.catagory.show = true
|
||||
} else {
|
||||
$scope.categories = res.data
|
||||
console.log(res)
|
||||
}
|
||||
}
|
||||
}).catch((res) => {
|
||||
console.log("server has encountered an error: " + res.status)
|
||||
})
|
||||
}
|
||||
|
||||
$scope.setLogin = () => {
|
||||
$location.path("/login")
|
||||
stateData.setPage("things")
|
||||
}
|
||||
|
||||
$scope.createTopic = () => {
|
||||
console.log("sending new topic to server!!")
|
||||
let formData = new FormData()
|
||||
formData.append('topicSubject', $scope.topic.topicSubject)
|
||||
formData.append('topicCat', $scope.topic.topicCat)
|
||||
formData.append('userNo', stateData.state.user.userNo)
|
||||
$http({
|
||||
url : server + "/forum/topic/create",
|
||||
method : "POST",
|
||||
data : formData,
|
||||
headers : { 'Content-Type' : undefined },
|
||||
transformRequest : angular.identity
|
||||
}).then((res) => {
|
||||
if (res.status == 200) {
|
||||
console.log("topic submitted")
|
||||
$scope.createPost($scope.topic.postContent, res.data.topicNo)
|
||||
}
|
||||
}).catch((res) => {
|
||||
if (res.status == 500) {
|
||||
console.log("something went wrong: " + res.data)
|
||||
$scope.status.text = "Something went wrong: " + res.status
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
$scope.createPost = (postContent, topicNo) => {
|
||||
console.log("sending new post to server")
|
||||
let formData = new FormData()
|
||||
formData.append('postContent', postContent)
|
||||
formData.append('topicNo', topicNo)
|
||||
formData.append('userNo', stateData.state.user.userNo)
|
||||
$http({
|
||||
url : server + "/forum/topic/post/create",
|
||||
method : "POST",
|
||||
data : formData,
|
||||
headers : { 'Content-Type' : undefined },
|
||||
transformRequest : angular.identity
|
||||
}).then((res) => {
|
||||
if (res.status == 200) {
|
||||
console.log("post added")
|
||||
$location.path("/forum/topic/" + topicNo)
|
||||
}
|
||||
}).catch((res) => {
|
||||
if (res.status == 500) {
|
||||
console.log("something went wrong: " + res.data)
|
||||
$scope.status.text = "Something went wrong: " + res.status
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
daddy.controller("createCategoryCtrlr", function($scope, $http, $location, stateData) {
|
||||
|
||||
let error = {
|
||||
loggedIn : {
|
||||
show : false,
|
||||
text1 : "You must be",
|
||||
link1 : "Logged In",
|
||||
text2 : "to create a category!"
|
||||
},
|
||||
userLevel : {
|
||||
show : false,
|
||||
text1 : "You must be an administrator to create a category!"
|
||||
}
|
||||
}
|
||||
|
||||
$scope.error = error
|
||||
|
||||
$scope.titles = {
|
||||
form : "Create a Category!"
|
||||
}
|
||||
|
||||
$scope.status = {
|
||||
show : false,
|
||||
text : ""
|
||||
}
|
||||
|
||||
$scope.start = () => {
|
||||
if (stateData.state.user.userName == null) {
|
||||
error.loggedIn.show = true
|
||||
}
|
||||
if (stateData.state.user.userLevel == 0) {
|
||||
error.userLevel.show = true
|
||||
}
|
||||
}
|
||||
|
||||
$scope.setLogin = () => {
|
||||
$location.path("/login")
|
||||
stateData.setPage("things")
|
||||
}
|
||||
|
||||
$scope.createCategory = () => {
|
||||
$scope.status.show = true
|
||||
$scope.status.text = "Adding category..."
|
||||
|
||||
let formData = new FormData()
|
||||
formData.append('catName', $scope.category.catName)
|
||||
formData.append('catDescr', $scope.category.catDescr)
|
||||
|
||||
console.log("sending to server...")
|
||||
$http({
|
||||
url : server + "/forum/category/create",
|
||||
method : "POST",
|
||||
data : formData,
|
||||
headers : { 'Content-Type' : undefined },
|
||||
transformRequest : angular.identity
|
||||
}).then((res) => {
|
||||
if (res.status == 200) {
|
||||
console.log("category submitted")
|
||||
$location.path("/forum/category/" + res.data.catNo)
|
||||
}
|
||||
}).catch((res) => {
|
||||
if (res.status == 500) {
|
||||
console.log("something went wrong: " + res.data)
|
||||
$scope.status.text = "Something went wrong: " + res.status
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
daddy.controller("topicCtrlr", function($scope, $routeParams, $timeout, $http, $location, stateData) {
|
||||
stateData.setPage("forum")
|
||||
|
||||
$scope.error = false
|
||||
$scope.message = {
|
||||
start : null,
|
||||
link : "Go Back!"
|
||||
}
|
||||
$scope.logged = {
|
||||
text1 : "You must be",
|
||||
link1 : "logged in",
|
||||
text2 : "to reply. You can also",
|
||||
link2 : "sign up",
|
||||
text3 : "for an account."
|
||||
}
|
||||
$scope.status = {
|
||||
show : false,
|
||||
text : "",
|
||||
}
|
||||
$scope.first = {
|
||||
show : false,
|
||||
text : "Be the first to create a post, write below..."
|
||||
}
|
||||
|
||||
$scope.getTopic = () => {
|
||||
console.log("getting topic")
|
||||
$http({
|
||||
url : server + "/forum/topic?topic=" + $routeParams.topicNo,
|
||||
method : "GET"
|
||||
}).then((res) => {
|
||||
if (res.status == 200) {
|
||||
let topic = res.data
|
||||
// if (res.data.posts.length == 0) {
|
||||
// $scope.first.show = true
|
||||
// }
|
||||
|
||||
for (let i = 0; i < topic.posts.length; i++) {
|
||||
topic.posts[i].postDate = niceDate(topic.posts[i].postDate)
|
||||
}
|
||||
$scope.topic = topic
|
||||
}
|
||||
}).catch((res) => {
|
||||
if (res.status == 404) {
|
||||
console.log(res.data)
|
||||
$scope.error = true
|
||||
$scope.message.start = "No such topic,"
|
||||
} else if (res.status == 500) {
|
||||
console.log(res.data)
|
||||
$scope.error = true
|
||||
$scope.message.start = "An error has occured: " + res.status
|
||||
} else {
|
||||
console.log(res)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
$scope.makeReply = (topicNo) => {
|
||||
console.log("sending new post to server")
|
||||
let formData = new FormData()
|
||||
formData.append('postContent', $scope.reply.postContent)
|
||||
formData.append('topicNo', topicNo)
|
||||
formData.append('userNo', stateData.state.user.userNo)
|
||||
$http({
|
||||
url : server + "/forum/topic/post/create",
|
||||
method : "POST",
|
||||
data : formData,
|
||||
headers : { 'Content-Type' : undefined },
|
||||
transformRequest : angular.identity
|
||||
}).then((res) => {
|
||||
if (res.status == 200) {
|
||||
console.log("post added")
|
||||
$scope.reply.postContent = ""
|
||||
$timeout(function() { $scope.getTopic() }, 2000)
|
||||
}
|
||||
}).catch((res) => {
|
||||
if (res.status == 500) {
|
||||
console.log("something went wrong: ")
|
||||
console.log(res.data)
|
||||
$scope.status.text = "Something went wrong: " + res.status
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
$scope.setLogin = () => {
|
||||
$location.path("/login")
|
||||
}
|
||||
|
||||
$scope.setSignup = () => {
|
||||
$location.path("/signup")
|
||||
}
|
||||
|
||||
$scope.deletePost = (postNo) => {
|
||||
if (!window.confirm("Are you sure you want to delete this post?")) {
|
||||
return
|
||||
}
|
||||
$http({
|
||||
url : server + "/forum/topic/post/delete?postNo=" + postNo,
|
||||
method : "POST"
|
||||
}).then((res) => {
|
||||
if (res.status == 200) {
|
||||
console.log("post deleted")
|
||||
for (let i = 0; i < $scope.topic.posts.length; i++) {
|
||||
if ($scope.topic.posts[i].postNo == postNo) {
|
||||
$scope.topic.posts[i].postContent = "[deleted]"
|
||||
}
|
||||
}
|
||||
}
|
||||
}).catch((res) => {
|
||||
if (res.status == 500) {
|
||||
console.log("something went wrong: ")
|
||||
console.log(res.data)
|
||||
$scope.status.text = "Something went wrong: " + res.status
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
$scope.editPost = (postNo, postContent) => {
|
||||
/* This is incomplete, need to figure out hiding the edit box after edit. Would rather not use timeout. */
|
||||
console.log("submitting edited post")
|
||||
let formData = new FormData()
|
||||
formData.append("postNo", postNo)
|
||||
formData.append("postContent", postContent)
|
||||
$http({
|
||||
url : server + "/forum/topic/post/edit",
|
||||
method : "POST",
|
||||
data : formData,
|
||||
headers : { 'Content-Type' : undefined },
|
||||
transformRequest : angular.identity
|
||||
}).then((res) => {
|
||||
if (res.status == 200) {
|
||||
console.log("post edited")
|
||||
for (let i = 0; i < $scope.topic.posts.length; i++) {
|
||||
if ($scope.topic.posts[i].postNo == postNo) {
|
||||
$scope.topic.posts[i].postContent = postContent + " [edited]"
|
||||
}
|
||||
}
|
||||
}
|
||||
}).catch((res) => {
|
||||
if (res.status == 500) {
|
||||
console.log("something went wrong: ")
|
||||
console.log(res.data)
|
||||
$scope.status.text = "Something went wrong: " + res.status
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
daddy.controller("categoryCtrlr", function($scope, $http, $routeParams, $location, stateData) {
|
||||
stateData.setPage("forum")
|
||||
|
||||
$scope.errors = {
|
||||
exists : {
|
||||
show : false,
|
||||
text1 : "No such category,",
|
||||
link1 : "Go Back!"
|
||||
},
|
||||
empty : {
|
||||
show : false,
|
||||
text : "No topics have been created yet..."
|
||||
}
|
||||
}
|
||||
|
||||
$scope.titles = {
|
||||
topic : "topic",
|
||||
date : "date"
|
||||
}
|
||||
|
||||
$scope.getCat = () => {
|
||||
console.log("getting category")
|
||||
$http({
|
||||
url : server + "/forum/category?cat=" + $routeParams.catNo,
|
||||
method : "GET"
|
||||
}).then((res) => {
|
||||
console.log(res)
|
||||
if (res.status == 200) {
|
||||
let category = res.data
|
||||
if (category.topics.length == 0) {
|
||||
$scope.errors.empty.show = true
|
||||
} else {
|
||||
for (let i = 0; i < category.topics.length; i++) {
|
||||
category.topics[i].topicDate = niceDate(category.topics[i].topicDate)
|
||||
}
|
||||
}
|
||||
$scope.category = category
|
||||
}
|
||||
}).catch((res) => {
|
||||
if (res.status == 404) {
|
||||
console.log(res.data)
|
||||
$scope.errors.exists.show = true
|
||||
} else if (res.status == 500) {
|
||||
console.log(res.data)
|
||||
} else {
|
||||
console.log(res)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
$scope.setTopic = (topicNo) => {
|
||||
$location.path("/forum/topic/"+topicNo)
|
||||
}
|
||||
|
||||
$scope.setForum = () => {
|
||||
$location.path("/forum")
|
||||
}
|
||||
})
|
||||
|
||||
niceDate = (string) => {
|
||||
let date = new Date(string)
|
||||
return "on " + date.getFullYear() + "-" + (date.getMonth()+1) + "-" + date.getDate() + " at " + date.getHours() + ":" + date.getMinutes()
|
||||
}
|
||||
|
||||
isNum = (str) => {
|
||||
let re = /^[0-9]+$/
|
||||
return re.test(String(str).toLowerCase())
|
||||
}
|
||||
103
scripts/main.js
103
scripts/main.js
@ -1,36 +1,18 @@
|
||||
let daddy = angular.module("daddy", ["ngRoute", "ngAnimate", "ngCookies"])
|
||||
let daddy = angular.module("daddy", ["ngRoute", "ngAnimate"])
|
||||
|
||||
let server = "http://127.0.0.1:7001"
|
||||
|
||||
daddy.controller("bodyCtrlr", function($scope, $cookies, stateData){
|
||||
daddy.controller("bodyCtrlr", function($scope, stateData){
|
||||
|
||||
$scope.state = stateData.state
|
||||
|
||||
let user = $cookies.getObject('user')
|
||||
|
||||
if (user == null) {
|
||||
stateData.logOut()
|
||||
} else {
|
||||
stateData.setUser(user)
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
daddy.controller("headerCtrlr", function($scope, stateData){
|
||||
daddy.controller("headerCtrlr", function($scope){
|
||||
$scope.subtitle = "Inks Things."
|
||||
})
|
||||
|
||||
daddy.controller("navCtrlr", function($scope, $location, $http, $cookies, stateData){
|
||||
|
||||
$scope.setLogin = () => {
|
||||
stateData.setPage("things")
|
||||
$location.path("/login")
|
||||
}
|
||||
|
||||
$scope.setSignup = () => {
|
||||
stateData.setPage("things")
|
||||
$location.path("/signup")
|
||||
}
|
||||
daddy.controller("navCtrlr", function($scope, $location, $http, stateData){
|
||||
|
||||
$scope.setThings = () => {
|
||||
stateData.setPage("things")
|
||||
@ -46,21 +28,6 @@ daddy.controller("navCtrlr", function($scope, $location, $http, $cookies, stateD
|
||||
stateData.setPage("gallery")
|
||||
$location.path("/gallery/upload")
|
||||
}
|
||||
|
||||
$scope.setForum = () => {
|
||||
stateData.setPage("forum")
|
||||
$location.path("/forum")
|
||||
}
|
||||
|
||||
$scope.setTopicCreate = () => {
|
||||
stateData.setPage("forum")
|
||||
$location.path("/forum/create/topic")
|
||||
}
|
||||
|
||||
$scope.setCategoryCreate = () => {
|
||||
stateData.setPage("forum")
|
||||
$location.path("/forum/create/category")
|
||||
}
|
||||
|
||||
switch ($location.path()) {
|
||||
case "":
|
||||
@ -74,27 +41,6 @@ daddy.controller("navCtrlr", function($scope, $location, $http, $cookies, stateD
|
||||
case "/gallery/upload":
|
||||
$scope.setUpload()
|
||||
break
|
||||
case "/forum":
|
||||
$scope.setForum()
|
||||
break
|
||||
case "/forum/topic":
|
||||
// this has to be done in the controller
|
||||
break
|
||||
case "/forum/create/topic":
|
||||
$scope.setTopicCreate()
|
||||
break
|
||||
case "/forum/category":
|
||||
// this has to be done in the controller
|
||||
break
|
||||
case "/forum/create/category":
|
||||
$scope.setCategoryCreate()
|
||||
break
|
||||
case "/login":
|
||||
$scope.setLogin()
|
||||
break
|
||||
case "/signup":
|
||||
$scope.setSignup()
|
||||
break
|
||||
}
|
||||
|
||||
$scope.clearGallery = () => {
|
||||
@ -116,11 +62,6 @@ daddy.controller("navCtrlr", function($scope, $location, $http, $cookies, stateD
|
||||
})
|
||||
}
|
||||
|
||||
$scope.logOut = () => {
|
||||
$cookies.remove('user')
|
||||
stateData.logOut()
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
daddy.controller("thingsCtrlr", function($scope){
|
||||
@ -137,13 +78,6 @@ daddy.config(function ($routeProvider) {
|
||||
$routeProvider.when("/pet", {templateUrl : "views/pet.html", controller : "petCtrlr"})
|
||||
$routeProvider.when("/gallery", {templateUrl : "views/gallery/gallery.html", controller : "galleryCtrlr"})
|
||||
$routeProvider.when("/gallery/upload", {templateUrl : "views/gallery/upload.html", controller : "uploadCtrlr"})
|
||||
$routeProvider.when("/forum", {templateUrl : "views/forum/forum.html", controller : "forumCtrlr"})
|
||||
$routeProvider.when("/forum/create/topic", {templateUrl : "views/forum/create_topic.html", controller : "createTopicCtrlr"})
|
||||
$routeProvider.when("/forum/topic/:topicNo", {templateUrl : "views/forum/topic.html", controller : "topicCtrlr"})
|
||||
$routeProvider.when("/forum/create/category", {templateUrl : "views/forum/create_category.html", controller : "createCategoryCtrlr"})
|
||||
$routeProvider.when("/forum/category/:catNo", {templateUrl : "views/forum/category.html", controller : "categoryCtrlr"})
|
||||
$routeProvider.when("/login", {templateUrl : "views/login.html", controller : "loginCtrlr"})
|
||||
$routeProvider.when("/signup", {templateUrl : "views/signup.html", controller : "signupCtrlr"})
|
||||
$routeProvider.otherwise({template : "<article><section class='item border'><h1>404 ... no clue fam ... try something else?</h1></section></article>"})
|
||||
})
|
||||
|
||||
@ -151,11 +85,6 @@ daddy.factory('stateData', function(){
|
||||
let state = {
|
||||
page : "things",
|
||||
title : "Things;",
|
||||
user : {
|
||||
userNo : null,
|
||||
userName : null,
|
||||
userLevel : 0
|
||||
},
|
||||
content : {
|
||||
gallery : null
|
||||
}
|
||||
@ -170,29 +99,12 @@ daddy.factory('stateData', function(){
|
||||
case "gallery":
|
||||
state.title = "Gallery;"
|
||||
break
|
||||
case "forum":
|
||||
state.title = "Forum;"
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
logOut = () => {
|
||||
state.user.userNo = null
|
||||
state.user.userName = null
|
||||
state.user.userLevel = 0
|
||||
}
|
||||
|
||||
setUser = (user) => {
|
||||
state.user.userNo = user.userNo
|
||||
state.user.userName = user.userName
|
||||
state.user.userLevel = user.userLevel
|
||||
}
|
||||
|
||||
return {
|
||||
state : state,
|
||||
setPage: setPage,
|
||||
logOut: logOut,
|
||||
setUser: setUser
|
||||
setPage: setPage
|
||||
}
|
||||
})
|
||||
|
||||
@ -200,9 +112,4 @@ function getDate() {
|
||||
let date = new Date()
|
||||
let out = date.getFullYear() + "-" + (date.getMonth()+1) + "-" + date.getDate() + " - " + date.getHours() + ":" + date.getMinutes()
|
||||
return out
|
||||
}
|
||||
|
||||
function validateEmail(email) {
|
||||
var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
||||
return re.test(String(email).toLowerCase());
|
||||
}
|
||||
@ -119,10 +119,6 @@ nav .msub:link, nav .msub:visited, nav .msub:active {
|
||||
color: #FAFAFA;
|
||||
}
|
||||
|
||||
nav .userbar {
|
||||
float: right;
|
||||
}
|
||||
|
||||
/* END menu CSS */
|
||||
|
||||
/* CSS for things */
|
||||
@ -207,38 +203,4 @@ nav .userbar {
|
||||
|
||||
/* END upload CSS */
|
||||
|
||||
/* END gallery CSS */
|
||||
|
||||
/* START forum CSS */
|
||||
|
||||
table {
|
||||
text-align: left;
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
table, td, th {
|
||||
border: 1px solid pink;
|
||||
}
|
||||
|
||||
table a:hover {
|
||||
color: pink;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
th {
|
||||
background-color: #2E2E2E;
|
||||
color: #FAFAFA;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
td {
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.right {
|
||||
margin: 0 5px 0 10px;
|
||||
float: right;
|
||||
}
|
||||
|
||||
/* END forum CSS */
|
||||
/* END gallery CSS */
|
||||
@ -1,22 +0,0 @@
|
||||
<article ng-controller="categoryCtrlr" ng-init="getCat()">
|
||||
<section ng-if="!errors.exists.show" class="item border">
|
||||
<h3>{{category.catName}}</h3>
|
||||
<p><em>{{category.catDescr}}</em></p>
|
||||
<table>
|
||||
<tr>
|
||||
<th>{{titles.topic}}</th>
|
||||
<th>{{titles.date}}</th>
|
||||
</tr>
|
||||
<tr ng-repeat="topic in category.topics">
|
||||
<td><span class="link" ng-click="setTopic(topic.topicNo)">{{topic.topicSubject}}</span></td>
|
||||
<td>{{topic.topicDate}}</td>
|
||||
</tr>
|
||||
<tr ng-if="errors.empty.show">
|
||||
<td colspan="2">{{errors.empty.text}}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</section>
|
||||
<section ng-if="errors.exists.show" class="item border">
|
||||
<p>{{errors.exists.text1}} <span class="link" ng-click="setForum()">{{errors.exists.link1}}</span></p>
|
||||
</section>
|
||||
</article>
|
||||
@ -1,17 +0,0 @@
|
||||
<article ng-controller="createCategoryCtrlr" ng-init="start()">
|
||||
<section ng-show="!(error.userLevel.show)" class="item border">
|
||||
<h3>{{titles.form}}</h3>
|
||||
<form id="categoryForm" name="categoryForm" ng-submit="createCategory()">
|
||||
<label for="catName">Name: </label> <br />
|
||||
<input type="text" name="catName" ng-model="category.catName" placeholder="A name for the category" required /> <br />
|
||||
<label for="catDescr">Description: </label> <br />
|
||||
<textarea name="catDescr" ng-model="category.catDescr" placeholder="A description for the category" required ></textarea> <br />
|
||||
<input type="submit" value="Add Category" ng-model="category.submit" />
|
||||
</form>
|
||||
<p class="status" ng-show="status.show">{{status.text}}</p>
|
||||
</section>
|
||||
<section ng-show="error.userLevel.show" class="item border">
|
||||
<p ng-show="error.userName.show">{{error.loggedIn.text1}} <span class="link" ng-click="setLogin()">{{error.loggedIn.link1}}</span> {{error.loggedIn.text2}}</p>
|
||||
<p ng-show="!(erro.userName.show)">{{error.userLevel.text1}}</p>
|
||||
</section>
|
||||
</article>
|
||||
@ -1,23 +0,0 @@
|
||||
<article ng-controller="createTopicCtrlr" ng-init="start()">
|
||||
<section ng-show="!(error.loggedIn.show)" class="item border">
|
||||
<h3>{{titles.form}}</h3>
|
||||
<p ng-show="error.category.show && !error.userLevel.show">{{error.category.text1}} <span class="link" ng-click="setCreateCat()">{{error.category.link1}}</span> {{error.category.text2}}</p>
|
||||
<p ng-show="error.category.show && error.userLevel.show">{{error.userLevel.text1}} <br /> {{error.userLevel.text2}}</p>
|
||||
<form ng-show="!error.category.show" ng-submit="createTopic()">
|
||||
<label for="topicSubject">Subject: </label></br>
|
||||
<input type="text" name="topicSubject" ng-model="topic.topicSubject" placeholder="What's this topic about?" required /><br />
|
||||
<label for="topicCat">Category: </label></br>
|
||||
<select name="topicCat" ng-model="topic.topicCat" required>
|
||||
<option selected disabled hidden style='display: none' value=''></option>
|
||||
<option ng-repeat="category in categories" value="{{category.catNo}}">{{category.catName}}</option>
|
||||
</select><br />
|
||||
<label for="postContent">Message: </label></br>
|
||||
<textarea name="postContent" ng-model="topic.postContent" placeholder="The first post in the topic..." required></textarea><br />
|
||||
<input type="submit" ng-model="topic.submit" value="Create topic" />
|
||||
</form>
|
||||
<p class="status" ng-show="status.show">{{status.text}}</p>
|
||||
</section>
|
||||
<section ng-show="error.loggedIn.show" class="item border">
|
||||
<p>{{error.loggedIn.text1}} <span class="link" ng-click="setLogin()">{{error.loggedIn.link1}}</span> {{error.loggedIn.text2}}</p>
|
||||
</section>
|
||||
</article>
|
||||
@ -1,20 +0,0 @@
|
||||
<article ng-controller="forumCtrlr" ng-init="getCategories()">
|
||||
<section class="item border">
|
||||
<h3>{{titles.main}}</h3> <br />
|
||||
<table>
|
||||
<tr>
|
||||
<th>{{titles.list}}</th>
|
||||
<th>{{titles.last}}</th>
|
||||
</tr>
|
||||
<tr ng-repeat="cat in categories">
|
||||
<td><span class="link" ng-click="setCat(cat.catNo)">{{cat.catName}}</span> <br />
|
||||
{{cat.catDescr}} </td>
|
||||
<td ng-if="!(cat.lastTopic.topicNo == null)"><span class="link" ng-click="setTopic(cat.lastTopic.topicNo)">{{cat.lastTopic.topicSubject}}</span> {{cat.lastTopic.topicDate}}</td>
|
||||
<td ng-if="cat.lastTopic.topicNo == null">{{errors.topic.text}}</td>
|
||||
</tr>
|
||||
<tr ng-if="errors.catagory.show">
|
||||
<td colspan="2">{{errors.catagory.text}}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</section>
|
||||
</article>
|
||||
@ -1,46 +0,0 @@
|
||||
<article ng-controller="topicCtrlr" ng-init="getTopic()">
|
||||
<section ng-show="!error" class="item border">
|
||||
<table>
|
||||
<tr>
|
||||
<th colspan="2">{{topic.topicSubject}}</th>
|
||||
</tr>
|
||||
<tr ng-show="first.show">
|
||||
<td colspan="2">
|
||||
<p>{{first.text}}</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr ng-repeat="post in topic.posts">
|
||||
<td ng-show="state.user.userNo != post.user.userNo">{{post.postContent}}</td>
|
||||
<td ng-show="state.user.userNo == post.user.userNo" ng-init="showEditor = false">{{post.postContent}} <span class="link right"
|
||||
ng-click="deletePost(post.postNo)">[delete]</span> <span class="link right"
|
||||
ng-click="showEditor = !showEditor">[edit]</span>
|
||||
<div ng-show="showEditor">
|
||||
<br />
|
||||
<form name="editForm" id="editForm" ng-submit="editPost(post.postNo, edit.editContent)">
|
||||
<textarea name="editContent" ng-model="edit.editContent" placeholder="{{post.postContent}}" required></textarea>
|
||||
<br />
|
||||
<input type="submit" name="editSubmit" ng-model="edit.submit" value="Edit" />
|
||||
</form>
|
||||
</div>
|
||||
</td>
|
||||
<td>{{post.user.userName}}<br />{{post.postDate}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" ng-show="state.user.userNo == null">{{logged.text1}} <span class="link"
|
||||
ng-click="setLogin()">{{logged.link1}}</span> {{logged.text2}} <span class="link"
|
||||
ng-click="setSignup()">{{logged.link2}}</span> {{logged.text3}}</td>
|
||||
<td colspan="2" ng-show="state.user.userNo != null">
|
||||
<form name="replyForm" id="replyForm" ng-submit="makeReply(topic.topicNo)">
|
||||
<label for="replyCotnent">Reply:</label>
|
||||
<textarea name="replyContent" ng-model="reply.postContent" required></textarea>
|
||||
<input type="submit" name="replySubmit" ng-model="reply.submit" value="Reply" />
|
||||
</form>
|
||||
<p class="status" ng-show="status.show">{{status.text}}</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</section>
|
||||
<section ng-show="error" class="item border">
|
||||
<p>{{message.start}} <span class="link" ng-click="setForum()">{{message.link}}</span></p>
|
||||
</section>
|
||||
</article>
|
||||
@ -1,17 +0,0 @@
|
||||
<article ng-controller="loginCtrlr">
|
||||
<section class="item border">
|
||||
<h3>{{titles.login}}</h3> <br />
|
||||
<form id="loginForm" name="loginForm" ng-submit="login()" enctype="application/x-www-form-urlencoded">
|
||||
<label for="username">Username: </label> <br />
|
||||
<input type="text" name="username" ng-model="user.username" placeholder="Your username" required /> <br />
|
||||
<label for="password">Password: </label> <br />
|
||||
<input type="password" name="password" ng-model="user.password" placeholder="Your password" required /> <br />
|
||||
<input type="submit" name="submit" ng-model="user.Submit" value="Log In" />
|
||||
</form>
|
||||
<p class="status" ng-show="status">{{loginStatus}}</p>
|
||||
</section>
|
||||
<section class="item border">
|
||||
<h3>{{titles.signup}}</h3>
|
||||
<p>{{message.start}} <span class="link" ng-click="setSignup()">{{message.link}}</span> {{message.end}}</p>
|
||||
</section>
|
||||
</article>
|
||||
@ -6,23 +6,4 @@
|
||||
<span class="msub" ng-click="setGallery()">Gallery<spanext ng-if="state.page == 'gallery'"> ></spanext></span>
|
||||
<span ng-if="state.page == 'gallery'" class="msub" ng-click="setUpload()">Upload</span>
|
||||
<span ng-if="state.page == 'gallery'" class="msub" ng-click="clearGallery()">Clear</span>
|
||||
</span>
|
||||
|
||||
<span class="mitem">
|
||||
<span class="msub" ng-click="setForum()">Forum<spanext ng-if="state.page == 'forum'"> ></spanext></span>
|
||||
<span ng-if="state.page == 'forum'" class="msub" ng-click="setCategoryCreate()">Create a Category</span>
|
||||
<span ng-if="state.page == 'forum'" class="msub" ng-click="setTopicCreate()">Create a Topic</span>
|
||||
</span>
|
||||
|
||||
<div class="userbar">
|
||||
<span ng-show="state.user.userNo != null" class="mitem">
|
||||
<span>Welcome {{state.user.userName}}!</span>
|
||||
<span class="msub" ng-click="logOut()">Log Out</span>
|
||||
</span>
|
||||
<span ng-show="state.user.userNo == null" class="mitem">
|
||||
<span class="msub" ng-click="setLogin()">Log in</span>
|
||||
</span>
|
||||
<span ng-show="state.user.userNo == null" class="mitem">
|
||||
<span class="msub" ng-click="setSignup()">Sign Up</span>
|
||||
</span>
|
||||
</div>
|
||||
</span>
|
||||
@ -1,23 +0,0 @@
|
||||
<article ng-controller="signupCtrlr">
|
||||
<section class="item border">
|
||||
<h3>{{titles.form}}</h3> <br />
|
||||
<form id="signupForm" name="signupForm" ng-submit="signup()" enctype="application/x-www-form-urlencoded">
|
||||
<label for="username">Username: </label> <br />
|
||||
<input type="text" name="username" ng-model="user.username" placeholder="Your username" required /> {{usernameError}} <br />
|
||||
<label for="email">Email: </label> <br />
|
||||
<input type="text" name="email" ng-model="user.email" placeholder="Your email" required /> {{emailError}}<br />
|
||||
<label for="password">Password: </label> <br />
|
||||
<input type="password" name="password" ng-model="user.password" placeholder="Your password" required />
|
||||
<br />
|
||||
<label for="password">Confirm Password: </label> <br />
|
||||
<input type="password" name="confirmPassword" ng-model="user.confirmPassword"
|
||||
placeholder="Your password, again" required /> {{passwordError}}<br />
|
||||
<input type="submit" name="submit" ng-model="user.Submit" value="Sign Up" />
|
||||
</form>
|
||||
<p class="status" ng-show="status">{{signupStatus}}</p>
|
||||
</section>
|
||||
<section class="item border" ng-show="success">
|
||||
<h3>{{titles.success}}</h3>
|
||||
<p>{{message.start}} <br /> {{message.line2}} <span class="link" ng-click="setLogin()">{{message.link}}</span> {{message.end}}</p>
|
||||
</section>
|
||||
</article>
|
||||
Reference in New Issue
Block a user