Skip to content

Commit

Permalink
Rename ".json" -> ".json.js"
Browse files Browse the repository at this point in the history
- The pseudo JSON files are renamed to ".json.js"
- There's another way to get JSON:  use JS module's `import` directive. But the module cannot be loaded from `localhost` (due to CORS). So we keep the good old non-module JS so that we can run the ebook locally.
  • Loading branch information
bixycler committed May 18, 2021
1 parent 69ae7e7 commit f95b39a
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 10 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion PhapCu-CreatZy.json → PhapCu-CreatZy.json.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PhapCu_CreatZy={
PhapCu_CreatZy = {
"title": "Kinh Pháp Cú (Dhammapada)",
"year": 2020,
"author": "CreatZy (Lê Xuân Định)",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 3 additions & 1 deletion dhammapada-html.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
toc = PhapCu_CreatZy;
//import toc from 'PhapCu_CreatZy.json'; // js module cannot be loaded from localhost!
toc = PhapCu_CreatZy; // so, just use the preloaded var from pseudo JSON file

poetries = { "id": "e",
"books": [PhapCu_TamMinh, PhapCu_MinhDuc, PhapCu_ThienNhut, PhapCu_MinhChau],
"book": PhapCu_TamMinh,
Expand Down
16 changes: 8 additions & 8 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<head>
<meta charset="utf-8"/>
<title>Kinh Pháp Cú</title>
<link rel="icon" href="img/real-lotus.png" type="image/png" size="799x544">
<link rel="icon" href="img/real-lotus.png" type="image/png" size="799x544">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lobster"/>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lora"/>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Charm"/>
Expand Down Expand Up @@ -186,13 +186,13 @@
}
</style>
<script src="https://code.jquery.com/jquery-3.5.0.js"></script>
<script src="Dhammapada-Wickramanayaka.json"></script>
<script src="PhapCu-CreatZy.json"></script>
<script src="PhapCu-TamMinh.json"></script>
<script src="PhapCu-MinhDuc.json"></script>
<script src="PhapCu-ThienNhut.json"></script>
<script src="PhapCu-MinhChau.json"></script>
<script src="PhapCu-ThienSieu.json"></script>
<script src="Dhammapada-Wickramanayaka.json.js"></script>
<script src="PhapCu-CreatZy.json.js"></script>
<script src="PhapCu-TamMinh.json.js"></script>
<script src="PhapCu-MinhDuc.json.js"></script>
<script src="PhapCu-ThienNhut.json.js"></script>
<script src="PhapCu-MinhChau.json.js"></script>
<script src="PhapCu-ThienSieu.json.js"></script>
<!-- Facebook Open Graph tags to customize link previews on fb -->
<!--meta property="og:url" content="http://creatzy.epizy.com/PhapCu-Dhammapada/" /-->
<meta property="og:type" content="book" />
Expand Down

1 comment on commit f95b39a

@bixycler
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The import is currently unsupported for JSON! It's only a requested feature!
=> For server run (not for local run), use either:

  1. Browser: fetch('./file.json') // still suffers CORS with local run
  2. Node.js: require('./file.json')

Please sign in to comment.