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(){ ...@@ -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(){ public function reject_booking_post(){
$postdata = file_get_contents("php://input"); $postdata = file_get_contents("php://input");
...@@ -2767,6 +2783,117 @@ public function end_ride_update_post(){ ...@@ -2767,6 +2783,117 @@ public function end_ride_update_post(){
print json_encode($res); 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(){ ...@@ -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'])); $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){ if($query){
return true; return true;
}else{ }else{
...@@ -801,7 +800,6 @@ function get_cars_details(){ ...@@ -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'])); $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){ if($query){
return true; return true;
}else{ }else{
...@@ -946,9 +944,9 @@ function get_cars_details(){ ...@@ -946,9 +944,9 @@ function get_cars_details(){
'comments'=>isset($request['comments'])?$request['comments']:'', 'comments'=>isset($request['comments'])?$request['comments']:'',
'max_luggage'=>$request['max_luggage'], 'max_luggage'=>$request['max_luggage'],
'users_id'=>$request['users_id'], 'users_id'=>$request['users_id'],
'stopover_lng'=>$request['stopover_lng'], 'stopover_lng'=>(isset($request['stopover_lng']) && !empty($request['stopover_lng']))? $request['stopover_lng'] : '0',
'stopover'=>$request['stopover'], 'stopover'=>(isset($request['stopover']) && !empty($request['stopover']))? $request['stopover'] : '0',
'stopover_lat'=>$request['stopover_lat'], 'stopover_lat'=>(isset($request['stopover_lat']) && !empty($request['stopover_lat']))? $request['stopover_lat'] : '0',
'car_id'=>$request['car_id'] 'car_id'=>$request['car_id']
); );
/*if($request['check']=="round"){ /*if($request['check']=="round"){
...@@ -1029,7 +1027,10 @@ function get_cars_details(){ ...@@ -1029,7 +1027,10 @@ function get_cars_details(){
} }
public function get_find_ride($request){ public function get_find_ride($request){
$this->db->where('no_of_seats >=',$request['seats']); $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'){ if($request['user_id']!='undefined'){
$this->db->where('users_id!=',$request['user_id']); $this->db->where('users_id!=',$request['user_id']);
} }
...@@ -1709,6 +1710,12 @@ function get_cars_details(){ ...@@ -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){ function reject_ride($request){
$data=array('status'=>2); $data=array('status'=>2);
$this->db->where('booking_id',$request); $this->db->where('booking_id',$request);
...@@ -2411,16 +2418,28 @@ public function otp_verify($data){ ...@@ -2411,16 +2418,28 @@ public function otp_verify($data){
$request = $this->db->get_where('ride',array('id'=>$data['ride_id']))->row_array(); $request = $this->db->get_where('ride',array('id'=>$data['ride_id']))->row_array();
if($request){ if($request){
$data =array('source'=>$request['source'], $data =array('source'=>$request['source'],
'destination'=>$request['destination'], 'destination'=>$request['destination'],
'source_lat'=>$request['source_lat'], 'source_lat'=>$request['source_lat'],
'source_lng'=>$request['source_lng'], 'source_lng'=>$request['source_lng'],
'destination_lat'=>$request['destination_lat'], 'destination_lat'=>$request['destination_lat'],
'destination_lng'=>$request['destination_lng'], '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'], 'departure_date'=>$data['departure_date'],
'detour_time'=>$data['detour_time'], 'detour_time'=>$data['detour_time'],
'reached_time'=>$request['reached_time'], 'reached_time'=>$request['reached_time'],
'is_round_trip'=>$request['round_trip'], 'is_round_trip'=>$request['is_round_trip'],
'status'=>1, 'status'=>1
); );
if($this->db->insert('ride',$data)){ if($this->db->insert('ride',$data)){
$res = array('status'=>'success'); $res = array('status'=>'success');
...@@ -2493,6 +2512,17 @@ public function otp_verify($data){ ...@@ -2493,6 +2512,17 @@ public function otp_verify($data){
} }
return $res; 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(); ...@@ -68,7 +68,17 @@ $admin_detail = pull_admin();
<?php } ?> <?php } ?>
</ul> </ul>
</li> </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> <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"> <ul class="treeview-menu">
......
...@@ -95,6 +95,73 @@ ...@@ -95,6 +95,73 @@
margin-top:10px; margin-top:10px;
height: 41px; 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.
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