过于脆弱,
// 一旦有人为可读性加上该标志即退化为存储型 XSS。
var peaks = [{"t":22.7257,"i":5.8347,"hkl":"(1,0,-1,1)","d":3.91286},{"t":27.3856,"i":2.2177,"hkl":"(2,0,-2,0)","d":3.25673},{"t":33.0376,"i":20.8408,"hkl":"(2,0,-2,1)","d":2.71136},{"t":36.4978,"i":20.1336,"hkl":"(3,-1,-2,0)","d":2.46186},{"t":36.4978,"i":10.0668,"hkl":"(2,1,-3,0)","d":2.46186},{"t":36.7238,"i":6.2751,"hkl":"(0,0,0,2)","d":2.44723},{"t":39.3298,"i":41.7327,"hkl":"(1,0,-1,2)","d":2.29087},{"t":41.0391,"i":100,"hkl":"(3,-1,-2,1)","d":2.19932},{"t":41.5959,"i":8.517,"hkl":"(3,0,-3,0)","d":2.17116},{"t":44.1535,"i":3.5382,"hkl":"(2,-1,-1,2)","d":2.05115},{"t":45.715,"i":31.4727,"hkl":"(3,0,-3,1)","d":1.98465},{"t":46.4127,"i":7.229,"hkl":"(2,-2,0,2)","d":1.95643},{"t":46.4127,"i":14.4578,"hkl":"(2,0,-2,2)","d":1.95643},{"t":48.4101,"i":9.9833,"hkl":"(4,-2,-2,0)","d":1.88028},{"t":52.7418,"i":3.5262,"hkl":"(3,-1,-2,2)","d":1.7356},{"t":54.1151,"i":2.2985,"hkl":"(4,-1,-3,1)","d":1.69476},{"t":54.1151,"i":1.1492,"hkl":"(3,1,-4,1)","d":1.69476},{"t":56.5145,"i":1.8133,"hkl":"(4,0,-4,0)","d":1.62837},{"t":58.3035,"i":1.1328,"hkl":"(1,0,-1,3)","d":1.58259},{"t":59.8605,"i":6.4863,"hkl":"(4,0,-4,1)","d":1.5451},{"t":62.269,"i":1.966,"hkl":"(4,-2,-2,2)","d":1.491},{"t":63.8088,"i":9.3097,"hkl":"(2,0,-2,3)","d":1.45868},{"t":64.068,"i":1.6821,"hkl":"(4,-1,-3,2)","d":1.45341},{"t":65.2881,"i":2.748,"hkl":"(5,-2,-3,1)","d":1.42917},{"t":65.6921,"i":1.33,"hkl":"(5,-1,-4,0)","d":1.42136},{"t":68.7756,"i":2.1301,"hkl":"(5,-1,-4,1)","d":1.36496},{"t":69.0645,"i":3.2441,"hkl":"(3,-1,-2,3)","d":1.35996},{"t":72.4654,"i":19.568,"hkl":"(3,0,-3,3)","d":1.30429},{"t":72.5681,"i":4.0197,"hkl":"(5,0,-5,0)","d":1.30269},{"t":74.3832,"i":23.2281,"hkl":"(5,-2,-3,2)","d":1.27534},{"t":75.5253,"i":15.8803,"hkl":"(5,0,-5,1)","d":1.25887},{"t":75.9046,"i":15.6632,"hkl":"(6,-3,-3,0)","d":1.25352},{"t":77.692,"i":1.6262,"hkl":"(5,-1,-4,2)","d":1.22909},{"t":78.1055,"i":3.2813,"hkl":"(0,0,0,4)","d":1.22361},{"t":79.0931,"i":3.8456,"hkl":"(4,-1,-3,3)","d":1.2108},{"t":79.7413,"i":2.6283,"hkl":"(1,0,-1,4)","d":1.20258},{"t":83.9635,"i":1.7591,"hkl":"(4,0,-4,3)","d":1.15253},{"t":84.6039,"i":1.2916,"hkl":"(2,0,-2,4)","d":1.14543},{"t":85.3051,"i":1.3548,"hkl":"(6,-1,-5,1)","d":1.1378},{"t":87.4171,"i":2.1369,"hkl":"(6,-3,-3,2)","d":1.11567},{"t":87.4171,"i":1.0685,"hkl":"(3,3,-6,2)","d":1.11567},{"t":88.7903,"i":2.2287,"hkl":"(5,-2,-3,3)","d":1.10194},{"t":89.0232,"i":1.8257,"hkl":"(6,-4,-2,2)","d":1.09966},{"t":89.0232,"i":3.6515,"hkl":"(6,-2,-4,2)","d":1.09966},{"t":89.4276,"i":2.4575,"hkl":"(3,-1,-2,4)","d":1.09573}];
// 图例文案(中文站字面量;英文站模板传英文,见 en/page/detail.php)
var LBL_MATERIAL_PEAK = '材料衍射峰';
var initialRadiation = 'Cu Kα';
var canvas = document.getElementById('xrd-detail-canvas');
var note = document.getElementById('xrd-note');
var body = document.getElementById('xrd-peaks-body');
var cnt = document.getElementById('xrd-peaks-count');
var sel = document.getElementById('xrd-target');
var link = document.getElementById('xrd-direct-link');
var mpId = "mp-1106180";
function renderChart(ps, radiation) {
if (typeof XrdChart === 'undefined' || !canvas || !Array.isArray(ps)) return;
var m = 0;
ps.forEach(function (p) { if (p.t > m) m = p.t; });
var mt = Math.max(90, Math.ceil((m + 5) / 10) * 10);
XrdChart.render(canvas, { materialPeaks: ps, label: radiation, maxTheta: mt, materialPeakLabel: LBL_MATERIAL_PEAK });
}
function renderTable(ps) {
if (!body) return;
var rows = '';
ps.slice(0, 24).forEach(function (pk) {
var t = (pk.t != null) ? Number(pk.t).toFixed(2) : '';
var d = (pk.d != null) ? Number(pk.d).toFixed(4) : '';
var i = (pk.i != null) ? Number(pk.i).toFixed(1) : '';
var h = (pk.hkl != null) ? String(pk.hkl).replace(/[<>&]/g, '') : '';
rows += '
' + t + '
' + d + '
' + i + '
' + h + '
';
});
body.innerHTML = rows;
if (cnt) cnt.textContent = Math.min(ps.length, 24);
}
function updateLink(target) {
if (link) link.href = location.origin + '/api/v1/materials/' + encodeURIComponent(mpId) + '/xrd?format=raw&target=' + encodeURIComponent(target);
}
// 初始渲染(服务端已预取默认靶材的图谱)
renderChart(peaks, initialRadiation);
if (sel) updateLink(sel.value);
// 切换靶材:重新拉取该靶材的衍射图谱并刷新图表 / 表格 / 直接链接
if (sel) {
var xrdSeq = 0;
sel.addEventListener('change', function () {
var t = sel.value;
updateLink(t);
var my = ++xrdSeq;
// 先清空 loading 态,避免请求失败后按钮一直停在“切换中”
if (note) note.textContent = '正在加载 ' + t + ' 图谱…';
fetch('/api/v1/materials/' + encodeURIComponent(mpId) + '/xrd?target=' + encodeURIComponent(t))
.then(function (r) {
if (!r.ok) throw new Error('HTTP ' + r.status);
return r.json();
})
.then(function (res) {
// 竞态防护:快速切换靶材时,先发的请求可能后到,丢弃过期响应
if (my !== xrdSeq) return;
if (!res.success || !res.data || !Array.isArray(res.data.peaks) || !res.data.peaks.length) {
throw new Error(res.error || '该靶材暂无衍射数据');
}
var d = res.data;
if (note) note.textContent = '横轴为 2θ (°),纵轴为相对强度,' + d.radiation + ' , λ=' + d.wavelength + ' Å';
renderChart(d.peaks, d.radiation);
renderTable(d.peaks);
})
.catch(function (e) {
if (my !== xrdSeq) return;
// 恢复服务端预取的默认靶材视图,并明确提示失败原因
// (旧实现是空 catch,静默失败会让图表停留在上一个靶材的数据而用户毫不知情)
if (note) note.textContent = '切换靶材失败:' + (e && e.message ? e.message : '未知错误');
renderChart(peaks, initialRadiation);
renderTable(peaks);
});
});
}
})();
The crystal structure and related material properties of Re7B3 were obtained from the Materials Project database (MP-ID: mp-1106180, database version v2026.04.13).
文献引用
Horton, M.K., Huck, P., Yang, R.X. et al. Accelerated data-driven materials science with the Materials Project. Nat. Mater. 24, 1522–1532 (2025).
https://doi.org/10.1038/s41563-025-02272-0
晶体结构 3D 渲染
加载 3D 结构...
样式: Ball & Stick|拖拽旋转 · 滚轮缩放 · 右键平移
原始 CIF 数据
# generated using pymatgen
data_Re7B3
_symmetry_space_group_name_H-M 'P 1'
_cell_length_a 7.52110628
_cell_length_b 7.52110628
_cell_length_c 4.89445154
_cell_angle_alpha 90.00000000
_cell_angle_beta 90.00000000
_cell_angle_gamma 120.00000319
_symmetry_Int_Tables_number 1
_chemical_formula_structural Re7B3
_chemical_formula_sum 'Re14 B6'
_cell_volume 239.77179930
_cell_formula_units_Z 2
loop_
_symmetry_equiv_pos_site_id
_symmetry_equiv_pos_as_xyz
1 'x, y, z'
loop_
_atom_site_type_symbol
_atom_site_label
_atom_site_symmetry_multiplicity
_atom_site_fract_x
_atom_site_fract_y
_atom_site_fract_z
_atom_site_occupancy
Re Re0 1 0.66666700 0.33333300 0.58400883 1.0
Re Re1 1 0.33333300 0.66666700 0.08400883 1.0
Re Re2 1 0.87718799 0.75437498 0.75225498 1.0
Re Re3 1 0.24562502 0.12281201 0.75225498 1.0
Re Re4 1 0.87718799 0.12281201 0.75225498 1.0
Re Re5 1 0.12281201 0.24562502 0.25225498 1.0
Re Re6 1 0.75437498 0.87718799 0.25225498 1.0
Re Re7 1 0.12281201 0.87718799 0.25225498 1.0
Re Re8 1 0.45411726 0.90823551 0.54986287 1.0
Re Re9 1 0.09176449 0.54588274 0.54986287 1.0
Re Re10 1 0.45411726 0.54588274 0.54986287 1.0
Re Re11 1 0.54588274 0.09176449 0.04986287 1.0
Re Re12 1 0.90823551 0.45411726 0.04986287 1.0
Re Re13 1 0.54588274 0.45411726 0.04986287 1.0
B B14 1 0.18938329 0.37876558 0.84053987 1.0
B B15 1 0.62123442 0.81061671 0.84053987 1.0
B B16 1 0.18938329 0.81061671 0.84053987 1.0
B B17 1 0.81061671 0.62123442 0.34053987 1.0
B B18 1 0.37876558 0.18938329 0.34053987 1.0
B B19 1 0.81061671 0.18938329 0.34053987 1.0