Qortal UI - Main Code Repository A User Interface for the Qortal Blockchain Project. Truly decentralized web hosting, application hosting, communications, data storage, and full infrastructure for the future global decentralized digital world.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

1 lines
6.9 KiB

!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";const e=new Epml({type:"WINDOW",source:window.parent});let t,n;new Epml({type:"PROXY",source:{proxy:e,target:"visible-plugin",id:"core-plugin"}});let o,a,s,r=0,d=!1,i=!1,l=!1,c=!0,p=!1,u=0,m=!1,g=!1,w=!1;e.subscribe("logged_in",(e=>{w="true"===e}));const S=async()=>{const t=await e.request("apiCall",{url:"/admin/info"});e.request("updateNodeInfo",t)};let h,C=0;const T=()=>{t.close(),d=!0,o.close(),p=!0},f=t=>{e.request("updateBlockInfo",t)},O=async t=>{e.request("updateNodeStatus",t)},b=e=>{0==e.node||1==e.node?k():void 0!==o&&(o.close(),p=!0)},x=()=>{let o,a=window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node],i=a.domain+":"+a.port;o="https:"===window.parent.location.protocol?`wss://${i}/websockets/blocks`:`ws://${i}/websockets/blocks`;const p=new WebSocket(o);p.onopen=e=>{console.log("[SOCKET-BLOCKS]: Connected."),d=!1,t=p,r+=1},p.onmessage=t=>{f(JSON.parse(t.data)),w&&(async t=>{let n={names:await e.request("apiCall",{url:`/names/address/${t}`}),addressInfo:await e.request("apiCall",{url:`/addresses/${t}`})};!0!==window.parent._.isEqual(s,n)&&(e.request("setAccountInfo",n),s=n)})(window.parent.reduxStore.getState().app.selectedAddress.address)},p.onclose=()=>{console.log("[SOCKET-BLOCKS]: CLOSED"),f({}),c=!0,clearInterval(n),!1===d&&r<=52&&(r<=52?(l=!0,setTimeout(N,1e4),r+=1):l=!1)},p.onerror=e=>{console.log(`[SOCKET-BLOCKS]: ${e.type}`),c=!0,f({})},c&&e.request("apiCall",{url:"/blocks/last"}).then((e=>{f(e),c=!1}))},N=()=>{i?(i=!1,x(),n=setTimeout(N,295e3)):l?(l=!1,clearTimeout(n),x(),i=!0,n=setTimeout(N,295e3)):(t.send("non-integer ping"),n=setTimeout(N,295e3))},q=()=>{let e,t=window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node],n=t.domain+":"+t.port;e="https:"===window.parent.location.protocol?`wss://${n}/websockets/admin/status`:`ws://${n}/websockets/admin/status`;const s=new WebSocket(e);s.onopen=e=>{console.log("[SOCKET-NODE-STATUS]: Connected."),p=!1,o=s,u+=1},s.onmessage=e=>{O(JSON.parse(e.data))},s.onclose=()=>{console.log("[SOCKET-NODE-STATUS]: CLOSED"),O({}),clearInterval(a),!1===p&&u<=52&&(u<=52?(m=!0,setTimeout(k,1e4),u+=1):m=!1)},s.onerror=e=>{console.log(`[SOCKET-NODE-STATUS]: ${e.type}`),O({})}},k=()=>{g?(clearTimeout(a),q(),g=!1,a=setTimeout(k,295e3)):m?(m=!1,clearTimeout(a),q(),a=setTimeout(k,295e3)):(o.send("non-integer ping"),a=setTimeout(k,295e3))},E=e=>[...e.groups.map((e=>0===e.groupId?{groupId:e.groupId,url:`group/${e.groupId}`,groupName:"Qortal General Chat",sender:e.sender,senderName:e.senderName,timestamp:void 0===e.timestamp?1:e.timestamp}:{...e,url:`group/${e.groupId}`})),...e.direct.map((e=>({...e,url:`direct/${e.address}`})))];let y=0;const $=t=>{let n=`${window.parent.reduxStore.getState().app.selectedAddress.address.substr(0,10)}_chat-heads`;try{let o=localStorage.getItem(n);null===o?e.request("setLocalStorage",{key:n,dataObj:t}).then((n=>{e.request("setChatHeads",t).then((e=>{}))})):(e.request("setLocalStorage",{key:n,dataObj:t}).then((n=>{e.request("setChatHeads",t).then((e=>{}))})),y>=1?((t,n)=>{let o=JSON.parse(n);if(!0!==window.parent._.isEqual(o,t)){let n=E(o);E(t).filter((e=>!n.some((t=>e.timestamp===t.timestamp)))).forEach((t=>{t.sender!==window.parent.reduxStore.getState().app.selectedAddress.address&&void 0!==t.sender&&e.request("showNotification",t)}))}})(t,o):y+=1)}catch(e){console.error(e)}};let I,v,K=0,A=!1,_=!1,D=!1,L=!1;e.subscribe("logged_in",(async t=>{const n=()=>{let t,n=window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node],a=n.domain+":"+n.port;t="https:"===window.parent.location.protocol?`wss://${a}/websockets/chat/active/${window.parent.reduxStore.getState().app.selectedAddress.address}`:`ws://${a}/websockets/chat/active/${window.parent.reduxStore.getState().app.selectedAddress.address}`;const s=new WebSocket(t);s.onopen=()=>{console.log("[SOCKET]: Connected."),I=s,K+=1,L=!0},s.onmessage=e=>{$(JSON.parse(e.data))},s.onclose=()=>{console.log("[SOCKET]: CLOSED"),clearInterval(v),!1===A&&K<=52&&(K<=52?(e.request("showSnackBar","Connection to the Qortal Core was lost, is your Core running ?"),D=!0,setTimeout(o,1e4),K+=1):e.request("showSnackBar","Cannot connect to the Qortal Core, restart UI and Core!"))},s.onerror=e=>{console.log(`[SOCKET]: ${e.type}`)}},o=()=>{!0===window.parent.reduxStore.getState().app.loggedIn?_?D?(D=!1,clearTimeout(v),n(),_=!0,v=setTimeout(o,295e3)):L&&(I.send("ping"),v=setTimeout(o,295e3)):(n(),_=!0,v=setTimeout(o,295e3)):_&&!A&&(A=!0,I.close(),clearTimeout(v),_=!1,L=!1)};"true"===t?((async t=>{let n={names:await e.request("apiCall",{url:`/names/address/${t}`}),addressInfo:await e.request("apiCall",{url:`/addresses/${t}`})};e.request("setAccountInfo",n)})(window.parent.reduxStore.getState().app.selectedAddress.address),o()):(_&&(A=!0,I.close(),clearTimeout(v),_=!1,L=!1),y=0)})),e.ready().then((()=>{e.subscribe("node_config",(e=>{if(0===C){let n=JSON.parse(e);h={node:n.node,knownNodes:n.knownNodes},C+=1,g=!0,i=!0,void 0!==t&&T(),void 0!==o&&T(),b(h),N(),S()}let n=JSON.parse(e),a={node:n.node,knownNodes:n.knownNodes};!0!==window.parent._.isEqual(h,a)&&(h=a,g=!0,i=!0,void 0!==t&&T(),void 0!==o&&T(),b(a),N(),S())}))})),e.imReady();let J={},W=!1;e.ready().then((()=>{let t=[{url:"minting",domain:"core",page:"minting/index.html",title:"Minting Details",icon:"info",menus:[],parent:!1},{url:"wallet",domain:"core",page:"wallet/index.html",title:"Wallet",icon:"account_balance_wallet",menus:[],parent:!1},{url:"send-coin",domain:"core",page:"send-coin/index.html",title:"Send Coin",icon:"send",menus:[],parent:!1},{url:"trade-portal",domain:"core",page:"trade-portal/index.html",title:"Trade Portal",icon:"toc",menus:[],parent:!1},{url:"reward-share",domain:"core",page:"reward-share/index.html",title:"Reward Share",icon:"call_split",menus:[],parent:!1},{url:"name-registration",domain:"core",page:"name-registration/index.html",title:"Name Registration",icon:"assignment_ind",menus:[],parent:!1},{url:"websites",domain:"core",page:"qdn/index.html",title:"Websites",icon:"computer",menus:[],parent:!1},{url:"data-management",domain:"core",page:"qdn/data-management/index.html",title:"Data Management",icon:"dns",menus:[],parent:!1},{url:"q-chat",domain:"core",page:"messaging/q-chat/index.html",title:"Q-Chat",icon:"message",menus:[],parent:!1},{url:"group-management",domain:"core",page:"group-management/index.html",title:"Group Management",icon:"group",menus:[],parent:!1},{url:"puzzles",domain:"core",page:"puzzles/index.html",title:"Puzzles",icon:"extension",menus:[],parent:!1}];const n=t=>{e.request("registerUrl",t)};e.subscribe("config",(e=>{if(J=JSON.parse(e),!W&&J.user.knownNodes[J.user.node].enableManagement){W=!0;let e={url:"node-management",domain:"core",page:"node-management/index.html",title:"Node Management",icon:"cloud",menus:[],parent:!1},o=[...t,e];n(o)}else n(t)}))}))}));