pmx-vmd-sync-player / v118-runtime.js
mg696's picture
Add v118 runtime patch for same VMD reselect
cf62ea6 verified
Raw History Blame Contribute Delete
1.62 kB
// v118-runtime.js: narrow runtime fixes only; do not touch v117 stable internals.
(function(){
const VER='v118';
function log(m,l){try{(window.__dbg||console.log)(m,l||'info')}catch(e){console.log(m)}}
function setVer(){try{document.title='MMD pmx Player '+VER;const v=document.getElementById('version-label');if(v)v.textContent=VER}catch(e){}}
function clearVmdInput(id,why){const el=document.getElementById(id);if(el){el.value='';log('[VMD:'+VER+'] '+id+' cleared for same-file reselect ('+why+')','info')}}
function bind(){
setVer();setTimeout(setVer,500);setTimeout(setVer,1500);
const pairs=[['file-input','vmd-input'],['file-input2','vmd-input2']];
pairs.forEach(([modelId,vmdId])=>{
const m=document.getElementById(modelId);
if(m&&!m.__v118ModelClear){m.__v118ModelClear=true;m.addEventListener('change',()=>clearVmdInput(vmdId,'model slot changed'),true)}
});
['vmd-input','vmd-input2','cam-vmd-input'].forEach(id=>{
const el=document.getElementById(id);
if(!el||el.__v118SameFile)return;
el.__v118SameFile=true;
el.addEventListener('click',()=>{el.value='';log('[VMD:'+VER+'] '+id+' cleared before picker','info')},true);
el.addEventListener('touchstart',()=>{el.value='';log('[VMD:'+VER+'] '+id+' cleared before picker(touch)','info')},{capture:true,passive:true});
el.addEventListener('change',()=>{setTimeout(()=>{try{el.value=''}catch(e){}},0)},false);
});
log('[Runtime:'+VER+'] 同一VMD再選択パッチ有効','info');
}
function wait(){if(window.__appReady)bind();else setTimeout(wait,100)}
wait();
})();