Skip to content

Commit

Permalink
Merge pull request #103 from dynamsoft-docs/preview
Browse files Browse the repository at this point in the history
update to internal commit 49802f24
  • Loading branch information
Jenny-Jiani authored Jul 25, 2024
2 parents d8b65ba + 16fa5b7 commit a893fb2
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 24 deletions.
6 changes: 5 additions & 1 deletion _includes/main-page-head.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,8 @@
{%- endif -%}
<span class="rightMenuControlBtn" style="margin-left: 15px;"><img src="{{ site.assets }}/img-icon/Menu-navigation-menu-4.svg" width="30px" height="30px" style="vertical-align: middle;" title="Collapse Sidebar" data-placement="bottom" data-toggle="tooltip" data-html="true" /></span>
</div>
</div>
</div>

{%- if page.latestPageUri -%}
<input id="latestPageUri" type="hidden" value="{{page.latestPageUri}}" />
{%- endif -%}
1 change: 1 addition & 0 deletions assets/js/historymanage.js
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,7 @@ function RequestNewPage(aTag, paramLink, needh3=false, redirectUrl = null, onlyL
$('#crumbs > ul').html($('#crumbs > ul > li').eq(0))
initCrumbs()
init()
initNoteForOldVersions(otherVersions)
var preList = $('.markdown-body .highlight pre')
for (var i=0; i<preList.length; i++) {
var iconItem = document.createElement("i")
Expand Down
2 changes: 1 addition & 1 deletion assets/js/historymanage.min.js

Large diffs are not rendered by default.

68 changes: 47 additions & 21 deletions assets/js/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ $(function() {
}

init();
initNoteForOldVersions();
//getLocation();
mutationObserverFunc();
initPageLayout();
Expand Down Expand Up @@ -615,17 +616,6 @@ function init() {
}
}
}

var queryProduct = getUrlVars(document.URL)["product"] ? getUrlVars(document.URL)["product"] : getCurrentUrlProductName(document.URL)
if (queryProduct == "dbr") {
var queryLang = getCurrentUrlLang(document.URL, true)
var currentVersion = $(".currentVersion").text().toLowerCase()
currentVersion = currentVersion.indexOf("latest version") >= 0 ? "latest" : (currentVersion.replace("version ", ""))
var majorVersion = currentVersion != "latest" ? Number(currentVersion.split(".")[0]) : "latest"
if ((queryLang == "js" || queryLang == "javascript") && majorVersion != "latest" && majorVersion <= 9 && $("#versionNote").length == 0) {
loadOldVersionNotes(queryProduct, queryLang);
}
}
}

function initFoldPanel() {
Expand Down Expand Up @@ -698,14 +688,50 @@ function closeThanksDownloading() {
$(".dbrThanksDownloading").hide()
}

function loadOldVersionNotes(product, lang) {
let productCurrentVersion = $(".currentVersion").text().toLowerCase()
productCurrentVersion = productCurrentVersion.indexOf("latest version") >= 0 ? "latest" : (productCurrentVersion.replace("version ", ""))
var productLatestVersion = getProductLangLatestVersion(product, lang)
var docsHomePage = getDocumentationLink(product, lang)
console.log(product, lang, docsHomePage)
let noteHtml = `
<div id="versionNote" style="width: 100%; padding: 20px; background: #b42727; color: #ffffff;border-radius: 5px;">This is the archived documentation for <span id="versionNoteOldVersion">${productCurrentVersion}</span>. If you are using the latest version<span id="versionNoteLatestVersion"> ${productLatestVersion}</span>, please visit <a class="noVersionAdd refreshLink" href="${docsHomePage}" style="color: #ffffff;text-decoration: underline !important;">this link</a>.
`
$(".markdown-body").prepend(noteHtml)
function initNoteForOldVersions(historyList = null) {
var queryProduct = getUrlVars(document.URL)["product"] ? getUrlVars(document.URL)["product"] : getCurrentUrlProductName(document.URL)
if (queryProduct == "dbr") {
var queryLang = getCurrentUrlLang(document.URL, true)
var currentVersion = $(".currentVersion").text().toLowerCase()
currentVersion = currentVersion.indexOf("latest version") >= 0 ? "latest" : (currentVersion.replace("version ", ""))
var majorVersion = currentVersion != "latest" ? Number(currentVersion.split(".")[0]) : "latest"
if ((queryLang == "js" || queryLang == "javascript") && majorVersion != "latest" && majorVersion <= 9) {
loadOldVersionNotes(queryProduct, queryLang, historyList);
}
}
}

function loadOldVersionNotes(product, lang, historyList = null) {
let lastestPageUri = $("#lastestPageUri").val()
if (!lastestPageUri || lastestPageUri == "") {
let historyLists = historyList? historyList : $("#categoryMenuTree_history .otherVersions li")
let flag = false
for(let i=0; i<historyLists.length; i++) {
let versionText = $(historyLists[i]).find("a").text().toLowerCase()
if (versionText.indexOf("latest") >= 0) {
lastestPageUri = $(historyLists[i]).find("a")[0].href
flag = true
}
}
if (!flag) {
lastestPageUri = location.origin + location.pathname
}
}
if (getCurrentUrlProductName(lastestPageUri) != product) {
lastestPageUri += ("?product=" + product + "&lang=" + lang)
}
if (getCurrentUrlProductName(lastestPageUri) == product && getCurrentUrlLang(lastestPageUri, true) != lang) {
lastestPageUri += ("?lang=" + lang)
}
if($("#versionNote").length == 0) {
let productCurrentVersion = $(".currentVersion").text().toLowerCase()
productCurrentVersion = productCurrentVersion.indexOf("latest version") >= 0 ? "latest" : (productCurrentVersion.replace("version ", ""))
var productLatestVersion = getProductLangLatestVersion(product, lang)
let noteHtml = `
<div id="versionNote" style="width: 100%; padding: 20px; background: #b42727; color: #ffffff;border-radius: 5px;">This is the archived documentation for <span id="versionNoteOldVersion">${productCurrentVersion}</span>. If you are using the latest version<span id="versionNoteLatestVersion"> ${productLatestVersion}</span>, please visit <a class="noVersionAdd refreshLink" href="${lastestPageUri}" style="color: #ffffff;text-decoration: underline !important;">this link</a>.
`
$(".markdown-body").prepend(noteHtml)
} else {
$("#versionNote .noVersionAdd").prop("href", lastestPageUri)
}
}
Loading

0 comments on commit a893fb2

Please sign in to comment.