2
0
visuddhinanda@gmail.com 3 жил өмнө
parent
commit
4519e1fd31

+ 27 - 13
public/app/article/article.js

@@ -388,7 +388,11 @@ function palicanon_load() {
 					let result = JSON.parse(data);
 					if (result) {
 						_sent_data=result;
-						$("#article_title").html(result.title);
+                        if(result.title==""){
+                            $("#article_title").html("[unnamed]");
+                        }else{
+                            $("#article_title").html(result.title);
+                        }
 						$("#article_path_title").html(result.title);
 						$("#page_title").text(result.title);
 						$("#article_subtitle").html(result.subtitle);
@@ -435,8 +439,13 @@ function reader_get_path() {
 			let suttaTitle = $("chapter").last().html();
 
 			$("#pali_pedia").html(bookTitle);
-			$("#article_title").html(suttaTitle);
-			$("#page_title").text(suttaTitle);
+            if(suttaTitle==""){
+                $("#article_title").html("[unnamed]");
+                $("#page_title").text("[unnamed]");
+            }else{
+                $("#article_title").html(suttaTitle);
+                $("#page_title").text(suttaTitle);
+            }
 		}
 	);
 }
@@ -523,17 +532,22 @@ function render_toc(){
 					prevChapter = it.prev_chapter;
 				}
                 let strTitle;
-                switch (getCookie('language')) {
-                    case 'my':
-                        strTitle = roman_to_my(it.toc);
-                        break;
-                    case 'si':
-                        strTitle = roman_to_si(it.toc);
-                        break;
-                    default:
-                        strTitle = it.toc;
-                        break;
+                if(it.toc==""){
+                    strTitle  = "[unnamed]";
+                }else{
+                    switch (getCookie('language')) {
+                        case 'my':
+                            strTitle = roman_to_my(it.toc);
+                            break;
+                        case 'si':
+                            strTitle = roman_to_si(it.toc);
+                            break;
+                        default:
+                            strTitle = it.toc;
+                            break;
+                    }                    
                 }
+
 				arrToc.push({article:it.paragraph,title:strTitle,title_roman:it.toc,level:it.level});
 			}
 			$("#toc_content").fancytree({

+ 30 - 21
public/app/palicanon/palicanon.js

@@ -210,27 +210,32 @@ function render_chapter_head(chapter_info, parent) {
 	html += "</div>";
 	let link = "../reader/?view=chapter&book=" + chapter_info.book + "&par=" + chapter_info.paragraph;
 	html += "<div class='title'>";
+    let sToc = chapter_info.toc;
+    html += "	<div class='title_1'>";
 	if (typeof chapter_info.trans_title == "undefined") {
-		html += "	<div class='title_1'>";
         html += "<a href='" + link + "' target='_blank'>" ;
-        switch (getCookie('language')) {
-            case 'my':
-                html += roman_to_my(chapter_info.text);
-                break;
-            case 'si':
-                html += roman_to_si(chapter_info.text);
-                break;        
-            default:
-                html += chapter_info.text ;
-                break;
+        if(sToc == ""){
+            html += "[unnamed]" ;
+        }else{
+            switch (getCookie('language')) {
+                case 'my':
+                    html += roman_to_my(sToc);
+                    break;
+                case 'si':
+                    html += roman_to_si(sToc);
+                    break;        
+                default:
+                    html += sToc ;
+                    break;
+            }            
         }
+
         html += "</a>";
-        html += "</div>";
 	} else {
-		html +=
-			"	<div class='title_1'><a href='" + link + "' target='_blank'>" + chapter_info.trans_title + "</a></div>";
+        html += "<a href='" + link + "' target='_blank'>" + chapter_info.trans_title + "</a>";
 	}
-	html += "<div class='title_2'>" + chapter_info.text + "</div>";
+    html += "</div>";
+	html += "<div class='title_2'>" + sToc + "</div>";
 	html += "</div>";
 	html += "<div class='res res_more'>";
 	html += "<h2>译文</h2>";
@@ -327,18 +332,22 @@ function palicanon_render_chapter_row(chapter) {
 		chapter.para +
 		'" onclick="chapter_onclick(this)">';
 	html += '<div class="title">';
-
-	if (typeof chapter.trans_title == "undefined") {
+    
+    let sPaliTitle = chapter.title;
+    if(chapter.title==""){
+        sPaliTitle = "unnamed";
+    }
+	if (typeof chapter.trans_title == "undefined" ||  chapter.trans_title == "") {
 		html += "	<div class='title_1'>" ;
         switch (getCookie('language')) {
             case 'my':
-                html += roman_to_my(chapter.title);
+                html += roman_to_my(sPaliTitle);
                 break;
             case 'si':
-                html += roman_to_si(chapter.title);
+                html += roman_to_si(sPaliTitle);
                 break;
             default:
-                html += chapter.title ;
+                html += sPaliTitle ;
                 break;
         }
         
@@ -347,7 +356,7 @@ function palicanon_render_chapter_row(chapter) {
 		html += "	<div class='title_1'>" + chapter.trans_title + "</div>";
 	}
 
-	html += '	<div class="title_2" lang="pali">' + chapter.title + "</div>";
+	html += '	<div class="title_2" lang="pali">' + sPaliTitle + "</div>";
 	html += "</div>";
 	html += '<div class="resource">';
 	if (chapter.progress) {

+ 8 - 2
public/app/reader/get_para1.php

@@ -121,18 +121,24 @@ if ($FetchParInfo) {
 		$ulLevel = 0;
 		foreach ($toc as $key => $value) {
 			# code...
+            if(empty($value["toc"])){
+                $sToc = "unnamed";
+            }else{
+                $sToc = $value["toc"];
+            }
+            $sToc = str_replace(['[',']'],[' [','] '],$sToc);
 			if($value["level"] > $currLevel  ){
 				$ulLevel++;
 			}
 			else if($value["level"] < $currLevel ){
-				$ulLevel--;		
+				$ulLevel--;
 			}
 			$currLevel = $value["level"];
 			for ($i=0; $i < $ulLevel; $i++) { 
 				# code...
 				$output["content"] .= "    ";
 			}
-			$output["content"] .= "- [{$value["toc"]}](../article/index.php?view=chapter&book={$_book}&par={$value["paragraph"]})\n";
+			$output["content"] .= "- [{$sToc}](../article/index.php?view=chapter&book={$_book}&par={$value["paragraph"]})\n";
 		}		
 	}