karlfloersch / friends-r-us Goto Github PK
View Code? Open in Web Editor NEWA socail media app for the impared.
License: MIT License
A socail media app for the impared.
License: MIT License
Enable "Choose new profile picture."
It should be modeled after Facebook's messages. The left side should have all the people you have conversations with and the right side should be the messages for the selected user.
It adds a like to the comment, but does not get the like correctly.
When you type in stuff in the search bar it should autocomplete the names of friends and pages showing their profile image next to their name, as it does in Facebook.
See: http://stackoverflow.com/questions/23034772/integrating-image-with-jquery-autocomplete
Also see implementation in socs:
@login_required(redirect_field_name='/login')
def friend_ajax(request):
data = {'first_name': request.POST["first_name"]}
print(data)
print("\n\n")
data = db_views.get_possible_friends(request.user.username,
request.POST["first_name"])
print(data)
return HttpResponse(json.dumps(data), content_type="application/json")
// Setup stuff for the CSRF Token/post requests
// using jQuery
function getCookie(name) {
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
}
var csrftoken = getCookie('csrftoken');
function csrfSafeMethod(method) {
// these HTTP methods do not require CSRF protection
return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
}
$.ajaxSetup({
beforeSend: function(xhr, settings) {
if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
xhr.setRequestHeader("X-CSRFToken", csrftoken);
}
}
});
// End CSRF stuff
function addFriendAutoComplete() {
$("#studentName").keyup(function(){
var textValue = $("#studentName").val();
if(textValue.slice(-1) != " "){
return;
}
var firstName = textValue.trim();
var getUrl = window.location;
var baseUrl = getUrl .protocol + "//" + getUrl.host + "/" + getUrl.pathname.split('/')[1];
var urlSubmit = baseUrl + "/get-friends";
var data ={
"first_name": firstName
};
$.ajax({
type: "POST",
url: urlSubmit,
dataType: "json",
data : data,
success: function(response){
// set the autocomplete
console.log("working?");
console.log(response);
var students = [];//JSON.parse(response);
var i = 0;
for(i = 0; i < response.length; i++){
students.push(response[i].first_name + " " +
response[i].last_name + " - " + response[i].email);
}
console.log(students);
addAutoComplete($("#studentName"), students);
}
});
});
}
Right now you can upload whatever you want to the server. That is extremely dangerious. However, honestly we wouldn't be using Django's image upload service anyway in any real application. It is a development only feature. But while we are developing we should probably still validate the filetype.
jQuery: Alice McKeeny, on 05/06/2015
What it should be: May 7, 2015, 3:30 a.m.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.