### Help Toolbar Search Form
Source: https://gitee.com/SanHuoYan/linshi/blob/master/llms.txt
Implements a search form within the side toolbar for the help center. It uses GET method to submit keywords for searching help documentation.
```html
```
--------------------------------
### Initialize Popover Card Locale
Source: https://gitee.com/SanHuoYan/linshi/blob/master/llms.txt
Sets up locale-specific text for popover cards, including follow/unfollow states and project/organization information. This script is typically run on page load.
```javascript
var officialEmail = $('#git-footer-email').text()
$('#git-footer-main .icon-popup').popup({ position: 'bottom center' })
$('#git-footer-email').text(officialEmail.replace('#', '@'))
window.gon.popover_card_locale = {
follow:"Follow",
unfollow:"Following",
gvp_title: "GVP - Gitee Most Valuable Project",
project: "The author of ",
org: "The member of ",
member: "",
author: "",
user_blocked: "This account has been blocked or destroyed",
net_error: "Network error ",
unknown_exception: "Unknown exception"
}
window.gon.select_message = {
placeholder: "Please enter Gitee Profile Address or email address"
}
```
--------------------------------
### Load External JavaScript and CSS
Source: https://gitee.com/SanHuoYan/linshi/blob/master/llms.txt
Includes external JavaScript bundles for popover cards, NPS functionality, and icons, along with CSS for NPS styling. These are essential for the interactive elements and styling on the page.
```html
```
--------------------------------
### Load Branch Data with AJAX
Source: https://gitee.com/SanHuoYan/linshi/blob/master/llms.txt
Fetches branch data from the server using AJAX. Handles pagination, search parameters, and displays branch information, including protected branch icons and rules. Appends data to the branches dropdown.
```javascript
function loadData(search, page) {
if (concurrentRequestLock) { return; }
concurrentRequestLock = true;
var searchParams = search || "";
var pageParams = page || 1;
$.ajax({
url: "/" + gon.user_project + "/branches/names.json",
type: 'GET',
data: {
search: searchParams,
page: pageParams,
},
dataType: 'json',
success: function (data) {
branch_total_pager = data.total_pages;
var html = '';
if (pageParams === 1) {
$branchesDropdown.empty();
}
data.branches.forEach(function (branch) {
var protectRule = '';
var branchName = filterXSS(branch.name);
var icon = 'gitee:branch'
if(branch.branch_type.value === 1) {
var rule = filterXSS(branch.protection_rule.wildcard);
protectRule = ``
icon ='gitee:pen-lock'
}else if(branch.branch_type.value === 2) {
icon ='gitee:pen-ban'
}
var branchIcon = ``
html += `
${branchIcon}
${branchName} ${protectRule}
`
});
$branchesDropdown.append(html);
$('.protected-branch-popup').popup()
if (pageParams === 1 && data.count === 0) {
toggleNoResultView($branchesDropdown);
}
},
complete: function () {
concurrentRequestLock = false;
}
});
}
```
--------------------------------
### Fetch Tag Data with AJAX
Source: https://gitee.com/SanHuoYan/linshi/blob/master/llms.txt
Fetches tag data from the server using AJAX. Handles pagination and search parameters. Appends new tag items to the tags dropdown.
```javascript
function fetchTags(search, page) {
var searchParams = search || "";
var pageParams = page || 1;
if (flag_is_loading) return;
flag_is_loading = true;
$.ajax({
url: "/" + gon.user_project + "/tags/names.json",
data: {
search: searchParams,
page: pageParams,
},
type: "GET",
xhrFields: {
withCredentials: true,
},
success: function (data) {
flag_total_pager = data.total_pages;
if (pageParams === 1) {
$tagsDropdown.html('');
}
data.tags.forEach((tag) => {
const itemDiv = document.createElement('div');
itemDiv.classList.add('item');
itemDiv.setAttribute('data-value', tag.name);
itemDiv.innerText = window.filterXSS(tag.name);
$tagsDropdown.append(itemDiv)
});
if (pageParams === 1 && data.count === 0) {
toggleNoResultView($tagsDropdown);
}
},
error: function () {
},
complete: function () {
flag_is_loading = false;
},
});
}
```
--------------------------------
### Tab Menu Click Handler for Branches and Tags
Source: https://gitee.com/SanHuoYan/linshi/blob/master/llms.txt
Handles click events on tab menu items for branches and tags. Resets search input and triggers data loading for the selected tab.
```javascript
$('.project-branch-tab-menu').on('click','.tab-menu-item', function (e) {
var $currentTab = $(this).data('tab')
if($currentTab === 'branches') {
$searchNameInput.val('')
search_text = '';
loadData()
}
if($currentTab === 'tags') {
$searchNameInput.val('')
search_text = '';
fetchTags();
}
})
```
--------------------------------
### Toggle No Result View
Source: https://gitee.com/SanHuoYan/linshi/blob/master/llms.txt
Appends an HTML element to a panel to indicate that no data is available. This is used when search results or data fetches return empty.
```javascript
function toggleNoResultView($popPanel) {
let no_data_html= `
暂无数据
`
$popPanel.append(no_data_html)
}
```
--------------------------------
### Debounce for Loading More Branches
Source: https://gitee.com/SanHuoYan/linshi/blob/master/llms.txt
Creates a debounced function to load more branch data. Prevents excessive API calls by delaying execution until after a specified period of inactivity. It checks for a concurrent request lock.
```javascript
var debounceLoadMoreBranches = window.globalUtils.debouce(function () {
if (concurrentRequestLock) return;
branch_page_number += 1;
if (branch_page_number > branch_total_pager) return;
loadData(search_text, branch_page_number);
}, 350);
```
--------------------------------
### Debounce for Loading More Tags
Source: https://gitee.com/SanHuoYan/linshi/blob/master/llms.txt
Creates a debounced function to fetch more tag data. This helps to limit the rate at which tag data is fetched, especially during scrolling or rapid user input. It checks a loading flag.
```javascript
var debounceLoadMore = window.globalUtils.debouce(function () {
if (flag_is_loading) return;
flag_page_number += 1;
if (flag_page_number > flag_total_pager) return;
fetchTags(search_text, flag_page_number);
}, 350);
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.