This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
option = { | |
visualMap: { | |
show: false, | |
dimension: 2, | |
min: 0, | |
max: 30 | |
}, | |
xAxis3D: { | |
type: 'value' | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var series = []; | |
for (var y = -1; y < 1; y += 0.4) { | |
var data = []; | |
// Parametric curve | |
for (var x = -1; x < 1; x += 0.1) { | |
data.push([+x.toFixed(5), +y.toFixed(5), +(Math.sin(x * Math.PI + 0.22) * Math.sin(y * Math.PI + 0.22)).toFixed(5)]); | |
} | |
series.push({ | |
type: 'line3D', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var xStr = ` | |
0.000 | |
0.000 | |
0.043 | |
0.162 | |
0.393 | |
0.769 | |
1.323 | |
2.116 | |
3.336 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const flattenArr = [ | |
{ title: '首頁', id: 11, parent_id: 0, children: [] }, | |
{ title: '子頁', id: 12, parent_id: 11, children: [] }, | |
{ title: '產品頁', id: 21, parent_id: 0, children: [] } | |
] | |
function treeify(nodes) { | |
var indexed_nodes = {}, tree_roots = []; | |
for (var i = 0; i < nodes.length; i += 1) { | |
indexed_nodes[nodes[i].id] = nodes[i]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const arr = [ | |
{ | |
title: '首頁', | |
id: 11, | |
parent_id: 0, | |
children: [ | |
{ | |
title: '子頁', | |
id: 12, | |
parent_id: 11, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"explorer.openEditors.visible": 0, | |
"workbench.colorTheme": "Default Light+", | |
"workbench.iconTheme": "vscode-simpler-icons", | |
"workbench.sideBar.location": "right", | |
// 需下載安裝 Fira Code 字型 (安裝 OTF 格式) | |
// https://github.com/tonsky/FiraCode/releases | |
// 需下載客製化過的 Microsoft YaHei Mono 字型 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Nextjs in server side to detect device with user agent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function uploadFile(file) { | |
var formData = new FormData(); | |
formData.append("userfile", file); | |
var request = new XMLHttpRequest(); | |
request.onload = function () { | |
if (request.status == 200) { | |
document.location.href='/'; | |
} else { | |
alert('Error! Upload failed'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// e.g. console.save({hello: 'world'}) | |
(function(console){ | |
console.save = function(data, filename){ | |
if(!data) { | |
console.error('Console.save: No data') | |
return; | |
} | |
if(!filename) filename = 'console.json' | |
if(typeof data === "object"){ | |
data = JSON.stringify(data, undefined, 4) |