MCPcopy Index your code
hub / github.com/hoothin/UserScripts / handleMessage

Function handleMessage

Picviewer CE+/dist.user.js:26231–26318  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

26229 var frameSentData;
26230 var frameSentSuccessData;
26231 function handleMessage(e){
26232 var data=e.data;
26233 if( !data || !data.messageID || data.messageID != messageID )return;
26234 var source=e.source,command,cusEvent;
26235 if(typeof source=='undefined' || source!==window){
26236 if(!isFrame){
26237 command=data.command;
26238 switch(command){
26239 case 'open':{
26240 if (data.buttonType === 'download') {
26241 downloadImg(data.src, document.title, prefs.saveName);
26242 return;
26243 }
26244 var img=document.createElement('img');
26245 img.src=data.src;
26246
26247 imgReady(img,{
26248 ready:function(){
26249 LoadingAnimC.prototype.open.call({
26250 img:img,
26251 data:data.data,
26252 buttonType:data.buttonType,
26253 from:data.from,
26254 });
26255 },
26256 });
26257 }break;
26258 case 'navigateToImg':{
26259 cusEvent=document.createEvent('CustomEvent');
26260 cusEvent.initCustomEvent('pv-navigateToImg',false,false,data.exist);
26261 document.dispatchEvent(cusEvent);
26262 }break;
26263 case 'topWindowValid':{
26264 if(data.from)
26265 window.postMessage({
26266 messageID:messageID,
26267 command:'topWindowValid_frame',
26268 valid:getBody(document).nodeName.toUpperCase()!='FRAMESET',
26269 to:data.from,
26270 },'*');
26271 }break;
26272 };
26273
26274 }else{
26275 command=data.command;
26276 switch(command){
26277 case 'navigateToImg':{
26278
26279 if(!frameSentData.unique){
26280 var unique=GalleryC.prototype.unique(frameSentData);
26281 frameSentData=unique.data;
26282 frameSentData.unique=true;
26283 };
26284 var targetImg=frameSentData[data.index].img;
26285 var exist=(document.documentElement.contains(targetImg) && unsafeWindow.getComputedStyle(targetImg).display!='none');
26286
26287 if(exist){
26288 if(gallery && gallery.shown){

Callers

nothing calls this directly

Calls 5

containsMethod · 0.80
downloadImgFunction · 0.70
imgReadyFunction · 0.70
getBodyFunction · 0.70
flashEleFunction · 0.70

Tested by

no test coverage detected