feat: 初始化导航网站项目
添加 Flask 导航站应用,包含 Docker 部署配置、SQLite 数据库、静态资源及 CI/CD 流水线。
这个提交包含在:
@@ -0,0 +1,842 @@
|
||||
|
||||
|
||||
// analytics.js
|
||||
|
||||
// date range
|
||||
var establishedAt = new Date($('meta[name=established_at]').attr('content'));
|
||||
// function siteEstablishedDays() {
|
||||
// let d = new Date();
|
||||
// let today = new Date(d.getFullYear(), d.getMonth(), d.getDate());
|
||||
// return Math.floor((today - establishedAt) / 86400000 + 1);
|
||||
// };
|
||||
|
||||
// clock
|
||||
$('#established-at').countdown(establishedAt, {
|
||||
elapse: true
|
||||
}).on('update.countdown', function (event) {
|
||||
if (event.elapsed) {
|
||||
$(this).html(event.strftime('<div class="ui label"><i class="rocket icon"></i>已上线</div><div class="ui label">%D<div class="detail">天</div></div><div class="ui label">%-H<div class="detail">小时</div></div><div class="ui label">%-M<div class="detail">分</div></div><div class="ui label">%-S<div class="detail">秒</div></div>'));
|
||||
};
|
||||
});
|
||||
|
||||
// visit
|
||||
var countUpOptions = {
|
||||
useEasing: true,
|
||||
useGrouping: true,
|
||||
separator: ',',
|
||||
decimal: '.',
|
||||
prefix: '',
|
||||
suffix: ''
|
||||
};
|
||||
var yesterdayVisitorsCountUp = new CountUp('yesterday-visitors-stat', 0, 0, 0, 2.5, countUpOptions);
|
||||
var yesterdayVisitsCountUp = new CountUp('yesterday-visits-stat', 0, 0, 0, 2.5, countUpOptions);
|
||||
var yesterdayActionsCountUp = new CountUp('yesterday-actions-stat', 0, 0, 0, 2.5, countUpOptions);
|
||||
// var totalActionsCountUp = new CountUp('total-actions', 0, 0, 0, 2.5, countUpOptions);
|
||||
var liveVisitorsCountUp = new CountUp('live-visitors-stat', 0, 0, 0, 2.5, countUpOptions);
|
||||
var todayVisitorsCountUp = new CountUp('today-visitors-stat', 0, 0, 0, 2.5, countUpOptions);
|
||||
var todayVisitsCountUp = new CountUp('today-visits-stat', 0, 0, 0, 2.5, countUpOptions);
|
||||
var todayActionsCountUp = new CountUp('today-actions-stat', 0, 0, 0, 2.5, countUpOptions);
|
||||
$.getJSON('{{ site.data.analytics.matomo.url }}', {
|
||||
'module': 'API',
|
||||
'method': 'VisitsSummary.getUniqueVisitors',
|
||||
'idSite': '{{ site.data.analytics.matomo.site_id }}',
|
||||
'period': 'day',
|
||||
'date': 'yesterday',
|
||||
'format': 'JSON',
|
||||
'token_auth': '{{ site.data.analytics.matomo.token }}'
|
||||
}, function (data) {
|
||||
yesterdayVisitorsCountUp.update(data.value);
|
||||
});
|
||||
$.getJSON('{{ site.data.analytics.matomo.url }}', {
|
||||
'module': 'API',
|
||||
'method': 'VisitsSummary.getVisits',
|
||||
'idSite': '{{ site.data.analytics.matomo.site_id }}',
|
||||
'period': 'day',
|
||||
'date': 'yesterday',
|
||||
'format': 'JSON',
|
||||
'token_auth': '{{ site.data.analytics.matomo.token }}'
|
||||
}, function (data) {
|
||||
yesterdayVisitsCountUp.update(data.value);
|
||||
});
|
||||
$.getJSON('{{ site.data.analytics.matomo.url }}', {
|
||||
'module': 'API',
|
||||
'method': 'VisitsSummary.getActions',
|
||||
'idSite': '{{ site.data.analytics.matomo.site_id }}',
|
||||
'period': 'day',
|
||||
'date': 'yesterday',
|
||||
'format': 'JSON',
|
||||
'token_auth': '{{ site.data.analytics.matomo.token }}'
|
||||
}, function (data) {
|
||||
yesterdayActionsCountUp.update(data.value);
|
||||
});
|
||||
(function updateVisit() {
|
||||
if (!document.hidden) {
|
||||
// $.getJSON('{{ site.data.analytics.matomo.url }}', {
|
||||
// 'module': 'API',
|
||||
// 'method': 'VisitsSummary.getActions',
|
||||
// 'idSite': '{{ site.data.analytics.matomo.site_id }}',
|
||||
// 'period': 'range',
|
||||
// 'date': `last${siteEstablishedDays()}`,
|
||||
// 'format': 'JSON',
|
||||
// 'token_auth': '{{ site.data.analytics.matomo.token }}'
|
||||
// }, function (data) {
|
||||
// totalActionsCountUp.update(data.value);
|
||||
// });
|
||||
$.getJSON('{{ site.data.analytics.matomo.url }}', {
|
||||
'module': 'API',
|
||||
'method': 'Live.getCounters',
|
||||
'idSite': '{{ site.data.analytics.matomo.site_id }}',
|
||||
'lastMinutes': '30',
|
||||
'format': 'JSON',
|
||||
'token_auth': '{{ site.data.analytics.matomo.token }}'
|
||||
}, function (data) {
|
||||
liveVisitorsCountUp.update(data[0].visitors);
|
||||
});
|
||||
$.getJSON('{{ site.data.analytics.matomo.url }}', {
|
||||
'module': 'API',
|
||||
'method': 'VisitsSummary.getUniqueVisitors',
|
||||
'idSite': '{{ site.data.analytics.matomo.site_id }}',
|
||||
'period': 'day',
|
||||
'date': 'today',
|
||||
'format': 'JSON',
|
||||
'token_auth': '{{ site.data.analytics.matomo.token }}'
|
||||
}, function (data) {
|
||||
todayVisitorsCountUp.update(data.value);
|
||||
});
|
||||
$.getJSON('{{ site.data.analytics.matomo.url }}', {
|
||||
'module': 'API',
|
||||
'method': 'VisitsSummary.getVisits',
|
||||
'idSite': '{{ site.data.analytics.matomo.site_id }}',
|
||||
'period': 'day',
|
||||
'date': 'today',
|
||||
'format': 'JSON',
|
||||
'token_auth': '{{ site.data.analytics.matomo.token }}'
|
||||
}, function (data) {
|
||||
todayVisitsCountUp.update(data.value);
|
||||
});
|
||||
$.getJSON('{{ site.data.analytics.matomo.url }}', {
|
||||
'module': 'API',
|
||||
'method': 'VisitsSummary.getActions',
|
||||
'idSite': '{{ site.data.analytics.matomo.site_id }}',
|
||||
'period': 'day',
|
||||
'date': 'today',
|
||||
'format': 'JSON',
|
||||
'token_auth': '{{ site.data.analytics.matomo.token }}'
|
||||
}, function (data) {
|
||||
todayActionsCountUp.update(data.value);
|
||||
});
|
||||
};
|
||||
setTimeout(function () {
|
||||
updateVisit();
|
||||
}, 1000);
|
||||
})();
|
||||
|
||||
// chart
|
||||
var visitSummaryChart = echarts.init(document.getElementById('visit-summary'), 'light');
|
||||
visitSummaryChart.setOption({
|
||||
baseOption: {
|
||||
title: {
|
||||
text: '访客数据总览(过去90天)',
|
||||
left: 'center'
|
||||
},
|
||||
legend: {
|
||||
data: ['访客数', '访问次数', '浏览次数'],
|
||||
right: 'center',
|
||||
top: 30
|
||||
},
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
axisPointer: {
|
||||
type: 'shadow'
|
||||
}
|
||||
},
|
||||
toolbox: {
|
||||
showTitle: false,
|
||||
feature: {
|
||||
restore: {},
|
||||
magicType: {
|
||||
type: ['bar', 'line']
|
||||
},
|
||||
dataView: {
|
||||
readOnly: true
|
||||
},
|
||||
saveAsImage: {
|
||||
excludeComponents: ['toolbox', 'dataZoom']
|
||||
}
|
||||
}
|
||||
},
|
||||
dataZoom: [
|
||||
{
|
||||
type: 'slider',
|
||||
show: true,
|
||||
realtime: true,
|
||||
xAxisIndex: [0],
|
||||
start: 50,
|
||||
end: 100
|
||||
}
|
||||
],
|
||||
xAxis: {
|
||||
type : 'category',
|
||||
data: []
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value'
|
||||
},
|
||||
series: [{
|
||||
name: '访客数',
|
||||
type: 'bar',
|
||||
data: [],
|
||||
animationDelay: function (idx) {
|
||||
return idx * 10;
|
||||
}
|
||||
}, {
|
||||
name: '访问次数',
|
||||
type: 'bar',
|
||||
data: [],
|
||||
animationDelay: function (idx) {
|
||||
return idx * 10 + 100;
|
||||
}
|
||||
}, {
|
||||
name: '浏览次数',
|
||||
type: 'bar',
|
||||
data: [],
|
||||
animationDelay: function (idx) {
|
||||
return idx * 10 + 200;
|
||||
}
|
||||
}],
|
||||
animationEasing: 'elasticOut',
|
||||
animationDelayUpdate: function (idx) {
|
||||
return idx * 5;
|
||||
}
|
||||
},
|
||||
media: [{
|
||||
query: {
|
||||
maxWidth: 767
|
||||
},
|
||||
option: {
|
||||
legend: {
|
||||
orient: 'vertical'
|
||||
},
|
||||
grid: {
|
||||
top: 110,
|
||||
left: 40,
|
||||
right: 10
|
||||
},
|
||||
toolbox: {
|
||||
show: false
|
||||
}
|
||||
}
|
||||
}]
|
||||
});
|
||||
(function updateVisitSummaryChart() {
|
||||
if (!document.hidden) {
|
||||
$.getJSON('{{ site.data.analytics.matomo.url }}', {
|
||||
'module': 'API',
|
||||
'method': 'VisitsSummary.getUniqueVisitors',
|
||||
'idSite': '{{ site.data.analytics.matomo.site_id }}',
|
||||
'period': 'day',
|
||||
'date': 'last90',
|
||||
'format': 'JSON',
|
||||
'token_auth': '{{ site.data.analytics.matomo.token }}'
|
||||
}, function (data) {
|
||||
var days = [];
|
||||
var visitors = [];
|
||||
for (var i in data) {
|
||||
days.push(i);
|
||||
visitors.push(data[i]);
|
||||
};
|
||||
visitSummaryChart.setOption({
|
||||
xAxis: {
|
||||
data: days
|
||||
},
|
||||
series: [{
|
||||
name: '访客数',
|
||||
data: visitors
|
||||
}]
|
||||
});
|
||||
});
|
||||
$.getJSON('{{ site.data.analytics.matomo.url }}', {
|
||||
'module': 'API',
|
||||
'method': 'VisitsSummary.getVisits',
|
||||
'idSite': '{{ site.data.analytics.matomo.site_id }}',
|
||||
'period': 'day',
|
||||
'date': 'last90',
|
||||
'format': 'JSON',
|
||||
'token_auth': '{{ site.data.analytics.matomo.token }}'
|
||||
}, function (data) {
|
||||
var visits = [];
|
||||
for (var i in data) {
|
||||
visits.push(data[i]);
|
||||
};
|
||||
visitSummaryChart.setOption({
|
||||
series: [{
|
||||
name: '访问次数',
|
||||
data: visits
|
||||
}]
|
||||
});
|
||||
});
|
||||
$.getJSON('{{ site.data.analytics.matomo.url }}', {
|
||||
'module': 'API',
|
||||
'method': 'VisitsSummary.getActions',
|
||||
'idSite': '{{ site.data.analytics.matomo.site_id }}',
|
||||
'period': 'day',
|
||||
'date': 'last90',
|
||||
'format': 'JSON',
|
||||
'token_auth': '{{ site.data.analytics.matomo.token }}'
|
||||
}, function (data) {
|
||||
var actions = [];
|
||||
for (var i in data) {
|
||||
actions.push(data[i]);
|
||||
};
|
||||
visitSummaryChart.setOption({
|
||||
series: [{
|
||||
name: '浏览次数',
|
||||
data: actions
|
||||
}]
|
||||
});
|
||||
});
|
||||
};
|
||||
setTimeout(function () {
|
||||
updateVisitSummaryChart();
|
||||
}, 1000);
|
||||
})();
|
||||
|
||||
var visitHourlyChart = echarts.init(document.getElementById('visit-hourly'), 'light');
|
||||
visitHourlyChart.setOption({
|
||||
baseOption: {
|
||||
title: {
|
||||
text: '访客数据(7×24小时)',
|
||||
left: 'center'
|
||||
},
|
||||
legend: {
|
||||
data: ['访客数', '访问次数', '浏览次数'],
|
||||
selectedMode: 'single',
|
||||
right: 'center',
|
||||
top: 30
|
||||
},
|
||||
tooltip: {
|
||||
position: 'top',
|
||||
formatter: function (params) {
|
||||
return `${params.value[1]} ${params.value[0]}<br>${params.seriesName}: ${params.value[2]}`;
|
||||
}
|
||||
},
|
||||
toolbox: {
|
||||
showTitle: false,
|
||||
feature: {
|
||||
restore: {},
|
||||
saveAsImage: {
|
||||
excludeComponents: ['toolbox']
|
||||
}
|
||||
}
|
||||
},
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
data: ['00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23'],
|
||||
boundaryGap: false,
|
||||
splitLine: {
|
||||
show: true,
|
||||
lineStyle: {
|
||||
type: 'dashed'
|
||||
}
|
||||
},
|
||||
axisLine: {
|
||||
show: false
|
||||
}
|
||||
},
|
||||
yAxis: {
|
||||
type: 'category',
|
||||
data: [],
|
||||
axisLine: {
|
||||
show: false
|
||||
}
|
||||
},
|
||||
series: [{
|
||||
name: '访客数',
|
||||
type: 'scatter',
|
||||
data: [],
|
||||
animationDelay: function (idx) {
|
||||
return idx * 10 + 100;
|
||||
}
|
||||
},
|
||||
{
|
||||
name: '访问次数',
|
||||
type: 'scatter',
|
||||
data: [],
|
||||
animationDelay: function (idx) {
|
||||
return idx * 10 + 100;
|
||||
}
|
||||
},
|
||||
{
|
||||
name: '浏览次数',
|
||||
type: 'scatter',
|
||||
data: [],
|
||||
animationDelay: function (idx) {
|
||||
return idx * 10 + 100;
|
||||
}
|
||||
}]
|
||||
},
|
||||
media: [{
|
||||
query: {
|
||||
maxWidth: 767
|
||||
},
|
||||
option: {
|
||||
legend: {
|
||||
orient: 'vertical'
|
||||
},
|
||||
grid: {
|
||||
top: 110,
|
||||
left: 70,
|
||||
right: 10
|
||||
},
|
||||
toolbox: {
|
||||
show: false
|
||||
}
|
||||
}
|
||||
}]
|
||||
});
|
||||
function normalizeSymbolSize(val, data, resize) {
|
||||
if (val === 0) {
|
||||
return 0;
|
||||
} else {
|
||||
if (resize) {
|
||||
var max = 20;
|
||||
var min = 5;
|
||||
} else {
|
||||
var max = 40;
|
||||
var min = 10;
|
||||
};
|
||||
var data_max = Math.max(...data.map(function(item) {
|
||||
return item[2];
|
||||
}));
|
||||
var data_min = Math.min(...data.map(function(item) {
|
||||
return item[2];
|
||||
}));
|
||||
if (data_max === data_min) {
|
||||
return (max - min) / 2 + min;
|
||||
} else {
|
||||
return (val - data_min) / (data_max - data_min) * (max - min) + min;
|
||||
};
|
||||
};
|
||||
};
|
||||
(function updateVisitHourlyChart() {
|
||||
if (!document.hidden) {
|
||||
$.getJSON('{{ site.data.analytics.matomo.url }}', {
|
||||
'module': 'API',
|
||||
'method': 'VisitTime.getVisitInformationPerServerTime',
|
||||
'idSite': '{{ site.data.analytics.matomo.site_id }}',
|
||||
'period': 'day',
|
||||
'date': 'last7',
|
||||
'format': 'JSON',
|
||||
'token_auth': '{{ site.data.analytics.matomo.token }}'
|
||||
}, function (data) {
|
||||
var days = [];
|
||||
var visitors = [];
|
||||
var visits = [];
|
||||
var actions = [];
|
||||
for (var day in data) {
|
||||
days.unshift(day);
|
||||
for (var hourNum in data[day]) {
|
||||
visitors.push([data[day][hourNum]['label'], day, data[day][hourNum]['nb_uniq_visitors']]);
|
||||
visits.push([data[day][hourNum]['label'], day, data[day][hourNum]['nb_visits']]);
|
||||
actions.push([data[day][hourNum]['label'], day, data[day][hourNum]['nb_actions']]);
|
||||
};
|
||||
};
|
||||
visitHourlyChart.setOption({
|
||||
baseOption: {
|
||||
yAxis: {
|
||||
data: days
|
||||
},
|
||||
series: [{
|
||||
name: '访客数',
|
||||
data: visitors,
|
||||
symbolSize: function (val) {
|
||||
return normalizeSymbolSize(val[2], visitors, false);
|
||||
}
|
||||
},
|
||||
{
|
||||
name: '访问次数',
|
||||
data: visits,
|
||||
symbolSize: function (val) {
|
||||
return normalizeSymbolSize(val[2], visits, false);
|
||||
}
|
||||
},
|
||||
{
|
||||
name: '浏览次数',
|
||||
data: actions,
|
||||
symbolSize: function (val) {
|
||||
return normalizeSymbolSize(val[2], actions, false);
|
||||
}
|
||||
}]
|
||||
},
|
||||
media: [{
|
||||
query: {
|
||||
maxWidth: 767
|
||||
},
|
||||
option: {
|
||||
series: [{
|
||||
name: '访客数',
|
||||
data: visitors,
|
||||
symbolSize: function (val) {
|
||||
return normalizeSymbolSize(val[2], visitors, true);
|
||||
}
|
||||
},
|
||||
{
|
||||
name: '访问次数',
|
||||
data: visits,
|
||||
symbolSize: function (val) {
|
||||
return normalizeSymbolSize(val[2], visits, true);
|
||||
}
|
||||
},
|
||||
{
|
||||
name: '浏览次数',
|
||||
data: actions,
|
||||
symbolSize: function (val) {
|
||||
return normalizeSymbolSize(val[2], actions, true);
|
||||
}
|
||||
}]
|
||||
}
|
||||
}]
|
||||
});
|
||||
});
|
||||
};
|
||||
setTimeout(function () {
|
||||
updateVisitHourlyChart();
|
||||
}, 1000);
|
||||
})();
|
||||
|
||||
var visitMapChart = echarts.init(document.getElementById('visit-map'), 'light');
|
||||
visitMapChart.setOption({
|
||||
baseOption: {
|
||||
title: {
|
||||
text: '本月访客来源',
|
||||
left: 'center'
|
||||
},
|
||||
legend: {
|
||||
data: ['访客数', '访问次数', '浏览次数'],
|
||||
selectedMode: 'single',
|
||||
right: 'center',
|
||||
top: 30
|
||||
},
|
||||
tooltip: {
|
||||
trigger: 'item',
|
||||
formatter: function (params) {
|
||||
var value = params.value;
|
||||
if (!value) {
|
||||
value = 0;
|
||||
};
|
||||
return `${params.seriesName}: ${value}`;
|
||||
}
|
||||
},
|
||||
toolbox: {
|
||||
showTitle: false,
|
||||
feature: {
|
||||
restore: {},
|
||||
saveAsImage: {
|
||||
excludeComponents: ['toolbox']
|
||||
}
|
||||
}
|
||||
},
|
||||
visualMap: {
|
||||
min: 0,
|
||||
max: 5000,
|
||||
text:['High','Low'],
|
||||
calculable: true
|
||||
},
|
||||
series: [{
|
||||
name: '访客数',
|
||||
type: 'map',
|
||||
mapType: 'world',
|
||||
showLegendSymbol: false,
|
||||
itemStyle: {
|
||||
emphasis: {
|
||||
label: {
|
||||
show:true
|
||||
}
|
||||
}
|
||||
},
|
||||
data:[]
|
||||
},
|
||||
{
|
||||
name: '访问次数',
|
||||
type: 'map',
|
||||
mapType: 'world',
|
||||
showLegendSymbol: false,
|
||||
itemStyle: {
|
||||
emphasis: {
|
||||
label: {
|
||||
show:true
|
||||
}
|
||||
}
|
||||
},
|
||||
data:[]
|
||||
},
|
||||
{
|
||||
name: '浏览次数',
|
||||
type: 'map',
|
||||
mapType: 'world',
|
||||
showLegendSymbol: false,
|
||||
itemStyle: {
|
||||
emphasis: {
|
||||
label: {
|
||||
show:true
|
||||
}
|
||||
}
|
||||
},
|
||||
data:[]
|
||||
}]
|
||||
},
|
||||
media: [{
|
||||
query: {
|
||||
maxWidth: 767
|
||||
},
|
||||
option: {
|
||||
legend: {
|
||||
orient: 'vertical'
|
||||
},
|
||||
toolbox: {
|
||||
show: false
|
||||
}
|
||||
}
|
||||
}]
|
||||
});
|
||||
(function updateVisitMapChart() {
|
||||
if (!document.hidden) {
|
||||
$.getJSON('{{ site.data.analytics.matomo.url }}', {
|
||||
'module': 'API',
|
||||
'method': 'UserCountry.getCountry',
|
||||
'idSite': '{{ site.data.analytics.matomo.site_id }}',
|
||||
'period': 'month',
|
||||
'date': 'today',
|
||||
'format': 'JSON',
|
||||
'token_auth': '{{ site.data.analytics.matomo.token }}'
|
||||
}, function (data) {
|
||||
var visitors = [];
|
||||
var visits = [];
|
||||
var actions = [];
|
||||
var visitorsChina = 0;
|
||||
var visitsChina = 0;
|
||||
var actionsChina = 0;
|
||||
for (var i in data) {
|
||||
if (data[i]['label'] == 'China') {
|
||||
var visitorsChina = visitorsChina + data[i]['sum_daily_nb_uniq_visitors'];
|
||||
var visitsChina = visitsChina + data[i]['nb_visits'];
|
||||
var actionsChina = actionsChina + data[i]['nb_actions'];
|
||||
} else if (data[i]['label'] == 'Hong Kong SAR China') {
|
||||
var visitorsChina = visitorsChina + data[i]['sum_daily_nb_uniq_visitors'];
|
||||
var visitsChina = visitsChina + data[i]['nb_visits'];
|
||||
var actionsChina = actionsChina + data[i]['nb_actions'];
|
||||
} else if (data[i]['label'] == 'Taiwan') {
|
||||
var visitorsChina = visitorsChina + data[i]['sum_daily_nb_uniq_visitors'];
|
||||
var visitsChina = visitsChina + data[i]['nb_visits'];
|
||||
var actionsChina = actionsChina + data[i]['nb_actions'];
|
||||
} else if (data[i]['label'] == 'Unknown') {
|
||||
var visitorsChina = visitorsChina + data[i]['sum_daily_nb_uniq_visitors'];
|
||||
var visitsChina = visitsChina + data[i]['nb_visits'];
|
||||
var actionsChina = actionsChina + data[i]['nb_actions'];
|
||||
} else {
|
||||
visitors.push({
|
||||
'name': data[i]['label'],
|
||||
'value': data[i]['sum_daily_nb_uniq_visitors']
|
||||
});
|
||||
visits.push({
|
||||
'name': data[i]['label'],
|
||||
'value': data[i]['nb_visits']
|
||||
});
|
||||
actions.push({
|
||||
'name': data[i]['label'],
|
||||
'value': data[i]['nb_actions']
|
||||
});
|
||||
};
|
||||
};
|
||||
visitors.push({
|
||||
'name': 'China',
|
||||
'value': visitorsChina
|
||||
});
|
||||
visits.push({
|
||||
'name': 'China',
|
||||
'value': visitsChina
|
||||
});
|
||||
actions.push({
|
||||
'name': 'China',
|
||||
'value': actionsChina
|
||||
});
|
||||
visitMapChart.setOption({
|
||||
series: [{
|
||||
name: '访客数',
|
||||
data: visitors
|
||||
},
|
||||
{
|
||||
name: '访问次数',
|
||||
data: visits
|
||||
},
|
||||
{
|
||||
name: '浏览次数',
|
||||
data: actions
|
||||
}]
|
||||
});
|
||||
});
|
||||
};
|
||||
setTimeout(function () {
|
||||
updateVisitMapChart();
|
||||
}, 1000);
|
||||
})();
|
||||
|
||||
var visitCalendarChart = echarts.init(document.getElementById('visit-calendar'), 'light');
|
||||
// var firstYear = establishedAt.getFullYear();
|
||||
var firstYear = 2019;
|
||||
var maxYear = 2023;
|
||||
visitCalendarChart.setOption({
|
||||
baseOption: {
|
||||
title: {
|
||||
text: '历年浏览数据',
|
||||
left: 'center'
|
||||
},
|
||||
tooltip: {
|
||||
position: 'top',
|
||||
formatter: function (p) {
|
||||
return `${echarts.format.formatTime('yyyy-MM-dd', p.data[0])} 浏览次数:${p.data[1]}`;
|
||||
}
|
||||
},
|
||||
toolbox: {
|
||||
showTitle: false,
|
||||
feature: {
|
||||
restore: {},
|
||||
saveAsImage: {
|
||||
excludeComponents: ['toolbox']
|
||||
}
|
||||
}
|
||||
},
|
||||
visualMap: {
|
||||
min: 50,
|
||||
max: 1000,
|
||||
calculable: true,
|
||||
orient: 'horizontal',
|
||||
top: 'top',
|
||||
left: 0
|
||||
},
|
||||
calendar: [{
|
||||
range: 2019,
|
||||
right: 5
|
||||
}, {
|
||||
range: 2020,
|
||||
right: 5,
|
||||
top: 240
|
||||
}, {
|
||||
range: 2021,
|
||||
right: 5,
|
||||
top: 420
|
||||
}, {
|
||||
range: 2022,
|
||||
right: 5,
|
||||
top: 600
|
||||
}, {
|
||||
range: 2023,
|
||||
right: 5,
|
||||
top: 780
|
||||
}],
|
||||
series: [{
|
||||
type: 'heatmap',
|
||||
coordinateSystem: 'calendar',
|
||||
calendarIndex: 0,
|
||||
data: []
|
||||
}, {
|
||||
type: 'heatmap',
|
||||
coordinateSystem: 'calendar',
|
||||
calendarIndex: 1,
|
||||
data: []
|
||||
}, {
|
||||
type: 'heatmap',
|
||||
coordinateSystem: 'calendar',
|
||||
calendarIndex: 2,
|
||||
data: []
|
||||
}, {
|
||||
type: 'heatmap',
|
||||
coordinateSystem: 'calendar',
|
||||
calendarIndex: 3,
|
||||
data: []
|
||||
}, {
|
||||
type: 'heatmap',
|
||||
coordinateSystem: 'calendar',
|
||||
calendarIndex: 4,
|
||||
data: []
|
||||
}]
|
||||
},
|
||||
media: [{
|
||||
query: {
|
||||
maxWidth: 767
|
||||
},
|
||||
option: {
|
||||
toolbox: {
|
||||
show: false
|
||||
},
|
||||
visualMap: {
|
||||
orient: 'vertical'
|
||||
},
|
||||
calendar: [{
|
||||
orient: 'vertical',
|
||||
left: 'center',
|
||||
top: 90
|
||||
}, {
|
||||
orient: 'vertical',
|
||||
left: 'center',
|
||||
top: 1220
|
||||
}, {
|
||||
orient: 'vertical',
|
||||
left: 'center',
|
||||
top: 2350
|
||||
}, {
|
||||
orient: 'vertical',
|
||||
left: 'center',
|
||||
top: 3480
|
||||
}, {
|
||||
orient: 'vertical',
|
||||
left: 'center',
|
||||
top: 4610
|
||||
}]
|
||||
}
|
||||
}]
|
||||
});
|
||||
(function updateVisitCalendarChart() {
|
||||
if (!document.hidden) {
|
||||
$.getJSON('{{ site.data.analytics.matomo.url }}', {
|
||||
'module': 'API',
|
||||
'method': 'VisitsSummary.getActions',
|
||||
'idSite': '{{ site.data.analytics.matomo.site_id }}',
|
||||
'period': 'day',
|
||||
// 'date': `last${siteEstablishedDays()}`,
|
||||
'date': 'last1825',
|
||||
'format': 'JSON',
|
||||
'token_auth': '{{ site.data.analytics.matomo.token }}'
|
||||
}, function (data) {
|
||||
var cursorYear = firstYear;
|
||||
var series = [{
|
||||
calendarIndex: cursorYear - firstYear,
|
||||
data: []
|
||||
}];
|
||||
for (var i in data) {
|
||||
if (data[i] !== 0) {
|
||||
year = Number(i.slice(0, 4));
|
||||
if (year > cursorYear && year <= maxYear) {
|
||||
cursorYear = year;
|
||||
series.push({
|
||||
calendarIndex: cursorYear - firstYear,
|
||||
data: []
|
||||
});
|
||||
} else if (year < firstYear || year > maxYear) {
|
||||
continue;
|
||||
};
|
||||
series[cursorYear - firstYear].data.push([
|
||||
echarts.format.formatTime('yyyy-MM-dd', i),
|
||||
data[i]
|
||||
]);
|
||||
};
|
||||
};
|
||||
visitCalendarChart.setOption({
|
||||
series: series
|
||||
});
|
||||
});
|
||||
};
|
||||
setTimeout(function () {
|
||||
updateVisitCalendarChart();
|
||||
}, 1000);
|
||||
})();
|
||||
+7
文件差异因一行或多行过长而隐藏
@@ -0,0 +1,27 @@
|
||||
|
||||
// common.js
|
||||
|
||||
// menu
|
||||
$(document).ready(function () {
|
||||
// fix menu when passed
|
||||
$('.masthead').visibility({
|
||||
once: false,
|
||||
onBottomPassed: function () {
|
||||
$('.fixed.menu').transition('fade in');
|
||||
},
|
||||
onBottomPassedReverse: function () {
|
||||
$('.fixed.menu').transition('fade out');
|
||||
}
|
||||
});
|
||||
// create sidebar and attach to menu open
|
||||
$('.ui.sidebar').sidebar('attach events', '.toc.item');
|
||||
// avatar
|
||||
let avatarId = $('#username').attr("data-user")
|
||||
fetch('https://api.multiavatar.com/'
|
||||
+JSON.stringify(avatarId))
|
||||
.then(res => res.text())
|
||||
.then(svg => $('#user-avatar').html(svg))
|
||||
});
|
||||
|
||||
// masthead background
|
||||
$('.ui.inverted.masthead.segment').addClass(`bg${Math.ceil(Math.random() * 14)}`).removeClass('zoomed');
|
||||
@@ -0,0 +1,90 @@
|
||||
// customize.js
|
||||
|
||||
function setJSONCookie(name, value) {
|
||||
Cookies.set(name, JSON.stringify(value), {
|
||||
expires: 365,
|
||||
domain: '.byr-navi.com',
|
||||
secure: true
|
||||
});
|
||||
};
|
||||
|
||||
function updateJSONCookie(name, key, value) {
|
||||
let shortcuts = JSON.parse(Cookies.get(name));
|
||||
shortcuts[key] = value;
|
||||
setJSONCookie(name, shortcuts);
|
||||
};
|
||||
|
||||
// initialize cookie
|
||||
if (Cookies.get('byr_navi_search_shortcuts') === undefined || Cookies.get('byr_navi_search_shortcuts') === '') {
|
||||
let shortcuts = {};
|
||||
$('.ui.button.shortcut-toggle-show').each(function () {
|
||||
shortcuts[$(this).data('search-service-id')] = $(this).data('show');
|
||||
});
|
||||
setJSONCookie('byr_navi_search_shortcuts', shortcuts);
|
||||
} else {
|
||||
let shortcuts = JSON.parse(Cookies.get('byr_navi_search_shortcuts'));
|
||||
$('.shortcut').each(function () {
|
||||
if (shortcuts[$(this).attr('id')]) {
|
||||
$(`#${$(this).attr('id')} .shortcut-visibility`).addClass('active').text('显示');
|
||||
$(`#${$(this).attr('id')} .shortcut-toggle-show`).data('show', true);
|
||||
$(`#${$(this).attr('id')} .shortcut-toggle-show`).addClass('grey').attr({
|
||||
'data-show': 'false',
|
||||
'data-tooltip': '标记“隐藏”'
|
||||
});
|
||||
$(`#${$(this).attr('id')} .shortcut-toggle-show .icon`).removeClass('slash');
|
||||
} else {
|
||||
$(`#${$(this).attr('id')} .shortcut-visibility`).removeClass('active').text('隐藏');
|
||||
$(`#${$(this).attr('id')} .shortcut-toggle-show`).data('show', false);
|
||||
$(`#${$(this).attr('id')} .shortcut-toggle-show`).removeClass('grey').attr({
|
||||
'data-show': 'false',
|
||||
'data-tooltip': '标记“显示”'
|
||||
});
|
||||
$(`#${$(this).attr('id')} .shortcut-toggle-show .icon`).addClass('slash');
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
// shortcut toggle button
|
||||
$('.ui.button.shortcut-toggle-show').each(function () {
|
||||
$(this).click(function () {
|
||||
if ($(this).data('show')) {
|
||||
$(this).data('show', false);
|
||||
$(this).removeClass('grey').attr({
|
||||
'data-show': 'false',
|
||||
'data-tooltip': '标记“显示”'
|
||||
});
|
||||
$(`#${$(this).data('search-service-id')} .shortcut-visibility`).removeClass('active').text('隐藏');
|
||||
$(`#${$(this).data('search-service-id')} .shortcut-toggle-show .icon`).addClass('slash');
|
||||
updateJSONCookie('byr_navi_search_shortcuts', $(this).data('search-service-id'), false);
|
||||
$('body').toast({
|
||||
class: 'success',
|
||||
showIcon: 'eye slash',
|
||||
title: `隐藏“${$(`#${$(this).data('search-service-id')} .shortcut-preview`).data('tooltip')}”`,
|
||||
message: `已标记快捷搜索项“${$(`#${$(this).data('search-service-id')} .shortcut-preview`).data('tooltip')}”为“隐藏”`
|
||||
});
|
||||
} else {
|
||||
$(this).data('show', true);
|
||||
$(this).addClass('grey').attr({
|
||||
'data-show': 'true',
|
||||
'data-tooltip': '标记“隐藏”'
|
||||
});
|
||||
$(`#${$(this).data('search-service-id')} .shortcut-visibility`).addClass('active').text('显示');
|
||||
$(`#${$(this).data('search-service-id')} .shortcut-toggle-show .icon`).removeClass('slash');
|
||||
updateJSONCookie('byr_navi_search_shortcuts', $(this).data('search-service-id'), true);
|
||||
$('body').toast({
|
||||
class: 'success',
|
||||
showIcon: 'eye',
|
||||
title: `显示“${$(`#${$(this).data('search-service-id')} .shortcut-preview`).data('tooltip')}”`,
|
||||
message: `已标记快捷搜索项“${$(`#${$(this).data('search-service-id')} .shortcut-preview`).data('tooltip')}”为“显示”`
|
||||
});
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
// reset button
|
||||
$('#reset-cookie').click(function () {
|
||||
Cookies.remove('byr_navi_search_shortcuts', {
|
||||
domain: '.byr-navi.com'
|
||||
});
|
||||
location.reload(true);
|
||||
});
|
||||
+1
文件差异因一行或多行过长而隐藏
@@ -0,0 +1 @@
|
||||
!function(r,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(r="undefined"!=typeof globalThis?globalThis:r||self).dayjs_plugin_relativeTime=e()}(this,(function(){"use strict";return function(r,e,t){r=r||{};var n=e.prototype,o={future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function i(r,e,t,o){return n.fromToBase(r,e,t,o)}t.en.relativeTime=o,n.fromToBase=function(e,n,i,d,u){for(var f,a,s,l=i.$locale().relativeTime||o,h=r.thresholds||[{l:"s",r:44,d:"second"},{l:"m",r:89},{l:"mm",r:44,d:"minute"},{l:"h",r:89},{l:"hh",r:21,d:"hour"},{l:"d",r:35},{l:"dd",r:25,d:"day"},{l:"M",r:45},{l:"MM",r:10,d:"month"},{l:"y",r:17},{l:"yy",d:"year"}],m=h.length,c=0;c<m;c+=1){var y=h[c];y.d&&(f=d?t(e).diff(i,y.d,!0):i.diff(e,y.d,!0));var p=(r.rounding||Math.round)(Math.abs(f));if(s=f>0,p<=y.r||!y.r){p<=1&&c>0&&(y=h[c-1]);var v=l[y.l];u&&(p=u(""+p)),a="string"==typeof v?v.replace("%d",p):v(p,n,y.l,s);break}}if(n)return a;var M=s?l.future:l.past;return"function"==typeof M?M(a):M.replace("%s",a)},n.to=function(r,e){return i(r,e,this,!0)},n.from=function(r,e){return i(r,e,this)};var d=function(r){return r.$u?t.utc():t()};n.toNow=function(r){return this.to(d(this),r)},n.fromNow=function(r){return this.from(d(this),r)}}}));
|
||||
@@ -0,0 +1 @@
|
||||
!function(e,_){"object"==typeof exports&&"undefined"!=typeof module?module.exports=_(require("dayjs")):"function"==typeof define&&define.amd?define(["dayjs"],_):(e="undefined"!=typeof globalThis?globalThis:e||self).dayjs_locale_zh_cn=_(e.dayjs)}(this,(function(e){"use strict";function _(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var t=_(e),d={name:"zh-cn",weekdays:"星期日_星期一_星期二_星期三_星期四_星期五_星期六".split("_"),weekdaysShort:"周日_周一_周二_周三_周四_周五_周六".split("_"),weekdaysMin:"日_一_二_三_四_五_六".split("_"),months:"一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split("_"),monthsShort:"1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),ordinal:function(e,_){return"W"===_?e+"周":e+"日"},weekStart:1,yearStart:4,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY/MM/DD",LL:"YYYY年M月D日",LLL:"YYYY年M月D日Ah点mm分",LLLL:"YYYY年M月D日ddddAh点mm分",l:"YYYY/M/D",ll:"YYYY年M月D日",lll:"YYYY年M月D日 HH:mm",llll:"YYYY年M月D日dddd HH:mm"},relativeTime:{future:"%s内",past:"%s前",s:"几秒",m:"1 分钟",mm:"%d 分钟",h:"1 小时",hh:"%d 小时",d:"1 天",dd:"%d 天",M:"1 个月",MM:"%d 个月",y:"1 年",yy:"%d 年"},meridiem:function(e,_){var t=100*e+_;return t<600?"凌晨":t<900?"早上":t<1100?"上午":t<1300?"中午":t<1800?"下午":"晚上"}};return t.default.locale(d,null,!0),d}));
|
||||
@@ -0,0 +1,15 @@
|
||||
// hitokoto.js
|
||||
|
||||
$.getJSON('https://v1.hitokoto.cn', function (data) {
|
||||
$('#hitokoto').attr({
|
||||
'href': `//hitokoto.cn?id=${data.id}`,
|
||||
'target': '_blank'
|
||||
}).append(data.hitokoto).append(
|
||||
$('<div>').addClass('detail').text(data.from)
|
||||
);
|
||||
}).fail(function () {
|
||||
$('#hitokoto').attr({
|
||||
'href': 'https://www.y-english.org/',
|
||||
'target': '_blank'
|
||||
}).html('<i class="lightbulb icon"></i>不背单词的GRE工程化解决方案<div class="detail">云英语</div>');
|
||||
});
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
|
||||
|
||||
// home.js
|
||||
|
||||
// GitHub
|
||||
(function updateGitHubBadges() {
|
||||
if (!document.hidden) {
|
||||
let repository = $('meta[name=repository]').attr('content');
|
||||
$('#github-star img').attr('src', `https://img.shields.io/github/stars/${repository}?style=social`);
|
||||
$('#github-fork img').attr('src', `https://img.shields.io/github/forks/${repository}?style=social`);
|
||||
};
|
||||
setTimeout(function () {
|
||||
updateGitHubBadges();
|
||||
}, 1000);
|
||||
})();
|
||||
|
||||
// build time
|
||||
dayjs.locale('zh-cn');
|
||||
dayjs.extend(window.dayjs_plugin_relativeTime);
|
||||
(function updateBuildTimeBadge() {
|
||||
if (!document.hidden) {
|
||||
$('#build-time img').attr('src', `https://img.shields.io/badge/%E6%9E%84%E5%BB%BA%E4%BA%8E-${encodeURIComponent(dayjs($('meta[name=built_at]').attr('content')).fromNow())}-brightgreen?logo=jekyll`);
|
||||
};
|
||||
setTimeout(function () {
|
||||
updateBuildTimeBadge();
|
||||
}, 1000);
|
||||
})();
|
||||
|
||||
|
||||
|
||||
|
||||
function setCookie(name, value) {
|
||||
Cookies.set(name, value, {
|
||||
expires: 365,
|
||||
domain: '.byr-navi.com',
|
||||
secure: true
|
||||
});
|
||||
};
|
||||
|
||||
function redirect(service, query) {
|
||||
if (service.data('transcode')) {
|
||||
query = query.replace(new RegExp(service.data('transcode-from'), 'g'), service.data('transcode-to'));
|
||||
};
|
||||
window.open(`search/?service=${encodeURIComponent(service.text())}&query=${query}&next=${encodeURIComponent(service.data('url').replace('{query}', query))}`, '_blank');
|
||||
};
|
||||
|
||||
// initialize previous used search service
|
||||
if (Cookies.get('byr_navi_previous_used_search_service') === undefined || Cookies.get('byr_navi_previous_used_search_service') === '' || $(`#${Cookies.get('byr_navi_previous_used_search_service')}`).length === 0) {
|
||||
setCookie('byr_navi_previous_used_search_service', $('#search-services').val());
|
||||
} else {
|
||||
updateDropdown();
|
||||
};
|
||||
|
||||
// search button
|
||||
$('#search-button').click(function () {
|
||||
let service = $(`#${$('#search-services').val()}`);
|
||||
let query = $('#search-query').val();
|
||||
query = encodeURIComponent(query);
|
||||
if (query) {
|
||||
setCookie('byr_navi_previous_used_search_service', service.val());
|
||||
redirect(service, query);
|
||||
} else {
|
||||
$('#search-div').addClass('error');
|
||||
$('#search-query').attr('placeholder', '请输入搜索内容');
|
||||
};
|
||||
});
|
||||
|
||||
// query input: click to select
|
||||
$('#search-query').click(function () {
|
||||
$(this).select();
|
||||
});
|
||||
|
||||
|
||||
// query input: press return/enter to submit
|
||||
$(window).keyup(function (event) {
|
||||
let windowTop = $(window).scrollTop();
|
||||
let windowHeight = $(window).innerHeight();
|
||||
let windowBottom = windowTop + windowHeight;
|
||||
let searchBoxTop = $('#search-div').offset().top;
|
||||
let searchBoxHeight = $('#search-div').innerHeight();
|
||||
let searchBoxBottom = searchBoxTop + searchBoxHeight;
|
||||
if (event.key === 'Enter' && searchBoxBottom > windowTop && searchBoxTop < windowBottom) {
|
||||
let service = $(`#${$('#search-services').val()}`);
|
||||
let query = $('#search-query').val();
|
||||
query = encodeURIComponent(query);
|
||||
if (query) {
|
||||
if ($('#search-query:focus').length > 0) {
|
||||
setCookie('byr_navi_previous_used_search_service', service.val());
|
||||
redirect(service, query);
|
||||
} else {
|
||||
$('#search-query').focus().select();
|
||||
};
|
||||
} else {
|
||||
$('#search-div').addClass('error');
|
||||
$('#search-query').attr('placeholder', '请输入搜索内容').focus();
|
||||
};
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
|
||||
// initialize customized shortcuts
|
||||
if (Cookies.get('byr_navi_search_shortcuts')) {
|
||||
let shortcuts = JSON.parse(Cookies.get('byr_navi_search_shortcuts'));
|
||||
$('#search-shortcuts .ui.label').each(function () {
|
||||
if (shortcuts[$(this).data('search-service-id')]) {
|
||||
if ($(this).hasClass('hidden')) {
|
||||
$(this).removeClass('hidden');
|
||||
};
|
||||
} else {
|
||||
if (!$(this).hasClass('hidden')) {
|
||||
$(this).addClass('hidden');
|
||||
};
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
+12
文件差异因一行或多行过长而隐藏
@@ -0,0 +1,242 @@
|
||||
/*
|
||||
* Lazy Load - jQuery plugin for lazy loading images
|
||||
*
|
||||
* Copyright (c) 2007-2013 Mika Tuupola
|
||||
*
|
||||
* Licensed under the MIT license:
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* Project home:
|
||||
* http://www.appelsiini.net/projects/lazyload
|
||||
*
|
||||
* Version: 1.9.3
|
||||
*
|
||||
*/
|
||||
|
||||
(function($, window, document, undefined) {
|
||||
var $window = $(window);
|
||||
|
||||
$.fn.lazyload = function(options) {
|
||||
var elements = this;
|
||||
var $container;
|
||||
var settings = {
|
||||
threshold : 0,
|
||||
failure_limit : 0,
|
||||
event : "scroll",
|
||||
effect : "show",
|
||||
container : window,
|
||||
data_attribute : "original",
|
||||
skip_invisible : true,
|
||||
appear : null,
|
||||
load : null,
|
||||
placeholder : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC"
|
||||
};
|
||||
|
||||
function update() {
|
||||
var counter = 0;
|
||||
|
||||
elements.each(function() {
|
||||
var $this = $(this);
|
||||
if (settings.skip_invisible && !$this.is(":visible")) {
|
||||
return;
|
||||
}
|
||||
if ($.abovethetop(this, settings) ||
|
||||
$.leftofbegin(this, settings)) {
|
||||
/* Nothing. */
|
||||
} else if (!$.belowthefold(this, settings) &&
|
||||
!$.rightoffold(this, settings)) {
|
||||
$this.trigger("appear");
|
||||
/* if we found an image we'll load, reset the counter */
|
||||
counter = 0;
|
||||
} else {
|
||||
if (++counter > settings.failure_limit) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
if(options) {
|
||||
/* Maintain BC for a couple of versions. */
|
||||
if (undefined !== options.failurelimit) {
|
||||
options.failure_limit = options.failurelimit;
|
||||
delete options.failurelimit;
|
||||
}
|
||||
if (undefined !== options.effectspeed) {
|
||||
options.effect_speed = options.effectspeed;
|
||||
delete options.effectspeed;
|
||||
}
|
||||
|
||||
$.extend(settings, options);
|
||||
}
|
||||
|
||||
/* Cache container as jQuery as object. */
|
||||
$container = (settings.container === undefined ||
|
||||
settings.container === window) ? $window : $(settings.container);
|
||||
|
||||
/* Fire one scroll event per scroll. Not one scroll event per image. */
|
||||
if (0 === settings.event.indexOf("scroll")) {
|
||||
$container.bind(settings.event, function() {
|
||||
return update();
|
||||
});
|
||||
}
|
||||
|
||||
this.each(function() {
|
||||
var self = this;
|
||||
var $self = $(self);
|
||||
|
||||
self.loaded = false;
|
||||
|
||||
/* If no src attribute given use data:uri. */
|
||||
if ($self.attr("src") === undefined || $self.attr("src") === false) {
|
||||
if ($self.is("img")) {
|
||||
$self.attr("src", settings.placeholder);
|
||||
}
|
||||
}
|
||||
|
||||
/* When appear is triggered load original image. */
|
||||
$self.one("appear", function() {
|
||||
if (!this.loaded) {
|
||||
if (settings.appear) {
|
||||
var elements_left = elements.length;
|
||||
settings.appear.call(self, elements_left, settings);
|
||||
}
|
||||
$("<img />")
|
||||
.bind("load", function() {
|
||||
|
||||
var original = $self.attr("data-" + settings.data_attribute);
|
||||
$self.hide();
|
||||
if ($self.is("img")) {
|
||||
$self.attr("src", original);
|
||||
} else {
|
||||
$self.css("background-image", "url('" + original + "')");
|
||||
}
|
||||
$self[settings.effect](settings.effect_speed);
|
||||
|
||||
self.loaded = true;
|
||||
|
||||
/* Remove image from array so it is not looped next time. */
|
||||
var temp = $.grep(elements, function(element) {
|
||||
return !element.loaded;
|
||||
});
|
||||
elements = $(temp);
|
||||
|
||||
if (settings.load) {
|
||||
var elements_left = elements.length;
|
||||
settings.load.call(self, elements_left, settings);
|
||||
}
|
||||
})
|
||||
.attr("src", $self.attr("data-" + settings.data_attribute));
|
||||
}
|
||||
});
|
||||
|
||||
/* When wanted event is triggered load original image */
|
||||
/* by triggering appear. */
|
||||
if (0 !== settings.event.indexOf("scroll")) {
|
||||
$self.bind(settings.event, function() {
|
||||
if (!self.loaded) {
|
||||
$self.trigger("appear");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
/* Check if something appears when window is resized. */
|
||||
$window.bind("resize", function() {
|
||||
update();
|
||||
});
|
||||
|
||||
/* With IOS5 force loading images when navigating with back button. */
|
||||
/* Non optimal workaround. */
|
||||
if ((/(?:iphone|ipod|ipad).*os 5/gi).test(navigator.appVersion)) {
|
||||
$window.bind("pageshow", function(event) {
|
||||
if (event.originalEvent && event.originalEvent.persisted) {
|
||||
elements.each(function() {
|
||||
$(this).trigger("appear");
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* Force initial check if images should appear. */
|
||||
$(document).ready(function() {
|
||||
update();
|
||||
});
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/* Convenience methods in jQuery namespace. */
|
||||
/* Use as $.belowthefold(element, {threshold : 100, container : window}) */
|
||||
|
||||
$.belowthefold = function(element, settings) {
|
||||
var fold;
|
||||
|
||||
if (settings.container === undefined || settings.container === window) {
|
||||
fold = (window.innerHeight ? window.innerHeight : $window.height()) + $window.scrollTop();
|
||||
} else {
|
||||
fold = $(settings.container).offset().top + $(settings.container).height();
|
||||
}
|
||||
|
||||
return fold <= $(element).offset().top - settings.threshold;
|
||||
};
|
||||
|
||||
$.rightoffold = function(element, settings) {
|
||||
var fold;
|
||||
|
||||
if (settings.container === undefined || settings.container === window) {
|
||||
fold = $window.width() + $window.scrollLeft();
|
||||
} else {
|
||||
fold = $(settings.container).offset().left + $(settings.container).width();
|
||||
}
|
||||
|
||||
return fold <= $(element).offset().left - settings.threshold;
|
||||
};
|
||||
|
||||
$.abovethetop = function(element, settings) {
|
||||
var fold;
|
||||
|
||||
if (settings.container === undefined || settings.container === window) {
|
||||
fold = $window.scrollTop();
|
||||
} else {
|
||||
fold = $(settings.container).offset().top;
|
||||
}
|
||||
|
||||
return fold >= $(element).offset().top + settings.threshold + $(element).height();
|
||||
};
|
||||
|
||||
$.leftofbegin = function(element, settings) {
|
||||
var fold;
|
||||
|
||||
if (settings.container === undefined || settings.container === window) {
|
||||
fold = $window.scrollLeft();
|
||||
} else {
|
||||
fold = $(settings.container).offset().left;
|
||||
}
|
||||
|
||||
return fold >= $(element).offset().left + settings.threshold + $(element).width();
|
||||
};
|
||||
|
||||
$.inviewport = function(element, settings) {
|
||||
return !$.rightoffold(element, settings) && !$.leftofbegin(element, settings) &&
|
||||
!$.belowthefold(element, settings) && !$.abovethetop(element, settings);
|
||||
};
|
||||
|
||||
/* Custom selectors for your convenience. */
|
||||
/* Use as $("img:below-the-fold").something() or */
|
||||
/* $("img").filter(":below-the-fold").something() which is faster */
|
||||
|
||||
$.extend($.expr[":"], {
|
||||
"below-the-fold" : function(a) { return $.belowthefold(a, {threshold : 0}); },
|
||||
"above-the-top" : function(a) { return !$.belowthefold(a, {threshold : 0}); },
|
||||
"right-of-screen": function(a) { return $.rightoffold(a, {threshold : 0}); },
|
||||
"left-of-screen" : function(a) { return !$.rightoffold(a, {threshold : 0}); },
|
||||
"in-viewport" : function(a) { return $.inviewport(a, {threshold : 0}); },
|
||||
/* Maintain BC for couple of versions. */
|
||||
"above-the-fold" : function(a) { return !$.belowthefold(a, {threshold : 0}); },
|
||||
"right-of-fold" : function(a) { return $.rightoffold(a, {threshold : 0}); },
|
||||
"left-of-fold" : function(a) { return !$.rightoffold(a, {threshold : 0}); }
|
||||
});
|
||||
|
||||
})(jQuery, window, document);
|
||||
+2
文件差异因一行或多行过长而隐藏
文件差异内容过多而无法显示
加载差异
文件差异因一行或多行过长而隐藏
+2
@@ -0,0 +1,2 @@
|
||||
/*! js-cookie v3.0.1 | MIT */
|
||||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self,function(){var n=e.Cookies,o=e.Cookies=t();o.noConflict=function(){return e.Cookies=n,o}}())}(this,(function(){"use strict";function e(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)e[o]=n[o]}return e}return function t(n,o){function r(t,r,i){if("undefined"!=typeof document){"number"==typeof(i=e({},o,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),t=encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var c="";for(var u in i)i[u]&&(c+="; "+u,!0!==i[u]&&(c+="="+i[u].split(";")[0]));return document.cookie=t+"="+n.write(r,t)+c}}return Object.create({set:r,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var t=document.cookie?document.cookie.split("; "):[],o={},r=0;r<t.length;r++){var i=t[r].split("="),c=i.slice(1).join("=");try{var u=decodeURIComponent(i[0]);if(o[u]=n.read(c,u),e===u)break}catch(e){}}return e?o[e]:o}},remove:function(t,n){r(t,"",e({},n,{expires:-1}))},withAttributes:function(n){return t(this.converter,e({},this.attributes,n))},withConverter:function(n){return t(e({},this.converter,n),this.attributes)}},{attributes:{value:Object.freeze(o)},converter:{value:Object.freeze(n)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"})}));
|
||||
@@ -0,0 +1,9 @@
|
||||
// search.js
|
||||
|
||||
var service = $.url('?service');
|
||||
var query = $.url('?query');
|
||||
var nextUrl = $.url('?next');
|
||||
if (nextUrl) {
|
||||
$('#next-url').text('正在跳转到页面').append($('<a>').addClass('sub header').attr('href', nextUrl).text(`${service}:${query}`));
|
||||
window.location.replace(nextUrl);
|
||||
};
|
||||
@@ -0,0 +1,497 @@
|
||||
// suggest-query.js
|
||||
|
||||
(function() {
|
||||
var A = window.baidu || { version: "1-1-0" };
|
||||
A.object = A.object || {};
|
||||
A.object.extend = function(B, D) {
|
||||
for (var C in D) {
|
||||
if (D.hasOwnProperty(C)) { B[C] = D[C] } } };
|
||||
A.extend = A.object.extend;
|
||||
A.dom = A.dom || {};
|
||||
A.dom.g = function(B) {
|
||||
if ("string" == typeof B || B instanceof String) {
|
||||
return document.getElementById(B) } else {
|
||||
if (B && (B.nodeName && (B.nodeType == 1 || B.nodeType == 9))) {
|
||||
return B } }
|
||||
return null };
|
||||
A.g = A.G = A.dom.g;
|
||||
A.dom.getDocument = function(B) { B = A.dom.g(B);
|
||||
return B.nodeType == 9 ? B : B.ownerDocument || B.document };
|
||||
A.dom._styleFixer = A.dom._styleFixer || {};
|
||||
A.dom._styleFilter = A.dom._styleFilter || [];
|
||||
A.dom._styleFilter.filter = function(C, G, E) {
|
||||
for (var B = 0, D = A.dom._styleFilter, F; F = D[B]; B++) {
|
||||
if (F = F[E]) { G = F(C, G) } }
|
||||
return G };
|
||||
A.string = A.string || {};
|
||||
A.string.toCamelCase = function(B) {
|
||||
return String(B).replace(/[-_]\D/g, function(C) {
|
||||
return C.charAt(1).toUpperCase() }) };
|
||||
A.dom.getStyle = function(F, G) {
|
||||
var D = A.dom;
|
||||
F = D.g(F);
|
||||
G = A.string.toCamelCase(G);
|
||||
var B = F.style[G];
|
||||
if (B) {
|
||||
return B }
|
||||
var C = D._styleFixer[G],
|
||||
E = F.currentStyle || (A.browser.ie ? F.style : getComputedStyle(F, null));
|
||||
B = "object" == typeof C && C.get ? C.get(F, E) : E[C || G];
|
||||
if (C = D._styleFilter) { B = C.filter(G, B, "get") }
|
||||
return B };
|
||||
A.getStyle = A.dom.getStyle;
|
||||
A.browser = A.browser || {};
|
||||
if (/msie (\d+\.\d)/i.test(navigator.userAgent)) { A.ie = A.browser.ie = parseFloat(RegExp.$1) }
|
||||
if (/opera\/(\d+\.\d)/i.test(navigator.userAgent)) { A.browser.opera = parseFloat(RegExp.$1) }
|
||||
A.browser.isWebkit = /webkit/i.test(navigator.userAgent);
|
||||
A.browser.isGecko = /gecko/i.test(navigator.userAgent) && !/like gecko/i.test(navigator.userAgent);
|
||||
A.browser.isStrict = document.compatMode == "CSS1Compat";
|
||||
A.dom.getPosition = function(D) {
|
||||
var B = A.dom.getDocument(D),
|
||||
E = A.browser;
|
||||
D = A.dom.g(D);
|
||||
var I = E.isGecko > 0 && (B.getBoxObjectFor && (A.dom.getStyle(D, "position") == "absolute" && (D.style.top === "" || D.style.left === ""))),
|
||||
J = { left: 0, top: 0 },
|
||||
H = E.ie && !E.isStrict ? B.body : B.documentElement;
|
||||
if (D == H) {
|
||||
return J }
|
||||
var C = null,
|
||||
F;
|
||||
if (D.getBoundingClientRect) { F = D.getBoundingClientRect();
|
||||
J.left = Math.floor(F.left) + Math.max(B.documentElement.scrollLeft, B.body.scrollLeft);
|
||||
J.top = Math.floor(F.top) + Math.max(B.documentElement.scrollTop, B.body.scrollTop);
|
||||
J.left -= B.documentElement.clientLeft;
|
||||
J.top -= B.documentElement.clientTop;
|
||||
if (E.ie && !E.isStrict) { J.left -= 2;
|
||||
J.top -= 2 } } else {
|
||||
if (B.getBoxObjectFor && !I) { F = B.getBoxObjectFor(D);
|
||||
var G = B.getBoxObjectFor(H);
|
||||
J.left = F.screenX - G.screenX;
|
||||
J.top = F.screenY - G.screenY } else { C = D;
|
||||
do { J.left += C.offsetLeft;
|
||||
J.top += C.offsetTop;
|
||||
if (E.isWebkit > 0 && A.dom.getStyle(C, "position") == "fixed") { J.left += B.body.scrollLeft;
|
||||
J.top += B.body.scrollTop;
|
||||
break }
|
||||
C = C.offsetParent } while (C && C != D);
|
||||
if (E.opera > 0 || E.isWebkit > 0 && A.dom.getStyle(D, "position") == "absolute") { J.top -= B.body.offsetTop }
|
||||
C = D.offsetParent;
|
||||
while (C && C != B.body) { J.left -= C.scrollLeft;
|
||||
if (!b.opera || C.tagName != "TR") { J.top -= C.scrollTop }
|
||||
C = C.offsetParent } } }
|
||||
return J };
|
||||
A.event = A.event || {};
|
||||
A.event._unload = function() {
|
||||
var C = A.event._listeners,
|
||||
B = C.length,
|
||||
D = !(!window.removeEventListener),
|
||||
E, F;
|
||||
while (B--) { E = C[B];
|
||||
F = E[0];
|
||||
if (F.removeEventListener) { F.removeEventListener(E[1], E[3], false) } else {
|
||||
if (F.detachEvent) { F.detachEvent("on" + E[1], E[3]) } } }
|
||||
if (D) { window.removeEventListener("unload", A.event._unload, false) } else { window.detachEvent("onunload", A.event._unload) } };
|
||||
if (window.attachEvent) { window.attachEvent("onunload", A.event._unload) } else { window.addEventListener("unload", A.event._unload, false) }
|
||||
A.event._listeners = A.event._listeners || [];
|
||||
A.event.on = function(F, B, E) { B = B.replace(/^on/i, "");
|
||||
if ("string" == typeof F) { F = A.dom.g(F) }
|
||||
var C = function(G) { E.call(F, G) },
|
||||
D = A.event._listeners;
|
||||
D[D.length] = [F, B, E, C];
|
||||
if (F.attachEvent) { F.attachEvent("on" + B, C) } else {
|
||||
if (F.addEventListener) { F.addEventListener(B, C, false) } }
|
||||
return F };
|
||||
A.on = A.event.on;
|
||||
A.event.preventDefault = function(B) {
|
||||
if (B.preventDefault) { B.preventDefault() } else { B.returnValue = false } };
|
||||
A.ui = A.ui || {};
|
||||
A.suggestion = A.ui.suggestion = A.ui.suggestion || {};
|
||||
(function() {
|
||||
var B = {},
|
||||
C = function(E) {
|
||||
var D = {};
|
||||
E.listen = function(F, H) { D[F] = D[F] || [];
|
||||
var G = 0;
|
||||
while (G < D[F].length && D[F][G] != H) { G++ }
|
||||
if (G == D[F].length) { D[F].push(H) }
|
||||
return E };
|
||||
E.call = function(G) {
|
||||
if (D[G]) {
|
||||
for (var F = 0; F < D[G].length; F++) { D[G][F].apply(this, Array.prototype.slice.call(arguments, 1)) } }
|
||||
return E } };
|
||||
B.extend = function(D) { new C(D);
|
||||
return D };
|
||||
B.extend(B);
|
||||
A.suggestion._Central = B })();
|
||||
A.ui.suggestion._Div = function(V, o, Z, a, X) {
|
||||
var d = this,
|
||||
h, T, Y, l, f = X.class_prefix,
|
||||
U, S = document.createElement("DIV");
|
||||
S.id = f + (new Date()).getTime();
|
||||
S.className = f + "wpr";
|
||||
S.style.display = "none";
|
||||
var c = document.createElement("IFRAME");
|
||||
c.className = f + "sd";
|
||||
c.style.display = "none";
|
||||
c.style.position = "absolute";
|
||||
c.style.borderWidth = "0px";
|
||||
if (X.apd_body) { document.body.appendChild(S) } else { o.parentNode.appendChild(S) }
|
||||
S.parentNode.insertBefore(c, S);
|
||||
V.listen("start", function() { A.on(document, "mousedown", function(B) { B = B || window.event;
|
||||
var C = B.target || B.srcElement;
|
||||
if (C == o) {
|
||||
return }
|
||||
while (C = C.parentNode) {
|
||||
if (C == S) {
|
||||
return } }
|
||||
W() });
|
||||
A.on(window, "blur", W) });
|
||||
V.listen("key_enter", function() {
|
||||
var B = i(),
|
||||
C = B[0] == -1 ? l : B[1];
|
||||
X.onconfirm(Z.getValue(), B[0], C, B[2], true);
|
||||
W() });
|
||||
|
||||
function m(F, D) {
|
||||
if (S.style.display == "none") { V.call("need_data", Z.getValue());
|
||||
return }
|
||||
var B = i()[0];
|
||||
j();
|
||||
if (F) {
|
||||
if (B == 0) { g(D);
|
||||
B--;
|
||||
return }
|
||||
if (B == -1) { B = T.length }
|
||||
B-- } else {
|
||||
if (B == T.length - 1) { g(D);
|
||||
B = -1;
|
||||
return }
|
||||
B++ }
|
||||
n(B);
|
||||
k();
|
||||
var E = Z.getValue();
|
||||
g(B);
|
||||
var C = i();
|
||||
X.onpick(E, C[0], C[1], C[2]) }
|
||||
V.listen("key_up", function(B) { m(1, B) });
|
||||
V.listen("key_down", function(B) { m(0, B) });
|
||||
V.listen("key_tab", W);
|
||||
V.listen("key_esc", W);
|
||||
V.listen("all_clear", W);
|
||||
V.listen("data_ready", function(E, C) { l = C;
|
||||
T = [];
|
||||
Y = [];
|
||||
for (var B = 0, D = C.length; B < D; B++) {
|
||||
if (typeof C[B].input != "undefined") { T[B] = C[B].input;
|
||||
Y[B] = C[B].selection } else { Y[B] = T[B] = C[B] } }
|
||||
if (T.length != 0) { U = a(S, Y, d);
|
||||
for (var B = 0, D = U.length; B < D; B++) { A.on(U[B], "mouseover", function() { j();
|
||||
this.className = f + "mo";
|
||||
k() });
|
||||
A.on(U[B], "mouseout", j);
|
||||
A.on(U[B], "mousedown", function(F) { V.call("mousedown_item");
|
||||
if (!A.ie) { F.stopPropagation();
|
||||
F.preventDefault();
|
||||
return false } });
|
||||
A.on(U[B], "click", e(B)) } } else { W() } });
|
||||
|
||||
function j() {
|
||||
for (var B = 0; B < U.length; B++) { U[B].className = f + "ml" } }
|
||||
|
||||
function i() {
|
||||
if (U && S.style.display != "none") {
|
||||
for (var B = 0; B < U.length; B++) {
|
||||
if (U[B].className == f + "mo") {
|
||||
return [B, T[B], Y[B]] } } }
|
||||
return [-1, ""] }
|
||||
|
||||
function k() {
|
||||
var B = i();
|
||||
X.onhighlight(Z.getValue(), B[0], B[1], B[2]) }
|
||||
|
||||
function n(B) { j();
|
||||
U[B].className = f + "mo" }
|
||||
|
||||
function g(C) {
|
||||
var B = T && (typeof C == "number" && typeof T[C] != "undefined") ? T[C] : C;
|
||||
V.call("pick_word", B) }
|
||||
|
||||
function W() {
|
||||
if (S.style.display == "none") {
|
||||
return null }
|
||||
c.style.display = S.style.display = "none";
|
||||
X.onhide() }
|
||||
|
||||
function e(B) {
|
||||
var C = B;
|
||||
return function() { V.call("confirm_item", Z.getValue(), T[C], C, Y[C]);
|
||||
var D = Z.getValue();
|
||||
g(T[C]);
|
||||
X.onpick(D, C, T[C], Y[C]);
|
||||
X.onconfirm(Z.getValue(), C, T[C], Y[C]);
|
||||
W() } }
|
||||
return { element: S, shade: c, pick: g, highlight: n, hide: W, dispose: function() { S.parentNode.removeChild(S) } } };
|
||||
A.ui.suggestion._Data = function(D, B) {
|
||||
var C = this,
|
||||
E = {};
|
||||
D.listen("response_data", function(G, F) { E[G] = F;
|
||||
D.call("data_ready", G, F) });
|
||||
D.listen("need_data", function(F) {
|
||||
if (typeof E[F] == "undefined") { B(F) } else { D.call("data_ready", F, E[F]) } });
|
||||
return {} };
|
||||
A.ui.suggestion._InputWatcher = function(H, G, E) {
|
||||
var F = this,
|
||||
K, D = 0,
|
||||
L = "",
|
||||
C = "",
|
||||
J = "",
|
||||
M, I = false,
|
||||
N = false,
|
||||
B = false;
|
||||
G.setAttribute("autocomplete", "off");
|
||||
A.on(G, "keydown", function(O) {
|
||||
if (!B) { H.call("start");
|
||||
B = true }
|
||||
O = O || window.event;
|
||||
var P;
|
||||
switch (O.keyCode) {
|
||||
case 9:
|
||||
P = "tab";
|
||||
break;
|
||||
case 27:
|
||||
P = "esc";
|
||||
break;
|
||||
case 13:
|
||||
P = "enter";
|
||||
break;
|
||||
case 38:
|
||||
P = "up";
|
||||
A.event.preventDefault(O);
|
||||
break;
|
||||
case 40:
|
||||
P = "down" }
|
||||
if (P) { H.call("key_" + P, C) } });
|
||||
A.on(G, "mousedown", function() {
|
||||
if (!B) { H.call("start");
|
||||
B = true } });
|
||||
A.on(G, "beforedeactivate", function() {
|
||||
if (I) { window.event.cancelBubble = true;
|
||||
window.event.returnValue = false } });
|
||||
H.listen("start", function() { J = G.value;
|
||||
D = setInterval(function() {
|
||||
if (N) {
|
||||
return }
|
||||
if (A.G(G) == null) { suggestion.dispose() }
|
||||
var O = G.value;
|
||||
if (O == L && (O != "" && (O != J && O != M))) {
|
||||
if (K == 0) { K = setTimeout(function() { H.call("need_data", O) }, 100) } } else { clearTimeout(K);
|
||||
K = 0;
|
||||
if (O == "" && L != "") { M = "";
|
||||
H.call("all_clear") }
|
||||
L = O;
|
||||
if (O != M) { C = O }
|
||||
if (J != G.value) { J = "" } } }, 10) });
|
||||
H.listen("pick_word", function(O) {
|
||||
if (I) {
|
||||
try { G.blur(); } catch (e) { setTimeout(function() { G.blur(); }, 600); } }
|
||||
G.value = M = O;
|
||||
if (I) { G.focus() } });
|
||||
H.listen("mousedown_item", function(O) { I = true;
|
||||
N = true;
|
||||
setTimeout(function() { N = false;
|
||||
I = false }, 500) });
|
||||
H.listen("confirm_item", function(R, P, Q, O) { N = false;
|
||||
C = L = Q });
|
||||
return { getValue: function() {
|
||||
return G.value }, dispose: function() { clearInterval(D) } } };
|
||||
A.ui.suggestion._Suggestion = function(F, B) {
|
||||
var E = this,
|
||||
C = A.ui.suggestion._MessageDispatcher;
|
||||
E.options = { onpick: function() {}, onconfirm: function() {}, onhighlight: function() {}, onhide: function() {}, view: null, getData: false, prepend_html: "", append_html: "", class_prefix: "tangram_sug_", apd_body: false };
|
||||
A.extend(E.options, B);
|
||||
if (!(F = A.G(F))) {
|
||||
return null }
|
||||
E.inputElement = F;
|
||||
if (F.id) { E.options._inputId = F.id } else { F.id = E.options._inputId = E.options.class_prefix + "ipt" + (new Date()).getTime() }
|
||||
E._adjustPos = function(S) {
|
||||
var J = G.element,
|
||||
M = G.shade,
|
||||
P = document,
|
||||
N = P.compatMode == "BackCompat" ? P.body : P.documentElement,
|
||||
O = N.clientHeight,
|
||||
K = N.clientWidth;
|
||||
if (J.style.display == "none" && S) {
|
||||
return }
|
||||
var Q = A.dom.getPosition(F),
|
||||
L = [Q.top + F.offsetHeight - 1, Q.left, F.offsetWidth];
|
||||
L = typeof E.options.view == "function" ? E.options.view(L) : L;
|
||||
J.style.display = M.style.display = "block";
|
||||
M.style.top = L[0] + "px";
|
||||
M.style.left = L[1] + "px";
|
||||
M.style.width = L[2] + "px";
|
||||
var V = parseFloat(A.getStyle(J, "marginTop")) || 0,
|
||||
R = parseFloat(A.getStyle(J, "marginLeft")) || 0;
|
||||
J.style.top = L[0] - V + "px";
|
||||
J.style.left = L[1] - R + "px";
|
||||
if (A.ie && document.compatMode == "BackCompat") { J.style.width = L[2] + "px" } else {
|
||||
var U = parseFloat(A.getStyle(J, "borderLeftWidth")) || 0,
|
||||
W = parseFloat(A.getStyle(J, "borderRightWidth")) || 0,
|
||||
T = parseFloat(A.getStyle(J, "marginRight")) || 0;
|
||||
J.style.width = L[2] - U - W - R - T + "px" }
|
||||
M.style.height = J.offsetHeight + "px";
|
||||
if (O != N.clientHeight || K != N.clientWidth) { E._adjustPos() } };
|
||||
E._draw = function(M, T) {
|
||||
var Q = [],
|
||||
L = document.createElement("TABLE");
|
||||
L.cellPadding = 2;
|
||||
L.cellSpacing = 0;
|
||||
var R = document.createElement("TBODY");
|
||||
L.appendChild(R);
|
||||
for (var O = 0, J = T.length; O < J; O++) {
|
||||
var S = R.insertRow(-1);
|
||||
Q.push(S);
|
||||
var K = S.insertCell(-1);
|
||||
K.innerHTML = T[O] }
|
||||
var P = document.createElement("DIV");
|
||||
P.className = E.options.class_prefix + "pre";
|
||||
P.innerHTML = E.options.prepend_html;
|
||||
var N = document.createElement("DIV");
|
||||
N.className = E.options.class_prefix + "app";
|
||||
N.innerHTML = E.options.append_html;
|
||||
M.innerHTML = "";
|
||||
M.appendChild(P);
|
||||
M.appendChild(L);
|
||||
M.appendChild(N);
|
||||
E._adjustPos();
|
||||
return Q };
|
||||
var H = A.suggestion._Central.extend(E),
|
||||
D = new A.ui.suggestion._Data(H, E.options.getData),
|
||||
I = new A.ui.suggestion._InputWatcher(H, F, G),
|
||||
G = new A.ui.suggestion._Div(H, F, I, E._draw, E.options);
|
||||
H.listen("start", function() { setInterval(function() {
|
||||
var J = G.element;
|
||||
if (J.offsetWidth != 0 && F.offsetWidth != J.offsetWidth) { E._adjustPos() } }, 100);
|
||||
A.on(window, "resize", function() { E._adjustPos(true) }) });
|
||||
return { pick: G.pick, hide: G.hide, highlight: G.highlight, getElement: function() {
|
||||
return G.element }, getData: E.options.getData, giveData: function(K, J) { H.call("response_data", K, J) }, dispose: function() { G.dispose();
|
||||
I.dispose() } } };
|
||||
A.ui.suggestion.create = function(B, C) {
|
||||
return new A.ui.suggestion._Suggestion(B, C) };
|
||||
window.baidu = A })();
|
||||
var BaiduSuggestion = (function() {
|
||||
var D = {};
|
||||
var E = {};
|
||||
|
||||
function O(P) {
|
||||
return document.createElement(P) }
|
||||
var J = { createSugOptions: function(S, R, Q, P) {
|
||||
return { class_prefix: "bdSug_", onconfirm: function(Y, W, U, V, X) {
|
||||
if (Q && W > -1) {
|
||||
try { Q.apply(window, [U]) } catch (T) {} }
|
||||
if (P && !X) { P.submit() } }, view: function(T) {
|
||||
if (R && R.width) { T[2] = parseInt(R.width) }
|
||||
if (R && R.XOffset && R.YOffset) {
|
||||
return [T[0] - R.YOffset, T[1] - R.XOffset, T[2]] }
|
||||
return [T[0], T[1], T[2]] }, getData: function(U) {
|
||||
var V = (new Date()).getTime();
|
||||
var W = baidu.G("bdSug_script");
|
||||
if (W) { document.body.removeChild(W) }
|
||||
var T = O("script");
|
||||
T.setAttribute("charset", "gbk");
|
||||
T.src = "https://sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su?wd=" + encodeURIComponent(U) + "&p=3&cb=BaiduSuggestion.callbacks.give" + S + "&t=" + V;
|
||||
T.id = "bdSug_script";
|
||||
document.body.appendChild(T) }, append_html: "", apd_body: true } }, createSugCallback: function(P) {
|
||||
return function(R) {
|
||||
if (!R) {
|
||||
return }
|
||||
var S = [];
|
||||
for (var T = 0; T < R.s.length; T++) {
|
||||
var Q = {};
|
||||
Q.input = R.s[T];
|
||||
Q.selection = R.s[T];
|
||||
S.push(Q) }
|
||||
E["sug" + P].giveData(R.q, S) } } };
|
||||
|
||||
function I(T, Z, S, X) {
|
||||
if (!T) {
|
||||
return }
|
||||
if (typeof(T) == "string" || T instanceof String) { T = baidu.G(T) }
|
||||
if (!T.sugId) { T.sugId = (new Date).getTime() }
|
||||
if (E["sug" + T.sugId]) {
|
||||
return false }
|
||||
if (Z == null) {
|
||||
var Z = [] } else { X = Z.sugSubmit;
|
||||
var Q = Z.fontColor ? Z.fontColor : "#000";
|
||||
var W = Z.fontSize ? Z.fontSize : "14px";
|
||||
var P = Z.fontFamily ? Z.fontFamily : "verdana";
|
||||
var U = Z.bgcolorHI ? Z.bgcolorHI : "#36c";
|
||||
var R = Z.fontColorHI ? Z.fontColorHI : "#FFF";
|
||||
var Y = Z.borderColor ? Z.borderColor : "#817f82";
|
||||
L(".bdSug_wpr", "border:1px solid " + Y + ";position:absolute;z-index:9;top:28px;left:0;color:" + Q);
|
||||
L(".bdSug_wpr td", "font-size:" + W + ";font-family:" + P);
|
||||
L(".bdSug_mo", "background-color:" + U + ";color:" + R) }
|
||||
if (G(document.body, "position") == "relative" || G(document.body, "position") == "absolute") {
|
||||
var V = B(document.body);
|
||||
Z.XOffset = (Z.XOffset ? parseInt(Z.XOffset) : 0) + V.x;
|
||||
Z.YOffset = (Z.YOffset ? parseInt(Z.YOffset) : 0) + V.y }
|
||||
E["sug" + T.sugId] = baidu.suggestion.create(T, J.createSugOptions(T.sugId, Z, S, X ? N(T) : null));
|
||||
D["give" + T.sugId] = J.createSugCallback(T.sugId) }
|
||||
|
||||
function N(Q) {
|
||||
var P = Q;
|
||||
while (P != document.body && P.tagName != "FORM") { P = P.parentNode }
|
||||
return (P.tagName == "FORM") ? P : null }
|
||||
|
||||
function B(R) {
|
||||
var P = document;
|
||||
var Q = 0;
|
||||
var S = 0;
|
||||
if (R.getBoundingClientRect) {
|
||||
var T = R.getBoundingClientRect();
|
||||
Q = T.left + Math.max(P.documentElement.scrollLeft, P.body.scrollLeft);
|
||||
S = T.top + Math.max(P.documentElement.scrollTop, P.body.scrollTop);
|
||||
Q -= P.documentElement.clientLeft;
|
||||
S -= P.documentElement.clientTop } else {
|
||||
while (R = R.offsetParent) { Q += R.offsetLeft;
|
||||
S += R.offsetTop } }
|
||||
return { x: Q, y: S } }
|
||||
|
||||
function L(R, Q) {
|
||||
var S = document.styleSheets;
|
||||
if (!S || S.length <= 0) {
|
||||
var P = document.createElement("STYLE");
|
||||
P.type = "text/css";
|
||||
var T = document.getElementsByTagName("HEAD")[0];
|
||||
T.appendChild(P) }
|
||||
S = document.styleSheets;
|
||||
S = S[S.length - 1];
|
||||
if (baidu.ie) { S.addRule(R, Q) } else { S.insertRule(R + " { " + Q + " }", S.cssRules.length) } }
|
||||
|
||||
function G(R, P, Q) {
|
||||
if (!R) {
|
||||
return }
|
||||
if (Q != undefined) { R.style[P] = Q } else {
|
||||
if (R.style[P]) {
|
||||
return R.style[P] } else {
|
||||
if (R.currentStyle) {
|
||||
return R.currentStyle[P] } else {
|
||||
if (document.defaultView && document.defaultView.getComputedStyle) { P = P.replace(/([A-Z])/g, "-\u00241").toLowerCase();
|
||||
var S = document.defaultView.getComputedStyle(R, "");
|
||||
return S && S.getPropertyValue(P) || "" } } } } }
|
||||
|
||||
function A() { L(".bdSug_wpr", "line-height:normal;background:#FFF;padding:0;margin:0;border:1px solid #817F82;position:absolute;z-index:9999;");
|
||||
L(".bdSug_wpr table", "padding:0;width:100%;background:#fff;cursor:default;");
|
||||
L(".bdSug_wpr tr", "padding:0;margin:0;");
|
||||
L(".bdSug_wpr td", "padding:10px 16px;margin:0;text-align:left;vertical-align:middle;font:14px verdana;font-weight:normal;text-decoration:none;text-indent:0;");
|
||||
L(".bdSug_mo", "background:#36c;color:#fff;");
|
||||
L(".bdSug_mo td", "font-weight:bold;");
|
||||
L(".bdSug_pre", "padding:0;margin:0;");
|
||||
L(".bdsug_copy", "margin:0;background:transparent url(http://www.baidu.com/img/bd.gif) no-repeat;font-size:13px;color:#77c;text-decoration:none;padding:0 2px 0 16px;") }
|
||||
A();
|
||||
var H = document.body.getElementsByTagName("INPUT");
|
||||
for (var K = 0, F = H.length; K < F; K++) {
|
||||
var M = H[K];
|
||||
if (M && M.type == "text" && (M.getAttribute("baiduSug") == 1 || M.getAttribute("baiduSug") == 2)) { M.sugId = K;
|
||||
var C = (M.getAttribute("baiduSug") == 1);
|
||||
I(M, null, null, C) } }
|
||||
return { bind: I, callbacks: D } })();
|
||||
+1
文件差异因一行或多行过长而隐藏
在新工单中引用
屏蔽一个用户