hv-unified/references/hveqc.js
GaboGG 402db6bb2f Initial commit: HV Unified v0.11.0 structure
- 23 source files in src/ (build via scripts/build.sh)
- Forum-sourced player knowledge in references/
- DESIGN.md with architecture and corrections
- References to existing scripts (Monsterbation, jpx, HV Utils)
2026-07-20 19:30:26 -04:00

37 lines
15 KiB
JavaScript

function get_eqdata(a){if("undefined"!=typeof dynjs_eqstore&&"undefined"!=typeof dynjs_eqstore[a])return dynjs_eqstore[a];if("undefined"!=typeof dynjs_equip&&"undefined"!=typeof dynjs_equip[a])return dynjs_equip[a]}
function rehover_last_checked(){if(0<last_checked_eqid){if(!e("e"+last_checked_eqid).checked)for(i=last_checked_eqid=0;i<equipform.elements.length;i++)if("eqids[]"==equipform.elements[i].name&&equipform.elements[i].checked){last_checked_eqid=equipform.elements[i].value;break}0<last_checked_eqid&&hover_equip(last_checked_eqid)}}
function hover_equip(a){if("undefined"!=typeof last_hover_eqid){last_hover_eqid||(infotext=equipinfo.innerHTML);var c=get_eqdata(a);if("undefined"!=typeof c){curr_hover_eqid=last_hover_eqid=a;last_hover_key=c.k;if("undefined"!=typeof showequipped_eqid)equipinfo.innerHTML=showequipped_eqid==a?"":'<div class="showequip"><div></div><div>'+c.d+"</div></div>";else{var b=void 0;const g=new URLSearchParams(window.location.search);g.has("filter")&&(b=g.get("filter"));b="purchase"!=title?"?s=Bazaar&amp;ss=am&amp;screen=modify"+
(b?"&amp;filter="+b:"")+"&amp;eqids[]="+a:null;equipinfo.innerHTML="undefined"==typeof c.n?'<div class="showequip"><div>'+(b?'<a href="'+b+'">'+c.t+"</a>":c.t)+"</div><div>"+c.d+"</div></div>":'<div class="showequip"><div><div>'+(b?'<a href="'+b+'">'+c.t+"</a>":c.t)+"</div><div>("+c.n+")</div></div><div>"+c.d+"</div></div>"}update_iteminfo()}if("sacrifice"==title&&eqitems[a]){c=0;for(f in eqitems[a].s)c+=eqitems[a].s[f].boost;var f='<p style="font-weight:normal">The selected equipment will be sacrified, and fused with your:</p><p><a href="'+
backurl+'">'+fusename+'</a></p><p style="font-weight:normal">This has the following effects and base costs:</p>';f+="<p>+"+c+" Base Stat Rolls</p>";for(let g in eqitems[a].m)if(60201>g||60239<g)f+="<p>"+eqitems[a].m[g]+"x "+itemdata[g].n+" ("+itemdata[g].c+")</p>";f+="<p"+(eqitems[a].c>credit_balance?' class="eqred"':"")+">"+number_format(eqitems[a].c)+" Credits</p>";e("itemlist").innerHTML=f}}}function unhover_equip(a){curr_hover_eqid==a&&(curr_hover_eqid=0,update_iteminfo())}
function reset_infopane(){"undefined"!=typeof infotext&&(curr_hover_eqid&&unhover_equip(curr_hover_eqid),void 0!=hoverow&&(hoverow.removeAttribute("data-hover"),hoverow=void 0),equipinfo.innerHTML=infotext,itemlist.innerHTML="")}
function update_iteminfo(){if("undefined"!=typeof eqitems){var a=show_items=show_credits=!1,c=single_header=void 0;"repair"==title&&(show_items=!0,a=!document.getElementById("replace_charms").checked,c="Total Repair Cost");"salvage"==title&&(show_items=!0,show_credits=document.getElementById("sell_salvage").checked,eqcredits.style.display=show_credits?"":"none",c="Total Salvage");"itemworld"==title&&(show_items=!0,c="Required Items");"soulbind"==title&&(show_items=!0,c="Required Items");if("sell"==
title||"purchase"==title)show_credits=!0;confirm_info=void 0;var b=[],f=[],g=0;for(i=0;i<equipform.elements.length;i++)"eqids[]"==equipform.elements[i].name&&equipform.elements[i].checked&&(eqid=equipform.elements[i].value,show_items&&"undefined"!=typeof eqitems[eqid]&&Object.keys(eqitems[eqid].m).forEach(d=>{let l;b[d]=(null!=(l=b[d])?l:0)+eqitems[eqid].m[d]}),show_credits&&(g+=eqitems[eqid].c),"undefined"!=typeof eqitems[eqid].p?(confirm_info=eqitems[eqid].p,confirm_info.eqname=eqitems[eqid].t):
"sacrifice"==title&&(confirm_info=eqitems[eqid]));show_items&&0<curr_hover_eqid&&"undefined"!=typeof eqitems[curr_hover_eqid]&&Object.keys(eqitems[curr_hover_eqid].m).forEach(d=>{void 0==b[d]&&(b[d]=0);f[d]=eqitems[curr_hover_eqid].m[d]});var h=[],k=0<curr_hover_eqid&&document.getElementById("e"+curr_hover_eqid).checked;block_submit=!1;if(0<b.length){h.push('<tr><th colspan="3">'+c+":</th></tr>");for(let d in b)a&&61900<=d&&64999>=d||(c=("repair"==title||"soulbind"==title)&&itemdata[d].c<b[d]||"itemworld"==
title&&itemdata[d].c<(curr_hover_eqid?f[d]:b[d]),multiselect?h.push("<tr"+(c?' style="color:red"':"")+"><td>"+b[d]+"x</td><td>"+itemdata[d].n+"</td><td>"+(hide_delta||k||!curr_hover_eqid||void 0==f[d]?"":" ("+(k?"-":"+")+f[d]+")")+"</td></tr>"):h.push("<tr"+(c?' style="color:red"':"")+"><td>"+(curr_hover_eqid?f[d]:b[d])+"x "+itemdata[d].n+"</td></tr>"),c&&(block_submit=!0))}show_items&&(itemlist.innerHTML=0<h.length?"<table>"+h.join("")+"</table>":"");show_credits&&(eqcrsum.innerHTML=g+" Credits",
eqcrsum.style.color="purchase"==title&&credit_balance<g?"red":"",eqcrdiff.innerHTML=curr_hover_eqid&&!k?" ("+(k?"-":"+")+eqitems[curr_hover_eqid].c+")":"")}}let unprotect_eqid=0,unprotect_rowelem=void 0;
function confirm_unprotect(a,c,b,f){e("e"+c).disabled&&(unprotect_eqid=c,unprotect_rowelem=a,e("confirm_body").innerHTML="<p>Are you sure you want to make this protected equipment selectable?</p><p><strong>"+b+"</strong></p>"+(f?"<p>Obtained: <strong>"+f+"</strong></p>":"")+'<button id="confirm_button" type="button" onclick="unprotect_equip()">Confirm Select</button>',confirm_open())}
function unprotect_equip(){unprotect_eqid&&(unprotect_rowelem.removeAttribute("data-eqprotect"),++selectable_count,update_multiselector(),e("e"+unprotect_eqid).disabled=!1,select_equip(unprotect_eqid,void 0,unprotect_rowelem),unprotect_eqid=0);confirm_close()}
function select_equip(a,c,b){if(e("e"+a).disabled)return!1;if(!multiselect)for(i=0;i<equipform.elements.length;i++)"eqids[]"==equipform.elements[i].name&&equipform.elements[i].checked&&(equipform.elements[i].checked=!1);last_hover_eqid!=a&&void 0!=b&&(hide_delta=!0,hover_equip(a),void 0!=hoverow&&hoverow.removeAttribute("data-hover"),hoverow=b,hoverow.setAttribute("data-hover",1));b=document.getElementById("e"+a);const f=b.checked?!1:"checked";if(multiselect&&void 0!=c&&c.shiftKey&&0<last_clicked_eqid&&
a!=last_clicked_eqid&&f==last_statechange)for(c=!1,i=0;i<equipform.elements.length;i++)if("eqids[]"==equipform.elements[i].name&&!equipform.elements[i].disabled){let g=equipform.elements[i].value==a||equipform.elements[i].value==last_clicked_eqid;!c&&g&&(c=!0,g=!1);c&&(equipform.elements[i].checked=f);c&&g&&(c=!1)}b.checked=f;last_clicked_eqid=a;(last_statechange=f)&&(last_checked_eqid=a);update_selected_count();return!1}let selected_count=0,selected_soulbound=0,selected_rarity=[];
function update_selected_count(){selected_soulbound=selected_count=0;selected_rarity=[];for(i=0;i<equipform.elements.length;i++)if("eqids[]"==equipform.elements[i].name&&equipform.elements[i].checked){++selected_count;let a=get_eqdata(parseInt(equipform.elements[i].value));if(void 0!=a){let c;selected_rarity[a.q]=(null!=(c=selected_rarity[a.q])?c:0)+1;let b;null!=(b=a.s)&&b&&++selected_soulbound}}1>selected_count&&(last_clicked_eqid=0);multiselect&&update_multiselector();update_iteminfo();document.getElementById("equipsubmit").disabled=
!block_submit&&0<selected_count?"":"disabled"}function update_multiselector(){multiselect&&(e("equipcount").innerHTML='<input type="checkbox" onclick="select_all()"'+(selected_count<selectable_count?"":'checked="checked"')+" /><span></span> Selected "+selected_count+" of "+selectable_count+" matching equipment available to "+title)}
function select_all(){last_clicked_eqid=0;let a=selected_count<selectable_count?"checked":!1;for(i=0;i<equipform.elements.length;i++)"eqids[]"!=equipform.elements[i].name||equipform.elements[i].disabled||(equipform.elements[i].checked=a);update_selected_count()}
function confirm_action(a,c,b,f,g){if(!a.disabled){a="<div>"+b.replace("%SELECTCOUNT%","<strong>"+selected_count+"</strong>")+"</div>";b=!1;if(confirm_info&&(console.log(JSON.stringify(confirm_info,null,2)),"itemworld"==title&&(a+="\n<p><strong>"+confirm_info.eqname+'</strong></p>\n<table id="iwinfo">\n\t<tr><td>World Level:</td><td>'+confirm_info.iwlvl+"</td></tr>\n\t<tr><td>Battle Rounds:</td><td>"+confirm_info.rounds+"</td></tr>\n\t<tr><td>Monster LVL:</td><td>"+confirm_info.monsterlevel+"</td></tr>\n\t<tr><td>Difficulty:</td><td>"+
confirm_info.diffname+(0<confirm_info.diffboost?" +"+confirm_info.diffboost+"%":"")+"</td></tr>\n\t<tr><td>Entry Cost:</td><td>"+confirm_info.req_worldseeds+" World Seed"+(1==confirm_info.req_worldseeds?"":"s")+" ("+confirm_info.has_worldseeds+")</td></tr>\n</table>"),"sacrifice"==title)){a+="\n<p><strong>"+confirm_info.t+'</strong></p>\n<table id="fuseinfo">';let k=[];for(let d in confirm_info.s){let l=confirm_info.s[d].bndid,m=itemdata[l].c<confirm_info.m[l];k.push("<tr><td>"+confirm_info.s[d].label+
"</td><td>"+confirm_info.s[d].value+"</td><td>+"+confirm_info.s[d].boost+"</td><td"+(m?' class="eqred"':"")+">"+confirm_info.m[l]+"x "+itemdata[l].n+" ("+itemdata[l].c+")</td></tr>");m&&(b=!0)}a+=k.join("");a+="\n</table>";for(let d in confirm_info.m)if(60201>d||60239<d)a+="<p>"+confirm_info.m[d]+"x "+itemdata[d].n+" ("+itemdata[d].c+")</p>";a+="<p"+(confirm_info.c>credit_balance?' class="eqred"':"")+">"+number_format(confirm_info.c)+" Credits</p>";credit_balance<confirm_info.c&&(b=!0)}if(f){var h;
f=null!=(h=selected_rarity[7])?h:0;let k,d;h=(null!=(k=selected_rarity[8])?k:0)+(null!=(d=selected_rarity[9])?d:0);multiselect?(0<selected_soulbound&&(a+="<p><strong>You have selected "+(1<selected_soulbound?selected_soulbound:"a")+" SOULBOUND equipment.</strong></p>"),0<f&&(a+="<p><strong>You have selected "+(1<f?f:"a")+" LEGENDARY equipment.</strong></p>"),0<h&&(a+="<p><strong>You have selected "+(1<h?h:"a")+" PEERLESS equipment.</strong></p>")):0<selected_soulbound+f+h&&(a+="<p><strong>You have selected a "+
(0<selected_soulbound?"SOULBOUND ":"")+(0<f?"LEGENDARY ":"")+(0<h?"PEERLESS ":"")+"equipment.</strong></p>");a=(b?a+"<p>You are missing some required resources.</p>":a+"<p>Check both safety boxes to continue.</p>")+('\n<table>\n\t<tr>\n\t\t<td><label class="lc"><input id="cfs1" type="checkbox" onchange="confirm_safety()"'+(b?' disabled="disabled"':"")+'><span></span></label></td>\n\t\t<td><input id="confirm_button" type="submit" value="'+c+'" disabled="disabled"'+(g?' formaction="'+g+'"':"")+' /></td>\n\t\t<td><label class="lc"><input id="cfs2" type="checkbox" onchange="confirm_safety()"'+
(b?' disabled="disabled"':"")+"><span></span></label></td>\n\t</tr>\n</table>")}else a+='<input id="confirm_button" id="equipsubmit" type="submit" value="'+c+'"'+(g?' formaction="'+g+'"':"")+(b?' disabled="disabled"':"")+" />";e("confirm_body").innerHTML=a;confirm_open()}}function confirm_safety(){e("confirm_button").disabled=e("cfs1").checked&&e("cfs2").checked?"":"disabled"}
function recalc_cp(a){var c=parseInt(a.getAttribute("data-cp"));"charmtype"==a.name?(sel_cp_charm=c,sel_charmtype=parseInt(a.value),charmname=a.getAttribute("data-name"),disabled_charm=a.getAttribute("data-disabled"),charm_stats[sel_charmtype]&&(e("eqstats").innerHTML=charm_stats[sel_charmtype])):(sel_cp_pouch=c,sel_pouchtype=parseInt(a.value),pouchname=a.getAttribute("data-name"),disabled_pouch=a.getAttribute("data-disabled"));if(a=sel_charmtype&&(disabled_charm||disabled_pouch)){var b;c=null!=(b=
disabled_charm)?b:disabled_pouch;e("cdreason").innerHTML="("+c+")"}else e("cdreason").innerHTML="&nbsp;";b=exl_cp+sel_cp_charm+sel_cp_pouch;e("cpreadout").innerHTML="Charm Points: "+b+" / "+max_cp;e("cpreadout").style.color=b>max_cp?"#FF0000":"";can_submit=!a&&(0==sel_charmtype||b<=max_cp)&&(cur_charm_worn||cur_charm_broken||cur_pouch_broken||cur_charmtype!=sel_charmtype||0<sel_charmtype&&cur_pouchtype!=sel_pouchtype);e("setcharm").disabled=can_submit?"":"disabled";!a&&b>max_cp&&(e("cdreason").innerHTML=
"(Insufficient Charm Points)");b="Attach Charm";!sel_charmtype&&0<cur_charmtype?b="Destroy Charm":sel_charmtype&&sel_charmtype==cur_charmtype&&(cur_charm_worn||cur_charm_broken?b="Replace Charm":cur_pouchtype!=sel_pouchtype?b="Replace Pouch":cur_pouch_broken&&(b="Repair Pouch"));e("setcharm").innerHTML=b}
function pop_setcharm(){if(can_submit){let b=[];if(cur_charm_worn||cur_charm_broken||cur_charmtype!=sel_charmtype)for(var a in charm_mats[sel_charmtype])b.push("<tr><td>"+charm_mats[sel_charmtype][a].c+"x</td><td>"+charm_mats[sel_charmtype][a].n+"</td></tr>");if((!cur_charm_broken||0<sel_pouchtype)&&(cur_pouch_broken||cur_pouchtype!=sel_pouchtype))for(var c in pouch_mats[sel_pouchtype])b.push("<tr><td>"+pouch_mats[sel_pouchtype][c].c+"x</td><td>"+pouch_mats[sel_pouchtype][c].n+"</td></tr>");a=cur_charmtype?
"Replace":"Attach";c="attach a new charm";sel_charmtype?(cur_charmtype==sel_charmtype&&(c=cur_charm_worn||cur_charm_broken?"replace the "+(cur_charm_broken?"torn":"worn")+" charm":cur_pouch_broken?"replace the destroyed pouch":"replace the intact pouch",a="Replace"),e("confirm_body").innerHTML="<p>Are you sure you want to "+c+" in <strong>Slot "+charmslot+"</strong>:</p><p><strong>"+charmname+"</strong> with a <strong>"+pouchname+"</strong></p>",0<b.length&&(e("confirm_body").innerHTML+='<p>by spending the following materials:</p><table id="charmats">'+
b.join("")+"</table>")):(e("confirm_body").innerHTML="<p>Are you sure you want to <strong>DESTROY</strong> the charm and pouch in <strong>Slot "+charmslot+"</strong>?</p>",a="Destroy");0<sel_charmtype&&(!cur_charmtype||cur_charm_worn||cur_charm_broken||cur_charmtype==sel_charmtype||(e("confirm_body").innerHTML+="<p>The existing charm will be <strong>DESTROYED</strong>.</p>"),cur_pouch_broken||(cur_pouchtype!=sel_pouchtype?0<cur_charmtype&&(e("confirm_body").innerHTML+="<p>The existing pouch will be <strong>DESTROYED</strong>.</p>"):
0<sel_pouchtype&&(e("confirm_body").innerHTML+="<p>The existing pouch will be reused.</p>")));e("confirm_body").innerHTML+='<button id="confirm_button" type="submit" name="action" value="setcharm">Confirm '+a+"</button>";confirm_open()}}let is_confirm_open=!1,is_confirm_text=!1;
function pop_rename(a,c){is_confirm_text=!0;e("confirm_body").innerHTML="<p>Enter a new customized name for your</p><p><strong>"+a+'</strong></p><input name="eqname" type="text" maxlength="50" placeholder="'+a+'" value="'+c+'" /><p>Enter a blank name to revert to the default name. Customized names are always removed if the equipment is sold or attached to a MoogleMail.</p><button id="confirm_button" type="submit" name="action" value="rename">Rename Equipment</button>';confirm_open()}
function pop_upgrade(){e("confirm_body").innerHTML='<p>Are you sure you want to spend the requisite materials and credits to upgrade this equipment? Credits and Cores cannot be refunded.</p><table class="upgrmats">'+e("upgrmats").innerHTML+'</table><button id="confirm_button" type="submit" name="action" value="upgrade">Confirm Upgrade</button>';confirm_open()}
function pop_unequip(){e("confirm_body").innerHTML='<p>Are you sure you want to force unequip this item from all equipment sets in all personas? This may also unequip other gear that depends on it.</p><button id="confirm_button" type="submit" name="action" value="unequip">Confirm Unequip</button>';confirm_open()}
function pop_equipwindow(){"undefined"!=typeof last_hover_eqid&&0<last_hover_eqid&&window.open(MAIN_URL+"equip/"+last_hover_eqid+"/"+last_hover_key,"_pu"+(Math.random()+"").replace(/0\./,""),"toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=450,height=520,left="+(screen.width-450)/2+",top="+(screen.height-520)/2)}function confirm_open(){is_confirm_open=!0;e("confirm_outer").style.visibility=""}
function confirm_close(){is_confirm_text=is_confirm_open=!1;e("confirm_outer").style.visibility="hidden"}
document.onkeydown=function(a){a.shiftKey||a.altKey||(is_confirm_open?(("Enter"==a.key||!is_confirm_text&&" "==a.key)&&e("confirm_button").click(),"Escape"==a.key&&confirm_close()):("c"==a.key&&(pop_equipwindow(),common.cancelEvent(a)),"x"==a.key&&"purchase"!=title&&last_hover_eqid&&(a=(new URLSearchParams(window.location.search)).get("filter"),document.location="?s=Bazaar&ss=am&screen=modify"+(a?"&filter="+a:"")+"&eqids[]="+last_hover_eqid)))};