将离线圣经合并到phonegap应用程序中?

时间:2014-10-10 16:25:37

标签: javascript html json cordova

您能否介绍如何在基于手机间隙的应用中合并离线圣经?它可能需要将来的章节和经文的书签。我将如何做到这一点。本地json文件可能是?但我找不到一个有意义的json。寻找KJV圣经。也不确定如何使json方法可扩展以符合书签。有什么想法吗?

1 个答案:

答案 0 :(得分:2)

全文只有~4MB,这意味着在应用运行时将全文加载到内存中应该不会有问题。然后,JSON应该可以用于书签 - 因为圣经的结构如何,拥有嵌套的哈希/数组查找是一件简单的事情:

var bible = {
    genesis: [
        [  // first chapter
            "In the beginning God created the heaven and the earth.",
            "And the earth was without form, and void; and darkness was upon the face of the deep. And the Spirit of God moved upon the face of the waters.",
            ...
        ],
        [  // second chapter
            "Thus the heavens and the earth were finished, and all the host of them.",
            "And on the seventh day God ended his work which he had made; and he rested on the seventh day from all his work which he had made.",
            ...
        ],
        ...
    ],
    exodus: [
        [  // first chapter
            "Now these are the names of the children of Israel, which came into Egypt; every man and his household came with Jacob.",
            ...
        ],
        ...
    ],
    ...
};

使用这种结构的任何一节都应该非常快速地查找:拉动书,这是一个哈希映射查找,然后章和节是数组偏移。