Version 5.0.0 beta 7

This commit is contained in:
Neo committed 2025-12-19 17:18:38 -08:00
1 parent fa2a720105
commit 54d5dcd0a0
156 files changed
+4337 -2995

No files matched your search

+23 -11
View File
@@ -152,7 +152,9 @@ ips.templates.set('tableOfContents.linkOptions',`\
{{/canEdit}}
</span>
</span>
`);;
`);ips.templates.set('ips.ui.controls.cannot_load',`
<div class="{{{classList}}} ipsControls__fail-message">{{message}}</div>
`,{classList:'ipsMessage ipsMessage--info',get message(){return ips.getString('ips.ui.controls.cannot_load')}});
;(function($,_,undefined){"use strict";ips.createModule('ips.loader',function(){var _loadedScripts=[],_loadingScripts=[];var init=function(){var scripts=$('script[src][data-ips]');scripts.each(function(){var scriptInfo=ips.utils.url.getURIObject($(this).attr('src'));if(scriptInfo.queryKey.src){var paths=_getPathScripts(scriptInfo.queryKey.src);_.each(paths,function(value){_loadedScripts.push(value);});}else if(scriptInfo.path.indexOf('interface/')!==-1){var interfaces=_getInterfaceScript(scriptInfo.path);if(interfaces){_loadedScripts.push(interfaces);}}else{var other=_getOtherScript(scriptInfo.source);if(other){_loadedScripts.push(other);}}});},_getOtherScript=function(path){path=path.replace(ips.getSetting('baseURL'),'');if(path.startsWith('/')){path=path.substring(1);}
if(path.startsWith('applications/')){path=path.replace(/^applications\//i,'')}
return path;},_getInterfaceScript=function(path){var pieces=_.compact(path.split('/').reverse());var path=[];for(var i=0;i<pieces.length;i++){if(pieces[i]=='interface'){path.push('interface');path.push(pieces[i+1]);break;}
@@ -199,7 +201,7 @@ _beingLoaded.push(controller);filePaths.push(_buildFilePath(controller));}
if(!_.size(needsLoading)){deferred.resolve();return deferred.promise();}
_.extend(_queue,needsLoading);ips.loader.get(filePaths).then(function(){deferred.resolve();});return deferred.promise();}
function _buildFilePath(controllerName){const bits=controllerName.split('.');if(ips.getSetting('useCompiledFiles')===false){return bits[0]+'/'+bits[1]+'/controllers/'+bits[2]+
'/ips.'+bits[2]+'.'+bits[3]+'.js';}else{try{if(_.indexOf(ips.getSetting('ipsApps'),bits[0])!==-1){const url=ips.getSetting('baseURL')+'static/js/'+bits[0]+'/'+bits[1]+'_'+bits[1]+'_'+bits[2]+'.js';}else{const url=ipsJsFileMap[bits[0]][bits[1]+'_'+bits[2]];}
'/ips.'+bits[2]+'.'+bits[3]+'.js';}else{try{let url;if(_.indexOf(ips.getSetting('ipsApps'),bits[0])!==-1){url=ips.getSetting('baseURL')+'static/js/'+bits[0]+'/'+bits[1]+'_'+bits[1]+'_'+bits[2]+'.js';}else{url=ipsJsFileMap[bits[0]][bits[1]+'_'+bits[2]];}
if(url.indexOf('?')!=-1){return url+'&v='+ips.getSetting('jsAntiCache');}else{return url+'?v='+ips.getSetting('jsAntiCache');}}catch(err){Debug.log(err);return'';}}}
function _findControllers(node){if(!_.isElement(node)&&!(node instanceof jQuery)){node=document;}
var controllersToLoad={};$(node).find('[data-controller]').addBack().each(function(idx,elem){if(!$(elem).data('_controllers')){$(elem).data('_controllers',[]);}
@@ -559,24 +561,34 @@ if(options.minAjaxLength>text.length){return;}
ajaxObj=ips.getAjax()(source,{dataType:'json'}).done(function(response){loadedCache=true;cache=response;_remoteFetch(text);}).fail(function(jqXHR,status,errorThrown){if(status!='abort'){Debug.log('aborting');}
deferred.reject();});}
cache.each(function(idx,item){if(item.value.toLowerCase().startsWith(text)){output.push(item);}});return deferred.promise();},stop=function(){if(ajaxObj){ajaxObj.abort();}};return{type:'remote',getResults:getResults,totalItems:totalItems,stop:stop};};var noData=function(){return{type:'none',getResults:$.noop,totalItems:-1,stop:$.noop};};}(jQuery,_));;
;(function(){"use strict";ips.createModule('ips.ui.controls',function(){document.addEventListener('click',handleEvent);function respond(elem){}
;(function($,_){"use strict";const CACHED_REMOTE_RESPONSES=new Map();ips.createModule('ips.ui.controls',function(){document.addEventListener('click',handleEvent);function respond(elem){}
function handleEvent(e){if(e.target.closest('.ipsEditor__toolbar-item, .ipsEditor__toolbar-panel')){return;}
let toggle=e.target.closest('[data-ipscontrols][aria-controls]');const lightDismiss=document.querySelectorAll("[data-ips-hidden-light-dismiss][open], [data-ips-hidden-light-dismiss]:not(dialog):not([hidden])");if(!toggle&&!lightDismiss.length)return;if(toggle){const name=toggle.getAttribute("aria-controls"),contentElementIds=name.split(" "),isExpanded=toggle.getAttribute("aria-expanded");if(!isExpanded){Debug.log("The clicked element has [aria-controls] but no [aria-expanded] value.")
return}
if(contentElementIds.length>1){document.querySelectorAll(`[aria-controls="${name}"]`).forEach(t=>t.setAttribute("aria-expanded",(isExpanded==="true")?"false":"true"));}
for(const id of contentElementIds){const content=document.querySelector(`#${id}`);if(!content){Debug.log(`An element with #${id} was not found and therefore can't be toggled.`);continue;}
_showEl(content,toggle,!(isExpanded==="true"));const isInGroup=content.getAttribute("data-ips-hidden-group");if(isInGroup){const groupElements=document.querySelectorAll(`[data-ips-hidden-group="${isInGroup}"]:not([hidden])`);for(const groupElement of groupElements){if(groupElement!=content){_showEl(groupElement,toggle,false);}}}}}
for(const lightDismissEl of lightDismiss){if(lightDismissEl.contains(e.target)&&e.target.tagName.toLowerCase()!=="dialog")continue;_showEl(lightDismissEl,e.target,false);}}
function _showEl(content,trigger,show=true){if(show&&(content.hasAttribute("data-ips-hidden-top-layer")||content.tagName==="DIALOG")){document.getElementById('ipsLayout')?.appendChild(content);}
showOrHide(content,toggle,!(isExpanded==="true"));const isInGroup=content.getAttribute("data-ips-hidden-group");if(isInGroup){const groupElements=document.querySelectorAll(`[data-ips-hidden-group="${isInGroup}"]:not([hidden])`);for(const groupElement of groupElements){if(groupElement!=content){showOrHide(groupElement,toggle,false);}}}}}
for(const lightDismissEl of lightDismiss){if(lightDismissEl.contains(e.target)&&e.target.tagName.toLowerCase()!=="dialog")continue;showOrHide(lightDismissEl,e.target,false);}}
async function showOrHide(content,trigger,show=true){if(show&&(content.hasAttribute("data-ips-hidden-top-layer")||content.tagName==="DIALOG")){document.getElementById('ipsLayout')?.appendChild(content);}
const contentTag=(content.tagName);document.querySelectorAll(`[data-ipscontrols][aria-controls="${content.id}"]`).forEach(t=>t.setAttribute("aria-expanded",show));if(show){if(contentTag==="DIALOG"){content.showModal();content.addEventListener("close",_closeEvent);}else{content.hidden=false;}
content.querySelector("[data-autofocus]")?.focus();}
const src=trigger.dataset.ipscontrolsSrc;if(typeof src==='string'&&!content.dataset.ipscontrolsLoaded){if(CACHED_REMOTE_RESPONSES.has(src)&&typeof CACHED_REMOTE_RESPONSES.get(src).html==='string'&&!(typeof CACHED_REMOTE_RESPONSES.get(src).expiresAt==='number'&&CACHED_REMOTE_RESPONSES.get(src).expiresAt<Date.now()/1000)){Debug.log(`ips.ui.controls: Using cached response for ${src}`);content.innerHTML=CACHED_REMOTE_RESPONSES.get(src).html;for(const cls of[...content.classList]){if(cls.startsWith('ipsLoading')){content.classList.remove('ipsLoading');}}
$(document).trigger('contentChange',[$(content)]);content.ipsHide();content.dataset.ipscontrolsLoaded='1';content.querySelector("[data-autofocus]")?.focus();await new Promise(resolve=>setTimeout(resolve,50));content.ipsShow();}else{content.classList.add('ipsLoading');const start=Date.now();loadContent(src).then(html=>new Promise(resolve=>{if(Date.now()-start<700){setTimeout(()=>resolve(html),700-(Date.now()-start))}else{resolve(html)}})).then(html=>{content.innerHTML=html;for(const cls of[...content.classList]){if(cls.startsWith('ipsLoading')){content.classList.remove('ipsLoading');}}
$(document).trigger('contentChange',[$(content)]);content.dataset.ipscontrolsLoaded='1';content.querySelector("[data-autofocus]")?.focus();})}}else{content.querySelector("[data-autofocus]")?.focus();}}
requestAnimationFrame(()=>{content.style.setProperty('--i-animating-height',content.scrollHeight+'px');})
content.setAttribute("data-ips-animating",(show)?'opening':'closing');Promise.all(content.getAnimations().map((a)=>a.finished)).then(()=>{if(!show){(contentTag==="DIALOG")?content.close():content.hidden=true;}
content.setAttribute("data-ips-animating",(show)?'opening':'closing');await Promise.allSettled(content.getAnimations().map((a)=>a.finished));if(!show){(contentTag==="DIALOG")?content.close():content.hidden=true;}
content.removeAttribute("data-ips-animating");const eventNames=['ips:toggleComplete']
if(content.dataset.ipsHiddenEvent){eventNames.push(content.dataset.ipsHiddenEvent)}
eventNames.forEach(eventName=>content.dispatchEvent(new CustomEvent(eventName,{bubbles:true,detail:{hidden:content.hidden,trigger:trigger}})));});}
function _closeEvent(e){if(!e.target.getAttribute("open")){_showEl(e.target,e.target,false);}}
ips.ui.registerWidget('controls',ips.ui.controls);return{respond}});}());;
eventNames.forEach(eventName=>content.dispatchEvent(new CustomEvent(eventName,{bubbles:true,detail:{hidden:content.hidden,trigger:trigger}})));}
function _closeEvent(e){if(!e.target.getAttribute("open")){showOrHide(e.target,e.target,false);}}
async function loadContent(src,forceRequest=false){src=(new URL(src)).toString();const cachedContents=CACHED_REMOTE_RESPONSES.get(src);if(!forceRequest&&cachedContents&&typeof cachedContents.html==='string'){if(!(typeof cachedContents.expiresAt==='number'&&cachedContents.expiresAt<Date.now()/1000)){Debug.log(`ips.ui.controls: Using cached response for ${src}`);return cachedContents.html;}
CACHED_REMOTE_RESPONSES.delete(src);}
try{const response=await ips.fetch(src);if(typeof response!=='object'||typeof response.html!=='string'){throw new TypeError(`Expected an object with an html:string property`);}
if(!response.noCache){response.expiresAt=response.expiresAt||Math.round(Date.now()/1000+3600);if(typeof response.expiresAt==='string'){response.expiresAt=parseInt(response.expiresAt);}
if(typeof response.expiresAt!=='number'||Number.isNaN(response.expiresAt)){response.expiresAt=Math.round(Date.now()/1000+3600);}
if(!Number.isInteger(response.expiresAt)){response.expiresAt=Math.round(response.expiresAt);}
if(response.expiresAt*1000>Date.now()){CACHED_REMOTE_RESPONSES.set(src,response);}}
return response.html;}catch(e){return ips.templates.render("ips.ui.controls.cannot_load",{message:typeof e.responseJSON?.errorMessage==='string'?e.responseJSON.errorMessage:undefined});}}
ips.ui.registerWidget('controls',ips.ui.controls,['src']);return{respond}});}(jQuery,_));;
;(function($,_,undefined){"use strict";ips.createModule('ips.ui.copy',function(){var respond=function(elem,options,e){ips.loader.get(['core/interface/clipboard/clipboard.min.js']).then(function(){if(ClipboardJS.isSupported()){elem.find('[data-role="copyButton"]').show();if(elem.find('[data-role="copyButton"]').attr('href')){elem.find('[data-role="copyButton"]').on('click',function(e){e.preventDefault();e.stopPropagation();});}
var clipboard=new ClipboardJS(elem.find('[data-role="copyButton"]').get(0));clipboard.on('success',function(e){if(elem.attr('data-ipsCopy-flashmessage')!==undefined){ips.ui.flashMsg.show(ips.getString('copied'))}else{elem.find('[data-role="copyButton"]').text(ips.getString('copied'));}});}});};ips.ui.registerWidget('copy',ips.ui.copy,[]);return{respond:respond,};});}(jQuery,_));;
;(function(){"use strict";ips.createModule('ips.ui.details',function(){var respond=function(elem){document.addEventListener('click',toggleDetails);},toggleDetails=function(e){const summary=e.target.closest('[data-ipsdetails] summary');if(!summary)return;const details=summary.closest('details'),content=details.querySelector('i-details-content'),isOpen=details.open;if(!details||!content)return;e.preventDefault();if(!isOpen)details.open=true;content.style.setProperty('--i-animating-height',content.scrollHeight+'px');content.setAttribute('data-ips-animating',(isOpen)?'closing':'opening');Promise.all(content.getAnimations().map((a)=>a.finished)).then(()=>{if(isOpen)details.open=false;content.removeAttribute('data-ips-animating');});};ips.ui.registerWidget('details',ips.ui.details);return{respond:respond}});}());;
+2 -2
View File
@@ -52,8 +52,8 @@ var value;var fallback;var output='';var replacement=params[b]+'';c.replace(/\[(
else if(x.charAt(0)=='%'&&x.substring(1)==replacement.substring(0,x.substring(1).length)){value=y.replace('#',replacement);}
else if(x.charAt(0)=='*'&&x.substring(1)==replacement.substr(-x.substring(1).length)){value=y.replace('#',replacement);}
else if(x==replacement){value=y.replace('#',replacement);}});output=a.replace(/^\{/,'').replace(/\}$/,'').replace('!#','');output=output.replace(b+'#',replacement).replace('#',replacement);output=output.replace(/\[.+\]/,value==null?fallback:value).trim();return output;});return word;},testConsole=function(){if(window.atob&&window.console){console.log(window.atob("ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgd293ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICBzdWNoIGZvcnVtICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgaG93IGFqYXggICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICB2ZXJ5IGNvbW11bml0eSAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtdWNoIG1lbWJlcgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCg=="));}
return'';};var templates=function(){var _templateStore={};var set=function(key,template){_templateStore[key]=template;},get=function(key){if(_templateStore[key]){if(_.isFunction(_templateStore[key])){return _templateStore[key]();}else{return _templateStore[key];}}
return'';},render=function(key,obj){obj=_.extend(obj||{},{baseURL:ips.getSetting('baseURL'),lang:_lang,blankImg:ips.getSetting('blankImg')||''});return Mustache.render(get(key),obj);},compile=function(key){if(_templateStore[key]){return Mustache.parse(get(key));}
return'';};var templates=function(){var _templateStore={};const _defaults={};var set=function(key,template,defaults={}){_templateStore[key]=template;_defaults[key]=defaults;},get=function(key){if(_templateStore[key]){if(_.isFunction(_templateStore[key])){return _templateStore[key]();}else{return _templateStore[key];}}
return'';},render=function(key,obj){obj=(obj&&typeof obj==='object')?obj:{};const defaults=_defaults[key]||{};const options={...defaults,...obj,baseURL:ips.getSetting('baseURL'),lang:_lang,blankImg:ips.getSetting('blankImg')||''};return Mustache.render(get(key),options);},compile=function(key){if(_templateStore[key]){const compiled=Mustache.parse(get(key));return(options,...otherArgs)=>{options=(options&&typeof options==='object')?options:{};const defaults=_defaults[key]||{};options={...defaults,...options};return compiled(options,...otherArgs);};}
return $.noop;},_lang=function(){return function(text,render){return ips.getString(render(text));}};return{set,get,render,compile};}();function cleanContentsOf(elem){elem=$(elem)
if(!elem.length){Debug.log(`Skipped the cleaning of IPS modules and controllers from an empty content selection`)
return}