Skip to content

Commit b744321

Browse files
update to internal commit 31ac9f0c
1 parent 863cd82 commit b744321

File tree

6 files changed

+227
-75
lines changed

6 files changed

+227
-75
lines changed

_includes/main-page-head.html

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
{%- assign enableLanguageSelection = "" -%}
2+
{%- if page.enableLanguageSelection -%}
3+
{%- assign enableLanguageSelection = "enableLanguageSelection" -%}
4+
{%- endif -%}
5+
{%- assign multiProgrammingLanguage = "" -%}
6+
{%- if page.multiProgrammingLanguage -%}
7+
{%- assign multiProgrammingLanguage = "multiProgrammingLanguage" -%}
8+
{%- endif -%}
9+
110
<div class="crumbsBox">
211
<div>
312
<div id="crumbs">
@@ -10,9 +19,34 @@
1019
{%- endcomment -%}
1120
</div>
1221
</div>
22+
23+
{%- if site.firstLevelUrl contains 'barcode-reader' -%}
24+
<div class="languageWrap {{multiProgrammingLanguage}} {{enableLanguageSelection}}">
25+
<label class="title">Language: </label>
26+
<div class="languageChange">
27+
<label class="chosenLanguage">Swift</label>
28+
<i class="fa fa-angle-down"></i>
29+
</div>
30+
<div class="languageSelectDown">
31+
<div data-value="swift" class="on">Swift</div>
32+
<div data-value="objc">Objective-C</div>
33+
</div>
34+
</div>
35+
{%- endif -%}
36+
1337
<div class="iconsBox">
1438
<div>
15-
<a href="{{ site.repositoryUrl }}/{{ page.path | strip }}" class="editLinkColour"><img src="{{ site.assets }}/img-icon/Edit-pencil-write-2.svg" width="30px" height="30px" style="vertical-align: middle;" title="Edit this page" data-placement="bottom" data-toggle="tooltip" data-html="true" /></a>
39+
{%- if page.category -%}
40+
{%- if page.category == 'js-repo' -%}
41+
<a href="{{ site.repositoryUrlJS }}/{{ page.path | strip }}" class="editLinkColour"><img src="{{ site.assets }}/img-icon/Edit-pencil-write-2.svg" width="30px" height="30px" style="vertical-align: middle;" title="Edit this page" data-placement="bottom" data-toggle="tooltip" data-html="true" /></a>
42+
{%- elsif page.category == 'mobile-repo' -%}
43+
<a href="{{ site.repositoryUrlMobile }}/{{ page.path | strip }}" class="editLinkColour"><img src="{{ site.assets }}/img-icon/Edit-pencil-write-2.svg" width="30px" height="30px" style="vertical-align: middle;" title="Edit this page" data-placement="bottom" data-toggle="tooltip" data-html="true" /></a>
44+
{%- else -%}
45+
<a href="{{ site.repositoryUrl }}/{{ page.path | strip }}" class="editLinkColour"><img src="{{ site.assets }}/img-icon/Edit-pencil-write-2.svg" width="30px" height="30px" style="vertical-align: middle;" title="Edit this page" data-placement="bottom" data-toggle="tooltip" data-html="true" /></a>
46+
{%- endif -%}
47+
{%- else -%}
48+
<a href="{{ site.repositoryUrl }}/{{ page.path | strip }}" class="editLinkColour"><img src="{{ site.assets }}/img-icon/Edit-pencil-write-2.svg" width="30px" height="30px" style="vertical-align: middle;" title="Edit this page" data-placement="bottom" data-toggle="tooltip" data-html="true" /></a>
49+
{%- endif -%}
1650
<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>
1751
</div>
1852
</div>

_includes/productNav/dbrNav.html

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,40 +10,19 @@
1010
<li class="breadcrumb-item active"><a href="/barcode-reader/docs/core/">Docs & SAMPLES</a></li>
1111
</ul>
1212
<div class="right-menu fr">
13+
<!-- {%- include search-input.html -%} -->
1314
<div class="trialAndPricing">
1415
<a href="https://www.dynamsoft.com/barcode-reader/downloads/" class="downloadBtn orangeBorder" style="margin-right: 10px;">Download <span class="hide-xl">30-Day Trial</span></a>
1516
<a class="downloadBtn" href="https://www.dynamsoft.com/store/dynamsoft-barcode-reader/">GetPricing</a>
1617
</div>
1718
</div>
18-
<!-- <div class="languageWrap" style="display: none;">
19-
<label class="title">Language: </label>
20-
<div class="languageChange">
21-
<label class="chosenLanguage">Swift</label>
22-
<i class="fa fa-angle-down"></i>
23-
</div>
24-
<div class="languageSelectDown">
25-
<div data-value="swift" class="on">Swift</div>
26-
<div data-value="objc">Objective-C</div>
27-
</div>
28-
</div> -->
2919
</div>
3020
</div>
3121
</div>
3222
<div class="container mobileProductMenu">
3323
<div class="row">
3424
<div class="col-12">
3525
<div class="productLogo"><i class="dbr-logo"></i> <i class="icon-orange-angle"></i></div>
36-
<!-- <div class="languageWrap" style="display: none;">
37-
<label class="title">Language: </label>
38-
<div class="languageChange">
39-
<label class="chosenLanguage">Swift</label>
40-
<i class="fa fa-angle-down"></i>
41-
</div>
42-
<div class="languageSelectDown">
43-
<div data-value="swift" class="on">Swift</div>
44-
<div data-value="objc">Objective-C</div>
45-
</div>
46-
</div> -->
4726
</div>
4827
</div>
4928
</div>
@@ -81,4 +60,4 @@
8160
</div>
8261
</div>
8362
</div>
84-
</div>
63+
</div>

_includes/productNav/dcvNav.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
<li class="breadcrumb-item overview"><a href="/capture-vision/docs/core/">Dynamsoft Capture Vision</a></li>
1010
<li class="breadcrumb-item active"><a href="/capture-vision/docs/core/introduction">Docs</a></li>
1111
</ul>
12+
<!-- <div class="right-menu fr">
13+
{%- include search-input.html -%}
14+
</div> -->
1215
</div>
1316
</div>
1417
</div>

_includes/search-input.html

Lines changed: 87 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<div class="d-search">
2+
<div id="facets" style="display: none;"></div>
23
<div class="d-search-input-wrap">
3-
<input class="d-search-input" id="searchbox" type="text" placeholder="Search">
4+
<input class="d-search-input" id="searchbox" type="text" placeholder="Search" autocomplete="new-password">
45
<button class="ais-SearchBox-reset" type="reset" title="Clear the search query">
56
<svg class="ais-SearchBox-resetIcon" viewBox="0 0 20 20" width="10" height="10" aria-hidden="true">
67
<path
@@ -16,6 +17,10 @@
1617
</div>
1718

1819
<script>
20+
var product = getCurrentUrlProductName(document.URL)
21+
var lang = getCurrentUrlLang(document.URL, true)
22+
var isNeedFilter = "{{site.searchNeedFilter}}"
23+
1924
const mySearch = instantsearch({
2025
indexName: '{{site.searchIndexName}}',
2126
searchClient: algoliasearch('989MTMK88E', '68565cc874554161b1842b2364287be7'),
@@ -29,27 +34,87 @@
2934
}
3035
});
3136

32-
mySearch.addWidgets([
33-
instantsearch.widgets.configure({
34-
hitsPerPage: 10,
35-
responseFields: ["*"],
36-
attributesToSnippet: ["content:15"],
37-
snippetEllipsisText: "...",
38-
removeWordsIfNoResults: "none"
39-
}),
37+
if (isNeedFilter == "true") {
38+
mySearch.addWidgets([
39+
instantsearch.widgets.configure({
40+
hitsPerPage: 10,
41+
responseFields: ["*"],
42+
attributesToRetrieve: ["*"],
43+
attributesToSnippet: ["content:15"],
44+
snippetEllipsisText: "...",
45+
removeWordsIfNoResults: "none",
46+
explain: ["*"],
47+
getRankingInfo: true,
48+
filters: 'languagues: "'+ (lang ? lang : "core") +'"'
49+
}),
4050

41-
instantsearch.widgets.hits({
42-
container: '#hits',
43-
templates: {
44-
item: (hit, { html, components }) => html`
45-
<div>
46-
<div class="hit-title"><a href="${hit.url}">${components.Highlight({ hit, attribute: 'title' })}</a></div>
47-
<div class="hit-content">${components.Snippet({ hit, attribute: 'content' })}</div>
48-
</div>
49-
`
50-
}
51-
})
52-
]);
51+
instantsearch.widgets.refinementList({
52+
container: '#facets',
53+
attribute: 'languagues',
54+
searchable: false
55+
}),
56+
57+
instantsearch.widgets.hits({
58+
container: '#hits',
59+
templates: {
60+
item: (hit, { html, components }) => {
61+
let temp_url = hit.url
62+
let temp_product = getCurrentUrlProductName(hit.url)
63+
let temp_lang = getCurrentUrlLang(hit.url, true)
64+
if (temp_product != product) {
65+
temp_url += "?product=" + product
66+
if (lang && lang != "") {
67+
temp_url += "&lang=" + lang
68+
}
69+
temp_url += "&q=" + $("#searchbox").val()
70+
} else {
71+
if (temp_lang != lang) {
72+
temp_url += "?lang=" + lang
73+
temp_url += "&q=" + $("#searchbox").val()
74+
} else {
75+
temp_url += "?q=" + $("#searchbox").val()
76+
}
77+
}
78+
var currentHost = location.host
79+
temp_url = temp_url.replace("www.dynamsoft.com", currentHost)
80+
return html`
81+
<div>
82+
<div class="hit-title"><a href="${temp_url}">${components.Highlight({ hit, attribute: 'title' })}</a></div>
83+
<div class="hit-content">${components.Snippet({ hit, attribute: 'content' })}</div>
84+
</div>
85+
`
86+
}
87+
}
88+
})
89+
]);
90+
} else {
91+
mySearch.addWidgets([
92+
instantsearch.widgets.configure({
93+
hitsPerPage: 10,
94+
responseFields: ["*"],
95+
attributesToSnippet: ["content:15"],
96+
snippetEllipsisText: "...",
97+
removeWordsIfNoResults: "none"
98+
}),
99+
100+
instantsearch.widgets.hits({
101+
container: '#hits',
102+
templates: {
103+
item: (hit, { html, components }) => {
104+
var temp_url = hit.url
105+
var currentHost = location.host
106+
temp_url = temp_url.replace("www.dynamsoft.com", currentHost)
107+
return html`
108+
<div>
109+
<div class="hit-title"><a href="${temp_url}?q=${$("#searchbox").val()}">${components.Highlight({ hit, attribute: 'title' })}</a></div>
110+
<div class="hit-content">${components.Snippet({ hit, attribute: 'content' })}</div>
111+
</div>
112+
`
113+
}
114+
}
115+
})
116+
]);
117+
}
53118

54119
mySearch.start();
55120

@@ -101,7 +166,7 @@
101166
} else {
102167
reporType = "core"
103168
}
104-
window.location.href = "/" + getDoumentName(product) + "/docs/" + reporType + "/search.html?q=" + $("#searchbox").val()
169+
window.location.href = "/" + getDoumentName(product) + "/docs/" + reporType + "/search.html?lang="+ (lang?lang:"core") + "&q=" + $("#searchbox").val()
105170
} else {
106171
let preUrl = document.URL.split("/docs/")[0]
107172
window.location.href = preUrl + "/docs/search.html?q=" + $("#searchbox").val()

_layouts/search-layout.html

Lines changed: 96 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
<div class="col-12 col-xl-10 col-xxl-8 offset-xl-1 offset-xxl-2">
5353
<h1 class="h2 fontOswald tc">{{page.h1}}</h1>
5454
<div class="content mt60">
55+
<div id="facets" style="display: none;"></div>
5556
<div id="searchbox">
5657
<div class="ais-SearchBox-form">
5758
<input id="custom-searchbox" class="ais-SearchBox-input" type="search" placeholder="Search for products..."
@@ -82,37 +83,107 @@ <h1 class="h2 fontOswald tc">{{page.h1}}</h1>
8283
<script src="https://www.dynamsoft.com/webres/wwwroot/js/util.min.js"></script>
8384
<script src="https://www.dynamsoft.com/webres/wwwroot/js/site.min.js"></script>
8485
<script src="https://www.dynamsoft.com/webres/wwwroot/js/header.min.js"></script>
86+
<script src="https://www.dynamsoft.com/webres/wwwroot/js/docs/index-banner.min.js"></script>
8587
<script>
88+
var product = getCurrentUrlProductName(document.URL)
89+
var lang = getCurrentUrlLang(document.URL, true)
90+
var isNeedFilter = "{{site.searchNeedFilter}}"
91+
8692
const mySearch = instantsearch({
8793
indexName: '{{indexName}}',
8894
searchClient: algoliasearch('989MTMK88E', '68565cc874554161b1842b2364287be7'),
8995
});
9096

91-
mySearch.addWidgets([
92-
instantsearch.widgets.configure({
93-
hitsPerPage: 10,
94-
responseFields: ["*"],
95-
attributesToSnippet: ["content:30"],
96-
snippetEllipsisText: "...",
97-
}),
98-
99-
instantsearch.widgets.hits({
100-
container: '#hits',
101-
templates: {
102-
item: (hit, { html, components }) => html`
103-
<div>
104-
<div class="hit-title"><a href="${hit.url}">${components.Highlight({ hit, attribute: 'title' })}</a></div>
105-
<div class="hit-url">${hit.url}</div>
106-
<div class="hit-content">${components.Snippet({ hit, attribute: 'content' })}</div>
107-
</div>
108-
`
109-
}
110-
}),
111-
112-
instantsearch.widgets.pagination({
113-
container: '#pagination'
114-
})
115-
]);
97+
if (isNeedFilter == "true") {
98+
mySearch.addWidgets([
99+
instantsearch.widgets.configure({
100+
hitsPerPage: 10,
101+
responseFields: ["*"],
102+
attributesToRetrieve: ["*"],
103+
attributesToSnippet: ["content:30"],
104+
snippetEllipsisText: "...",
105+
explain: ["*"],
106+
getRankingInfo: true,
107+
filters: 'languagues: "'+ (lang ? lang : "core") +'"'
108+
}),
109+
110+
instantsearch.widgets.refinementList({
111+
container: '#facets',
112+
attribute: 'languagues',
113+
searchable: false
114+
}),
115+
116+
instantsearch.widgets.hits({
117+
container: '#hits',
118+
templates: {
119+
item: (hit, { html, components }) => {
120+
let temp_url = hit.url
121+
let temp_product = getCurrentUrlProductName(hit.url)
122+
let temp_lang = getCurrentUrlLang(hit.url, true)
123+
if (temp_product != product) {
124+
temp_url += "?product=" + product
125+
if (lang && lang != "") {
126+
temp_url += "&lang=" + lang
127+
}
128+
temp_url += "&q=" + $("#custom-searchbox").val()
129+
} else {
130+
if (temp_lang != lang) {
131+
temp_url += "?lang=" + lang
132+
temp_url += "&q=" + $("#custom-searchbox").val()
133+
} else {
134+
temp_url += "?q=" + $("#custom-searchbox").val()
135+
}
136+
}
137+
var currentHost = location.host
138+
temp_url = temp_url.replace("www.dynamsoft.com", currentHost)
139+
return html`
140+
<div>
141+
<div class="hit-title"><a href="${temp_url}">${components.Highlight({ hit, attribute: 'title' })}</a></div>
142+
<div class="hit-url">${hit.url}</div>
143+
<div class="hit-content">${components.Snippet({ hit, attribute: 'content' })}</div>
144+
</div>
145+
`
146+
}
147+
}
148+
}),
149+
150+
instantsearch.widgets.pagination({
151+
container: '#pagination'
152+
})
153+
]);
154+
} else {
155+
mySearch.addWidgets([
156+
instantsearch.widgets.configure({
157+
hitsPerPage: 10,
158+
responseFields: ["*"],
159+
attributesToRetrieve: ["*"],
160+
attributesToSnippet: ["content:30"],
161+
snippetEllipsisText: "..."
162+
}),
163+
164+
instantsearch.widgets.hits({
165+
container: '#hits',
166+
templates: {
167+
item: (hit, { html, components }) => {
168+
var temp_url = hit.url
169+
var currentHost = location.host
170+
temp_url = temp_url.replace("www.dynamsoft.com", currentHost)
171+
return html`
172+
<div>
173+
<div class="hit-title"><a href="${temp_url}?q=${$("#custom-searchbox").val()}">${components.Highlight({ hit, attribute: 'title' })}</a></div>
174+
<div class="hit-url">${hit.url}</div>
175+
<div class="hit-content">${components.Snippet({ hit, attribute: 'content' })}</div>
176+
</div>
177+
`
178+
}
179+
}
180+
}),
181+
182+
instantsearch.widgets.pagination({
183+
container: '#pagination'
184+
})
185+
]);
186+
}
116187

117188
mySearch.start();
118189

0 commit comments

Comments
 (0)