Commit a8339847 by Jansa Jose

chat implementation

parent 8055a1fb
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Chat extends CI_Controller {
public function __construct() {
parent::__construct();
$this->load->model('Chat_model');
$this->load->helper('access');
if(!$this->session->userdata('logged_in')) {
redirect(base_url());
}
$class = $this->router->fetch_class();
$method = $this->router->fetch_method();
$r = check_access($class,$method);
// $r);exit();
if($r == false)
{
redirect(base_url().'welcome/error_404');
}
}
public function index (){
$template['page'] = "Chat/chatusers";
$template['page_title'] = "Chat Users";
$this->load->view('template',$template);
}
public function get_all_chat_users(){
//echo"dfg";
$data = $_POST;
$result = $this->Chat_model->get_all_chat_users($data);
echo json_encode($result);
}
public function get_all_chat_data(){
$template['page'] = "Chat/viewchat";
$template['page_title'] = "Chats";
$this->load->view('template',$template);
}
}
\ No newline at end of file
......@@ -1757,6 +1757,22 @@ public function goverment_upload_post(){
}
public function update_ride_status_post(){
$postdata = file_get_contents("php://input");
$request = json_decode($postdata);
$result=$this->Webservice_model->update_ride_status($request);
if($result){
$response=array('status' => 'success');
}else{
$response=array('status' => 'error');
}
print json_encode($response);
}
#################################################################################################
public function reject_booking_post(){
$postdata = file_get_contents("php://input");
......@@ -2767,6 +2783,117 @@ public function end_ride_update_post(){
print json_encode($res);
}
public function calculate_distance_post(){
$postdata = file_get_contents("php://input");
$request = json_decode($postdata,true);
$from = $request['source'];
$remFrom = str_replace(',', '', $from); //Remove Commas
$from = urlencode($remFrom);
$to = $request['destination'];
$remTo = str_replace(',', '', $to); //Remove Commas
$to = urlencode($remTo);
$data = file_get_contents("https://maps.googleapis.com/maps/api/distancematrix/json?&key=AIzaSyA30TEywZIiq6dv6l-JKezQWrEnLeoCiTc&origins=$from&destinations=$to&language=en-EN&sensor=false");
$data = json_decode($data, true);
$time = $data['rows'][0]['elements'][0]['duration']['text']; //Text for String and Value for INT
$distance = $data['rows'][0]['elements'][0]['distance']['text'];//T
$settings= $this->Webservice_model->getkm_charge();
$kmcharge=$distance *($settings->kmcharge);
if($kmcharge){
$res = array('status'=>'success','km_price'=>$kmcharge);
}else{
$res = array('status'=>'error');
}
print json_encode($res);
}
public function recurring_ride_post(){
$postdata = file_get_contents("php://input");
$request =(array) json_decode($postdata,true);
$recur_data = $this->Webservice_model->recurring_ride($request);
if($recur_data){
if($request['recur_type'] == '0'){
$monday = strtotime("last monday");
$monday = date('w', $monday)==date('w') ? $monday+7*86400 : $monday;
$sunday = strtotime(date("Y-m-d",$monday)." +6 days");
$this_week_sd = strtotime(date("Y-m-d",$monday));
$this_week_ed = strtotime(date("Y-m-d",$sunday));
$ride_data = $this->Webservice_model->get_recuring_rideid_data($request['ride_id']);
$depart_date= strtotime($ride_data->departure_date);
$ride_start_ride = strtotime($request['start_date']);
if(($ride_start_ride >= $this_week_sd) && ($ride_start_ride <= $this_week_ed)){
$numeric_depart_date = strtolower(date('l',$ride_start_ride));
if($request['week_available'][0][$numeric_depart_date]['status'] == 1){
$nextday = strtotime(date('Y-m-d', strtotime('+1 day',strtotime($ride_data->departure_date))));
$rec_res = $this->insert_new_recring_ride($ride_data,$this_week_ed,$request,$nextday);
if($rec_res){
$res = array('status'=>'success');
}else{
$res = array('status'=>'error');
}
}
}
}
}else{
$res = array('status'=>'error','error'=>'error','messgae'=>'Something Went Wrong.. Try Again Later');
}
print json_encode($res);
}
public function insert_new_recring_ride($ride_data,$this_week_ed,$request,$nextday){
$depart_date= strtotime($ride_data->departure_date);
$numeric_depart_date = strtolower(date('l',$depart_date));
if(($nextday <= $this_week_ed) && ($nextday <= $request['end_date'])){
$data =array('source'=>$ride_data['source'],
'destination'=>$ride_data['destination'],
'source_lat'=>$ride_data['source_lat'],
'source_lng'=>$ride_data['source_lng'],
'destination_lat'=>$ride_data['destination_lat'],
'destination_lng'=>$ride_data['destination_lng'],
'stopover'=>$ride_data['stopover'],
'stopover_lng'=>$ride_data['stopover_lng'],
'stopover_lat'=>$ride_data['stopover_lat'],
'pickup_flexibility'=>$ride_data['pickup_flexibility'],
'for_ladies'=>$ride_data['for_ladies'],
'to_airport'=>$ride_data['to_airport'],
'detour'=>$ride_data['detour'],
'no_of_seats'=>$ride_data['no_of_seats'],
'car_id'=>$ride_data['car_id'],
'max_luggage'=>$ride_data['max_luggage'],
'price'=>$ride_data['price'],
'users_id'=>$ride_data['users_id'],
'departure_date'=>$nextday,
'detour_time'=>$request['week_available'][0][$numeric_depart_date]['time'],
'reached_time'=>$ride_data['reached_time'],
'is_round_trip'=>$ride_data['is_round_trip'],
'status'=>1
);
$this->db->insert('ride',$data);
$nextday = strtotime(date('Y-m-d', strtotime('+1 day',$nextday)));
return $this->insert_new_recring_ride($ride_data,$this_week_ed,$request,$nextday);
}else{
return true;
}
}
/* public function newwelkdr_post(){
$monday = strtotime("last monday");
print_r(date('d-m-y',$monday));
$monday = date('w', $monday)==date('w') ? $monday+7*86400 : $monday;
$sunday = strtotime(date("Y-m-d",$monday)." +6 days");
$this_week_sd = date("Y-m-d",$monday);
$this_week_ed = date("Y-m-d",$sunday);
echo "Current week range from $this_week_sd to $this_week_ed ";
}*/
......
<?php
class Chat_model extends CI_Model {
public function _consruct(){
parent::_construct();
}
public function get_all_chat_users($data){
$user = array();
$i=0;
foreach ($data['user_id'] as $key => $value) {
$new = explode('-',$value);
$this->db->select("TRIM(concat(users.first_name,' ',IFNULL(users.last_name,''))) as name");
$user_first = $this->db->get_where('users',array('id'=>$new[0]))->row();
$name[0] = $user_first->name;
$this->db->select("TRIM(concat(users.first_name,' ',IFNULL(users.last_name,''))) as name");
$user_sec = $this->db->get_where('users',array('id'=>$new[1]))->row();
$name[1] = $user_sec->name;
$new_data = implode(' - ',$name);
$user[$i]['name']=$new_data;
$user[$i]['id']=$value;
$i++;
}
if($user){
return $user;
}
}
}
?>
\ No newline at end of file
......@@ -786,7 +786,6 @@ function get_cars_details(){
$query = $this->db->insert('car_details',array('user_id'=>$data['user_id'],'no_of_seats'=>$data['no_of_seats'],'car_year'=>$data['car_year'],'car_type'=>$data['car_type'],'car_make'=>$data['car_make'],'car_color'=>$data['car_color']));
// $car_id = $this->db->insert_id();
if($query){
return true;
}else{
......@@ -801,7 +800,6 @@ function get_cars_details(){
$query = $this->db->insert('ride',array('source'=>$data['place_from'],'destination'=>$data['place_to'],'departure_date '=>$data['dep_date'],'car_type'=>$data['car_type'],'car_make'=>$data['car_make'],'car_color'=>$data['car_color']));
// $car_id = $this->db->insert_id();
if($query){
return true;
}else{
......@@ -946,9 +944,9 @@ function get_cars_details(){
'comments'=>isset($request['comments'])?$request['comments']:'',
'max_luggage'=>$request['max_luggage'],
'users_id'=>$request['users_id'],
'stopover_lng'=>$request['stopover_lng'],
'stopover'=>$request['stopover'],
'stopover_lat'=>$request['stopover_lat'],
'stopover_lng'=>(isset($request['stopover_lng']) && !empty($request['stopover_lng']))? $request['stopover_lng'] : '0',
'stopover'=>(isset($request['stopover']) && !empty($request['stopover']))? $request['stopover'] : '0',
'stopover_lat'=>(isset($request['stopover_lat']) && !empty($request['stopover_lat']))? $request['stopover_lat'] : '0',
'car_id'=>$request['car_id']
);
/*if($request['check']=="round"){
......@@ -1029,7 +1027,10 @@ function get_cars_details(){
}
public function get_find_ride($request){
$this->db->where('no_of_seats >=',$request['seats']);
$this->db->where('ride.status!=',3);
$this->db->where('ride.status!=',2);
$this->db->where('ride.ride_status!=',3);
$this->db->or_where('ride.ride_status!=',4);
$this->db->or_where('ride.ride_status!=',5);
if($request['user_id']!='undefined'){
$this->db->where('users_id!=',$request['user_id']);
}
......@@ -1709,6 +1710,12 @@ function get_cars_details(){
}
public function update_ride_status($data){
if($this->db->update('ride',array('ride_status'=>$data->status),array('id'=>$data->ride_id))){
return true;
}
}
function reject_ride($request){
$data=array('status'=>2);
$this->db->where('booking_id',$request);
......@@ -2411,16 +2418,28 @@ public function otp_verify($data){
$request = $this->db->get_where('ride',array('id'=>$data['ride_id']))->row_array();
if($request){
$data =array('source'=>$request['source'],
'destination'=>$request['destination'],
'source_lat'=>$request['source_lat'],
'source_lng'=>$request['source_lng'],
'destination'=>$request['destination'],
'source_lat'=>$request['source_lat'],
'source_lng'=>$request['source_lng'],
'destination_lat'=>$request['destination_lat'],
'destination_lng'=>$request['destination_lng'],
'stopover'=>$request['stopover'],
'stopover_lng'=>$request['stopover_lng'],
'stopover_lat'=>$request['stopover_lat'],
'pickup_flexibility'=>$request['pickup_flexibility'],
'for_ladies'=>$request['for_ladies'],
'to_airport'=>$request['to_airport'],
'detour'=>$request['detour'],
'no_of_seats'=>$request['no_of_seats'],
'car_id'=>$request['car_id'],
'max_luggage'=>$request['max_luggage'],
'price'=>$request['price'],
'users_id'=>$request['users_id'],
'departure_date'=>$data['departure_date'],
'detour_time'=>$data['detour_time'],
'reached_time'=>$request['reached_time'],
'is_round_trip'=>$request['round_trip'],
'status'=>1,
'is_round_trip'=>$request['is_round_trip'],
'status'=>1
);
if($this->db->insert('ride',$data)){
$res = array('status'=>'success');
......@@ -2493,6 +2512,17 @@ public function otp_verify($data){
}
return $res;
}
public function recurring_ride($data){
$data['week_available'] = json_encode($data['week_available']);
if($this->db->insert('recurring_ride',$data)){
return true;
}
}
public function get_recuring_rideid_data($id){
return $this->db->get_where('ride',array('id'=>$id))->row();
}
......
<script src="https://www.gstatic.com/firebasejs/4.12.1/firebase.js"></script>
<script>
var config = {
apiKey: "AIzaSyB2_C7dz6z0-aRNoPzooVwtj1sEgTF5eK4",
authDomain: "joyride-9b774.firebaseapp.com",
databaseURL: "https://joyride-9b774.firebaseio.com",
projectId: "joyride-9b774",
storageBucket: "",
messagingSenderId: "1094203463203"
};
firebase.initializeApp(config);
</script>
<div ng-app='myApp'>
<div ng-controller="mainCtrl" ng-init="load_recent_chat()">
<div class="content-wrapper" >
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
Chat Users
</h1>
<ol class="breadcrumb">
<li><a href="#"><i class="fa fa-male"></i>Home</a></li>
<li class="active"> Chat Users</li>
</ol>
</section>
<!-- Main content -->
<section class="content">
<div class="row">
<div class="col-xs-12">
<?php
if($this->session->flashdata('message')) {
$message = $this->session->flashdata('message');
?>
<div class="alert alert-<?php echo $message['class']; ?>">
<button class="close" data-dismiss="alert" type="button">×</button>
<?php echo $message['message']; ?>
</div>
<?php
}
?>
</div>
<div class="col-xs-12">
<!-- /.box -->
<div class="box">
<div class="box-header">
<h3 class="box-title"> Chat Users</h3>
</div>
<!-- /.box-header -->
<div class="box-body">
<table class="table table-bordered table-striped datatable">
<thead>
<tr>
<th class="hidden">ID</th>
<th>Users</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="val in allUsers" >
<td class="hidden">1</td>
<td class="center">{{val.name}}</td>
<td class="center">
<a class="btn btn-sm btn-primary" href="<?php echo base_url();?>Chat/get_all_chat_data/{{val.id}}" >
<i class="fa fa-eye"></i> View Chat</a>
</td>
</tr>
</tbody>
</table>
</div>
<!-- /.box-body -->
</div>
<!-- /.box -->
</div>
<!-- /.col -->
</div>
<!-- /.row -->
</section>
<!-- /.content -->
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular.min.js"></script>
<script src="https://cdn.firebase.com/libs/angularfire/2.3.0/angularfire.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular-sanitize.min.js"></script>
<script src="<?php echo base_url(); ?>assets/js/chat/dist/ng-scrollbar.js"></script>
<script src="<?php echo base_url(); ?>assets/js/chat/jquery.js"></script>
<script src="<?php echo base_url(); ?>assets/js/chat/chat-page.js"></script>
<?php
$id = $this->uri->segment(3);
$new_id = explode('-',$id);
$id1 = $new_id[0];
$id2 = $new_id[1];
$name1 = $this->db->query("select(TRIM(concat(users.first_name,' ',IFNULL(users.last_name,'')))) as name from users where id =$id1")->row();
$name2 = $this->db->query("select(TRIM(concat(users.first_name,' ',IFNULL(users.last_name,'')))) as name from users where id =$id2")->row();
?>
<script src="https://www.gstatic.com/firebasejs/4.12.1/firebase.js"></script>
<script>
var config = {
apiKey: "AIzaSyB2_C7dz6z0-aRNoPzooVwtj1sEgTF5eK4",
authDomain: "joyride-9b774.firebaseapp.com",
databaseURL: "https://joyride-9b774.firebaseio.com",
projectId: "joyride-9b774",
storageBucket: "",
messagingSenderId: "1094203463203"
};
firebase.initializeApp(config);
</script>
<div ng-app='myApp'>
<div ng-controller="mainCtrl">
<div class="content-wrapper" ng-init="view_chats('<?php echo $id;?>')">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
View Chats
</h1>
<ol class="breadcrumb">
<li><a href="#"><i class="fa fa-male"></i>Home</a></li>
<li class="active"> View Chat</li>
</ol>
</section>
<!-- Main content -->
<section class="content">
<div class="row">
<div class="col-xs-12">
<?php
if($this->session->flashdata('message')) {
$message = $this->session->flashdata('message');
?>
<div class="alert alert-<?php echo $message['class']; ?>">
<button class="close" data-dismiss="alert" type="button">×</button>
<?php echo $message['message']; ?>
</div>
<?php
}
?>
</div>
<div class="col-xs-12">
<!-- /.box -->
<div class="box">
<div class="box-header">
<h3 class="box-title">View chats</h3>
</div>
<!-- /.box-header -->
<div class="box-body">
<div class="msg_box">
<ul ng-repeat="values in recentmsgs">
<li class="sender" ng-if="values.From_id == <?php echo $id1;?>">
<div class="sender_name"><?php echo $name1->name;?></div> <br>
<span class="msg_time">{{values.timestamp | date:'dd/MM/yy hh:mm a'}}</span><br>
<div class="message">{{values.message}}</div>
<div class="clear"></div>
</li>
<li class="receiver" ng-if="values.From_id == <?php echo $id2;?> ">
<div class="receiver_name"><?php echo $name2->name;?> </div>
<span class="msg_time">{{values.timestamp | date:'dd/MM/yy hh:mm a'}}</span><br>
<div class="message">{{values.message}}</div>
<div class="clear"></div>
</li>
</ul>
</div>
</div>
<!-- /.box-body -->
</div>
<!-- /.box -->
</div>
<!-- /.col -->
</div>
<!-- /.row -->
</section>
<!-- /.content -->
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular.min.js"></script>
<script src="https://cdn.firebase.com/libs/angularfire/2.3.0/angularfire.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular-sanitize.min.js"></script>
<script src="<?php echo base_url(); ?>assets/js/chat/dist/ng-scrollbar.js"></script>
<script src="<?php echo base_url(); ?>assets/js/chat/jquery.js"></script>
<script src="<?php echo base_url(); ?>assets/js/chat/chat-page.js"></script>
......@@ -68,7 +68,17 @@ $admin_detail = pull_admin();
<?php } ?>
</ul>
</li>
<?php } if( in_array('11',$page_name) || in_array('12',$page_name) || in_array('13',$page_name))
<?php } ?>
<li class="treeview"><a href="<?php echo base_url();?>chat/index"><i class="fa fa-male"></i> <span>Chat</span><i class="fa fa-angle-left pull-right"></i></a>
</li>
<?php if( in_array('11',$page_name) || in_array('12',$page_name) || in_array('13',$page_name))
{?>
<li class="treeview"><a href="#"><i class="fa fa-th" aria-hidden="true"></i> <span>Offer Rides</span><i class="fa fa-angle-left pull-right"></i></a>
<ul class="treeview-menu">
......
......@@ -95,6 +95,73 @@
margin-top:10px;
height: 41px;
}
.msg_box {
max-height: 350px;
height: 350px;
border: 1px solid #ccc;
background: transparent;
width: 100%;
overflow-x: auto;
}
.msg_box ul {
margin: 0px;
padding: 0px;
}
.msg_box ul li {
margin: 0px;
padding: 0px;
list-style: none;
font-size: 14px;
width: 100%;
float: left;
}
.msg_box .sender .message {
float: right;
background: #162d38;
max-width: 65%;
text-align: justify;
color: #fff;
padding: 10px;
margin: 5px;
border-radius: 10px;
margin-top: 5px
}
.msg_box .receiver .message {
float: left;
background: #faae3f;
max-width: 65%;
text-align: justify;
color: #fff;
padding: 10px;
margin: 5px;
border-radius: 10px;
margin-top: 5px
}
.msg_box .sender .sender_name{
float: right;
font-weight: 600;
color: #ff7703;
}
.msg_box .sender .msg_time{
float: right;
font-weight:200;
color: #ff7703;
}
.msg_box .receiver .msg_time{
font-weight:200;
color: #ff7703;
float: left;
}
.msg_box .receiver .receiver_name{
font-weight: 600;
color: #ff7703;
}
......
This source diff could not be displayed because it is too large. You can view the blob instead.
/*!
* AngularFire is the officially supported AngularJS binding for Firebase. Firebase
* is a full backend so you don't need servers to build your Angular app. AngularFire
* provides you with the $firebase service which allows you to easily keep your $scope
* variables in sync with your Firebase backend.
*
* AngularFire 2.0.2
* https://github.com/firebase/angularfire/
* Date: 08/19/2016
* License: MIT
*/
!function(a){"use strict";angular.module("firebase.utils",[]),angular.module("firebase.config",[]),angular.module("firebase.auth",["firebase.utils"]),angular.module("firebase.database",["firebase.utils"]),angular.module("firebase",["firebase.utils","firebase.config","firebase.auth","firebase.database"]).value("Firebase",a.firebase).value("firebase",a.firebase)}(window),function(){"use strict";var a;angular.module("firebase.auth").factory("$firebaseAuth",["$q","$firebaseUtils",function(b,c){return function(d){d=d||firebase.auth();var e=new a(b,c,d);return e.construct()}}]),a=function(a,b,c){if(this._q=a,this._utils=b,"string"==typeof c)throw new Error("The $firebaseAuth service accepts a Firebase auth instance (or nothing) instead of a URL.");if("undefined"!=typeof c.ref)throw new Error("The $firebaseAuth service accepts a Firebase auth instance (or nothing) instead of a Database reference.");this._auth=c,this._initialAuthResolver=this._initAuthResolver()},a.prototype={construct:function(){return this._object={$signInWithCustomToken:this.signInWithCustomToken.bind(this),$signInAnonymously:this.signInAnonymously.bind(this),$signInWithEmailAndPassword:this.signInWithEmailAndPassword.bind(this),$signInWithPopup:this.signInWithPopup.bind(this),$signInWithRedirect:this.signInWithRedirect.bind(this),$signInWithCredential:this.signInWithCredential.bind(this),$signOut:this.signOut.bind(this),$onAuthStateChanged:this.onAuthStateChanged.bind(this),$getAuth:this.getAuth.bind(this),$requireSignIn:this.requireSignIn.bind(this),$waitForSignIn:this.waitForSignIn.bind(this),$createUserWithEmailAndPassword:this.createUserWithEmailAndPassword.bind(this),$updatePassword:this.updatePassword.bind(this),$updateEmail:this.updateEmail.bind(this),$deleteUser:this.deleteUser.bind(this),$sendPasswordResetEmail:this.sendPasswordResetEmail.bind(this),_:this},this._object},signInWithCustomToken:function(a){return this._q.when(this._auth.signInWithCustomToken(a))},signInAnonymously:function(){return this._q.when(this._auth.signInAnonymously())},signInWithEmailAndPassword:function(a,b){return this._q.when(this._auth.signInWithEmailAndPassword(a,b))},signInWithPopup:function(a){return this._q.when(this._auth.signInWithPopup(this._getProvider(a)))},signInWithRedirect:function(a){return this._q.when(this._auth.signInWithRedirect(this._getProvider(a)))},signInWithCredential:function(a){return this._q.when(this._auth.signInWithCredential(a))},signOut:function(){return null!==this.getAuth()?this._q.when(this._auth.signOut()):this._q.when()},onAuthStateChanged:function(a,b){var c=this._utils.debounce(a,b,0),d=this._auth.onAuthStateChanged(c);return d},getAuth:function(){return this._auth.currentUser},_routerMethodOnAuthPromise:function(a){var b=this;return this._initialAuthResolver.then(function(){var c=b.getAuth(),d=null;return d=a&&null===c?b._q.reject("AUTH_REQUIRED"):b._q.when(c)})},_getProvider:function(a){var b;if("string"==typeof a){var c=a.slice(0,1).toUpperCase()+a.slice(1);b=new firebase.auth[c+"AuthProvider"]}else b=a;return b},_initAuthResolver:function(){var a=this._auth;return this._q(function(b){function c(){d(),b()}var d;d=a.onAuthStateChanged(c)})},requireSignIn:function(){return this._routerMethodOnAuthPromise(!0)},waitForSignIn:function(){return this._routerMethodOnAuthPromise(!1)},createUserWithEmailAndPassword:function(a,b){return this._q.when(this._auth.createUserWithEmailAndPassword(a,b))},updatePassword:function(a){var b=this.getAuth();return b?this._q.when(b.updatePassword(a)):this._q.reject("Cannot update password since there is no logged in user.")},updateEmail:function(a){var b=this.getAuth();return b?this._q.when(b.updateEmail(a)):this._q.reject("Cannot update email since there is no logged in user.")},deleteUser:function(){var a=this.getAuth();return a?this._q.when(a.delete()):this._q.reject("Cannot delete user since there is no logged in user.")},sendPasswordResetEmail:function(a){return this._q.when(this._auth.sendPasswordResetEmail(a))}}}(),function(){"use strict";function a(a){return a()}a.$inject=["$firebaseAuth"],angular.module("firebase.auth").factory("$firebaseAuthService",a)}(),function(){"use strict";angular.module("firebase.database").factory("$firebaseArray",["$log","$firebaseUtils","$q",function(a,b,c){function d(a){if(!(this instanceof d))return new d(a);var c=this;return this._observers=[],this.$list=[],this._ref=a,this._sync=new e(this),b.assertValidRef(a,"Must pass a valid Firebase reference to $firebaseArray (not a string or URL)"),this._indexCache={},b.getPublicMethods(c,function(a,b){c.$list[b]=a.bind(c)}),this._sync.init(this.$list),this.$list}function e(d){function e(a){if(!r.isDestroyed){r.isDestroyed=!0;var b=d.$ref();b.off("child_added",j),b.off("child_moved",l),b.off("child_changed",k),b.off("child_removed",m),d=null,q(a||"destroyed")}}function f(b){var c=d.$ref();c.on("child_added",j,p),c.on("child_moved",l,p),c.on("child_changed",k,p),c.on("child_removed",m,p),c.once("value",function(c){angular.isArray(c.val())&&a.warn("Storing data using array indices in Firebase can result in unexpected behavior. See https://firebase.google.com/docs/database/web/structure-data for more information."),q(null,b)},q)}function g(a,b){o||(o=!0,a?i.reject(a):i.resolve(b))}function h(a,b){var d=c.when(a);d.then(function(a){a&&b(a)}),o||n.push(d)}var i=c.defer(),j=function(a,b){d&&h(d.$$added(a,b),function(a){d.$$process("child_added",a,b)})},k=function(a){if(d){var b=d.$getRecord(a.key);b&&h(d.$$updated(a),function(){d.$$process("child_changed",b)})}},l=function(a,b){if(d){var c=d.$getRecord(a.key);c&&h(d.$$moved(a,b),function(){d.$$process("child_moved",c,b)})}},m=function(a){if(d){var b=d.$getRecord(a.key);b&&h(d.$$removed(a),function(){d.$$process("child_removed",b)})}},n=[],o=!1,p=b.batch(function(a){g(a),d&&d.$$error(a)}),q=b.batch(g),r={destroy:e,isDestroyed:!1,init:f,ready:function(){return i.promise.then(function(a){return c.all(n).then(function(){return a})})}};return r}return d.prototype={$add:function(a){this._assertNotDestroyed("$add");var d,e=this,f=c.defer(),g=this.$ref().ref.push();try{d=b.toJSON(a)}catch(a){f.reject(a)}return"undefined"!=typeof d&&b.doSet(g,d).then(function(){e.$$notify("child_added",g.key),f.resolve(g)}).catch(f.reject),f.promise},$save:function(a){this._assertNotDestroyed("$save");var d=this,e=d._resolveItem(a),f=d.$keyAt(e),g=c.defer();if(null!==f){var h,i=d.$ref().ref.child(f);try{h=b.toJSON(e)}catch(a){g.reject(a)}"undefined"!=typeof h&&b.doSet(i,h).then(function(){d.$$notify("child_changed",f),g.resolve(i)}).catch(g.reject)}else g.reject("Invalid record; could not determine key for "+a);return g.promise},$remove:function(a){this._assertNotDestroyed("$remove");var d=this.$keyAt(a);if(null!==d){var e=this.$ref().ref.child(d);return b.doRemove(e).then(function(){return e})}return c.reject("Invalid record; could not determine key for "+a)},$keyAt:function(a){var b=this._resolveItem(a);return this.$$getKey(b)},$indexFor:function(a){var b=this,c=b._indexCache;if(!c.hasOwnProperty(a)||b.$keyAt(c[a])!==a){var d=b.$list.findIndex(function(c){return b.$$getKey(c)===a});d!==-1&&(c[a]=d)}return c.hasOwnProperty(a)?c[a]:-1},$loaded:function(a,b){var c=this._sync.ready();return arguments.length&&(c=c.then.call(c,a,b)),c},$ref:function(){return this._ref},$watch:function(a,b){var c=this._observers;return c.push([a,b]),function(){var d=c.findIndex(function(c){return c[0]===a&&c[1]===b});d>-1&&c.splice(d,1)}},$destroy:function(a){this._isDestroyed||(this._isDestroyed=!0,this._sync.destroy(a),this.$list.length=0)},$getRecord:function(a){var b=this.$indexFor(a);return b>-1?this.$list[b]:null},$$added:function(a){var c=this.$indexFor(a.key);if(c===-1){var d=a.val();return angular.isObject(d)||(d={$value:d}),d.$id=a.key,d.$priority=a.getPriority(),b.applyDefaults(d,this.$$defaults),d}return!1},$$removed:function(a){return this.$indexFor(a.key)>-1},$$updated:function(a){var c=!1,d=this.$getRecord(a.key);return angular.isObject(d)&&(c=b.updateRec(d,a),b.applyDefaults(d,this.$$defaults)),c},$$moved:function(a){var b=this.$getRecord(a.key);return!!angular.isObject(b)&&(b.$priority=a.getPriority(),!0)},$$error:function(b){a.error(b),this.$destroy(b)},$$getKey:function(a){return angular.isObject(a)?a.$id:null},$$process:function(a,b,c){var d,e=this.$$getKey(b),f=!1;switch(a){case"child_added":d=this.$indexFor(e);break;case"child_moved":d=this.$indexFor(e),this._spliceOut(e);break;case"child_removed":f=null!==this._spliceOut(e);break;case"child_changed":f=!0;break;default:throw new Error("Invalid event type: "+a)}return angular.isDefined(d)&&(f=this._addAfter(b,c)!==d),f&&this.$$notify(a,e,c),f},$$notify:function(a,b,c){var d={event:a,key:b};angular.isDefined(c)&&(d.prevChild=c),angular.forEach(this._observers,function(a){a[0].call(a[1],d)})},_addAfter:function(a,b){var c;return null===b?c=0:(c=this.$indexFor(b)+1,0===c&&(c=this.$list.length)),this.$list.splice(c,0,a),this._indexCache[this.$$getKey(a)]=c,c},_spliceOut:function(a){var b=this.$indexFor(a);return b>-1?(delete this._indexCache[a],this.$list.splice(b,1)[0]):null},_resolveItem:function(a){var b=this.$list;if(angular.isNumber(a)&&a>=0&&b.length>=a)return b[a];if(angular.isObject(a)){var c=this.$$getKey(a),d=this.$getRecord(c);return d===a?d:null}return null},_assertNotDestroyed:function(a){if(this._isDestroyed)throw new Error("Cannot call "+a+" method on a destroyed $firebaseArray object")}},d.$extend=function(a,c){return 1===arguments.length&&angular.isObject(a)&&(c=a,a=function(b){return this instanceof a?(d.apply(this,arguments),this.$list):new a(b)}),b.inherit(a,d,c)},d}]),angular.module("firebase").factory("$FirebaseArray",["$log","$firebaseArray",function(a,b){return function(){return a.warn("$FirebaseArray has been renamed. Use $firebaseArray instead."),b.apply(null,arguments)}}])}(),function(){"use strict";angular.module("firebase.database").factory("$firebaseObject",["$parse","$firebaseUtils","$log","$q",function(a,b,c,d){function e(a){return this instanceof e?(this.$$conf={sync:new g(this,a),ref:a,binding:new f(this),listeners:[]},Object.defineProperty(this,"$$conf",{value:this.$$conf}),this.$id=a.ref.key,this.$priority=null,b.applyDefaults(this,this.$$defaults),void this.$$conf.sync.init()):new e(a)}function f(a){this.subs=[],this.scope=null,this.key=null,this.rec=a}function g(a,e){function f(b){n.isDestroyed||(n.isDestroyed=!0,e.off("value",k),a=null,m(b||"destroyed"))}function g(){e.on("value",k,l),e.once("value",function(a){angular.isArray(a.val())&&c.warn("Storing data using array indices in Firebase can result in unexpected behavior. See https://firebase.google.com/docs/database/web/structure-data for more information. Also note that you probably wanted $firebaseArray and not $firebaseObject."),m(null)},m)}function h(b){i||(i=!0,b?j.reject(b):j.resolve(a))}var i=!1,j=d.defer(),k=b.batch(function(b){var c=a.$$updated(b);c&&a.$$notify()}),l=b.batch(function(b){h(b),a&&a.$$error(b)}),m=b.batch(h),n={isDestroyed:!1,destroy:f,init:g,ready:function(){return j.promise}};return n}return e.prototype={$save:function(){var a,c=this,e=c.$ref(),f=d.defer();try{a=b.toJSON(c)}catch(a){f.reject(a)}return"undefined"!=typeof a&&b.doSet(e,a).then(function(){c.$$notify(),f.resolve(c.$ref())}).catch(f.reject),f.promise},$remove:function(){var a=this;return b.trimKeys(a,{}),a.$value=null,b.doRemove(a.$ref()).then(function(){return a.$$notify(),a.$ref()})},$loaded:function(a,b){var c=this.$$conf.sync.ready();return arguments.length&&(c=c.then.call(c,a,b)),c},$ref:function(){return this.$$conf.ref},$bindTo:function(a,b){var c=this;return c.$loaded().then(function(){return c.$$conf.binding.bindTo(a,b)})},$watch:function(a,b){var c=this.$$conf.listeners;return c.push([a,b]),function(){var d=c.findIndex(function(c){return c[0]===a&&c[1]===b});d>-1&&c.splice(d,1)}},$destroy:function(a){var c=this;c.$isDestroyed||(c.$isDestroyed=!0,c.$$conf.sync.destroy(a),c.$$conf.binding.destroy(),b.each(c,function(a,b){delete c[b]}))},$$updated:function(a){var c=b.updateRec(this,a);return b.applyDefaults(this,this.$$defaults),c},$$error:function(a){c.error(a),this.$destroy(a)},$$scopeUpdated:function(a){var c=d.defer();return this.$ref().set(b.toJSON(a),b.makeNodeResolver(c)),c.promise},$$notify:function(){var a=this,b=this.$$conf.listeners.slice();angular.forEach(b,function(b){b[0].call(b[1],{event:"value",key:a.$id})})},forEach:function(a,c){return b.each(this,a,c)}},e.$extend=function(a,c){return 1===arguments.length&&angular.isObject(a)&&(c=a,a=function(b){return this instanceof a?void e.apply(this,arguments):new a(b)}),b.inherit(a,e,c)},f.prototype={assertNotBound:function(a){if(this.scope){var b="Cannot bind to "+a+" because this instance is already bound to "+this.key+"; one binding per instance (call unbind method or create another FirebaseObject instance)";return c.error(b),d.reject(b)}},bindTo:function(c,d){function e(e){function f(a){return angular.equals(a,k)&&a.$priority===k.$priority&&a.$value===k.$value}function g(a){j.assign(c,b.scopeData(a))}function h(){var a=j(c);return[a,a.$priority,a.$value]}var i=!1,j=a(d),k=e.rec;e.scope=c,e.varName=d;var l=b.debounce(function(a){var d=b.scopeData(a);k.$$scopeUpdated(d).finally(function(){i=!1,d.hasOwnProperty("$value")||(delete k.$value,delete j(c).$value),g(k)})},50,500),m=function(a){a=a[0],f(a)||(i=!0,l(a))},n=function(){i||f(j(c))||g(k)};return g(k),e.subs.push(c.$on("$destroy",e.unbind.bind(e))),e.subs.push(c.$watch(h,m,!0)),e.subs.push(k.$watch(n)),e.unbind.bind(e)}return this.assertNotBound(d)||e(this)},unbind:function(){this.scope&&(angular.forEach(this.subs,function(a){a()}),this.subs=[],this.scope=null,this.key=null)},destroy:function(){this.unbind(),this.rec=null}},e}]),angular.module("firebase").factory("$FirebaseObject",["$log","$firebaseObject",function(a,b){return function(){return a.warn("$FirebaseObject has been renamed. Use $firebaseObject instead."),b.apply(null,arguments)}}])}(),function(){"use strict";function a(){this.urls=null,this.registerUrl=function(a){"string"==typeof a&&(this.urls={},this.urls.default=a),angular.isObject(a)&&(this.urls=a)},this.$$checkUrls=function(a){return a?a.default?void 0:new Error('No default Firebase URL registered. Use firebaseRefProvider.registerUrl({ default: "https://<my-firebase-app>.firebaseio.com/"}).'):new Error("No Firebase URL registered. Use firebaseRefProvider.registerUrl() in the config phase. This is required if you are using $firebaseAuthService.")},this.$$createRefsFromUrlConfig=function(a){var b={},c=this.$$checkUrls(a);if(c)throw c;return angular.forEach(a,function(a,c){b[c]=firebase.database().refFromURL(a)}),b},this.$get=function(){return this.$$createRefsFromUrlConfig(this.urls)}}angular.module("firebase.database").provider("$firebaseRef",a)}(),function(){"use strict";angular.module("firebase").factory("$firebase",function(){return function(){throw new Error("$firebase has been removed. You may instantiate $firebaseArray and $firebaseObject directly now. For simple write operations, just use the Firebase ref directly. See the AngularFire 1.0.0 changelog for details: https://github.com/firebase/angularfire/releases/tag/v1.0.0")}})}(),Array.prototype.indexOf||(Array.prototype.indexOf=function(a,b){if(void 0===this||null===this)throw new TypeError("'this' is null or not defined");var c=this.length>>>0;for(b=+b||0,Math.abs(b)===1/0&&(b=0),b<0&&(b+=c,b<0&&(b=0));b<c;b++)if(this[b]===a)return b;return-1}),Function.prototype.bind||(Function.prototype.bind=function(a){if("function"!=typeof this)throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var b=Array.prototype.slice.call(arguments,1),c=this,d=function(){},e=function(){return c.apply(this instanceof d&&a?this:a,b.concat(Array.prototype.slice.call(arguments)))};return d.prototype=this.prototype,e.prototype=new d,e}),Array.prototype.findIndex||Object.defineProperty(Array.prototype,"findIndex",{enumerable:!1,configurable:!0,writable:!0,value:function(a){if(null==this)throw new TypeError("Array.prototype.find called on null or undefined");if("function"!=typeof a)throw new TypeError("predicate must be a function");for(var b,c=Object(this),d=c.length>>>0,e=arguments[1],f=0;f<d;f++)if(f in c&&(b=c[f],a.call(e,b,f,c)))return f;return-1}}),"function"!=typeof Object.create&&!function(){var a=function(){};Object.create=function(b){if(arguments.length>1)throw new Error("Second argument not supported");if(null===b)throw new Error("Cannot set a null [[Prototype]]");if("object"!=typeof b)throw new TypeError("Argument must be an object");return a.prototype=b,new a}}(),Object.keys||(Object.keys=function(){"use strict";var a=Object.prototype.hasOwnProperty,b=!{toString:null}.propertyIsEnumerable("toString"),c=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],d=c.length;return function(e){if("object"!=typeof e&&("function"!=typeof e||null===e))throw new TypeError("Object.keys called on non-object");var f,g,h=[];for(f in e)a.call(e,f)&&h.push(f);if(b)for(g=0;g<d;g++)a.call(e,c[g])&&h.push(c[g]);return h}}()),"function"!=typeof Object.getPrototypeOf&&("object"==typeof"test".__proto__?Object.getPrototypeOf=function(a){return a.__proto__}:Object.getPrototypeOf=function(a){return a.constructor.prototype}),function(){"use strict";function a(b){if(!angular.isObject(b))return b;var c=angular.isArray(b)?[]:{};return angular.forEach(b,function(b,d){"string"==typeof d&&"$"===d.charAt(0)||(c[d]=a(b))}),c}angular.module("firebase.utils").factory("$firebaseConfig",["$firebaseArray","$firebaseObject","$injector",function(a,b,c){return function(d){var e=angular.extend({},d);return"string"==typeof e.objectFactory&&(e.objectFactory=c.get(e.objectFactory)),"string"==typeof e.arrayFactory&&(e.arrayFactory=c.get(e.arrayFactory)),angular.extend({arrayFactory:a,objectFactory:b},e)}}]).factory("$firebaseUtils",["$q","$timeout","$rootScope",function(b,c,d){var e={batch:function(a,b){return function(){var c=Array.prototype.slice.call(arguments,0);e.compile(function(){a.apply(b,c)})}},debounce:function(a,b,c,d){function f(){j&&(j(),j=null),i&&Date.now()-i>d?l||(l=!0,e.compile(g)):(i||(i=Date.now()),j=e.wait(g,c))}function g(){j=null,i=null,l=!1,a.apply(b,k)}function h(){k=Array.prototype.slice.call(arguments,0),f()}var i,j,k,l;if("number"==typeof b&&(d=c,c=b,b=null),"number"!=typeof c)throw new Error("Must provide a valid integer for wait. Try 0 for a default");if("function"!=typeof a)throw new Error("Must provide a valid function to debounce");return d||(d=10*c||100),h.running=function(){return i>0},h},assertValidRef:function(a,b){if(!angular.isObject(a)||"object"!=typeof a.ref||"function"!=typeof a.ref.transaction)throw new Error(b||"Invalid Firebase reference")},inherit:function(a,b,c){var d=a.prototype;return a.prototype=Object.create(b.prototype),a.prototype.constructor=a,angular.forEach(Object.keys(d),function(b){a.prototype[b]=d[b]}),angular.isObject(c)&&angular.extend(a.prototype,c),a},getPrototypeMethods:function(a,b,c){for(var d={},e=Object.getPrototypeOf({}),f=angular.isFunction(a)&&angular.isObject(a.prototype)?a.prototype:Object.getPrototypeOf(a);f&&f!==e;){for(var g in f)f.hasOwnProperty(g)&&!d.hasOwnProperty(g)&&(d[g]=!0,b.call(c,f[g],g,f));f=Object.getPrototypeOf(f)}},getPublicMethods:function(a,b,c){e.getPrototypeMethods(a,function(a,d){"function"==typeof a&&"_"!==d.charAt(0)&&b.call(c,a,d)})},makeNodeResolver:function(a){return function(b,c){null===b?(arguments.length>2&&(c=Array.prototype.slice.call(arguments,1)),a.resolve(c)):a.reject(b)}},wait:function(a,b){var d=c(a,b||0);return function(){d&&(c.cancel(d),d=null)}},compile:function(a){return d.$evalAsync(a||function(){})},deepCopy:function(a){if(!angular.isObject(a))return a;var b=angular.isArray(a)?a.slice():angular.extend({},a);for(var c in b)b.hasOwnProperty(c)&&angular.isObject(b[c])&&(b[c]=e.deepCopy(b[c]));return b},trimKeys:function(a,b){e.each(a,function(c,d){b.hasOwnProperty(d)||delete a[d]})},scopeData:function(a){var b={$id:a.$id,$priority:a.$priority},c=!1;return e.each(a,function(a,d){c=!0,b[d]=e.deepCopy(a)}),!c&&a.hasOwnProperty("$value")&&(b.$value=a.$value),b},updateRec:function(a,b){var c=b.val(),d=angular.extend({},a);return angular.isObject(c)?delete a.$value:(a.$value=c,c={}),e.trimKeys(a,c),angular.extend(a,c),a.$priority=b.getPriority(),!angular.equals(d,a)||d.$value!==a.$value||d.$priority!==a.$priority},applyDefaults:function(a,b){return angular.isObject(b)&&angular.forEach(b,function(b,c){a.hasOwnProperty(c)||(a[c]=b)}),a},dataKeys:function(a){var b=[];return e.each(a,function(a,c){b.push(c)}),b},each:function(a,b,c){if(angular.isObject(a)){for(var d in a)if(a.hasOwnProperty(d)){var e=d.charAt(0);"_"!==e&&"$"!==e&&"."!==e&&b.call(c,a[d],d,a)}}else if(angular.isArray(a))for(var f=0,g=a.length;f<g;f++)b.call(c,a[f],f,a);return a},toJSON:function(b){var c;return angular.isObject(b)||(b={$value:b}),angular.isFunction(b.toJSON)?c=b.toJSON():(c={},e.each(b,function(b,d){c[d]=a(b)})),angular.isDefined(b.$value)&&0===Object.keys(c).length&&null!==b.$value&&(c[".value"]=b.$value),angular.isDefined(b.$priority)&&Object.keys(c).length>0&&null!==b.$priority&&(c[".priority"]=b.$priority),angular.forEach(c,function(a,b){if(b.match(/[.$\[\]#\/]/)&&".value"!==b&&".priority"!==b)throw new Error("Invalid key "+b+" (cannot contain .$[]#/)");if(angular.isUndefined(a))throw new Error("Key "+b+" was undefined. Cannot pass undefined in JSON. Use null instead.")}),c},doSet:function(a,c){var d=b.defer();if(angular.isFunction(a.set)||!angular.isObject(c))try{a.set(c,e.makeNodeResolver(d))}catch(a){d.reject(a)}else{var f=angular.extend({},c);a.once("value",function(b){b.forEach(function(a){f.hasOwnProperty(a.key)||(f[a.key]=null)}),a.ref.update(f,e.makeNodeResolver(d))},function(a){d.reject(a)})}return d.promise},doRemove:function(a){var c=b.defer();return angular.isFunction(a.remove)?a.remove(e.makeNodeResolver(c)):a.once("value",function(b){var d=[];b.forEach(function(a){d.push(a.ref.remove())}),e.allPromises(d).then(function(){c.resolve(a)},function(a){c.reject(a)})},function(a){c.reject(a)}),c.promise},VERSION:"2.0.2",allPromises:b.all.bind(b)};return e}])}();
\ No newline at end of file
var App = angular.module('myApp', ['firebase','ngSanitize']);
App.directive('ngEnter', function () {
return function (scope, element, attrs) {
element.bind("keydown keypress", function (event) {
if(event.which === 13) {
scope.$apply(function (){
scope.$eval(attrs.ngEnter);
});
event.preventDefault();
}
});
};
});
App.controller("mainCtrl", function($scope,$timeout,$firebaseObject,$rootScope,$http,$sce)
{
$scope.variables = {};
$scope.recentmsgs = [];
$scope.messages = [];
$scope.list = [];
$scope.load_recent_chat = function(){
//var datas = [];
var connRef = firebase.database().ref('chats');
connRef.on('value', function(snapshot)
{
$scope.messages = snapshot.val();
angular.forEach($scope.messages,(data,key)=>{
$scope.list.push(key);
})
console.log($scope.list);
$.ajax({
url: base_url+"Chat/get_all_chat_users",
type: "POST",
dataType: "json",
data:{"user_id": $scope.list},
success: function(result,status){
console.log(result);
$scope.allUsers = result;
$scope.$apply();
},
complete(xhr,status){
//console.log('completed')
},
error(xhr,status,error){
// alert(status)
}
})
});
}
$scope.view_chats = function(id){
var connRef = firebase.database().ref('chats/'+id+'/').orderByChild("timestamp");
connRef.on('value', function(snapshot)
{
$scope.messages = snapshot.val();
angular.forEach($scope.messages,(data,key)=>{
var d = new Date(data.timestamp);
var dat=(d.getDate() + '/' + (d.getMonth()+1) + '/' + d.getFullYear());
console.log(dat);
var a = $scope.list.indexOf(dat);
/*if(a=="-1")
{
$scope.list.push(dat);
data.show_date = true;
}
else
{data.show_date = false;}*/
$scope.recentmsgs.push(data);
$scope.$apply();
})
console.log($scope.recentmsgs);
// $timeout(function(){$scope.$apply()},5);
// $timeout(function()
// {
// var scroller = document.getElementById("chat_autoscroll");
// scroller.scrollTop = scroller.scrollHeight;
// }, 10,false);
//console.log($scope.messages)
});
}
});
\ No newline at end of file
.ngsb-wrap {
-ms-touch-action: none;
}
.ngsb-wrap .ngsb-container {
width: auto;
overflow: hidden;
transition: 0.5s all;
}
.ngsb-wrap:hover .ngsb-scrollbar {
opacity: 1;
filter: "alpha(opacity=100)";
-ms-filter: "alpha(opacity=100)";
/* old ie */
}
.ngsb-wrap .ngsb-scrollbar {
width: 16px;
height: 100%;
top: 0;
right: 0;
opacity: 0.75;
filter: "alpha(opacity=75)";
-ms-filter: "alpha(opacity=75)";
/* old ie */
}
.ngsb-wrap .ngsb-scrollbar .ngsb-thumb-container {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
height: auto;
}
.ngsb-wrap .ngsb-scrollbar a.ngsb-thumb-container {
margin: 20px 0;
}
.ngsb-wrap .ngsb-scrollbar .ngsb-track {
height: 100%;
margin: 0 auto;
width: 6px;
background: #000;
background: rgba(0, 0, 0, 0.4);
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
border-radius: 2px;
filter: "alpha(opacity=40)";
-ms-filter: "alpha(opacity=40)";
/* old ie */
box-shadow: 1px 1px 1px rgba(255, 255, 255, 0.1);
}
.ngsb-wrap .ngsb-scrollbar .ngsb-thumb-pos {
cursor: pointer;
width: 100%;
height: 30px;
}
.ngsb-wrap .ngsb-scrollbar .ngsb-thumb-pos .ngsb-thumb {
transition: 0.5s all;
width: 4px;
height: 100%;
margin: 0 auto;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
text-align: center;
background: #fff;
/* rgba fallback */
background: rgba(255, 255, 255, 0.4);
filter: "alpha(opacity=40)";
-ms-filter: "alpha(opacity=40)";
/* old ie */
}
.ngsb-wrap .ngsb-scrollbar .ngsb-thumb-pos:hover .ngsb-thumb {
background: rgba(255, 255, 255, 0.5);
filter: "alpha(opacity=50)";
-ms-filter: "alpha(opacity=50)";
/* old ie */
}
.ngsb-wrap .ngsb-scrollbar .ngsb-thumb-pos:active {
background: rgba(255, 255, 255, 0.6);
filter: "alpha(opacity=60)";
-ms-filter: "alpha(opacity=60)";
/* old ie */
}
'use strict';
angular.module('ngScrollbar', []).directive('ngScrollbar', [
'$parse',
'$window',
function ($parse, $window) {
return {
restrict: 'A',
replace: true,
transclude: true,
scope: { 'showYScrollbar': '=?isBarShown' },
link: function (scope, element, attrs) {
var mainElm, transculdedContainer, tools, thumb, thumbLine, track;
var flags = { bottom: attrs.hasOwnProperty('bottom') };
var win = angular.element($window);
var hasAddEventListener = !!win[0].addEventListener;
var hasRemoveEventListener = !!win[0].removeEventListener;
// Elements
var dragger = { top: 0 }, page = { top: 0 };
// Styles
var scrollboxStyle, draggerStyle, draggerLineStyle, pageStyle;
var calcStyles = function () {
scrollboxStyle = {
position: 'relative',
overflow: 'hidden',
'max-width': '100%',
height: '100%'
};
if (page.height) {
scrollboxStyle.height = page.height + 'px';
}
draggerStyle = {
position: 'absolute',
height: dragger.height + 'px',
top: dragger.top + 'px'
};
draggerLineStyle = {
position: 'relative',
'line-height': dragger.height + 'px'
};
pageStyle = {
position: 'relative',
top: page.top + 'px',
overflow: 'hidden'
};
};
var redraw = function () {
thumb.css('top', dragger.top + 'px');
var draggerOffset = dragger.top / page.height;
page.top = -Math.round(page.scrollHeight * draggerOffset);
transculdedContainer.css('top', page.top + 'px');
};
var trackClick = function (event) {
var offsetY = event.hasOwnProperty('offsetY') ? event.offsetY : event.layerY;
var newTop = Math.max(0, Math.min(parseInt(dragger.trackHeight, 10) - parseInt(dragger.height, 10), offsetY));
dragger.top = newTop;
redraw();
event.stopPropagation();
};
var wheelHandler = function (event) {
var wheelSpeed = 40;
// Mousewheel speed normalization approach adopted from
// http://stackoverflow.com/a/13650579/1427418
var o = event, d = o.detail, w = o.wheelDelta, n = 225, n1 = n - 1;
// Normalize delta
d = d ? w && (f = w / d) ? d / f : -d / 1.35 : w / 120;
// Quadratic scale if |d| > 1
d = d < 1 ? d < -1 ? (-Math.pow(d, 2) - n1) / n : d : (Math.pow(d, 2) + n1) / n;
// Delta *should* not be greater than 2...
event.delta = Math.min(Math.max(d / 2, -1), 1);
event.delta = event.delta * wheelSpeed;
dragger.top = Math.max(0, Math.min(parseInt(page.height, 10) - parseInt(dragger.height, 10), parseInt(dragger.top, 10) - event.delta));
redraw();
if (!!event.preventDefault) {
event.preventDefault();
} else {
return false;
}
};
var lastOffsetY = 0;
var thumbDrag = function (event, offsetX, offsetY) {
dragger.top = Math.max(0, Math.min(parseInt(dragger.trackHeight, 10) - parseInt(dragger.height, 10), offsetY));
event.stopPropagation();
};
var dragHandler = function (event) {
var newOffsetX = 0;
var newOffsetY = event.pageY - thumb[0].scrollTop - lastOffsetY;
thumbDrag(event, newOffsetX, newOffsetY);
redraw();
};
var _mouseUp = function (event) {
win.off('mousemove', dragHandler);
win.off('mouseup', _mouseUp);
event.stopPropagation();
};
var _touchDragHandler = function (event) {
var newOffsetX = 0;
var newOffsetY = event.originalEvent.changedTouches[0].pageY - thumb[0].scrollTop - lastOffsetY;
thumbDrag(event, newOffsetX, newOffsetY);
redraw();
};
var _touchEnd = function (event) {
win.off('touchmove', _touchDragHandler);
win.off('touchend', _touchEnd);
event.stopPropagation();
};
var registerEvent = function (elm) {
var wheelEvent = win[0].onmousewheel !== undefined ? 'mousewheel' : 'DOMMouseScroll';
if (hasAddEventListener) {
elm.addEventListener(wheelEvent, wheelHandler, false);
} else {
elm.attachEvent('onmousewheel', wheelHandler);
}
};
var removeEvent = function (elm) {
var wheelEvent = win[0].onmousewheel !== undefined ? 'mousewheel' : 'DOMMouseScroll';
if (hasRemoveEventListener) {
elm.removeEventListener(wheelEvent, wheelHandler, false);
} else {
elm.detachEvent('onmousewheel', wheelHandler);
}
};
var buildScrollbar = function (rollToBottom) {
rollToBottom = flags.bottom || rollToBottom;
mainElm = angular.element(element.children()[0]);
transculdedContainer = angular.element(mainElm.children()[0]);
tools = angular.element(mainElm.children()[1]);
thumb = angular.element(angular.element(tools.children()[0]).children()[0]);
thumbLine = angular.element(thumb.children()[0]);
track = angular.element(angular.element(tools.children()[0]).children()[1]);
page.height = element[0].offsetHeight;
page.scrollHeight = transculdedContainer[0].scrollHeight;
if (page.height < page.scrollHeight) {
scope.showYScrollbar = true;
scope.$emit('scrollbar.show');
// Calculate the dragger height
dragger.height = Math.round(page.height / page.scrollHeight * page.height);
dragger.trackHeight = page.height;
// update the transcluded content style and clear the parent's
calcStyles();
element.css({ overflow: 'hidden' });
mainElm.css(scrollboxStyle);
transculdedContainer.css(pageStyle);
thumb.css(draggerStyle);
thumbLine.css(draggerLineStyle);
// Bind scroll bar events
track.bind('click', trackClick);
// Handle mousewheel
registerEvent(transculdedContainer[0]);
// Drag the scroller with the mouse
thumb.on('mousedown', function (event) {
lastOffsetY = event.pageY - thumb[0].offsetTop;
win.on('mouseup', _mouseUp);
win.on('mousemove', dragHandler);
event.preventDefault();
});
// Drag the scroller by touch
thumb.on('touchstart', function (event) {
lastOffsetY = event.originalEvent.changedTouches[0].pageY - thumb[0].offsetTop;
win.on('touchend', _touchEnd);
win.on('touchmove', _touchDragHandler);
event.preventDefault();
});
if (rollToBottom) {
flags.bottom = false;
dragger.top = parseInt(page.height, 10) - parseInt(dragger.height, 10);
} else {
dragger.top = Math.max(0, Math.min(parseInt(page.height, 10) - parseInt(dragger.height, 10), parseInt(dragger.top, 10)));
}
redraw();
} else {
scope.showYScrollbar = false;
scope.$emit('scrollbar.hide');
thumb.off('mousedown');
removeEvent(transculdedContainer[0]);
transculdedContainer.attr('style', 'position:relative;top:0');
// little hack to remove other inline styles
mainElm.css({ height: '100%' });
}
};
var rebuildTimer;
var rebuild = function (e, data) {
/* jshint -W116 */
if (rebuildTimer != null) {
clearTimeout(rebuildTimer);
}
/* jshint +W116 */
var rollToBottom = !!data && !!data.rollToBottom;
rebuildTimer = setTimeout(function () {
page.height = null;
buildScrollbar(rollToBottom);
if (!scope.$$phase) {
scope.$digest();
}
// update parent for flag update
if (!scope.$parent.$$phase) {
scope.$parent.$digest();
}
}, 72);
};
buildScrollbar();
if (!!attrs.rebuildOn) {
attrs.rebuildOn.split(' ').forEach(function (eventName) {
scope.$on(eventName, rebuild);
});
}
if (attrs.hasOwnProperty('rebuildOnResize')) {
win.on('resize', rebuild);
}
},
template: '<div>' + '<div class="ngsb-wrap">' + '<div class="ngsb-container" ng-transclude></div>' + '<div class="ngsb-scrollbar" style="position: absolute; display: block;" ng-show="showYScrollbar">' + '<div class="ngsb-thumb-container">' + '<div class="ngsb-thumb-pos" oncontextmenu="return false;">' + '<div class="ngsb-thumb" ></div>' + '</div>' + '<div class="ngsb-track"></div>' + '</div>' + '</div>' + '</div>' + '</div>'
};
}
]);
\ No newline at end of file
.ngsb-wrap{-ms-touch-action:none}.ngsb-wrap .ngsb-container{width:auto;overflow:hidden;transition:.5s all}.ngsb-wrap:hover .ngsb-scrollbar{opacity:1;filter:"alpha(opacity=100)";-ms-filter:"alpha(opacity=100)"}.ngsb-wrap .ngsb-scrollbar{width:16px;height:100%;top:0;right:0;opacity:.75;filter:"alpha(opacity=75)";-ms-filter:"alpha(opacity=75)"}.ngsb-wrap .ngsb-scrollbar .ngsb-thumb-container{position:absolute;top:0;left:0;bottom:0;right:0;height:auto}.ngsb-wrap .ngsb-scrollbar a.ngsb-thumb-container{margin:20px 0}.ngsb-wrap .ngsb-scrollbar .ngsb-track{height:100%;margin:0 auto;width:6px;background:#000;background:rgba(0,0,0,.4);-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px;filter:"alpha(opacity=40)";-ms-filter:"alpha(opacity=40)";box-shadow:1px 1px 1px rgba(255,255,255,.1)}.ngsb-wrap .ngsb-scrollbar .ngsb-thumb-pos{cursor:pointer;width:100%;height:30px}.ngsb-wrap .ngsb-scrollbar .ngsb-thumb-pos .ngsb-thumb{transition:.5s all;width:4px;height:100%;margin:0 auto;-webkit-border-radius:10px;-moz-border-radius:10px;border-radius:10px;text-align:center;background:#fff;background:rgba(255,255,255,.4);filter:"alpha(opacity=40)";-ms-filter:"alpha(opacity=40)"}.ngsb-wrap .ngsb-scrollbar .ngsb-thumb-pos:hover .ngsb-thumb{background:rgba(255,255,255,.5);filter:"alpha(opacity=50)";-ms-filter:"alpha(opacity=50)"}.ngsb-wrap .ngsb-scrollbar .ngsb-thumb-pos:active{background:rgba(255,255,255,.6);filter:"alpha(opacity=60)";-ms-filter:"alpha(opacity=60)"}
\ No newline at end of file
/**
* ng-scrollbar
* @version v0.0.7 - 2015-06-19
* @link https://github.com/asafdav/ng-scrollbar
* @author Asaf David <[email protected]>
* @license MIT License, http://www.opensource.org/licenses/MIT
*/
"use strict";angular.module("ngScrollbar",[]).directive("ngScrollbar",["$parse","$window",function(a,b){return{restrict:"A",replace:!0,transclude:!0,scope:{showYScrollbar:"=?isBarShown"},link:function(a,c,d){var e,g,h,i,j,k,l,m,n,o,p,q={bottom:d.hasOwnProperty("bottom")},r=angular.element(b),s=!!r[0].addEventListener,t=!!r[0].removeEventListener,u={top:0},v={top:0},w=function(){l={position:"relative",overflow:"hidden","max-width":"100%",height:"100%"},v.height&&(l.height=v.height+"px"),m={position:"absolute",height:u.height+"px",top:u.top+"px"},n={position:"relative","line-height":u.height+"px"},o={position:"relative",top:v.top+"px",overflow:"hidden"}},x=function(){i.css("top",u.top+"px");var a=u.top/v.height;v.top=-Math.round(v.scrollHeight*a),g.css("top",v.top+"px")},y=function(a){var b=a.hasOwnProperty("offsetY")?a.offsetY:a.layerY,c=Math.max(0,Math.min(parseInt(u.trackHeight,10)-parseInt(u.height,10),b));u.top=c,x(),a.stopPropagation()},z=function(a){var b=40,c=a,d=c.detail,e=c.wheelDelta,g=225,h=g-1;return d=d?e&&(f=e/d)?d/f:-d/1.35:e/120,d=1>d?-1>d?(-Math.pow(d,2)-h)/g:d:(Math.pow(d,2)+h)/g,a.delta=Math.min(Math.max(d/2,-1),1),a.delta=a.delta*b,u.top=Math.max(0,Math.min(parseInt(v.height,10)-parseInt(u.height,10),parseInt(u.top,10)-a.delta)),x(),a.preventDefault?void a.preventDefault():!1},A=0,B=function(a,b,c){u.top=Math.max(0,Math.min(parseInt(u.trackHeight,10)-parseInt(u.height,10),c)),a.stopPropagation()},C=function(a){var b=0,c=a.pageY-i[0].scrollTop-A;B(a,b,c),x()},D=function(a){r.off("mousemove",C),r.off("mouseup",D),a.stopPropagation()},E=function(a){var b=0,c=a.originalEvent.changedTouches[0].pageY-i[0].scrollTop-A;B(a,b,c),x()},F=function(a){r.off("touchmove",E),r.off("touchend",F),a.stopPropagation()},G=function(a){var b=void 0!==r[0].onmousewheel?"mousewheel":"DOMMouseScroll";s?a.addEventListener(b,z,!1):a.attachEvent("onmousewheel",z)},H=function(a){var b=void 0!==r[0].onmousewheel?"mousewheel":"DOMMouseScroll";t?a.removeEventListener(b,z,!1):a.detachEvent("onmousewheel",z)},I=function(b){b=q.bottom||b,e=angular.element(c.children()[0]),g=angular.element(e.children()[0]),h=angular.element(e.children()[1]),i=angular.element(angular.element(h.children()[0]).children()[0]),j=angular.element(i.children()[0]),k=angular.element(angular.element(h.children()[0]).children()[1]),v.height=c[0].offsetHeight,v.scrollHeight=g[0].scrollHeight,v.height<v.scrollHeight?(a.showYScrollbar=!0,a.$emit("scrollbar.show"),u.height=Math.round(v.height/v.scrollHeight*v.height),u.trackHeight=v.height,w(),c.css({overflow:"hidden"}),e.css(l),g.css(o),i.css(m),j.css(n),k.bind("click",y),G(g[0]),i.on("mousedown",function(a){A=a.pageY-i[0].offsetTop,r.on("mouseup",D),r.on("mousemove",C),a.preventDefault()}),i.on("touchstart",function(a){A=a.originalEvent.changedTouches[0].pageY-i[0].offsetTop,r.on("touchend",F),r.on("touchmove",E),a.preventDefault()}),b?(q.bottom=!1,u.top=parseInt(v.height,10)-parseInt(u.height,10)):u.top=Math.max(0,Math.min(parseInt(v.height,10)-parseInt(u.height,10),parseInt(u.top,10))),x()):(a.showYScrollbar=!1,a.$emit("scrollbar.hide"),i.off("mousedown"),H(g[0]),g.attr("style","position:relative;top:0"),e.css({height:"100%"}))},J=function(b,c){null!=p&&clearTimeout(p);var d=!!c&&!!c.rollToBottom;p=setTimeout(function(){v.height=null,I(d),a.$$phase||a.$digest(),a.$parent.$$phase||a.$parent.$digest()},72)};I(),d.rebuildOn&&d.rebuildOn.split(" ").forEach(function(b){a.$on(b,J)}),d.hasOwnProperty("rebuildOnResize")&&r.on("resize",J)},template:'<div><div class="ngsb-wrap"><div class="ngsb-container" ng-transclude></div><div class="ngsb-scrollbar" style="position: absolute; display: block;" ng-show="showYScrollbar"><div class="ngsb-thumb-container"><div class="ngsb-thumb-pos" oncontextmenu="return false;"><div class="ngsb-thumb" ></div></div><div class="ngsb-track"></div></div></div></div></div>'}}]);
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
<?php
namespace Firebase;
require_once __DIR__ . '/firebaseInterface.php';
use \Exception;
/**
* Firebase PHP Client Library
*
* @author Tamas Kalman <[email protected]>
* @url https://github.com/ktamas77/firebase-php/
* @link https://www.firebase.com/docs/rest-api.html
*/
/**
* Firebase PHP Class
*
* @author Tamas Kalman <[email protected]>
* @link https://www.firebase.com/docs/rest-api.html
*/
class FirebaseLib implements FirebaseInterface
{
private $_baseURI;
private $_timeout;
private $_token;
private $_curlHandler;
/**
* Constructor
*
* @param string $baseURI
* @param string $token
*/
function __construct($baseURI = '', $token = '')
{
if ($baseURI == '') {
trigger_error('You must provide a baseURI variable.', E_USER_ERROR);
}
if (!extension_loaded('curl')) {
trigger_error('Extension CURL is not loaded.', E_USER_ERROR);
}
$this->setBaseURI($baseURI);
$this->setTimeOut(10);
$this->setToken($token);
$this->initCurlHandler();
}
/**
* Initializing the CURL handler
*
* @return void
*/
public function initCurlHandler()
{
$this->_curlHandler = curl_init();
}
/**
* Closing the CURL handler
*
* @return void
*/
public function closeCurlHandler()
{
curl_close($this->_curlHandler);
}
/**
* Sets Token
*
* @param string $token Token
*
* @return void
*/
public function setToken($token)
{
$this->_token = $token;
}
/**
* Sets Base URI, ex: http://yourcompany.firebase.com/youruser
*
* @param string $baseURI Base URI
*
* @return void
*/
public function setBaseURI($baseURI)
{
$baseURI .= (substr($baseURI, -1) == '/' ? '' : '/');
$this->_baseURI = $baseURI;
}
/**
* Returns with the normalized JSON absolute path
*
* @param string $path Path
* @param array $options Options
* @return string
*/
private function _getJsonPath($path, $options = array())
{
$url = $this->_baseURI;
if ($this->_token !== '') {
$options['auth'] = $this->_token;
}
$path = ltrim($path, '/');
return $url . $path . '.json?' . http_build_query($options);
}
/**
* Sets REST call timeout in seconds
*
* @param integer $seconds Seconds to timeout
*
* @return void
*/
public function setTimeOut($seconds)
{
$this->_timeout = $seconds;
}
/**
* Writing data into Firebase with a PUT request
* HTTP 200: Ok
*
* @param string $path Path
* @param mixed $data Data
* @param array $options Options
*
* @return array Response
*/
public function set($path, $data, $options = array())
{
return $this->_writeData($path, $data, 'PUT', $options);
}
/**
* Pushing data into Firebase with a POST request
* HTTP 200: Ok
*
* @param string $path Path
* @param mixed $data Data
* @param array $options Options
*
* @return array Response
*/
public function push($path, $data, $options = array())
{
return $this->_writeData($path, $data, 'POST', $options);
}
/**
* Updating data into Firebase with a PATH request
* HTTP 200: Ok
*
* @param string $path Path
* @param mixed $data Data
* @param array $options Options
*
* @return array Response
*/
public function update($path, $data, $options = array())
{
return $this->_writeData($path, $data, 'PATCH', $options);
}
/**
* Reading data from Firebase
* HTTP 200: Ok
*
* @param string $path Path
* @param array $options Options
*
* @return array Response
*/
public function get($path, $options = array())
{
try {
$ch = $this->_getCurlHandler($path, 'GET', $options);
$return = curl_exec($ch);
} catch (Exception $e) {
$return = null;
}
return $return;
}
/**
* Deletes data from Firebase
* HTTP 204: Ok
*
* @param string $path Path
* @param array $options Options
*
* @return array Response
*/
public function delete($path, $options = array())
{
try {
$ch = $this->_getCurlHandler($path, 'DELETE', $options);
$return = curl_exec($ch);
} catch (Exception $e) {
$return = null;
}
return $return;
}
/**
* Returns with Initialized CURL Handler
*
* @param string $path Path
* @param string $mode Mode
* @param array $options Options
*
* @return resource Curl Handler
*/
private function _getCurlHandler($path, $mode, $options = array())
{
$url = $this->_getJsonPath($path, $options);
$ch = $this->_curlHandler;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT, $this->_timeout);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->_timeout);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $mode);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
return $ch;
}
private function _writeData($path, $data, $method = 'PUT', $options = array())
{
$jsonData = json_encode($data);
$header = array(
'Content-Type: application/json',
'Content-Length: ' . strlen($jsonData)
);
try {
$ch = $this->_getCurlHandler($path, $method, $options);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
$return = curl_exec($ch);
} catch (Exception $e) {
$return = null;
}
return $return;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment