causefx 8 lat temu
rodzic
commit
0d5662da04
14 zmienionych plików z 246 dodań i 66 usunięć
  1. 13 47
      chat.php
  2. 34 13
      chatjs.php
  3. 1 0
      config/configDefaults.php
  4. 7 0
      functions.php
  5. 2 0
      homepage.php
  6. 171 1
      index.php
  7. 1 0
      lang/de.ini
  8. 1 0
      lang/en.ini
  9. 1 0
      lang/es.ini
  10. 1 0
      lang/fr.ini
  11. 1 0
      lang/it.ini
  12. 1 0
      lang/nl.ini
  13. 1 0
      lang/pl.ini
  14. 11 5
      settings.php

+ 13 - 47
chat.php

@@ -143,12 +143,9 @@ endif;
 
             }  
         
-            if( $db = new SQLite3("chatpack.db") )
-            {
-                if( $db->busyTimeout(5000) )
-                {
-                    if( $db->exec("PRAGMA journal_mode = wal;") )
-                    {
+            if( $db = new SQLite3("chatpack.db") ){
+                if( $db->busyTimeout(5000) ){
+                    if( $db->exec("PRAGMA journal_mode = wal;") ) {
                         $logtable = "CREATE TABLE IF NOT EXISTS chatpack_log
                                      (id INTEGER PRIMARY KEY,
                                      timestamp INTEGER NOT NULL,
@@ -156,9 +153,7 @@ endif;
                                      avatar TEXT NOT NULL,
                                      message TEXT NOT NULL,
                                      liked INTEGER DEFAULT 0)";
-
-                        if( $db->exec($logtable) )
-                        {
+                        if( $db->exec($logtable) ){
                             $usertable = "CREATE TABLE IF NOT EXISTS chatpack_typing
                                           (id INTEGER PRIMARY KEY,
                                           timestamp INTEGER NOT NULL,
@@ -170,44 +165,28 @@ endif;
                                           timestamp INTEGER NOT NULL,
                                           avatar TEXT NOT NULL)";
 
-                            if( $db->exec($usertable) && $db->exec($onlinetable) )
-                            {
+                            if( $db->exec($usertable) && $db->exec($onlinetable) ){
                                 $dbcreated = true;
-                            }
-                            else
-                            {
+                            }else{
                                 errormessage("creating database table for typing");
                             }
-                        }
-                        else
-                        {
+                        }else{
                             errormessage("creating database table for messages");
                         }
-
-                        if( !$db->close() )
-                        {
+                        if( !$db->close() ){
                             errormessage("closing database connection");
                         }
-                    }
-                    else
-                    {
+                    }else{
                         errormessage("setting journal mode");
                     }
-                }
-                else
-                {
+                }else{
                     errormessage("setting busy timeout");
                 }
-            }
-            else
-            {
+            }else{
                 errormessage("using SQLite");
             }
         
-            if( $dbcreated )
-            {
-
-        ?>
+            if( $dbcreated ){?>
         
         <div class="main-wrapper" style="position: initial;">
             <div id="content" class="container-fluid">
@@ -241,23 +220,10 @@ endif;
                         </div>
                     </div>
                 </div>
-
             </div>    
         </div>
         
-        <?php
-            
-            }
-        
-            function errormessage($msg)
-            {
-                echo "<div style=\"margin-top: 50px;\">";
-                echo "<span style=\"color:#d89334;\">error </span>";
-                echo $msg;
-                echo "</div>";
-            }
-                
-        ?>
+        <?php } ?>
     </body>
 
     <script>

+ 34 - 13
chatjs.php

@@ -297,8 +297,7 @@ $(document).ready(function()
     $(window).focus();
     var tabinfocus = true;
     $("#chat").hide();
-    $("#username").val("");
-    $("#username").focus();
+
     
     // allowed characters in username
     
@@ -344,8 +343,6 @@ $(document).ready(function()
         //$(userfavicon).appendTo("head");
         
         // start chat
-        
-        $("#createuser").hide();
         $("#chat").show();
         $("#message").focus();
         
@@ -572,6 +569,7 @@ $(document).ready(function()
 
                     for( var i=0; i<newmessages.length; i++ )
                     {
+                        
                         var message = newmessages[i];
                         
                         if( message != "" )
@@ -603,7 +601,11 @@ $(document).ready(function()
 
                                     if( message.lastIndexOf(userwriting) == -1 )
                                     {
-                                        newmessagealert(message);
+                                        if ($('.chat-box').hasClass('email-active')){
+                                            console.log("supress message");
+                                        }else{
+                                            newmessagealert(message);
+                                        }
                                     }
                                     
                                     // refresh eventlisteners of messages to set likes
@@ -677,26 +679,46 @@ $(document).ready(function()
     }
     
     // tab focus
-    
+    window.onload = function()
+    {
+        if ($('.chat-box').hasClass('email-active')){
+            tabinfocus = true;
+            $(".mdi-forum").removeClass("tada loop-animation new-message");//SET MESSAGE TO ZERO
+            console.log("in focus");
+        }else{
+            tabinfocus = false;
+            console.log("not in focus");
+        }
+ 
+    };
+
     window.onfocus = function()
     {
-        tabinfocus = true;
-        parent.document.title = "Chat";
-        window.parent.$("span[id^='chat.phps']").html("");
+        if ($('.chat-box').hasClass('email-active')){
+            tabinfocus = true;
+            $(".mdi-forum").removeClass("tada loop-animation new-message");//SET MESSAGE TO ZERO
+            console.log("in focus");
+        }else{
+            tabinfocus = false;
+            console.log("not in focus");
+        }
+ 
     };
     
     window.onblur = function()
     {
         tabinfocus = false;
+        console.log("not in focus");
     };
     
     // new message tab alert
     
     function newmessagealert(message)
     {   
+
+
         if( !tabinfocus )
         {
-            // title marker
             i = parseInt(parent.document.title);
             if(isNaN(i)){
                 i = 1;
@@ -704,9 +726,8 @@ $(document).ready(function()
                 i++
              }
 
-            parent.document.title = i + " Chat";
-            //window.parent.$("#chat.phpx").addClass("gottem");
-            window.parent.$("span[id^='chat.phps']").html(i);
+            console.log("new message");
+            $(".mdi-forum").addClass("tada loop-animation new-message");
             var $jQueryObject = $($.parseHTML(message));
             var alertMessage = $jQueryObject.find(".chat-body").html();
             var alertUsername = $jQueryObject.find("h4[class^='pull-left zero-m']").html();

+ 1 - 0
config/configDefaults.php

@@ -91,4 +91,5 @@ return array(
 	"downloadRefresh" => "30000",
 	"organizrAPI" => "",
 	"splash" => "false",
+	"chat" => "false",
 );

+ 7 - 0
functions.php

@@ -4506,6 +4506,13 @@ function buildMenu($array){
 	}
 }
 
+function errormessage($msg) {
+	echo "<div style=\"margin-top: 50px;\">";
+	echo "<span style=\"color:#d89334;\">error </span>";
+	echo $msg;
+	echo "</div>";
+}
+
 class Mobile_Detect
 {
     /**

+ 2 - 0
homepage.php

@@ -477,6 +477,8 @@ foreach(loadAppearance() as $key => $value) {
             </div>    
         </div>
         <script>
+        //Tooltips
+        $('[data-toggle="tooltip"]').tooltip();
         $(".swal-legend").click(function () {
             swal({
                 title: "Calendar Legend",

+ 171 - 1
index.php

@@ -26,6 +26,7 @@ $settingsActive = "";
 $action = "";
 $loadingIcon = "images/organizr-load-w-thick.gif";
 $baseURL = "";
+$dbcreated = false;
 
 // Get Action
 if(isset($_POST['action'])) {
@@ -163,6 +164,51 @@ if (file_exists('config/config.php')) {
 
 	endif;
 
+	//NEW CHAT
+	if(CHAT == "true"){
+		if( $db = new SQLite3("chatpack.db") ){
+			if( $db->busyTimeout(5000) ){
+				if( $db->exec("PRAGMA journal_mode = wal;") ) {
+					$logtable = "CREATE TABLE IF NOT EXISTS chatpack_log
+									(id INTEGER PRIMARY KEY,
+									timestamp INTEGER NOT NULL,
+									user TEXT NOT NULL,
+									avatar TEXT NOT NULL,
+									message TEXT NOT NULL,
+									liked INTEGER DEFAULT 0)";
+					if( $db->exec($logtable) ){
+						$usertable = "CREATE TABLE IF NOT EXISTS chatpack_typing
+										(id INTEGER PRIMARY KEY,
+										timestamp INTEGER NOT NULL,
+										user TEXT NOT NULL)";
+						
+						$onlinetable = "CREATE TABLE IF NOT EXISTS chatpack_last_message
+										(
+										user TEXT PRIMARY KEY NOT NULL,
+										timestamp INTEGER NOT NULL,
+										avatar TEXT NOT NULL)";
+
+						if( $db->exec($usertable) && $db->exec($onlinetable) ){
+							$dbcreated = true;
+						}else{
+							errormessage("creating database table for typing");
+						}
+					}else{
+						errormessage("creating database table for messages");
+					}
+					if( !$db->close() ){
+						errormessage("closing database connection");
+					}
+				}else{
+					errormessage("setting journal mode");
+				}
+			}else{
+				errormessage("setting busy timeout");
+			}
+		}else{
+			errormessage("using SQLite");
+		}
+	}
 }
 
 if(!defined('SLIMBAR')) : define('SLIMBAR', 'true'); endif;
@@ -251,6 +297,46 @@ if(file_exists("images/settings2.png")) : $iconRotate = "false"; $settingsIcon =
 		<![endif]-->
 	</head>
 	<style>
+		.new-message{
+			color: #46bc99 !important;
+		}
+		@media screen and (max-width:737px){
+			.email-body{width: 100%; overflow: auto;height: 100%;}
+			.email-content, .email-new {
+				-webkit-overflow-scrolling: touch;
+				-webkit-transform: translateZ(0);
+				overflow: scroll;
+				position: fixed;
+				height:100% !important;
+				margin-top:<?=$slimBar;?>px;
+			}.email-content .email-header, .email-new .email-header{
+				padding: 10px 30px;
+				z-index: 1000;
+			}
+		}@media screen and (min-width:737px){
+			.email-body{width: 100%}
+			.email-content .close-button, .email-content .email-actions, .email-new .close-button, .email-new .email-actions {
+				position: relative;
+				top: 15px;
+				right: 0px;
+				float: right;
+			}.email-inner-section {
+				margin-top: 30px;
+			}.email-content, .email-new {
+				overflow: auto;
+				margin: <?=$slimBar;?>px 0 0 0 !important;
+				height: 100%;
+				position: fixed;
+				max-width: 100%;
+				width: calc(30%) !important;
+				right: calc(-30%);
+			}.email-content .email-header, .email-new .email-header{
+				position: fixed;
+				padding: 0px 30px;
+				width: calc(30%) !important;
+				z-index: 1000;
+			}
+		}
 		.loop-animation {
 			animation-iteration-count: infinite;
 			-webkit-animation-iteration-count: infinite;
@@ -563,6 +649,14 @@ if(file_exists("images/settings2.png")) : $iconRotate = "false"; $settingsIcon =
 								<i class="mdi mdi-window-restore"></i>
 							</a>
 						</li>
+						<?php if(CHAT == "true"){?>
+						<li class="dropdown some-btn">
+							<a id="chat-open" class="chat-open">
+								<i class="mdi mdi-forum animated"></i>
+								<span class="label label-new-message"></span>
+							</a>
+						</li>
+						<?php } ?>
 						<li style="display: block" id="splitView" class="dropdown some-btn">
 							<a class="spltView">
 								<i class="mdi mdi-window-close"></i>
@@ -1101,6 +1195,62 @@ if(file_exists("images/settings2.png")) : $iconRotate = "false"; $settingsIcon =
 			</div>
 		</div>
 		<?php } ?>
+		<!-- CHAT BOX -->
+		<?php if(CHAT == "true"){?>
+		<div class="email-content chat-box white-bg">
+			<div class="email-body">
+				<div class="email-inner small-box" style="padding: 0">
+
+				
+					<div class="email-inner-section" style="margin-top: 0;">
+						<div class="small-box fade in" style="padding: 0">
+						
+								
+								<?php if( $dbcreated ){ ?>
+									<div class="main-wrapper" style="position: initial; left:0;">
+										<div id="content">
+												<div id="chat-div" class="">
+													<div class="content-box big-box chat gray-bg">
+													<?php if($userDevice !== "phone"){ ?>
+														<div class="box" style="overflow: hidden; width: auto; height: calc(100vh - 112px) !important;">
+													<?php }else{ ?>
+														<div class="box" style="overflow: hidden; width: auto; height: 85vh !important;">
+													<?php }?>
+															<div id="intro">
+																<center><img class="logo" alt="logo" src="images/organizr-logo-h.png" style="width: 100%;">
+																<br><br>start chatting...</center>
+															</div>
+															<ul id="messages" class="chat-double chat-container"></ul>
+															<ul class="chat-double chat-container" style="padding: 0px;"><li id="istyping"></li></ul>
+														</div>
+														<br/>
+														<input id="message" autofocus type="text" class="form-control gray-bg" placeholder="Enter your text" autocomplete="off"/>
+														<audio id="tabalert" preload="auto">
+															<source src="chat/audio/newmessage.mp3" type="audio/mpeg">
+														</audio>
+
+													</div>
+												</div>
+												<div id="chat-users-div" class="col-lg-12" style="display: none">
+													<div class="content-box">
+														<div class="content-title big-box i-block gray-bg">
+															<h4 class="zero-m">Online</h4>
+														</div>
+														<div class="clearfix"></div>
+														<div id="onlineusers" class="big-box"></div>
+													</div>
+												</div>
+											
+							
+        						<?php } ?>
+								
+							
+						</div>
+					</div>
+				</div>
+			</div>
+		</div>
+		<?php } ?>
 
 		<!--Scripts-->
 		<script src="<?=$baseURL;?>bower_components/jquery/dist/jquery.min.js"></script>
@@ -1130,8 +1280,21 @@ if(file_exists("images/settings2.png")) : $iconRotate = "false"; $settingsIcon =
 		<script src="<?=$baseURL;?>js/common.js?v=<?php echo INSTALLEDVERSION; ?>"></script>
 		<script src="<?=$baseURL;?>js/mousetrap.min.js"></script>
 		<script src="js/jquery.mousewheel.min.js" type="text/javascript"></script>
+		<?php if(CHAT == "true"){?><script src="chatjs.php" defer="true"></script><?php }?>
 
 		<script>
+		//Tooltips
+		$('[data-toggle="tooltip"]').tooltip();
+		$(".box").niceScroll({
+            railpadding: {top:0,right:0,left:0,bottom:0},
+            scrollspeed: 30,
+            mousescrollstep: 60
+        });
+        $("#onlineusers").niceScroll({
+            railpadding: {top:0,right:0,left:0,bottom:0},
+            scrollspeed: 30,
+            mousescrollstep: 60
+        });
 		<?php if (file_exists('config/config.php') && $configReady == "Yes" && $tabSetup == "No" && SPLASH == "true") {?>    
 		$('.splash-modal').modal("show");
 		<?php } ?>
@@ -1497,7 +1660,14 @@ if(file_exists("images/settings2.png")) : $iconRotate = "false"; $settingsIcon =
 			var activeFrame = $('#content').find('.active').children('iframe');
 			console.log(activeFrame.attr('src'));
 			window.open(activeFrame.attr('src'), '_blank');
-		});    
+		});  
+		$('#chat-open').on('click tap', function(){
+			$('.chat-box').toggleClass('email-active');
+			$(".mdi-forum").removeClass("tada loop-animation new-message");//SET MESSAGE TO ZERO
+			$("#message").focus();
+
+		});
+
 		$('#reload').on('contextmenu', function(e){
 
 			$("i[class^='mdi mdi-refresh']").attr("class", "mdi mdi-refresh fa-spin");

+ 1 - 0
lang/de.ini

@@ -324,3 +324,4 @@ TEST_URL = "Enter URL to Test"
 MORE = "More"
 LESS = "Less"
 ENABLE_SPLASH_SCREEN = "Enable Splash Screen"
+ENABLE_CHAT = "Enable Chat"

+ 1 - 0
lang/en.ini

@@ -324,3 +324,4 @@ TEST_URL = "Enter URL to Test"
 MORE = "More"
 LESS = "Less"
 ENABLE_SPLASH_SCREEN = "Enable Splash Screen"
+ENABLE_CHAT = "Enable Chat"

+ 1 - 0
lang/es.ini

@@ -324,3 +324,4 @@ TEST_URL = "Enter URL to Test"
 MORE = "More"
 LESS = "Less"
 ENABLE_SPLASH_SCREEN = "Enable Splash Screen"
+ENABLE_CHAT = "Enable Chat"

+ 1 - 0
lang/fr.ini

@@ -324,3 +324,4 @@ TEST_URL = "Enter URL to Test"
 MORE = "More"
 LESS = "Less"
 ENABLE_SPLASH_SCREEN = "Enable Splash Screen"
+ENABLE_CHAT = "Enable Chat"

+ 1 - 0
lang/it.ini

@@ -324,3 +324,4 @@ TEST_URL = "Enter URL to Test"
 MORE = "More"
 LESS = "Less"
 ENABLE_SPLASH_SCREEN = "Enable Splash Screen"
+ENABLE_CHAT = "Enable Chat"

+ 1 - 0
lang/nl.ini

@@ -324,3 +324,4 @@ TEST_URL = "Enter URL to Test"
 MORE = "More"
 LESS = "Less"
 ENABLE_SPLASH_SCREEN = "Enable Splash Screen"
+ENABLE_CHAT = "Enable Chat"

+ 1 - 0
lang/pl.ini

@@ -324,3 +324,4 @@ TEST_URL = "Enter URL to Test"
 MORE = "More"
 LESS = "Less"
 ENABLE_SPLASH_SCREEN = "Enable Splash Screen"
+ENABLE_CHAT = "Enable Chat"

+ 11 - 5
settings.php

@@ -481,9 +481,11 @@ if($userDevice !== "phone"){ echo "<br><br><br>".buildMenu($buildMenu); }else{ e
 
 
                     </div>
-                    <div class="col-lg-10">
-						<h1 class="text-center">ORGANIZR <3 YOU</h1>
+					<?php if($userDevice !== "phone"){?>
+                    <div class="col-lg-10" style="position: absolute;top: 50%;left: 10%;width: 80%;">
+						<h1 style="font-size: 50px" class="text-center">ORGANIZR <i class="fa fa-heart fa-1x red loop-animation animated pulse" aria-hidden="true"></i> YOU</h1>
                     </div>
+					<?php } ?>
                 </div>
                 <div class="email-content tab-box white-bg">
                     <div class="email-body">
@@ -1684,7 +1686,13 @@ echo buildSettings(
 						),
 					),
 					array(
-                        array(
+						array(
+							'type' => 'checkbox',
+							'labelTranslate' => 'ENABLE_CHAT',
+							'name' => 'chat',
+							'value' => CHAT,
+						),
+						array(
 							'type' => 'checkbox',
 							'labelTranslate' => 'ENABLE_SPLASH_SCREEN',
 							'name' => 'splash',
@@ -2713,8 +2721,6 @@ echo buildSettings(
                 $(".settingsMenu").removeClass("settingsMenuActive");
                 $(this).addClass("settingsMenuActive");
             })
-            //Tooltips
-            $('[data-toggle="tooltip"]').tooltip();
             //IP INFO
             $(".ipInfo").click(function(){
                 $.getJSON("https://ipinfo.io/"+$(this).text()+"/?token=<?php echo IPINFOTOKEN;?>", function (response) {