Output comma separated checkbox values

I am retrieving the value of multiple checkbox options in the following format (only unique ID’s are available and no way to modify the form) :

const general = document.getElementById("checkbox-tag-209");
if (general.checked) { var generalValue = document.getElementById("checkbox-tag-209").value="General"; } else { generalValue = ""; }

Then, attempting to display all the selected options with a comma separation:

const shopType = [generalValue + collisionValue + tireValue + dealershipValue];
const array = shopType.split(",");

I have tried .split(“,”); as well as .join(‘, ‘); but of course the results do not contain a comma.

Is there an easy way of adding a comma when multiple values are checked? I see examples of loops, but they contain a common ‘name’ which is not available; just unique input id’s. Many thanks.

dlopen failed: library “libhermes.so” not found react native

I’m trying to debug a React Native application on my Mac with an M1 chip in an Android environment, but I’m running into an issue. The app compiles successfully, but when it opens on an Android emulator or physical device, it crashes immediately.

Here’s the error I see in Logcat:

dlopen failed: library "libhermes.so" not found react native

I already have trying enabling hermes but this does not work and I already looking for how to solve this error at many sites but I dont found the solve

  • React Native Version: 0.73.0
  • Hermes Enabled: I already trying both ways
  • NDK Version: 25.2.9519653
  • Build Steps: I’ve already tried cleaning the project (./gradlew clean) and recompiling, but the issue persists.

If anyone has encountered this issue before or has any ideas on how to fix it, I’d greatly appreciate your guidance.

Thank you in advance for your help!

It must be on one orbit, how I can fix the moon? How I can made dynamic day and night above the horizon?

Im trying to learn HTML/JS/CSS but I cant fix it by myself.
Its my code:

HTML:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Daun Clicker</title>
    <style>
        @keyframes spin {
            from {
                transform: rotate(0turn)
                translateY(-1150px) translateY(50%)
                rotate(1turn)
            }
            to {
                transform: rotate(1turn)
                translateY(-1150px) translateY(50%)
                rotate(0turn)
            }
        }

        .avatar1 {
            animation: spin 5s infinite linear;
        }

        /* Sun */
        .avatar1 {
            display: block;
            width: 180px;
            margin: calc(50% - 25px) auto 0;
            border-radius: 50%;
            overflow: hidden;
            transform-origin: center -300px;
        }

        .avatar2 {
            animation: spin 5s infinite linear;
            animation-delay: 2.5s;
        }

        /* Not Sun */
        .avatar2 {
            display: block;
            width: 180px;
            margin: calc(50% - 25px) auto 0;
            border-radius: 50%;
            overflow: hidden;
            transform-origin: center -300px;
        }

        /* Контейнер */
        .path {
            width: 450px;
            height: 300px;
            padding: 20px;
            margin: 960px auto;
            border-radius: 50%;
        }

        /* Убираем прокрутку */
        .noscroll {
            position: fixed;
            width: 100%;
            height: 100%;
            overflow: hidden;
        }

        .noscroll::-webkit-scrollbar {
            display: none;
        }
    </style>
</head>
<body class="noscroll">
<div class="path">
<div class="avatar1"><img src="sun1.png" alt="Sun" width="150" height="150"></div>
    <div class="avatar2"><img src="moon1.png" alt="Moon" width="150" height="150"></div>
</div>
</body>
</html>

Im tried to change variables like margin, transform-origin, padding or like this, but it doesnt gave any result.
What variables I can change to change moon orbit? Maybe I must paste any formules in this vars?
I doesnt have javascript code in this project now.

How to simplify Leaflet’s focusing if I need any combination of latLng and bounds?

I keep struggling with keeping track of center (with zoom) and bounds in parallel while (re)combining them as I collect further markers and shape bounds to focus on map.

What I wish is to have a single object like centerOrBounds, which I can extend by any number of latLng, e.g. centerOrBounds.addLatLng(latLng) and bounds e.g. centerOrBounds.addBouns(bounds) and finally: centerOrBounds.getFocusedOn(map). See my code below (a class wrapping would be my next step).

I haven’t found an out of the box solution for my problem yet and have the feeling like reinventing the wheel. Is there a solution to my problem that I might have missed?
Or is there a better way to handle combining bounds and lat/lng inputs for focusing a map in Leaflet?

The problem is, that bounds vs center is logically different stuff, with accordingly different handling – either: map.setView(center, zoom), or map.fitBounds(bounds) and fitBounds currently cannot handle bounds with just 1 coordinate, or 2 identical coordinates.

On some events, e.g. on shape or marker editing in the map I need to recollect my centerOrBounds.
(I need this in plain HTML/JavaScript/CSS page environ of my django-leaflet project.)

// an instace to collect my focusing info:
myCenterOrBounds = { 
  'standaloneCoords': undefined,  // I have either the center
  'bounds': L.latLngBounds()      // or valid bounds, bot not both at the same time
};

function addBoundsToCollected(centerOrBounds, boundsToAdd) {
    if (!centerOrBounds && (!boundsToAdd || !boundsToAdd.isValid())) {
        return centerOrBounds;
    }
    if (!centerOrBounds) {
        centerOrBounds =  { 'standaloneCoords': undefined, 'bounds': L.latLngBounds() };
    }

    // fill if empty or just extend
    centerOrBounds.bounds.extend(boundsToAdd);

    if (centerOrBounds.standaloneCoords) {
        // if there was just standaloneCoords before, integrate it in bounds and empty it:
        centerOrBounds.bounds.extend(centerOrBounds.standaloneCoords);
        centerOrBounds.standaloneCoords = undefined;
    }

    return centerOrBounds;
}

function addLatLngToCenterOrBounds(centerOrBounds, latLng) {
    if (!centerOrBounds && !latLng) return centerOrBounds ;
    if (!centerOrBounds) {
        centerOrBounds =  { 'standaloneCoords': undefined, 'bounds': L.latLngBounds() };
    }

    if (centerOrBounds.bounds.isValid()) {
        centerOrBounds.bounds.extend(latLng);
    } else if (centerOrBounds.standaloneCoords) {
        // now combine the stored standaloneCoords with latLng to bounds and empty it:
        centerOrBounds.bounds = L.latLngBounds(centerOrBounds.standaloneCoords, latLng);
        centerOrBounds.standaloneCoords = undefined;
    } else {
        centerOrBounds.standaloneCoords = latLng;
    }

    return centerOrBounds;
}

function getFocusedOn(map, centerOrBounds) {
    if (!map || !centerOrBounds) return;

    if (centerOrBounds.bounds) {
        map.fitBounds(centerOrBounds.bounds);
    } else if (centerOrBounds.standaloneCoords) {
        map.setView(centerOrBounds.standaloneCoords, 15);
    }
}

Recreating a frontendmedia display that mimics backend preview display in WP

i am busy with a wordpress plugin (first time for everything), and i have got the following preview modal, that has several elements and components that run over/in conjunction with the media that is displayed, to enhance the visuals with title, description, and some buttons. now, this works perfectly in the dashboard area of the wordpress environment, but i am battling how to figure out how to generate links so that viewers outside of the WP environment can view the media files, in the frontend, in exactly the same way as this preview modal shows it in the backend.

i have tried using a shortcode embedded in a page on the frontend and then using the link to do a filename query back to the shortcode and the scripts, and all i get is constant 400 and 404 errors, no matter how i restructure the url, and make sure that it is pointing to the right folders and so forth, amongst other errors. I have also tried using a template file and reconstructing the below modal in the front end and trying to hook the ajax calls and functions to bring the wp_options and post meta to the front end, but to no avail. i just get constant access denied and file not found errors.

is there any simple way to recreate this modal in the front end, or to hook into the existing preview modal, and to call on the post meta and wp_options so that i can recreate, or somehow reshow, this modal in the front end, to display in the same manner as it does in the backend for specific media files when being passed through a link that is generated?

i.e. in this modal it has a preview and copy link button on each media item in the grid. when you click the preview button, the below code runs, and creates a preview of how the media will look with all the wp_options stored settings/components enabled/disabled. when you click the copy link button, it should generate a link that allows users outside the WP admin dashboard to view the media in the same way, sans the preview and copy link button. As stated, i have tried several ideas, and none of them have panned out, and i am now just looking for an absolutely simple idea to get the backend to display on the frontend with a mediafile query link. if that is even possible…

Any help in being pointed in the right direction would be greatly appreciated.

        // Media Preview function
    $(document).on('click', '.media-preview-clickable, .preview-media', function() {
        showLoading('Preparing preview...');

        const mediaItem = $(this).closest('.media-item');
        const mediaUrl = mediaItem.find('.media-preview').data('media-url');
        const mediaType = mediaItem.find('.media-preview').data('media-type');
        const filename = mediaItem.data('filename');

        const previewModal = $('#reemi-media-preview-modal');
        const modalImage = $('#preview-modal-image');
        const modalVideo = $('#preview-modal-video');
        const unmuteButton = $('#unmute-button');
        const clickToPlayOverlay = $('#click-to-play-overlay');
        const mediaTitle = previewModal.find('.media-title');
        const mediaDescription = previewModal.find('.media-description');
        const clickthroughButton = $('#clickthrough-button');
        const shareButton = $('#share-button');
        const topBlackArea = $('.top-black-area');
        const bottomBlackArea = $('.bottom-black-area');

        modalImage.hide().attr('src', '');
        modalVideo.hide().attr('src', '').removeAttr('autoplay');
        unmuteButton.hide();
        clickToPlayOverlay.hide();
        mediaTitle.hide();
        mediaDescription.hide();
        clickthroughButton.hide();
        shareButton.hide();
        topBlackArea.hide();
        bottomBlackArea.hide();
        const buttonContainer = $('.bottom-black-area .button-container');
        buttonContainer.removeClass('visible hard-on fade-in');

        setTimeout(() => {
            const isAdvertEnabled = uiState.lastSavedSettings.advert_enable === '1';
            const showTitleSetting = uiState.lastSavedSettings.show_title === '1';
            const showDescriptionSetting = uiState.lastSavedSettings.show_description === '1';
            const showClickthroughSetting = uiState.lastSavedSettings.show_clickthrough === '1'; 
            const showShareSetting = uiState.lastSavedSettings.show_share === '1';
            const buttonDisplayOption = uiState.lastSavedSettings.advert_button_display || 'Fade In';

            if (!isAdvertEnabled) {
                if (mediaType === 'video') {
                    handleVideoPreview(
                        modalVideo, 
                        mediaUrl, 
                        unmuteButton, 
                        clickToPlayOverlay, 
                        false
                    );
                } else if (mediaType === 'image') {
                    handleImagePreview(modalImage, mediaUrl);
                }
            
                hideLoading();
                previewModal.show();
                return;
            }

            $.ajax({
                url: reemiMediaParams.ajaxurl,
                type: 'GET',
                data: {
                    action: 'get_media_metadata',
                    security: reemiMediaParams.nonce,
                    filename: filename
                },
                dataType: 'json',
                success: function(metadataResponse) {
                    if (metadataResponse.success) {
                        const metadata = metadataResponse.data.metadata;
                        const title = metadata.title || '';
                        const description = metadata.description || '';
                        const clickthroughUrl = metadata.custom_url || '';
                        const buttonContainer = $('.bottom-black-area .button-container');
                        
                        buttonContainer.removeClass('visible hard-on fade-in');

                        if (showTitleSetting && title) {
                            mediaTitle.text(title).show();
                            topBlackArea.show();
                            bottomBlackArea.show();
                        }

                        if (showDescriptionSetting && description) {
                            mediaDescription.text(description).show();
                            topBlackArea.show();
                            bottomBlackArea.show();
                        }
                        
                        if (showClickthroughSetting) {
                            if (clickthroughUrl) {
                                clickthroughButton
                                    .data('clickthrough-url', clickthroughUrl)
                                    .show();
                            }
                            topBlackArea.show();
                            bottomBlackArea.show();
                        }
                        
                        if (showShareSetting) {
                            shareButton.show();
                            topBlackArea.show();
                            bottomBlackArea.show();
                        }
                        
                        if (buttonDisplayOption === 'Hard On') {
                            buttonContainer.addClass('hard-on');
                            buttonContainer.find('.clickthrough-button, .share-button').css('opacity', 1);
                        } else if (buttonDisplayOption === 'Fade In') {
                            buttonContainer.addClass('fade-in');
            
                            setTimeout(() => {
                                buttonContainer.addClass('visible');
                            }, 500);
                        }
                        
                        if (isAdvertEnabled) {
                            const closeType = uiState.lastSavedSettings.advert_close_type || 'Close Button';
                            const exitFollowthroughOption = uiState.lastSavedSettings.exit_followthrough || 'exit';

                            switch(closeType) {
                                case 'Close Button':
                                    const closeButton = $('#close-media-button');
                                    const closeButtonDuration = uiState.lastSavedSettings.image_timer || 15
                                    closeButton.hide();

                                    setTimeout(() => {
                                        closeButton.show();
                                    }, closeButtonDuration * 1000);

                                    closeButton.off('click').on('click', (e) => {
                                        e.preventDefault();
                                        e.stopPropagation();

                                        handleExitFollowthrough(exitFollowthroughOption, {
                                            isPlaybackClose: true,  
                                            isModal: false
                                        });

                                        return false;
                                    });
                                    break;

                                case 'End of Playback':
                                    if (mediaType === 'video') {
                                        modalVideo[0].addEventListener('ended', () => {
                                            handleExitFollowthrough(exitFollowthroughOption, {
                                                isPlaybackClose: true,
                                                isModal: false
                                            });
                                        });
                                    } else if (mediaType === 'image') {
                                    const imageTimer = uiState.lastSavedSettings.image_timer || 15;
                                        setTimeout(() => {
                                            handleExitFollowthrough(exitFollowthroughOption, {
                                                isPlaybackClose: true,
                                            isModal: false
                                            });
                                        }, imageTimer * 1000);
                                    }
                                    break;
        
                                case 'Follow Me':
                                    const hasClickthrough = showClickthroughSetting && clickthroughUrl;
                                    const hasShareButton = showShareSetting;

                                                                        $('#close-media-button').off('click');

                                    if (!hasClickthrough && !hasShareButton) {
                                        const closeButtonDuration = uiState.lastSavedSettings.image_timer || 15;
                                        $('#close-media-button').hide();

                                        setTimeout(() => {
                                            $('#close-media-button').show();
                                        }, closeButtonDuration * 1000);

                                        $('#close-media-button').on('click', (e) => {
                                            e.preventDefault();
                                            e.stopPropagation();

                                            handleExitFollowthrough(exitFollowthroughOption, {
                                                isPlaybackClose: true,
                                                isModal: false
                                            });

                                            const modalVideo = $('#preview-modal-video');
                                            const modalImage = $('#preview-modal-image');
            
                                            if (modalVideo.length) {
                                                const videoElement = modalVideo[0];
                                                videoElement.pause();
                                                videoElement.currentTime = 0;
                                                videoElement.src = '';
                                            }
            
                                            if (modalImage.length) {
                                                modalImage.attr('src', '');
                                            }

                                            previewModal.hide();

                                            return false;
                                        });
                                    } else {
                                        $('#close-media-button').hide();

                                        if (hasClickthrough) {
                                            clickthroughButton
                                                .data('clickthrough-url', clickthroughUrl)
                                                .off('click')
                                                .on('click', (e) => {
                                                    e.preventDefault();
                                                    e.stopPropagation();
                    
                                                    if (clickthroughUrl) {
                                                        window.open(clickthroughUrl, '_blank');
                                                    }
                    
                                                    const modalVideo = $('#preview-modal-video');
                                                    const modalImage = $('#preview-modal-image');
                    
                                                    if (modalVideo.length) {
                                                        const videoElement = modalVideo[0];
                                                        videoElement.pause();
                                                        videoElement.currentTime = 0;
                                                        videoElement.src = '';
                                                    }
                    
                                                    if (modalImage.length) {
                                                        modalImage.attr('src', '');
                                                    }
                    
                                                    previewModal.hide();
                    
                                                    return false;
                                                });
                                        }

                                        if (hasShareButton) {
                                            shareButton
                                                .off('click')
                                                .on('click', (e) => {
                                                    e.preventDefault();
                                                    e.stopPropagation();
                    
                                                    console.log('Share button clicked');
                    
                                                    const modalVideo = $('#preview-modal-video');
                                                    const modalImage = $('#preview-modal-image');
                    
                                                    if (modalVideo.length) {
                                                        const videoElement = modalVideo[0];
                                                        videoElement.pause();
                                                        videoElement.currentTime = 0;
                                                        videoElement.src = '';
                                                    }
                    
                                                    if (modalImage.length) {
                                                        modalImage.attr('src', '');
                                                    }
                    
                                                    previewModal.hide();
                    
                                                    return false;
                                                });
                                        }
                                    }
                                    break;
                            }
                        }

                        if (mediaType === 'video') {
                            handleVideoPreview(
                                modalVideo, 
                                mediaUrl, 
                                unmuteButton, 
                                clickToPlayOverlay, 
                                isAdvertEnabled
                            );
                        } else if (mediaType === 'image') {
                            handleImagePreview(modalImage, mediaUrl);
                        }

                        hideLoading();
                        previewModal.show();
                    } else {
                        console.error('Failed to load media metadata');
                        hideLoading();
                    }
                },
                error: function(xhr, status, error) {
                    console.error('Error retrieving media metadata:', error);
                    hideLoading();
                }
            });
        }, 1000);
    });

function to rety script element is not defined

I have a script that kinda runs but im not sure its correct.here at least the button works and does not throw out error first. Gives error

Error attaching event listener: ReferenceError: element is not defined

here is the code

<html>
<head>
<title>test function</title>
</head>
<body>
                     
<input type="button" id="markerinfo"name="next" class="next" value="ALMOST DONE" />
<script>
document.getElementById("markerinfo").addEventListener("click", addEventListenerWithRetry);
function addEventListenerWithRetry(markerinfo,click, fillmark, retryInterval = 5000, maxRetries = 3){
  let retries = 0;

  function tryAttachListener() {
    try {
      element.addEventListener(click, fillmark);
      console.log('Event listener attached successfully.');
    } catch (error) {
      console.error('Error attaching event listener:', error);

      if (retries < maxRetries) {
        retries++;
        console.log(`Retrying in ${retryInterval / 1000} seconds...`);
        setTimeout(tryAttachListener, retryInterval);
      } else {
        console.error('Max retries reached. Event listener not attached.');
      }
    }
  }

  tryAttachListener();

}

//document.getElementById("markerinfo").addEventListener("click", fillmark);
function fillmark() {
console.error('It working!');
}



</script>




</body>
</html>

However when I make it look nice it gives this error

Uncaught SyntaxError: missing formal parameter

Now everything looks good here whats going on im confused? Can anyone help I know its got to be something simple that im missing.I think it has to do with the paramaters of the listener

<html>
<head>
<title>test function</title>
</head>
<body>
                     
<input type="button" id="markerinfo"name="next" class="next" value="ALMOST DONE" />
<script>
document.getElementById("markerinfo").addEventListener("click", addEventListenerWithRetry);
function addEventListenerWithRetry('markerinfo','click', fillmark, retryInterval = 5000, maxRetries = 3){
  let retries = 0;

  function tryAttachListener() {
    try {
      element.addEventListener('click', fillmark);
      console.log('Event listener attached successfully.');
    } catch (error) {
      console.error('Error attaching event listener:', error);

      if (retries < maxRetries) {
        retries++;
        console.log(`Retrying in ${retryInterval / 1000} seconds...`);
        setTimeout(tryAttachListener, retryInterval);
      } else {
        console.error('Max retries reached. Event listener not attached.');
      }
    }
  }

  tryAttachListener();

}

//document.getElementById("markerinfo").addEventListener("click", fillmark);
function fillmark() {
console.error('It working!');
}



</script>




</body>
</html>

Now i also tried like this but get a different error and this looks the best

Uncaught SyntaxError: unexpected token: '{

Here is the code

<html>
<head>
<title>test function</title>
</head>
<body>
                     
<input type="button" id="markerinfo"name="next" class="next" value="ALMOST DONE" />
<script>



document.getElementById('markerinfo').addEventListener('markerinfo','click', fillmark, retryInterval = 20000, maxRetries = 3){
  let retries = 0;

  function tryAttachListener() {
    try {
      element.addEventListener('click', fillmark);
      console.log('Event listener attached successfully.');
    } catch (error) {
      console.error('Error attaching event listener:', error);

      if (retries < maxRetries) {
        retries++;
        console.log(`Retrying in ${retryInterval / 1000} seconds...`);
        setTimeout(tryAttachListener, retryInterval);
      } else {
        console.error('Max retries reached. Event listener not attached.');
      }
    }
  }

  tryAttachListener();

}





//document.getElementById("markerinfo").addEventListener("click", fillmark);
function fillmark() {
console.error('It working!');
}



</script>




</body>
</html>

Changing nested markup with getElementsByClassName

I’m working with the API of Google’s Programmable Search Engine and using a callback to chnage the stying of output, specificaly the font size of the title of each search result snippet.

What I have below works and changes the gs-title font size to 24px. But the problem is that some gs-title divs have the search term inside <b> and </b> tags, and so that the title is rendered at 24px, but inside the bold tags, the font is the original size. See the image below with the search term “test”.

Area culinary students <b>test</b> their kitchen skills in 'Chopped' cooking ...

image showing title rendered

How can I also apply fontSize to text inside the bold tags?

Fiddle: https://jsfiddle.net/jqh4ntdv/

SearchResultsRenderedCallback = function(){

var elements = document.getElementsByClassName('gs-title');
for (var i = 0; i < elements.length; i++) {
  var element = elements[i];
  element.style.fontSize = "24px";
}

};

window.__gcse || (window.__gcse = {});
window.__gcse.searchCallbacks = {
  web: {
      rendered: SearchResultsRenderedCallback,
  },
};

Values are returning null objects despite existing in mysql db

I am perplexed as to why my values are returning as object types instead of number/int types even though they are defined as such, in addition, there are values existing in the table but upon sequelizing the results, they return as null objects!

Below is a masked version of my sequelize query in node/express js:

const queryResult = await sequelize.query(
  `SELECT tbl1.identifier, 
          COUNT(DISTINCT tbl1.item_id) AS item_count,
          tbl2.assigned_items, 
          tbl3.current_items, 
          tbl3.total_required_items,
          tbl3.expected_items_assigned, 
          tbl3.items_required
   FROM data_table_1 tbl1
   LEFT JOIN data_table_3 tbl3 ON tbl1.identifier = tbl3.identifier
   LEFT JOIN (
       SELECT identifier, COUNT(*) AS assigned_items
       FROM data_table_2
       GROUP BY identifier
   ) tbl2 ON tbl1.identifier = tbl2.identifier
   WHERE tbl1.identifier = "${someIdentifier}"
   GROUP BY tbl1.identifier;`,
  { type: QueryTypes.SELECT, logging: console.log, raw: true }
);

const {
  identifier,
  total_required_items,
  current_items,
  expected_items_assigned,
  assigned_items,
  item_count,
  items_required,
} = queryResult[0] || {};

Output:

console.log(queryResult);
[
  {
    identifier: 'abc123',
    item_count: 12,
    assigned_items: 2,
    current_items: null,
    total_required_items: null,
    expected_items_assigned: null,
    items_required: null
  }
]

Why are the values returning as null objects ? The same query works in MySQL but it fails during sequelize and i am unsure if it even truly executed the check below even though the results looked good to me.

const canProceed=
  (total_required_items== current_items && item_count> items_required) ||
  total_required_items> current_items||
  identifier== null ||
  identifier== "";

Ruffle loading from a path, how do I load from a file input button?

<!DOCTYPE html>
<html>
<title>emu</title>
<script src="https://unpkg.com/@ruffle-rs/ruffle"></script>
<div id="gameWin"></div>
<input type="file" id="flash" accept="application/x-shockwave-flash">
<button onclick="runSWF()">Click to load the SWF!</button>
<script>
function runSWF() {
// flash emu load
var ruf = window.RufflePlayer.newest();
var plr = ruf.createPlayer();
var cont = document.querySelector("#gameWin");
cont.appendChild(plr);

var file = document.querySelector("#flash")
if (file && file.files[0]) {

plr.load(INPUT FILE NOT FILE PATH); // basically load the file input's file instead of a preset file from a path
} else {
alert("You forgot to input your SWF!!")
}
}
</script>
</html>

Issue explained in comment, load the file DIRECTLY for ruffle instead of a file path, basically to load a file through an <input type=”file”>, so you can basically load any SWF file that you can grab, instead of loading a preset amount of them, via a directory.

Sorry if this is a poor explanation, I’m not that good with this stuff.

currently i am working on apple mdm devices/disown api i am passing everything in header and body as per documentation but i am 403 forbiddenerror

async disableActivationLock(orgId: number, deviceSerialNumber: string) {
let sessionToken = await this.generateToken(orgId);
const activationlockURL = ${this.mdmUrl}/devices/disown;

try {
  console.log("Requesting with token:", sessionToken);

  const response = await axios.post(
    activationlockURL,
    { devices: [deviceSerialNumber] },
    {
      headers: {
        "X-Server-Protocol-Version": 3,
        "X-ADM-Auth-Session": sessionToken,
      },
    }
  );

  console.log("Response:", response.data);
  return response.data;
} catch (error: any) {
  console.log("Error occurred:", error.response ? error.response.data : error.message);

  if (error.response) {
    const { status, data } = error.response;

    if (status === 403) {
      // console.log("Full error response:", JSON.stringify(error.response, null, 2));

      // Look for specific error messages
      if (data?.includes?.("ACCESS_DENIED")) {
        console.log("Access denied: MDM server or token doesn't have permission.");
      } else if (data?.includes?.("T_C_NOT_SIGNED")) {
        console.log("Terms and conditions not signed by the organization.");
      } else {
        console.log("Unexpected 403 error:", JSON.stringify(data, null, 2));
      }
    } else if (status === 401) {
      console.log("Token expired. Renewing session token...");

      sessionToken = await this.generateToken(orgId);

      try {
        const retryResponse = await axios.post(
          activationlockURL,
          { devices: [deviceSerialNumber] },
          {
            headers: {
              "X-Server-Protocol-Version": 3,
              "X-ADM-Auth-Session": sessionToken,
            },
          }
        );
        console.log("Response after retry:", retryResponse.data);
        return retryResponse.data;
      } catch (retryError: any) {
        console.log("Retry failed:", retryError.response ? retryError.response.data : retryError.message);
        throw retryError;
      }
    }
  }

  // If the error isn't 401 or 403, throw it
  throw error.message;
}

}

i was trying disown device from apple mdm by reading the doc but i am getting 403 forbidden error

created / installed npm package, getting ‘unexpected token’ error when trying to import and use in Playwright [duplicate]

I have checked the similar questions, but many of them seem specific to use Typescript. However, in our environment, we’re using Javascript.

So we have a simple file of functions (functions.js), which has been published as a scoped package in our internal system.

export Class Functions {
//  functions here 
} 

Then in index.js, I have

export { Functions } from "./Functions"

And in the package.json, we have

main: 'index.js'
type: 'commonjs'

When I try to use it in our Playwright tests, if I import it like this:

const { Functions } = require{'@qa/functions')

Playwright shows an error, “unexpected token export” and it references the index.js file.

I also see an additional error “could not find a declaration file, typescript error 7016). I’m a bit confused since we are not using typescript at all in this environment.

if window width less than X, do something if overpasses X on resize

I’m trying to add a rule that goes as: If the window width is less than 991 and resizes to something more or equal to 992, then do something.

I want to remove the class ‘opened’ from a megamenu only once if the screen is resized from mobile/tablet view (less than 991) to desktop view (more or equal to 992). But if the screen is already more than 992, do nothing.

All I can come up with are the resizes rules, but these keep applying every time I resize

if ($(window).width() >= 992) {
   $('.megamenu').removeClass('opened');
}

Website impossible to reverse engineer its Javascript [closed]

I have this website that I want to scrape through python requests, and not a headless browser, the problem is I couldn’t find how the url changes when you click on a filter (e.g 1 BHK or something else) when make a filter, the relative url changes to a weird typo !

Here is the link : https://housing.com/in/buy/searches/mumbai

Try to change the Bhk type and select two types of bhk for example, you’ll have a link like this : https://housing.com/in/buy/searches/CcPskwz0ocdh7q42r5 (selected 2 bhk, 3 bhk).

Please help me out to reverse engineer this website, I spent nights without no results !

I inspected all the APIs in network tab, the first api sent has in its payload the hash value that I want, so I don’t know from where he get it !

I can’t grab an element with querySelector with this attribute xlink:href=””

As the title says. I tried CSS.escape, used *=. This an attribute of an image element in Messenger.com. This is the attribute:

xlink:href="https://scontent.fmnl30-3.fna.fbcdn.net/v/t1.15752-9/465963771_544837275103647_4349826739070598419_n.jpg?stp=dst-jpg_s100x100_tt6&_nc_cat=105&ccb=1-7&_nc_sid=b70caf&_nc_eui2=AeEE5u8FlX9KtW7o_4a1fcWzQWyJI-PzqL9BbIkj4_Oov6uILnLZg6T1c8o-T2A485rybU_gN9fnXxXiRImyJhV6&_nc_ohc=WrSpzvLT1H8Q7kNvgESzF8i&_nc_zt=23&_nc_ht=scontent.fmnl30-3.fna&oh=03_Q7cD1QHLwyfkg9vNTc79uL6_mfOkWFpf2y2DCqNFF0KdUo0goA&oe=677A81BA"

I’m expecting for an element to be selected because it exists in the DOM. An interesting finding is when the element is inspected, it seems like the href attribute is an object instead of a string. I never encountered something like this before.

Solved by ChatGPT, it has something to do with XML namespace.

const namespace = "http://www.w3.org/1999/xlink";
const images = Array.from(document.querySelectorAll("image")).filter(
    (el) => el.getAttributeNS(namespace, "href") === "url"
);
console.log(images);

However, please answer if you have an additional information, it might help others 🙂