OrcaSlicer/resources/web/homepage/js/home.js
lane.wei e9e4d75877 Update the codes to 01.01.00.10 for the formal release
1. first formal version of macos
2. add the bambu networking plugin install logic
3. auto compute the wipe volume when filament change
4. add the logic of wiping into support
5. refine the GUI layout and icons, improve the gui apperance in lots of
   small places
6. serveral improve to support
7. support AMS auto-mapping
8. disable lots of unstable features: such as params table, media file download, HMS
9. fix serveral kinds of bugs
10. update the document of building
11. ...
2022-07-22 20:35:34 +08:00

218 lines
5.1 KiB
JavaScript

/*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);
}
else if( strCmd=="network_plugin_installtip" )
{
let nShow=pVal["show"]*1;
if(nShow==1)
{
$("#NoPluginTip").show();
$("#NoPluginTip").css("display","flex");
}
else
{
$("#NoPluginTip").hide();
}
}
}
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) );
}
function BeginDownloadNetworkPlugin()
{
var tSend={};
tSend['sequence_id']=Math.round(new Date() / 1000);
tSend['command']="begin_network_plugin_download";
SendWXMessage( JSON.stringify(tSend) );
}
window.postMessage = HandleStudio;