Kaynağa Gözat

Merge pull request #518 from visuddhinanda/master

wbw channel list add nickname and tab
visuddhinanda 4 yıl önce
ebeveyn
işleme
c47ab57d51
3 değiştirilmiş dosya ile 79 ekleme ve 16 silme
  1. 10 0
      app/term/term.css
  2. 62 12
      app/uwbw/wbw_channal_list.js
  3. 7 4
      app/uwbw/wbw_channel_list.php

+ 10 - 0
app/term/term.css

@@ -981,4 +981,14 @@ pali>p {
 
 .sent_mode>div>p {
     border-bottom: 0.5em solid var(--btn-color);
+}
+
+
+.circle_num { border: 1px solid var(--border-line-color);
+    border-radius: 99px;
+    line-height: 20px;
+    width: 22px;
+    text-align: center;
+    display: inline-block;
+    margin-left: 5px;
 }

+ 62 - 12
app/uwbw/wbw_channal_list.js

@@ -1,14 +1,34 @@
 var _wbw_channel;
 function wbw_channal_list_init() {
-	$("body").append(
-		'<div id="wbw_channal_list_dlg" title=' +
-			gLocal.gui.open +
-			gLocal.gui.wbw +
-			' style="overflow-y:scroll;"><div id="wbw_channal_list_dlg_content"></div></div>'
-	);
+	let channelListHtml = "";
+	let style = "<style>";
+	style += "#wbw_channal_list_dlg_content .ui-widget-content{border:unset;} ";
+	style += "#wbw_channal_list_dlg_content .ui-widget-header{background:unset;border:unset;border-bottom: 1px solid #dddddd;} ";
+	style += "</style>";
+	channelListHtml += '<div id="wbw_channal_list_dlg" title=' + gLocal.gui.open + gLocal.gui.wbw + '>';
+	channelListHtml += style;
+	channelListHtml += '<div id="wbw_channal_list_dlg_content">';
+	channelListHtml += '<div id="tabs">';
+	channelListHtml += '<ul>';
+    channelListHtml += '<li><a href="#tabs-1">我的<span id="my-num" class="circle_num">3</span></a></li>';
+    channelListHtml += '<li><a href="#tabs-2">协作<span id="co-num"  class="circle_num">2</span></a></li>';
+    channelListHtml += '<li><a href="#tabs-3">网络公开<span id="pu-num"  class="circle_num">1</span></a></li>';
+	channelListHtml += '</ul>';
+	channelListHtml += '<div id="tabs-1">';
+	channelListHtml += '</div>';
+	channelListHtml += '<div id="tabs-2">';
+	channelListHtml += '</div>';
+	channelListHtml += '<div id="tabs-3">';
+	channelListHtml += '</div>';
+	channelListHtml += '</div>';
+	channelListHtml += '</div>';
+	channelListHtml += '</div>';
+
+	$("body").append(channelListHtml);
 	$("#wbw_channal_list_dlg").dialog({
 		autoOpen: false,
-		width: 550,
+		width: 700,
+		height:650,
 		maxHeight: $(window).height()*0.7,
 		buttons: [
 			{
@@ -19,6 +39,7 @@ function wbw_channal_list_init() {
 			},
 		],
 	});
+	$( "#tabs" ).tabs();
 }
 
 function wbw_channal_list_open(book, paralist) {
@@ -31,11 +52,18 @@ function wbw_channal_list_open(book, paralist) {
 		function (data) {
 			_wbw_channel = JSON.parse(data);
 			if (_wbw_channel.status == 0) {
-				let html = "";
+				let htmlMy = "";
+				let htmlCollaborate = "";
+				let htmlPublic = "";
+				let myNum = 0;
+				let coNum = 0;
+				let puNum = 0;
+
 				for (let index = 0; index < _wbw_channel.data.length; index++) {
 					const element = _wbw_channel.data[index];
+					let html = "";
 					html += "<div style='display:flex;line-height: 2.5em;border-bottom: 1px solid gray;'>";
-					html += "<span style='flex:4'>";
+					html += "<span style='flex:3'>";
 					let style = "";
 					let text = "";
 					if (parseInt(element.wbw_para) > 0) {
@@ -61,7 +89,7 @@ function wbw_channal_list_open(book, paralist) {
 					html += "</span>";
 					html += "<span  style='flex:1'>" + (index + 1) + "</span>";
 					html += "<span style='flex:5'>" + element.name + "</span>";
-					html += "<span style='flex:1'>";
+					html += "<span style='flex:2'>";
 					let power = [
 						{ id: 10, note: gLocal.gui.viewer },
 						{ id: 20, note: gLocal.gui.editor },
@@ -73,12 +101,34 @@ function wbw_channal_list_open(book, paralist) {
 						}
 					}
 					html += "</span>";
-					html += "<span style='flex:2'>" + element.lang + "</span>";
+					html += "<span style='flex:2'>";
+					html += element.user.nickname;
+					html += "</span>";
+					html += "<span style='flex:1;text-align: right;'>" + element.lang + "</span>";
 					html += "<span style='flex:2;display:none;'>" + element.wbw_para + "/" + element.count + "</span>";
 					html += "</div>";
+					switch (element.type) {
+						case "my":
+							htmlMy +=html;
+							myNum++;
+							break;
+						case "collaborate":
+							htmlCollaborate +=html;
+							coNum++
+							break;	
+						case "public":
+							htmlPublic +=html;
+							puNum++
+							break;		
+					}
 				}
 
-				$("#wbw_channal_list_dlg_content").html(html);
+				$("#tabs-1").html(htmlMy);
+				$("#tabs-2").html(htmlCollaborate);
+				$("#tabs-3").html(htmlPublic);
+				$("#my-num").text(myNum);
+				$("#co-num").text(coNum);
+				$("#pu-num").text(puNum);
 				$("#wbw_channal_list_dlg").dialog("open");
 			} else {
 				ntf_show(_wbw_channel.error);

+ 7 - 4
app/uwbw/wbw_channel_list.php

@@ -4,6 +4,7 @@ require_once "../public/_pdo.php";
 require_once "../public/function.php";
 require_once '../share/function.php';
 require_once '../channal/function.php';
+require_once '../ucenter/function.php';
 require_once '../redis/function.php';
 
 $redis = redis_connect();
@@ -30,14 +31,14 @@ $params[] = $_book;
 
 #查重复
 $channelList = array();
-
+#先查自己的
 PDO_Connect(_FILE_DB_CHANNAL_);
 $query = "SELECT id FROM channal WHERE owner = ? and status>0 LIMIT 0,100";
 $FetchChannal = PDO_FetchAll($query, array($_COOKIE["userid"]));
 
 foreach ($FetchChannal as $key => $value) {
 	# code...
-	$channelList[$value["id"]]=array("power"=>30);
+	$channelList[$value["id"]]=array("power"=>30,"type"=>"my");
 }
 
 # 找协作的
@@ -50,7 +51,7 @@ foreach ($coop_channal as $key => $value) {
 		}
 	}
 	else{
-		$channelList[$value["res_id"]]=array("power"=>(int)$value["power"]);
+		$channelList[$value["res_id"]]=array("power"=>(int)$value["power"],"type"=>"collaborate");
 	}
 }
 
@@ -61,11 +62,12 @@ $publicChannel = PDO_FetchAll($query, $params);
 foreach ($publicChannel as $key => $channel) {
 	# code...
 	if(!isset($channelList[$channel["channal"]])){
-		$channelList[$channel["channal"]]=array("power"=>10);
+		$channelList[$channel["channal"]]=array("power"=>10,"type"=>"public");
 	}
 }
 
 $channelInfo = new Channal($redis);
+$userInfo = new UserInfo();
 $i = 0;
 $outputData = array();
 
@@ -81,6 +83,7 @@ foreach ($channelList as $key => $row) {
     $channelList[$key]["id"] = $info["id"];
     $channelList[$key]["name"] = $info["name"];
     $channelList[$key]["lang"] = $info["lang"];
+	$channelList[$key]["user"] = $userInfo->getName($info["owner"]);
 	$outputData[]=$channelList[$key];
 }