//var TestData={"sequence_id":"0","command":"get_recent_projects","response":[{"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"}]};
var m_HotModelList=null;
var m_ForUModelList=null;
var m_MakerlabList=null;
function OnHomeInit()
{
//-----Official-----
TranslatePage();
SendMsg_GetRecentFile();
SendMsg_GetStaffPick();
SendMsg_GetMakerlabList();
//ShowMakerlabList(Test_MakerlabList['list']);
}
//Recent详情页面的状态
var Recent_Normal=1;
var Recent_BatchDelete=2;
var RecentPage_Mode=Recent_Normal;
function OnRecentInit()
{
TranslatePage();
SendMsg_GetRecentFile();
Set_RecentFile_Delete_Checkbox_Event();
}
function OnLineInit()
{
TranslatePage();
}
//------最佳打开文件的右键菜单功能----------
var RightBtnFilePath='';
var MousePosX=0;
var MousePosY=0;
var sImages = {};
function Set_RecentFile_MouseRightBtn_Event()
{
$(".FileItem").mousedown(
function(e)
{
//FilePath
RightBtnFilePath=$(this).attr('fpath');
if(e.which == 3){
//鼠标点击了右键+$(this).attr('ff') );
ShowRecnetFileContextMenu();
}else if(e.which == 2){
//鼠标点击了中键
}else if(e.which == 1){
//鼠标点击了左键
OnOpenRecentFile( encodeURI(RightBtnFilePath) );
}
});
$(document).bind("contextmenu",function(e){
//在这里书写代码,构建个性右键化菜单
return false;
});
$(document).mousemove( function(e){
MousePosX=e.pageX;
MousePosY=e.pageY;
let ContextMenuWidth=$('#recnet_context_menu').width();
let ContextMenuHeight=$('#recnet_context_menu').height();
let DocumentWidth=$(document).width();
let DocumentHeight=$(document).height();
//$("#DebugText").text( ContextMenuWidth+' - '+ContextMenuHeight+'
'+
// DocumentWidth+' - '+DocumentHeight+'
'+
// MousePosX+' - '+MousePosY +'
' );
} );
$(document).click( function(){
var e = e || window.event;
var elem = e.target || e.srcElement;
while (elem) {
if (elem.id && elem.id == 'recnet_context_menu') {
return;
}
elem = elem.parentNode;
}
$("#recnet_context_menu").hide();
} );
}
function HandleStudio( pVal )
{
let strCmd = pVal['command'];
if(strCmd=='get_recent_projects')
{
ShowRecentFileList(pVal['response']);
}
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();
}
}
else if( strCmd=="modelmall_model_advise_get")
{
//alert('hot');
if( m_HotModelList!=null && pVal['hits'].length>0 )
{
let SS1=JSON.stringify(pVal['hits']);
let SS2=JSON.stringify(m_HotModelList);
if( SS1==SS2 )
return;
}
m_HotModelList=pVal['hits'];
ShowStaffPick( m_HotModelList );
}
else if( strCmd=="modelmall_model_customized_get")
{
//alert('For U');
if( m_ForUModelList!=null && pVal['hits'].length>0 )
{
let SS1=JSON.stringify(pVal['hits']);
let SS2=JSON.stringify(m_ForUModelList);
if( SS1==SS2 )
return;
}
m_ForUModelList=pVal['hits'];
Show4UPick( m_ForUModelList );
}
else if(strCmd=='homepage_makerlab_get')
{
if( m_MakerlabList!=null && pVal['list'].length>0 )
{
let SS1=JSON.stringify(pVal['list']);
let SS2=JSON.stringify(m_MakerlabList);
if( SS1==SS2 )
return;
}
m_MakerlabList=pVal['list'];
ShowMakerlabList(m_MakerlabList);
}
else if(strCmd=='homepage_leftmenu_clicked')
{
let strName=pVal['menu'];
OnBoardChange(strName);
}
else if(strCmd=='homepage_rightarea_reset')
{
$('#HotModelList').html('');
$('#HotModelArea').hide();
m_HotModelList=null;
m_ForUModelList=null;
$('#LabList').html('');
$('#MakerlabArea').hide();
m_MakerlabList=null;
OnHomeInit();
}
}
function OnBoardChange( strMenu )
{
if( strMenu=='home' )
{
$('#MenuArea').css('display','flex');
$('#HomeFullArea').css('display','inline');
$('#RecentFileArea').css('display','none');
$('#WikiGuideBoard').css('display','none');
if( (m_HotModelList==null || m_HotModelList.length==0) && (m_ForUModelList==null || m_ForUModelList.length==0))
SendMsg_GetStaffPick();
if( m_MakerlabList==null || m_MakerlabList.length==0 )
SendMsg_GetMakerlabList();
}
else if(strMenu=='recent')
{
$('#MenuArea').css('display','flex');
$('#HomeFullArea').css('display','none');
$('#RecentFileArea').css('display','flex');
$('#WikiGuideBoard').css('display','none');
}
else if(strMenu=='manual')
{
$('#MenuArea').css('display','none');
$('#HomeFullArea').css('display','none');
$('#RecentFileArea').css('display','none');
$('#WikiGuideBoard').css('display','flex');
}
}
function SwtichLeftMenu( strMenu )
{
//SendWX
var tSend={};
tSend['sequence_id']=Math.round(new Date() / 1000);
tSend['command']="homepage_leftmenu_switch";
tSend['menu']=strMenu;
SendWXMessage( JSON.stringify(tSend) );
}
function SetMallUrl( strUrl )
{
$("#MallWeb").prop("src",strUrl);
}
function ShowRecentFileList( pList )
{
let nTotal=pList.length;
let strHtml='';
for(let n=0;n0?sPath.lastIndexOf('\\'):sPath.lastIndexOf('\/');
//let sShortName=sPath.substring(index+1,sPath.length);
let TmpHtml=''+
'
'+
'
'+
'
'+sName+'
'+
'
'+sTime+'
'+
'
'+
'
'+
'
';
strHtml+=TmpHtml;
}
$("#FileList").html(strHtml);
$("#MiniFileList").html(strHtml);
Set_RecentFile_MouseRightBtn_Event();
UpdateRecentClearBtnDisplay();
Set_RecentFile_Delete_Checkbox_Event();
}
function ShowRecnetFileContextMenu()
{
if( RecentPage_Mode!=Recent_Normal )
return;
$("#recnet_context_menu").offset({top: 10000, left:-10000});
$('#recnet_context_menu').show();
let ContextMenuWidth=$('#recnet_context_menu').width();
let ContextMenuHeight=$('#recnet_context_menu').height();
let DocumentWidth=$(document).width();
let DocumentHeight=$(document).height();
let RealX=MousePosX;
let RealY=MousePosY;
if( MousePosX + ContextMenuWidth + 24 >DocumentWidth )
RealX=DocumentWidth-ContextMenuWidth-24;
if( MousePosY+ContextMenuHeight+24>DocumentHeight )
RealY=DocumentHeight-ContextMenuHeight-24;
$("#recnet_context_menu").offset({top: RealY, left:RealX});
}
/*-------RecentFile 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 OnClickModelDepot()
{
var tSend={};
tSend['sequence_id']=Math.round(new Date() / 1000);
tSend['command']="homepage_modeldepot";
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 )
{
if( RecentPage_Mode!=Recent_Normal )
return;
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 OnDeleteRecentFile( )
{
//Clear in UI
$("#recnet_context_menu").hide();
let AllFile=$(".FileItem");
let nFile=AllFile.length;
for(let p=0;p0 )
{
$("#Menu_Clear").show();
$('#Menu_Batch').show();
}
else
{
$("#Menu_Clear").hide();
$('#Menu_Batch').hide();
}
}
function OnExploreRecentFile( )
{
var tSend={};
tSend['sequence_id']=Math.round(new Date() / 1000);
tSend['command']="homepage_explore_recentfile";
tSend['data']={};
tSend['data']['path']=decodeURI(RightBtnFilePath);
SendWXMessage( JSON.stringify(tSend) );
$("#recnet_context_menu").hide();
}
function BeginDownloadNetworkPlugin()
{
var tSend={};
tSend['sequence_id']=Math.round(new Date() / 1000);
tSend['command']="begin_network_plugin_download";
SendWXMessage( JSON.stringify(tSend) );
}
function SendMsg_GetMakerlabList()
{
var tSend={};
tSend['sequence_id']=Math.round(new Date() / 1000);
tSend['command']="homepage_makerlab_get";
SendWXMessage( JSON.stringify(tSend) );
setTimeout("SendMsg_GetMakerlabList()",3600*1000*6);
}
function SwitchContent(strMenu)
{
var tSend={};
tSend['sequence_id']=Math.round(new Date() / 1000);
tSend['command']="homepage_leftmenu_clicked";
tSend['menu']=strMenu;
SendWXMessage( JSON.stringify(tSend) );
}
function OnBatchDelete()
{
//切换页面工作模式
RecentPage_Mode=Recent_BatchDelete;
$('#Menu_Batch').hide();
$('#Menu_Clear').hide();
$('#Menu_Delete').css('display','flex');
$('#Menu_Cancel').css('display','flex');
$('.FileCheckBox.FileCheckBox_checked').removeClass('FileCheckBox_checked');
$('.FileCheckBox').show();
}
function OnCancelDelete()
{
//切换页面工作模式
RecentPage_Mode=Recent_Normal;
$('#Menu_Batch').css('display','flex');
$('#Menu_Clear').css('display','flex');
$('#Menu_Delete').hide();
$('#Menu_Cancel').hide();
$('.FileCheckBox.FileCheckBox_checked').removeClass('FileCheckBox_checked');
$('.FileCheckBox').hide();
$('.FileMask').hide();
}
function OnMultiDelete()
{
let ChooseFiles=$('.FileCheckBox.FileCheckBox_checked');
let nChoose=ChooseFiles.length;
var tBatchDel={};
tBatchDel['sequence_id']=Math.round(new Date() / 1000);
tBatchDel['command']="homepage_delete_recentfile";
tBatchDel['data']={};
for(let n=0;n=1000*1000*1000 )
{
nNew=Math.round(number/(1000*1000*1000)*10)/10;
nNew=nNew+'b';
}
else if( number>=1000*1000 )
{
nNew=Math.round(number/(1000*1000)*10)/10;
nNew=nNew+'m';
}
if( number>=1000 )
{
nNew=Math.round(number/(1000)*10)/10;
nNew=nNew+'k';
}
return nNew;
}
function ShowStaffPick( ModelList )
{
let PickTotal=ModelList.length;
if(PickTotal==0)
{
$('#HotModelList').html('');
$('#HotModelArea').hide();
return;
}
$("#Online_Models_Bar").css('display','flex');
$("#ForU_Models_Bar").css('display','none');
let strPickHtml='';
for(let a=0;a'+
''+
'

'+
'
'+
''+
'
'+
'

'+
'
'+
'
'+
'
'+ModelName+'
'+
'
'+
'
'+DesignerName+'
'+
'
'+
'
'+NumZan+''+
'
'+NumDownload+''+
'
'+
'
'+
'
'+
'
'+
'';
}
$('#HotModelList').html(strPickHtml);
InitStaffPick();
$('#HotModelArea').show();
}
function Show4UPick( ModelList )
{
let PickTotal=ModelList.length;
if(PickTotal==0)
{
$('#HotModelList').html('');
$('#HotModelArea').hide();
return;
}
$("#Online_Models_Bar").css('display','none');
$("#ForU_Models_Bar").css('display','flex');
let strPickHtml='';
for(let a=0;a'+
''+
'

'+
'
'+
''+
'
'+
'

'+
'
'+
'
'+
'
'+ModelName+'
'+
'
'+
'
'+DesignerName+'
'+
'
'+
'
'+NumZan+''+
'
'+NumDownload+''+
'
'+
'
'+
'
'+
'
'+
'';
}
$('#HotModelList').html(strPickHtml);
InitStaffPick();
$('#HotModelArea').show();
}
function OpenOneStaffPickModel( ModelID )
{
//alert(ModelID);
var tSend={};
tSend['sequence_id']=Math.round(new Date() / 1000);
tSend['command']="modelmall_model_open";
tSend['data']={};
tSend['data']['id']=ModelID;
SendWXMessage( JSON.stringify(tSend) );
}
//----------MakerLab------------
function IsChinese()
{
let strLang=GetQueryString("lang");
if(strLang!=null)
{
}
else
{
strLang=localStorage.getItem(LANG_COOKIE_NAME);
}
if(strLang!=null)
return strLang.includes('zh')
else
return false;
}
function ShowMakerlabList( LabList )
{
let LabTotal=LabList.length;
if(LabTotal==0)
{
$('#LabList').html('');
$('#MakerlabArea').hide();
return;
}
let bCN=IsChinese();
let strLabHtml='';
for(let a=0;a'+
''+
''+
'
'+LabName+'
'+
'
'+LabDesc+'
'+
'
'+LabAuthor+'
'+
'
';
}
$('#LabList').html(strLabHtml);
$('#MakerlabArea').show();
}
function OnOpenOneMakerlab( ChildUrl )
{
var tSend={};
tSend['sequence_id']=Math.round(new Date() / 1000);
tSend['command']="homepage_makerlab_open";
tSend['url']=ChildUrl;
SendWXMessage( JSON.stringify(tSend) );
}
//---------------Global-----------------
window.postMessage = HandleStudio;