-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
06f5cf4
commit aa1c32c
Showing
6 changed files
with
601 additions
and
622 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,89 +1,84 @@ | ||
var data; | ||
function showOwner() | ||
{ | ||
$('.active-link-btn').removeClass('active-link-btn'); | ||
$('#admins-list-btn').addClass('active-link-btn'); | ||
$('.comUsersList').hide() | ||
$('.OwnerDivMain').show() | ||
} | ||
|
||
var data; | ||
function showMembers() | ||
{ | ||
$('.active-link-btn').removeClass('active-link-btn'); | ||
$('#users-list-btn').addClass('active-link-btn'); | ||
$('.OwnerDivMain').hide() | ||
$('.comUsersList').show() | ||
} | ||
|
||
function showOwner() | ||
window.onload = function() | ||
{ | ||
$('.comUsersList').hide() | ||
var id = $('#id').html(); | ||
var obj = Object(); | ||
obj._id = id; | ||
var request = new XMLHttpRequest() | ||
request.open('POST','/get') | ||
request.setRequestHeader("Content-Type","application/json"); | ||
request.send(JSON.stringify(obj)); | ||
request.onload = function() | ||
{ | ||
$('.active-link-btn').removeClass('active-link-btn'); | ||
$('#admins-list-btn').addClass('active-link-btn'); | ||
$('.comUsersList').hide() | ||
$('.OwnerDivMain').show() | ||
data = JSON.parse(request.responseText); | ||
addtoDOM1(); | ||
addtoDOM2(); | ||
} | ||
} | ||
|
||
function showMembers() | ||
{ | ||
$('.active-link-btn').removeClass('active-link-btn'); | ||
$('#users-list-btn').addClass('active-link-btn'); | ||
$('.OwnerDivMain').hide() | ||
$('.comUsersList').show() | ||
} | ||
|
||
window.onload = function() | ||
{ | ||
$('.comUsersList').hide() | ||
var id = $('#id').html(); | ||
var obj = Object(); | ||
obj._id = id; | ||
console.log(id); | ||
var request = new XMLHttpRequest() | ||
request.open('POST','/get') | ||
request.setRequestHeader("Content-Type","application/json"); | ||
request.send(JSON.stringify(obj)); | ||
request.onload = function() | ||
{ | ||
data = JSON.parse(request.responseText); | ||
console.log(data); | ||
addtoDOM1(); | ||
addtoDOM2(); | ||
} | ||
} | ||
|
||
function addtoDOM1() | ||
{ | ||
let div = '<div class="col-sm-12 community-user-div" style="margin-top: 5px">' | ||
+'<div class="col-sm-3" style="padding:5px;">' | ||
+'<a href="/viewprofile/'+data.communityownerid._id+'">' | ||
+'<img src="'+data.communityownerid.photoname+'" class="community-member-pic">' | ||
+'</a>' | ||
+'<span class="label label-primary">Owner</span>' | ||
+'</div>' | ||
+'<div class="col-sm-9 scrollable">' | ||
+'<a class="comusername" href="/viewprofile/'+data.communityownerid._id+'">'+data.communityownerid.name+'</a>' | ||
+'</div>' | ||
function addtoDOM1() | ||
{ | ||
let div = '<div class="col-sm-12 community-user-div" style="margin-top: 5px">' | ||
+'<div class="col-sm-3" style="padding:5px;">' | ||
+'<a href="/viewprofile/'+data.communityownerid._id+'">' | ||
+'<img src="'+data.communityownerid.photoname+'" class="community-member-pic">' | ||
+'</a>' | ||
+'<span class="label label-primary">Owner</span>' | ||
+'</div>' | ||
$('.OwnerDivMain').append(div); | ||
for(let i=0;i<data.communitymanager.length;i++) | ||
{ | ||
let div = '<div class="col-sm-12 community-user-div" style="margin-top: 5px">' | ||
+'<div class="col-sm-3" style="padding:5px;">' | ||
+'<a href="/viewprofile/'+data.communitymanager[i]._id+'">' | ||
+'<img src="'+data.communitymanager[i].photoname+'" class="community-member-pic">' | ||
+'</a>' | ||
+'<span class="label label-primary">Admin</span>' | ||
+'</div>' | ||
+'<div class="col-sm-9 scrollable">' | ||
+'<a class="comusername" href="/viewprofile/'+data.communitymanager[i]._id+'">'+data.communitymanager[i].name+'</a>' | ||
+'</div>' | ||
+'</div>' | ||
$('.OwnerDivMain').append(div); | ||
} | ||
} | ||
|
||
function addtoDOM2() | ||
{ | ||
for(let i=0;i<data.communitymember.length;i++) | ||
+'<div class="col-sm-9 scrollable">' | ||
+'<a class="comusername" href="/viewprofile/'+data.communityownerid._id+'">'+data.communityownerid.name+'</a>' | ||
+'</div>' | ||
+'</div>' | ||
$('.OwnerDivMain').append(div); | ||
for(let i=0;i<data.communitymanager.length;i++) | ||
{ | ||
// console.log("hello"); | ||
let div = '<div class="col-sm-12 community-user-div" style="margin-top: 5px">' | ||
+'<div class="col-sm-3" style="padding:5px;">' | ||
+'<a href="/viewprofile/'+data.communitymember[i]._id+'">' | ||
+'<img src="'+data.communitymember[i].photoname+'" class="community-member-pic">' | ||
+'<a href="/viewprofile/'+data.communitymanager[i]._id+'">' | ||
+'<img src="'+data.communitymanager[i].photoname+'" class="community-member-pic">' | ||
+'</a>' | ||
+'<span class="label label-primary">Admin</span>' | ||
+'</div>' | ||
+'<div class="col-sm-9 scrollable">' | ||
+'<a class="comusername" href="/viewprofile/'+data.communitymember[i]._id+'">'+data.communitymember[i].name+'</a>' | ||
+'<a class="comusername" href="/viewprofile/'+data.communitymanager[i]._id+'">'+data.communitymanager[i].name+'</a>' | ||
+'</div>' | ||
+'</div>' | ||
|
||
$('.comUsersList').append(div); | ||
$('.OwnerDivMain').append(div); | ||
} | ||
} | ||
|
||
function addtoDOM2() | ||
{ | ||
for(let i=0;i<data.communitymember.length;i++) | ||
{ | ||
let div = '<div class="col-sm-12 community-user-div" style="margin-top: 5px">' | ||
+'<div class="col-sm-3" style="padding:5px;">' | ||
+'<a href="/viewprofile/'+data.communitymember[i]._id+'">' | ||
+'<img src="'+data.communitymember[i].photoname+'" class="community-member-pic">' | ||
+'</a>' | ||
+'</div>' | ||
+'<div class="col-sm-9 scrollable">' | ||
+'<a class="comusername" href="/viewprofile/'+data.communitymember[i]._id+'">'+data.communitymember[i].name+'</a>' | ||
+'</div>' | ||
+'</div>' | ||
|
||
$('.comUsersList').append(div); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,95 +1,85 @@ | ||
var data = []; | ||
var start=0; | ||
var end=3; | ||
var total=0; | ||
var total_data = []; | ||
$(document).ready(function() { | ||
getCommunities() | ||
}) | ||
|
||
var data = []; | ||
var start=0; | ||
var end=3; | ||
var total=0; | ||
var total_data = []; | ||
$(document).ready(function() { | ||
getCommunities() | ||
}) | ||
function addtoDOM(obj) | ||
{ | ||
var div = '<div class="container" style="padding:0" id="'+obj._id+'"><div class="panel community-show-item panel-default allSidesSoft" style="style=" padding:0;background:white;"=""><div class="panel-body" style="padding:0;padding-top:20px"> <div class="col-sm-2 col-xs-3 col-lg-1 col-md-2"> <a href="#"><img src='+obj.communityimage+' class="allSides" style="height:70px;width:70px;border:3px solid rgb(235, 235, 235)"> </a> </div> <div class="col-sm-8 col-xs-6 col-lg-8 col-md-8 community-name"> <a href="/community/communityprofile/'+obj._id+'" class="community-name">'+obj.communityname+'</a> </div> <div class="col-sm-2 col-xs-3 col-lg-3 col-md-2" style="padding:15px 10px 0 10px"><div id="joinBtns5cbf18d7f54a481812074358"><button class="btn btn-primary btn-sm pull-right" id="ccs" onclick=join("'+obj._id+'","'+obj.communitymembershiprule+'") data-id="0">' | ||
if(obj.communitymembershiprule=='Direct') | ||
div = div + 'Join'; | ||
else { | ||
div = div + 'Ask To Join'; | ||
} | ||
div = div + '</button></div> </div></div><div class="panel-body" style="padding:10px 0 10px 0;"> <div class="col-sm-12 col-xs-12 col-lg-12 col-md-12"><p class="totalUsers">'+obj.communitymember.length+'</p> </div> <div class="col-sm-12 col-xs-12 col-lg-12 col-md-12 community-description" style="font-size:16px"><div id="less5cbf18d7f54a481812074358" class="community-description">'+obj.communitydescription+'</div><div id="" class="community-description community-description-full"></div></div></div></div></div>' | ||
|
||
function addtoDOM(obj) | ||
{ | ||
// console.log(obj); | ||
var div = '<div class="container" style="padding:0" id="'+obj._id+'"><div class="panel community-show-item panel-default allSidesSoft" style="style=" padding:0;background:white;"=""><div class="panel-body" style="padding:0;padding-top:20px"> <div class="col-sm-2 col-xs-3 col-lg-1 col-md-2"> <a href="#"><img src='+obj.communityimage+' class="allSides" style="height:70px;width:70px;border:3px solid rgb(235, 235, 235)"> </a> </div> <div class="col-sm-8 col-xs-6 col-lg-8 col-md-8 community-name"> <a href="/community/communityprofile/'+obj._id+'" class="community-name">'+obj.communityname+'</a> </div> <div class="col-sm-2 col-xs-3 col-lg-3 col-md-2" style="padding:15px 10px 0 10px"><div id="joinBtns5cbf18d7f54a481812074358"><button class="btn btn-primary btn-sm pull-right" id="ccs" onclick=join("'+obj._id+'","'+obj.communitymembershiprule+'") data-id="0">' | ||
if(obj.communitymembershiprule=='Direct') | ||
div = div + 'Join'; | ||
else { | ||
div = div + 'Ask To Join'; | ||
} | ||
div = div + '</button></div> </div></div><div class="panel-body" style="padding:10px 0 10px 0;"> <div class="col-sm-12 col-xs-12 col-lg-12 col-md-12"><p class="totalUsers">'+obj.communitymember.length+'</p> </div> <div class="col-sm-12 col-xs-12 col-lg-12 col-md-12 community-description" style="font-size:16px"><div id="less5cbf18d7f54a481812074358" class="community-description">'+obj.communitydescription+'</div><div id="" class="community-description community-description-full"></div></div></div></div></div>' | ||
$("#community-lists").append(div); | ||
} | ||
|
||
$("#community-lists").append(div); | ||
function join(_id,rule) | ||
{ | ||
console.log(_id); | ||
console.log(rule); | ||
var obj = Object(); | ||
obj._id = _id; | ||
var request = new XMLHttpRequest(); | ||
if(rule=='Direct') | ||
{ | ||
request.open('POST','/djoin') | ||
} | ||
|
||
function join(_id,rule) | ||
else { | ||
request.open('POST','/pjoin') | ||
} | ||
request.setRequestHeader("content-Type","application/JSON"); | ||
request.send(JSON.stringify(obj)); | ||
request.onload = function() | ||
{ | ||
console.log(_id); | ||
console.log(rule); | ||
var obj = Object(); | ||
obj._id = _id; | ||
var request = new XMLHttpRequest(); | ||
if(rule=='Direct') | ||
{ | ||
request.open('POST','/djoin') | ||
} | ||
else { | ||
request.open('POST','/pjoin') | ||
} | ||
request.setRequestHeader("content-Type","application/JSON"); | ||
request.send(JSON.stringify(obj)); | ||
request.onload = function() | ||
{ | ||
var p = document.getElementById(_id.toString()); | ||
p.parentNode.removeChild(p); | ||
} | ||
var p = document.getElementById(_id.toString()); | ||
p.parentNode.removeChild(p); | ||
} | ||
} | ||
|
||
document.getElementById("searchCommunitybox").onkeyup=function() | ||
document.getElementById("searchCommunitybox").onkeyup=function() | ||
{ | ||
document.getElementById("community-lists").innerHTML="" | ||
var val=document.getElementById("searchCommunitybox").value; | ||
for(j=0;j<total;j++) | ||
{ | ||
document.getElementById("community-lists").innerHTML="" | ||
var val=document.getElementById("searchCommunitybox").value; | ||
console.log(val) | ||
for(j=0;j<total;j++) | ||
{ | ||
if((total_data[j].communityname).includes(val)) | ||
{ | ||
console.log("klkl") | ||
addtoDOM(total_data[j]); | ||
} | ||
} | ||
if((total_data[j].communityname).includes(val)) | ||
{ | ||
addtoDOM(total_data[j]); | ||
} | ||
} | ||
} | ||
|
||
function getCommunities() | ||
function getCommunities() | ||
{ | ||
let obj = { | ||
start : start, | ||
end : end, | ||
} | ||
let request = new XMLHttpRequest() | ||
request.open('POST','/freeCommunities'); | ||
request.setRequestHeader('Content-Type','application/json') | ||
request.send(JSON.stringify(obj)); | ||
request.onload = function() | ||
{ | ||
let obj = { | ||
start : start, | ||
end : end, | ||
} | ||
console.log(obj); | ||
let request = new XMLHttpRequest() | ||
request.open('POST','/freeCommunities'); | ||
request.setRequestHeader('Content-Type','application/json') | ||
request.send(JSON.stringify(obj)); | ||
request.onload = function() | ||
{ | ||
data = JSON.parse(request.responseText); | ||
console.log(data); | ||
total+=data.length; | ||
total_data = total_data.concat(data); | ||
console.log(total_data); | ||
console.log("total + "+total); | ||
for(var i in data) | ||
addtoDOM(data[i]); | ||
} | ||
data = JSON.parse(request.responseText); | ||
total+=data.length; | ||
total_data = total_data.concat(data); | ||
for(var i in data) | ||
addtoDOM(data[i]); | ||
} | ||
} | ||
|
||
$(window).scroll(function() { | ||
if($(window).scrollTop() == $(document).height() - $(window).height()) { | ||
// ajax call get data from server and append to the div | ||
// console.log("dsddsj") | ||
start+=3; | ||
// end+=3; | ||
getCommunities(); | ||
} | ||
}); | ||
$(window).scroll(function() { | ||
if($(window).scrollTop() == $(document).height() - $(window).height()) { | ||
// ajax call get data from server and append to the div | ||
start+=3; | ||
getCommunities(); | ||
} | ||
}); |
Oops, something went wrong.