Add the full source of BambuStudio

using version 1.0.10
This commit is contained in:
lane.wei 2022-07-15 23:37:19 +08:00 committed by Lane.Wei
parent 30bcadab3e
commit 1555904bef
3771 changed files with 1251328 additions and 0 deletions

View file

@ -0,0 +1,320 @@
*
{
padding:0px;
border: 0px;
margin: 0px;
font-size: 16px;
}
html, body {
height: 100%;
width: 100%;
margin: 0px;
padding: 0px;
line-height: 20px;
}
/*------------------*/
body
{
display:flex;
justify-content: flex-start;
}
#LeftBoard
{
border-right: 1px solid #EFF0F0;
width:262px;
height: 100%;
}
#LoginArea
{
height: 180px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
flex-wrap: nowrap;
}
#Login1
{
height:36px;
line-height: 36px;
display: flex;
justify-content: center;
}
#LoginBtn
{
cursor:pointer;
}
#Icon1
{
margin-right: 10px;
}
#BBLIcon
{
height:36px;
}
#Login2
{
display: none;
flex-direction: column;
align-items: center;
text-align: center;
width: 262px;
}
#UserAvatarIcon
{
height: 85px;
}
#UserName
{
white-space: nowrap;
text-overflow: ellipsis;
text-align: center;
overflow: hidden;
width: 80%;
}
#LogoutBtn
{
font-size: 14px;
height: 24px;
line-height: 24px;
color: #00B731;
border: 1px solid #00AE42;
border-radius: 4px;
cursor: pointer;
margin-top: 5px;
padding: 0px 8px;
}
#LogoutBtn:hover
{
background: #00B731;
color: #fff;
}
/*------------------*/
#BtnArea
{
}
.BtnItem
{
padding-left:40px;
height:50px;
line-height: 50px;
display: flex;
justify-content:flex-start;
cursor: pointer;
}
.BtnItem:hover
{
background-color: #E0FCEB;
}
.BtnItemSelected
{
background-color: #E0FCEB;
}
.BtnIcon
{
margin-right:6px;
display: flex;
flex-direction: column;
justify-content: center;
}
.LeftIcon
{
width:20px;
height: 20px;
}
/*--------------------*/
#RightBoard
{
width: 100%;
height: 100%;
overflow-y:auto;
}
#ContentBoard
{
overflow-y:hidden;
padding: 0px 40px;
display: flex;
flex-direction: column;
}
#MenuArea
{
height: 140px;
display: flex;
align-items: center;
}
.MenuItem
{
border: 1px solid #4CAA50;
border-radius: 12px;
height: 101px;
width: 253px;
padding-left: 20px;
display: flex;
justify-content: flex-start;
align-items: center;
margin-right: 16px;
cursor: pointer;
}
.MenuItem:hover
{
background-color: #E0FCEB;
}
.MenuIcon
{
margin-right: 1em;
}
.MenuIcon img
{
width:56px;
height: 56px;
}
.MenuDesc
{
color: #A8A8A8;
}
.Content-Title
{
line-height: 30px;
font-weight: 700;
}
#HotspotWEB
{
width:100%;
height: 420px;
}
#RecentFileArea
{
margin-top: 10px;
flex: 1;
display: flex;
flex-direction: column;
}
#RecentTitle
{
border-bottom: 1px solid #D9D9D9;
}
#FileList
{
flex: 1;
display: flex;
flex-wrap: wrap;
align-content: flex-start;
overflow-y: auto;
}
.FileItem
{
width: 184px;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
word-break: break-all;
position: relative;
cursor: pointer;
margin: 8px;
}
.FileTip
{
position: absolute;
top: 0px;
left: 0px;
right: 0px;
bottom: 0px;
}
.FileImg
{
text-align: center;
background-color: #E4E4E4;
border-radius: 8px;
width: 184px;
height: 184px;
}
.FileItem img
{
width: 184px;
height: 184px;
border-radius: 8px;
display: inline-block;
}
.FileDate
{
color: #A8A8A8;
}
/*--------Mall------*/
#MallBoard
{
height: 100%;
max-width: 1600px;
overflow-y: hidden;
padding: 0px 40px;
display: none;
}
#MallWeb
{
width: 100%;
height: 95%;
border: 1px solid #D9D9D9;
}
/*------Manual------*/
#ManualBoard
{
height: 100%;
max-width: 1600px;
overflow-y: hidden;
padding: 0px 40px;
display: none;
}
#ManualWeb
{
width: 100%;
height: 95%;
border: 1px solid #D9D9D9;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

View file

@ -0,0 +1,154 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="Cache-Control" content="max-age=7200" />
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" name="viewport" />
<title>homepage</title>
<link rel="stylesheet" type="text/css" href="css/home.css" />
<script type="text/javascript" src="js/jquery-3.6.0.min.js"></script>
<script type="text/javascript" src="../data/text.js"></script>
<script type="text/javascript" src="js/json2.js"></script>
<script type="text/javascript" src="js/globalapi.js"></script>
<script type="text/javascript" src="js/home.js"></script>
</head>
<body onLoad="OnInit()">
<div id="LeftBoard">
<div id="LoginArea">
<div id="Login1">
<div id="Icon1"><img id="BBLIcon" src="../image/logo2.png" /></div>
<div id="LoginBtn" style="font-weight: 700;" onClick="OnLoginOrRegister()"><span class="trans" tid="t26">login</span>/<span class="trans" tid="t27">register</span></div>
</div>
<div id="Login2">
<div>
<img id="UserAvatarIcon" src="img/c.jpg" onerror="this.onerror=null;this.src='img/c.jpg';" />
</div>
<div id="UserName"></div>
<div id="LogoutBtn" class="Btn trans" tid="t50" onClick="OnLogOut()">log out</div>
</div>
</div>
<div id="BtnArea">
<div menu="recent" class="BtnItem BtnItemSelected" onClick="GotoMenu('recent')">
<div class="BtnIcon "><img class="LeftIcon" src="img/i2.png" /></div>
<div class="trans" tid="t28">recent</div>
</div>
</div>
</div>
<div id="RightBoard">
<div id="ContentBoard" board="recent">
<div style="height: 14px;"></div>
<div id="MenuArea">
<div class="MenuItem" onClick="OnClickNewProject()">
<div class="MenuIcon"><img src="img/i4.png"></div>
<div>
<div class="trans" tid="t31">new project</div>
<div class="MenuDesc trans" tid="t32">create new project</div>
</div>
</div>
<div class="MenuItem" onClick="OnClickOpenProject()">
<div class="MenuIcon"><img src="img/i5.png"></div>
<div>
<div class="trans" tid="t33">open project</div>
<div class="MenuDesc">3mf</div>
</div>
</div>
</div>
<div id="RecentFileArea">
<div id="RecentTitle" class="Content-Title trans" tid="t35">recent open</div>
<div id="FileList">
<!-- <div class="FileItem" onClick="OnOpenRecentFile('aaaa')">
<a class="FileTip" title="d:\model\11.3mf"></a>
<div class="FileImg"><img src="img/b.jpg"/></div>
<a>abcd12334.3mf</a>
<div class="FileDate">2021/12/27 09:22</div>
</div>
<div class="FileItem">
<a class="FileTip" title="d:\model\11.3mf"></a>
<div class="FileImg"><img src="img/b.jpg"/></div>
<a>abcd12334.3mf</a>
<div class="FileDate">2021/12/27 09:22</div>
</div>
<div class="FileItem">
<a class="FileTip" title="d:\model\11.3mf"></a>
<div class="FileImg"><img src="img/b.jpg"/></div>
<a>abcd12334.3mf</a>
<div class="FileDate">2021/12/27 09:22</div>
</div>
<div class="FileItem">
<a class="FileTip" title="d:\model\11.3mf"></a>
<div class="FileImg"><img src="img/b.jpg"/></div>
<a>abcd12334.3mf</a>
<div class="FileDate">2021/12/27 09:22</div>
</div>
<div class="FileItem">
<a class="FileTip" title="d:\model\11.3mf"></a>
<div class="FileImg"><img src="img/b.jpg"/></div>
<a>abcd12334.3mf</a>
<div class="FileDate">2021/12/27 09:22</div>
</div>
<div class="FileItem">
<a class="FileTip" title="d:\model\11.3mf"></a>
<div class="FileImg"><img src="img/b.jpg"/></div>
<a>abcd12334.3mf</a>
<div class="FileDate">2021/12/27 09:22</div>
</div>
<div class="FileItem">
<a class="FileTip" title="d:\model\11.3mf"></a>
<div class="FileImg"><img src="img/b.jpg"/></div>
<a>abcd12334.3mf</a>
<div class="FileDate">2021/12/27 09:22</div>
</div>
<div class="FileItem">
<a class="FileTip" title="d:\model\11.3mf"></a>
<div class="FileImg"><img src="img/b.jpg"/></div>
<a>abcd12334.3mf</a>
<div class="FileDate">2021/12/27 09:22</div>
</div>
<div class="FileItem" >
<a class="FileTip" title="d:\model\11.3mf"></a>
<div class="FileImg"><img src="img/xxxx.jpg" onerror="this.onerror=null;this.src='img/d.png';" alt="No Image" /></div>
<a>abcd12334.3mf</a>
<div class="FileDate">2021/12/27 09:22</div>
</div>
<div class="FileItem">
<a class="FileTip" title="d:\model\11.3mf"></a>
<div class="FileImg"><img src="img/b.jpg"/></div>
<a>abcd12334.3mf</a>
<div class="FileDate">2021/12/27 09:22</div>
</div>
<div class="FileItem">
<a class="FileTip" title="d:\model\11.3mf"></a>
<div class="FileImg"><img src="img/b.jpg"/></div>
<a>abcd12334.3mf</a>
<div class="FileDate">2021/12/27 09:22</div>
</div>-->
</div>
</div>
<div style="height: 14px;"></div>
</div>
</div>
</body>
<script type="text/javascript">
//HandleStudio(TestData);
</script>
</html>

View file

@ -0,0 +1,280 @@
/*------------------ Date Function ------------------------*/
function GetFullToday( )
{
var d=new Date();
var nday=d.getDate();
var nmonth=d.getMonth()+1;
var nyear=d.getFullYear();
var strM=nmonth+'';
if( nmonth<10 )
strM='0'+nmonth;
var strD=nday+'';
if( nday<10 )
strD='0'+nday;
return nyear+'-'+strM+'-'+strD;
}
function GetFullDate()
{
var d=new Date();
var tDate={};
tDate.nyear=d.getFullYear();
tDate.nmonth=d.getMonth()+1;
tDate.nday=d.getDate();
tDate.nhour=d.getHours();
tDate.nminute=d.getMinutes();
tDate.nsecond=d.getSeconds();
tDate.nweek=d.getDay();
tDate.ndate=d.getDate();
var strM=tDate.nmonth+'';
if( tDate.nmonth<10 )
strM='0'+tDate.nmonth;
var strD=tDate.nday+'';
if( tDate.nday<10 )
strD='0'+tDate.nday;
var strH=tDate.nhour+'';
if( tDate.nhour<10 )
strH='0'+tDate.nhour;
var strMin=tDate.nminute+'';
if( tDate.nminute<10 )
strMin='0'+tDate.nminute;
var strS=tDate.nsecond+'';
if( tDate.nsecond<10 )
strS='0'+tDate.nsecond;
tDate.strdate=tDate.nyear+'-'+strM+'-'+strD;
tDate.strFulldate=tDate.strdate+' '+strH+':'+strMin+':'+strS;
return tDate;
}
function Unixtimestamp2Date( nSecond )
{
var d=new Date(nSecond*1000);
var tDate={};
tDate.nyear=d.getFullYear();
tDate.nmonth=d.getMonth()+1;
tDate.nday=d.getDate();
tDate.nhour=d.getHours();
tDate.nminute=d.getMinutes();
tDate.nsecond=d.getSeconds();
tDate.nweek=d.getDay();
tDate.ndate=d.getDate();
var strM=tDate.nmonth+'';
if( tDate.nmonth<10 )
strM='0'+tDate.nmonth;
var strD=tDate.nday+'';
if( tDate.nday<10 )
strD='0'+tDate.nday;
tDate.strdate=tDate.nyear+'-'+strM+'-'+strD;
return tDate.strdate;
}
//------------Array Function-------------
Array.prototype.in_array = function (e) {
let sArray= ',' + this.join(this.S) + ',';
let skey=','+e+',';
if(sArray.indexOf(skey)>=0)
return true;
else
return false;
}
//------------String Function------------------
/**
* Delete Left/Right Side Blank
*/
String.prototype.trim=function()
{
return this.replace(/(^\s*)|(\s*$)/g, '');
}
/**
* Delete Left Side Blank
*/
String.prototype.ltrim=function()
{
return this.replace(/(^\s*)/g,'');
}
/**
* Delete Right Side Blank
*/
String.prototype.rtrim=function()
{
return this.replace(/(\s*$)/g,'');
}
//----------------Get Param-------------
function GetQueryString(name)
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r!=null)
{
return unescape(r[2]);
}
else
{
return null;
}
}
function GetGetStr()
{
let strGet="";
//获取当前URL
let url = document.location.href;
//获取?的位置
let index = url.indexOf("?")
if(index != -1) {
//截取出?后面的字符串
strGet = url.substr(index + 1);
}
return strGet;
}
/*--------------------JSON Function------------*/
/*
功能检查一个字符串是不是标准的JSON格式
参数 strJson 被检查的字符串
返回值 如果字符串是一个标准的JSON格式则返回JSON对象
如果字符串不是标准JSON格式则返回null
*/
function IsJson( strJson )
{
var tJson=null;
try
{
tJson=JSON.parse(strJson);
}
catch(exception)
{
return null;
}
return tJson;
}
/*-----------------------Ajax Function--------------------*/
/*JQueryAjax
参数说明
url 目标地址
action post/get
data 字符串格式的发送内容
asyn true---异步模式;false-----同步模式;
*/
function HttpReq( url,action, data,callbackfunc)
{
var strAction=action.toLowerCase();
if( strAction=="post")
{
$.post(url,data,callbackfunc);
}
else if( strAction=="get")
{
$.get(url,callbackfunc);
}
}
/*---------------Cookie Function-------------------*/
function setCookie(name, value, time='',path='') {
if(time && path){
var strsec = time * 1000;
var exp = new Date();
exp.setTime(exp.getTime() + strsec * 1);
document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString() + ";path="+path;
}else if(time){
var strsec = time * 1000;
var exp = new Date();
exp.setTime(exp.getTime() + strsec * 1);
document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString();
}else if(path){
document.cookie = name + "=" + escape(value) + ";path="+path;
}else{
document.cookie = name + "=" + escape(value);
}
}
function getCookie(c_name)
{
if(document.cookie.length > 0) {
c_start = document.cookie.indexOf(c_name + "=");//获取字符串的起点
if(c_start != -1) {
c_start = c_start + c_name.length + 1;//获取值的起点
c_end = document.cookie.indexOf(";", c_start);//获取结尾处
if(c_end == -1) c_end = document.cookie.length;//如果是最后一个结尾就是cookie字符串的结尾
return decodeURI(document.cookie.substring(c_start, c_end));//截取字符串返回
}
}
return "";
}
function checkCookie(c_name) {
username = getCookie(c_name);
console.log(username);
if (username != null && username != "")
{ return true; }
else
{ return false; }
}
function clearCookie(name) {
setCookie(name, "", -1);
}
/*--------Studio WX Message-------*/
function IsInSlicer()
{
let bMatch=navigator.userAgent.match( RegExp('BBL-Slicer','i') );
return bMatch;
}
function SendWXMessage( strMsg )
{
let bCheck=IsInSlicer();
if(bCheck!=null)
{
window.wx.postMessage(strMsg);
}
}

View file

@ -0,0 +1,195 @@
/*var TestData={"sequence_id":"0","command":"studio_send_recentfile","data":[{"path":"D:\\work\\Models\\Toy\\3d-puzzle-cube-model_files\\3d-puzzle-cube.3mf","time":"2022\/3\/24 20:33:10"},{"path":"D:\\work\\Models\\Art\\Carved Stone Vase - remeshed+drainage\\Carved Stone Vase.3mf","time":"2022\/3\/24 17:11:51"},{"path":"D:\\work\\Models\\Art\\Kity & Cat\\Cat.3mf","time":"2022\/3\/24 17:07:55"},{"path":"D:\\work\\Models\\Toy\\鐩村墤.3mf","time":"2022\/3\/24 17:06:02"},{"path":"D:\\work\\Models\\Toy\\minimalistic-dual-tone-whistle-model_files\\minimalistic-dual-tone-whistle.3mf","time":"2022\/3\/22 21:12:22"},{"path":"D:\\work\\Models\\Toy\\spiral-city-model_files\\spiral-city.3mf","time":"2022\/3\/22 18:58:37"},{"path":"D:\\work\\Models\\Toy\\impossible-dovetail-puzzle-box-model_files\\impossible-dovetail-puzzle-box.3mf","time":"2022\/3\/22 20:08:40"}]};*/
function OnInit()
{
//-----Test-----
//$("#Login1").hide();
//$("#UserName").text("ZZZZZZZZ");
//$("#Login2").css("display","flex");
TranslatePage();
SendMsg_GetLoginInfo();
SendMsg_GetRecentFile();
}
function HandleStudio( pVal )
{
let strCmd = pVal['command'];
//alert(strCmd);
if(strCmd=='get_recent_projects')
{
ShowRecentFileList(pVal['response']);
}
else if(strCmd=='studio_userlogin')
{
SetLoginInfo(pVal['data']['avatar'],pVal['data']['name']);
}
else if(strCmd=='studio_useroffline')
{
SetUserOffline();
}
else if( strCmd=="studio_set_mallurl" )
{
SetMallUrl( pVal['data']['url'] );
}
else if( strCmd=="studio_clickmenu" )
{
let strName=pVal['data']['menu'];
GotoMenu(strName);
}
}
function GotoMenu( strMenu )
{
let MenuList=$(".BtnItem");
let nAll=MenuList.length;
for(let n=0;n<nAll;n++)
{
let OneBtn=MenuList[n];
if( $(OneBtn).attr("menu")==strMenu )
{
$(".BtnItem").removeClass("BtnItemSelected");
$(OneBtn).addClass("BtnItemSelected");
$("div[board]").hide();
$("div[board=\'"+strMenu+"\']").show();
}
}
}
function SetLoginInfo( strAvatar, strName )
{
$("#Login1").hide();
$("#UserAvatarIcon").prop("src",strAvatar);
$("#UserName").text(strName);
$("#Login2").show();
$("#Login2").css("display","flex");
}
function SetUserOffline()
{
$("#UserAvatarIcon").prop("src","img/c.jpg");
$("#UserName").text('');
$("#Login2").hide();
$("#Login1").show();
$("#Login1").css("display","flex");
}
function SetMallUrl( strUrl )
{
$("#MallWeb").prop("src",strUrl);
}
function ShowRecentFileList( pList )
{
let nTotal=pList.length;
let strHtml='';
for(let n=0;n<nTotal;n++)
{
let OneFile=pList[n];
let sImg=OneFile["image"];
let sPath=OneFile['path'];
let sTime=OneFile['time'];
let sName=OneFile['project_name'];
//let index=sPath.lastIndexOf('\\')>0?sPath.lastIndexOf('\\'):sPath.lastIndexOf('\/');
//let sShortName=sPath.substring(index+1,sPath.length);
let TmpHtml='<div class="FileItem" onClick="OnOpenRecentFile(\''+ encodeURI(sPath)+'\')" >'+
'<a class="FileTip" title="'+sPath+'"></a>'+
'<div class="FileImg" ><img src="'+sImg+'" onerror="this.onerror=null;this.src=\'img/d.png\';" alt="No Image" /></div>'+
'<a>'+sName+'</a>'+
'<div class="FileDate">'+sTime+'</div>'+
'</div>';
strHtml+=TmpHtml;
}
$("#FileList").html(strHtml);
}
/*-------MX Message------*/
function SendMsg_GetLoginInfo()
{
var tSend={};
tSend['sequence_id']=Math.round(new Date() / 1000);
tSend['command']="get_login_info";
SendWXMessage( JSON.stringify(tSend) );
}
function SendMsg_GetRecentFile()
{
var tSend={};
tSend['sequence_id']=Math.round(new Date() / 1000);
tSend['command']="get_recent_projects";
SendWXMessage( JSON.stringify(tSend) );
}
function OnLoginOrRegister()
{
var tSend={};
tSend['sequence_id']=Math.round(new Date() / 1000);
tSend['command']="homepage_login_or_register";
SendWXMessage( JSON.stringify(tSend) );
}
function OnClickNewProject()
{
var tSend={};
tSend['sequence_id']=Math.round(new Date() / 1000);
tSend['command']="homepage_newproject";
SendWXMessage( JSON.stringify(tSend) );
}
function OnClickOpenProject()
{
var tSend={};
tSend['sequence_id']=Math.round(new Date() / 1000);
tSend['command']="homepage_openproject";
SendWXMessage( JSON.stringify(tSend) );
}
function OnOpenRecentFile( strPath )
{
var tSend={};
tSend['sequence_id']=Math.round(new Date() / 1000);
tSend['command']="homepage_open_recentfile";
tSend['data']={};
tSend['data']['path']=decodeURI(strPath);
SendWXMessage( JSON.stringify(tSend) );
}
function OnLogOut()
{
var tSend={};
tSend['sequence_id']=Math.round(new Date() / 1000);
tSend['command']="homepage_logout";
SendWXMessage( JSON.stringify(tSend) );
}
window.postMessage = HandleStudio

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,185 @@
var JSON;
if (!JSON) {
JSON = {};
}
(function () {
'use strict';
function f(n) {
// Format integers to have at least two digits.
return n < 10 ? '0' + n : n;
}
if (typeof Date.prototype.toJSON !== 'function') {
Date.prototype.toJSON = function (key) {
return isFinite(this.valueOf())
? this.getUTCFullYear() + '-' +
f(this.getUTCMonth() + 1) + '-' +
f(this.getUTCDate()) + 'T' +
f(this.getUTCHours()) + ':' +
f(this.getUTCMinutes()) + ':' +
f(this.getUTCSeconds()) + 'Z'
: null;
};
String.prototype.toJSON =
Number.prototype.toJSON =
Boolean.prototype.toJSON = function (key) {
return this.valueOf();
};
}
var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
gap,
indent,
meta = { // table of character substitutions
'\b': '\\b',
'\t': '\\t',
'\n': '\\n',
'\f': '\\f',
'\r': '\\r',
'"' : '\\"',
'\\': '\\\\'
},
rep;
function quote(string) {
escapable.lastIndex = 0;
return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
var c = meta[a];
return typeof c === 'string'
? c
: '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
}) + '"' : '"' + string + '"';
}
function str(key, holder) {
var i, // The loop counter.
k, // The member key.
v, // The member value.
length,
mind = gap,
partial,
value = holder[key];
if (value && typeof value === 'object' &&
typeof value.toJSON === 'function') {
value = value.toJSON(key);
}
if (typeof rep === 'function') {
value = rep.call(holder, key, value);
}
switch (typeof value) {
case 'string':
return quote(value);
case 'number':
return isFinite(value) ? String(value) : 'null';
case 'boolean':
case 'null':
return String(value);
case 'object':
if (!value) {
return 'null';
}
gap += indent;
partial = [];
if (Object.prototype.toString.apply(value) === '[object Array]') {
length = value.length;
for (i = 0; i < length; i += 1) {
partial[i] = str(i, value) || 'null';
}
v = partial.length === 0
? '[]'
: gap
? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']'
: '[' + partial.join(',') + ']';
gap = mind;
return v;
}
if (rep && typeof rep === 'object') {
length = rep.length;
for (i = 0; i < length; i += 1) {
if (typeof rep[i] === 'string') {
k = rep[i];
v = str(k, value);
if (v) {
partial.push(quote(k) + (gap ? ': ' : ':') + v);
}
}
}
} else {
for (k in value) {
if (Object.prototype.hasOwnProperty.call(value, k)) {
v = str(k, value);
if (v) {
partial.push(quote(k) + (gap ? ': ' : ':') + v);
}
}
}
}
v = partial.length === 0
? '{}'
: gap
? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}'
: '{' + partial.join(',') + '}';
gap = mind;
return v;
}
}
if (typeof JSON.stringify !== 'function') {
JSON.stringify = function (value, replacer, space) {
var i;
gap = '';
indent = '';
if (typeof space === 'number') {
for (i = 0; i < space; i += 1) {
indent += ' ';
}
} else if (typeof space === 'string') {
indent = space;
}
rep = replacer;
if (replacer && typeof replacer !== 'function' &&
(typeof replacer !== 'object' ||
typeof replacer.length !== 'number')) {
throw new Error('JSON.stringify');
}
return str('', {'': value});
};
}
if (typeof JSON.parse !== 'function') {
JSON.parse = function (text, reviver) {
var j;
function walk(holder, key) {
var k, v, value = holder[key];
if (value && typeof value === 'object') {
for (k in value) {
if (Object.prototype.hasOwnProperty.call(value, k)) {
v = walk(value, k);
if (v !== undefined) {
value[k] = v;
} else {
delete value[k];
}
}
}
}
return reviver.call(holder, key, value);
}
text = String(text);
cx.lastIndex = 0;
if (cx.test(text)) {
text = text.replace(cx, function (a) {
return '\\u' +
('0000' + a.charCodeAt(0).toString(16)).slice(-4);
});
}
if (/^[\],:{}\s]*$/
.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')
.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
.replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
j = eval('(' + text + ')');
return typeof reviver === 'function'
? walk({'': j}, '')
: j;
}
throw new SyntaxError('JSON.parse');
};
}
}());

View file

@ -0,0 +1,31 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="Cache-Control" content="max-age=7200" />
<title>homepage</title>
<link rel="stylesheet" type="text/css" href="css/home.css" />
<script type="text/javascript" src="js/jquery-3.6.0.min.js"></script>
<script type="text/javascript" src="../data/text.js"></script>
<script type="text/javascript" src="js/json2.js"></script>
<script type="text/javascript" src="js/globalapi.js"></script>
</head>
<body>
<div id="d1">
<div id="d2"></div>
</div>
</body>
</html>