Skip to content

Commit b21fd12

Browse files
committed
initial commit
0 parents  commit b21fd12

File tree

4 files changed

+166
-0
lines changed

4 files changed

+166
-0
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# simpleQA
2+
A simple question answer application
3+
4+

css/style.css

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
body{
2+
background: #ebebeb;
3+
font-family: "Montserrat", sans-serif;
4+
font-style: normal;
5+
font-weight: normal;
6+
font-size: 14px;
7+
margin: 0 100px 100px 100px;
8+
-webkit-font-smoothing: antialiased;
9+
text-rendering: optimizeSpeed;
10+
}
11+
12+
.thumbnail img{
13+
width: 100%;
14+
}
15+
16+
.thumbnail .caption{
17+
min-height: 139px;
18+
}
19+
20+
.search{
21+
max-width: 450px;
22+
margin: 0 auto;
23+
margin-top: 50px;
24+
}
25+
26+
.filter ul{
27+
display: inline-block;
28+
}
29+
30+
.filter ul li{
31+
display: inline-block;
32+
}

index.html

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<!DOCTYPE html>
2+
<html ng-app="app">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>App Showcase</title>
6+
7+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css">
8+
<link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet">
9+
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
10+
<link rel="stylesheet" type="text/css" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
11+
<link rel="stylesheet" href="css/style.css">
12+
</head>
13+
14+
<body ng-controller="mainCtrl">
15+
<div class="row">
16+
<div class="col-md-offset-2 col-md-8 col-sm-12 col-xs-12">
17+
<div class="search">
18+
<div class="input-group">
19+
<input type="text" ng-model="user" class="form-control" placeholder="Search for...">
20+
<span class="input-group-btn">
21+
<button class="btn btn-default" ng-click="getUser()" type="button">Go!</button>
22+
</span>
23+
</div><!-- /input-group -->
24+
</div>
25+
</div>
26+
</div>
27+
<hr>
28+
<!-- <div >
29+
{{user.name}} -->
30+
<div class="col-md-offset-2 col-md-8 col-sm-12 col-xs-12">
31+
<div class="filter">
32+
Sort by
33+
<ul>
34+
<li ng-click="sortTag(1)">name</li>
35+
<li ng-click="sortTag(2)">location</li>
36+
<li ng-click="sortTag(3)">followers</li>
37+
</ul>
38+
</div>
39+
</div>
40+
<div class="container">
41+
<div class="row">
42+
<div ng-repeat="user in allUsers | orderBy:sortBy" class="col-xs-18 col-sm-6 col-md-3">
43+
<div class="thumbnail">
44+
<img ng-src="{{user.avatar_url}}">
45+
<div class="caption">
46+
<h4>{{user.name || user.login}}</h4>
47+
<p>Followers : {{user.followers}}</p>
48+
<p>Location : {{user.location}}</p>
49+
<a href="#" class="btn btn-default btn-xs pull-right" role="button"><i class="glyphicon glyphicon-edit"></i></a>
50+
<a href="#" class="btn btn-info btn-xs" role="button">Visit profile</a>
51+
<a href="#" ng-click="remove(user)" class="btn btn-danger btn-xs" role="button">Remove</a>
52+
</div>
53+
</div>
54+
</div>
55+
</div><!--/row-->
56+
</div><!--/container -->
57+
58+
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.1/angular.min.js"></script>
59+
<script src="js/app.js"></script>
60+
</body>
61+
</html>

js/app.js

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
2+
var app = angular.module('app',[]);
3+
4+
app.controller('mainCtrl',function($scope,$http){
5+
console.log("you are in the js now");
6+
7+
$scope.allUsers = [];
8+
9+
$scope.sortByLocation = false;
10+
$scope.sortByName = false;
11+
$scope.sortByFollowers = false;
12+
13+
$scope.getUser = function(){
14+
if(!$scope.user){
15+
return;
16+
}
17+
18+
$http({
19+
method : "GET",
20+
url : "https://api.github.com/users/"+$scope.user
21+
}).then(function(res){
22+
console.log(res);
23+
$scope.user = '';
24+
$scope.allUsers.push(res.data);
25+
},function(res){
26+
console.log(res);
27+
})
28+
};
29+
30+
$scope.remove = function(user){
31+
for(var i=0;i<$scope.allUsers.length;i++){
32+
if($scope.allUsers[i].id == user.id){
33+
$scope.allUsers.splice(i,1);
34+
}
35+
}
36+
}
37+
38+
$scope.sortTag = function(index){
39+
$scope.sortByName = false;
40+
$scope.sortByFollowers = false;
41+
$scope.sortByLocation = false;
42+
if(index == '1'){
43+
$scope.sortByName = true;
44+
} else if(index == '2'){
45+
sortByLocation = true;
46+
} else {
47+
sortByFollowers = true;
48+
}
49+
}
50+
51+
$scope.sortBy = function(user){
52+
if($scope.sortByName){
53+
return user.name;
54+
}
55+
if($scope.sortByFollowers){
56+
return user.followers;
57+
}
58+
if($scope.sortByLocation){
59+
return user.location;
60+
}
61+
}
62+
63+
});
64+
65+
app.factory('store',function(){
66+
67+
return{
68+
}
69+
})

0 commit comments

Comments
 (0)