Limit the calendar event in javascript

document.addEventListener('DOMContentLoaded', () => {
    window.calendar = new Calendar({
        target: document.getElementById('app'),
        props: {
            plugins: [TimeGrid, DayGrid, ResourceTimeGrid, ResourceTimeline, List],
            options: {
                view: 'dayGridMonth',
                eventSources: eventSources,
                resources: resources,
                height: '725px',
                headerToolbar: {
                    start: 'prev,next today',
                    center: 'title',
                    end: 'dayGridMonth,timeGridWeek,timeGridDay,listWeek    resourceTimeGridWeek,resourceTimelineWeek'
                },
                eventClick: function(info) {
                    let extendedProps = info.event.extendedProps;
                    let titleHtml = extendedProps.title;
                    let assigned_to =  extendedProps.assigned_to;
                    let priority = extendedProps.priority;
                    let related_job = extendedProps.related_job;
                    let description = extendedProps.description;
                    let status = extendedProps.status;
                    

                    let modalContent = `
                        <div class="container">
                            <div class="row">
                                <div class="col-6">
                                <dl>
                                    <dt>Task:</dt>
                                    <dd>${titleHtml}</dd>
                                    <dt>Assigned To:</dt>
                                    <dd>${assigned_to}</dd>
                                    <dt>Priority:</dt>
                                    <dd>${priority}</dd>
                                    
                                    </dl>
                                </div>
                                <div class="col-6">
                                <dl>
                                    <dt>Related Job:</dt>
                                    <dd>${related_job}</dd>
                                    <dt>Status:</dt>
                                    <dd>${status}</dd>
                                </dl>
                                </div>
                            </div>
                            <div class="row">
                              
                                <div class="col-12">
                                <dl>
                                    <dt>Description:</dt>
                                    <dd>${description}</dd>
                                </dl>
                                </div>
                            </div>
                    </div>`;

                    document.getElementById('eventModalBody').innerHTML = modalContent;
                    new bootstrap.Modal(document.getElementById('eventModal')).show();
                },
                eventContent: function(arg) {

                    let titleHtml = arg.event.extendedProps.title;
                    let assigned_to =  arg.event.extendedProps.assigned_to;
                    let priority =  arg.event.extendedProps.priority;
                    let color = "#000";
                    if(priority=="High")
                    {
                        color = "#bb2124";
                    }
                    if(priority=="Medium")
                    {
                        color = "#f0ad4e";
                    }
                    if(priority=="Low")
                    {
                        color = "#22bb33";
                    }


                    return {
                        html: `
                            <div style="color:${color}">
                                <ul style="list-style-type:disc;padding-left:20px;font-size:12px">
                                    <li> ${titleHtml}<br>
                                    Assigned To: <span> ${assigned_to}</span></li>
                                </ul>
                            </div>
                        `
                    };
                },
                eventDidMount: function(arg) {
                    arg.el.style.backgroundColor = 'transparent';
                }
            }
        }
    });
});

I want to limit the events on calendar to 3 if there are more than 3 tasks than a read more button will appear dynamically. I am working in laravel 11 and here is a javascript script i am using for calendar……………………………………………………………………………………………………………………………………………………………………………………

jQuery .load() event not firing on image load in Django template

I’m working on a Django project and trying to trigger a jQuery .load() event when an image loads on my webpage. However, the event is not firing as expected. My HTML template uses Django’s {% static %} tag to reference a CSS file, and the image is loaded directly with a relative path (src=”static/p5.jpeg”). The jQuery script is supposed to display an alert when the image finishes loading, but nothing happens. I’m unsure whether the issue lies with how I’m referencing the image, the event binding, or something else.

I tried using jQuery’s .load() event to trigger an alert when an image finishes loading. I expected the alert to display once the image (#img1) was fully loaded. I included the jQuery library from a CDN and wrote the script inside a $(document).ready() function to ensure it runs after the DOM is fully loaded. However, the alert never appears, which suggests that the .load() event isn’t firing as expected. I also double-checked the image path and ensured that jQuery is correctly linked, but the issue persists.

CSS working in the HTML, but not in Javascript?

CSS Sprites are working in the HTML of the page, but not in Javascript?

I am trying to install http://www.spyka.net/scripts/javascript/easy-social-bookmarks and add CSS Sprites to minimise the server calls.

Here is the main workings of the script which may also affect it:

sites[0] = new Array(‘https://easkme.com/index.php?Action=Blink/addblink.php&Url={url}’, ‘Easkme’, ”);

Here is the main workflow:

<script>
function swgbookmarks()
{
    for(i = 0; i < sites.length; i++)
    {
        var g = sites[i];
        var u = g[0];
        u = u.replace('{url}', escape(window.location.href));
        u = u.replace('{title}', escape(window.document.title));
        var img = (imagepath == '0') ? '' : '<img src="'+g[2]+'" alt="'+g[1]+'" />&nbsp; ';
        var k = '<a href="'+u+'">'+img+g[1]+'</a>&nbsp;';
        window.document.write(html_before+k+html_after);                
    }
}</script>

The social bookmark and image JS code:

sites[0] = new Array(‘https://easkme.com/index.php?Action=Blink/addblink.php&Url={url}’, ‘Blinklist’, ‘socialsprite social blinklist’);

Any ideas or help is very much appreciated.

Thank you.

with interceptBufferProtocol deprecated, how would I utilize protocol.handle to intercept http & https?

Within my electron application, I was wanting to create a captcha harvester pop up window and I came across a git repo, specifically this https://github.com/sashapisdets/Captcha-Solver and fresh after the clone, it works fine, but the problem is, it utilizes an extremely old version of Electron while my personal application utilizes the latest. A main core function within the harvester is that it intercepts the http protocol and has a callback to display an html, but with the new version of electron, interceptBufferProtocol is deprecated and got replaced with .handle, but no matter what I do, I can’t seem to get it to intercept the http protocol using protocol.handle, does anyone have any ideas on how I’d go about updating it?

Original Function

function SetupIntercept() {
    protocol.interceptBufferProtocol('http', (req, callback) => {
        if(req.url == 'https://www.google.com/recaptcha/api2/demo') {
            fs.readFile(__dirname + '/captcha.html', 'utf8', function(err, html){
                callback({mimeType: 'text/html', data: Buffer.from(html)});
            });
        }else{
            const request = net.request(req)
            request.on('response', res => {
                const chunks = []
    
                res.on('data', chunk => {
                    chunks.push(Buffer.from(chunk))
                })
    
                res.on('end', async () => {
                    const file = Buffer.concat(chunks)
                    callback(file)
                })
            })
    
            if (req.uploadData) {
                req.uploadData.forEach(part => {
                    if (part.bytes) {
                        request.write(part.bytes)
                    } else if (part.file) {
                        request.write(readFileSync(part.file))
                    }
                })
            }
    
            request.end()
        }
    })
};

Updated Function

function SetupIntercept() {
    protocol.handle('http', async (req) => {
        if (req.url === 'http://supremenewyork.com/') {
            try {
                const html = await fs.promises.readFile(__dirname + '/captcha.html', 'utf8');
                return {
                    mimeType: 'text/html',
                    data: Buffer.from(html),
                };
            } catch (err) {
                console.error('Error reading captcha.html:', err);
                return {
                    mimeType: 'text/plain',
                    data: Buffer.from('Error loading page'),
                };
            }
        } else {
            return new Promise((resolve, reject) => {
                const request = net.request(req);
                request.on('response', (res) => {
                    const chunks = [];
        
                    res.on('data', (chunk) => {
                    chunks.push(Buffer.from(chunk));
                    });
        
                    res.on('end', () => {
                    const file = Buffer.concat(chunks);
                    resolve({ data: file });
                    });
        
                    res.on('error', (error) => {
                    console.error('Error in response:', error);
                    reject({
                        mimeType: 'text/plain',
                        data: Buffer.from('Error loading page'),
                    });
                    });
                });
        
                if (req.uploadData) {
                    req.uploadData.forEach((part) => {
                    if (part.bytes) {
                        request.write(part.bytes);
                    } else if (part.file) {
                        request.write(readFileSync(part.file));
                    }
                    });
                }
        
                request.end();
            });
        }
    });
}

What are the limitations of the HTML tag when implementing dynamic updates in a data table? [closed]

I’m building a data table from scratch and need to implement advanced features like dynamic updates, sorting, and filtering. I noticed that many modern data table libraries do not use the HTML <table> tag but instead rely on div elements and CSS.

I want to understand if there are any specific limitations or challenges when using the <table>tag for these kinds of advanced features.

For instance, are there performance issues or difficulties in managing dynamic content updates when using <table>?

I would appreciate insights or references on this topic, especially regarding the best practices for creating a responsive and interactive data table.

In ECHARTS how to start with a hidden serie and then make it visible with custom legend

How start with a hidden serie on graph and then display it with a custom legend button like

<div>
  <input type="button" value="hide show NAME_OF_THE_SERIE" id="buttonid">
</div>

<script>
button = document.body.querySelector('#buttonid');
button.addEventListener('click', (e) => {   
    myChart.dispatchAction({
      type: "legendToggleSelect",
      name: "NAME_OF_THE_SERIE"
    });
    console.log(myChart.getOption().series);
});
</script>

Here the link of the codepen.io where I took this

Now, like you see in console (if you implement this method) the object with the serie name “NAME_OF_THE_SERIE” returned with chart.getOption().series it’s exactly the same when the serie is hidden and when it’s showed on graph.

So also how to know if a serie it’s hidden?

I am facing this error i18n is not a function

I want to add Map.ir Map in web application using .net core when I write the following code it gives me the error “i18n is not a function jquery-3.2.1.min.js”

<link href="~/dist/css/mapp.min.css" rel="stylesheet" />
<link href="~/app/css/app.css" rel="stylesheet" />

<div id="app" style="width:100%; height:50%;margin-top:10px; border:2px dashed red; padding:200px"></div>
<script src="~/dist/js/jquery-3.2.1.min.js"></script>
<script src="~/dist/js/mapp.env.js"></script>
<script src="~/dist/js/mapp.min.js"></script>
<script>
    $(document).ready(function () {
        var app = new Mapp({
            element: '#app',
            presets: {
                latlng: {
                    lat: 35.73249,
                    lng: 51.42268,
                },
                zoom: 10
            },
            apiKey: 'my api key'
        });
    });
</script> 

I want to save this to fit my piano keys, what should I do

enter image description here

The media currently stored in Roblox is made up of this

{
    "VOLUME_SETTINGS": {
        "MIN_VOLUME": 10,
        "MAX_VOLUME": 200,
        "INITIAL_VOLUME": 100,
        "VOLUME_STEP": 10,
        "ADJUSTMENT_INTERVAL_MS": 50
    },
    "DRUM_FILTER_SETTINGS": {
        "ENABLED": true
    },
    "SUSTAIN_SETTINGS": {
        "SUSTAIN_CUTOFF": 64
    },
    "LEGIT_MODE_SETTINGS": {
        "ENABLED": false,
        "TIMING_VARIATION": 0.1,
        "NOTE_SKIP_CHANCE": 0.02,
        "EXTRA_DELAY_CHANCE": 0.02,
        "EXTRA_DELAY_MIN": 0.01,
        "EXTRA_DELAY_MAX": 0.2
      },
    "KEY_MAPPINGS": {
        "LIMITED": {
            "C2": "1", "C#2": "!", "D2": "2", "D#2": "@", "E2": "3", "F2": "4",
            "F#2": "$", "G2": "5", "G#2": "%", "A2": "6", "A#2": "^", "B2": "7",
            "C3": "8", "C#3": "*", "D3": "9", "D#3": "(", "E3": "0", "F3": "q",
            "F#3": "Q", "G3": "w", "G#3": "W", "A3": "e", "A#3": "E", "B3": "r",
            "C4": "t", "C#4": "T", "D4": "y", "D#4": "Y", "E4": "u", "F4": "i",
            "F#4": "I", "G4": "o", "G#4": "O", "A4": "p", "A#4": "P", "B4": "a",
            "C5": "s", "C#5": "S", "D5": "d", "D#5": "D", "E5": "f", "F5": "g",
            "F#5": "G", "G5": "h", "G#5": "H", "A5": "j", "A#5": "J", "B5": "k",
            "C6": "l", "C#6": "L", "D6": "z", "D#6": "Z", "E6": "x", "F6": "c",
            "F#6": "C", "G6": "v", "G#6": "V", "A6": "b", "A#6": "B", "B6": "n",
            "C7": "m"        },


        "FULL": {
            "A0": "ctrl+1", "A#0": "ctrl+2", "B0": "ctrl+3", "C1": "ctrl+4", "C#1": "ctrl+5",
            "D1": "ctrl+6", "D#1": "ctrl+7", "E1": "ctrl+8", "F1": "ctrl+9", "F#1": "ctrl+0",
            "G1": "ctrl+q", "G#1": "ctrl+w", "A1": "ctrl+e", "A#1": "ctrl+r", "B1": "ctrl+t",
            "C2": "1", "C#2": "!", "D2": "2", "D#2": "@", "E2": "3", "F2": "4",
            "F#2": "$", "G2": "5", "G#2": "%", "A2": "6", "A#2": "^", "B2": "7",
            "C3": "8", "C#3": "*", "D3": "9", "D#3": "(", "E3": "0", "F3": "q",
            "F#3": "Q", "G3": "w", "G#3": "W", "A3": "e", "A#3": "E", "B3": "r",
            "C4": "t", "C#4": "T", "D4": "y", "D#4": "Y", "E4": "u", "F4": "i",
            "F#4": "I", "G4": "o", "G#4": "O", "A4": "p", "A#4": "P", "B4": "a",
            "C5": "s", "C#5": "S", "D5": "d", "D#5": "D", "E5": "f", "F5": "g",
            "F#5": "G", "G5": "h", "G#5": "H", "A5": "j", "A#5": "J", "B5": "k",
            "C6": "l", "C#6": "L", "D6": "z", "D#6": "Z", "E6": "x", "F6": "c",
            "F#6": "C", "G6": "v", "G#6": "V", "A6": "b", "A#6": "B", "B6": "n",
            "C7": "m", "C#7": "ctrl+y", "D7": "ctrl+u", "D#7": "ctrl+i", "E7": "ctrl+o",
            "F7": "ctrl+p", "F#7": "ctrl+a", "G7": "ctrl+s", "G#7": "ctrl+d", "A7": "ctrl+f",
            "A#7": "ctrl+g", "B7": "ctrl+h", "C8": "ctrl+j"
        }
    },
    "HOTKEY_SETTINGS": {
        "SUSTAIN_KEY": "SPACE",
        "VOLUME_UP_KEY": "RIGHT",
        "VOLUME_DOWN_KEY": "LEFT"
    },
    "CONTROLS": {
        "PLAY_PAUSE": "DELETE",
        "REWIND": "HOME",
        "SKIP": "END",
        "SPEED_UP": "PAGEUP",
        "SLOW_DOWN": "PAGEDOWN",
        "LOAD_NEW_SONG": "F5",
        "TOGGLE_88_KEY_MODE": "F6",
        "TOGGLE_VOLUME_ADJUSTMENT": "F7",
        "TOGGLE_TRANSPOSE_ADJUSTMENT": "F8",
        "RESTART_SONG": "F1",
        "STOP_AND_EXIT": "ESCAPE",
        "TOGGLE_SUSTAIN_MODE": "F10"
    }
    
}

I want to save this in this key, but it doesn’t work no matter how hard I try.

Please put the sauce just right for me. I’m in a hurry..

Data returned from JavaScript endpoint is shown as a placeholder in a Flow JSON

I’m returning data from an endpoint to a WhatsApp FLow JSON in this format and when I log it, the logs say that the data is being returned successfully:

const response = {
  screen: "CART",
  data: {
    totalAmount: totalAmount
  }
};

And then I try to use that returned value in the CART screen of the WhatsApp Flow JSON by using the ${data.totalAmount} format like this:

"id": "CART",
  "title": "Cart",
  "terminal": true,
  
  "layout": {
    "type": "SingleColumnLayout",
    "children": [
      {
        "type": "TextBody",
        "text": "Total Amount: ${data.totalAmount}",
        "visible": true
      }

But it just returns the placeholder and not the values that was received from the endpoint.
I have tried the to add this data property to the screen, but it still returned the placeholder and not the values that was returned by the endpoint:

{
      "id": "CART",
      "title": "Cart",
      "terminal": true,
      "data": {
        "amount": {
          "type": "object",
          "__example__": {
            "value": "100.00"
          },
          "value": "${data.totalAmount}"
        }
      },
      "layout": {
        "type": "SingleColumnLayout",
        "children": [
          {
            "type": "TextBody",
            "text": "Total Amount: ${data.value}",
            "visible": true
          },

The same result is returned when I try to use ${data.amount.value} as it just returns the placeholder.

Detects whether the browser’s devtools are open

i trying Detects whether the browser’s devtools are open using php. I using user-agent to detect platform is mobile/talblet and desktop. If platform is mobile/tablet then redirect to my website and platform is desktop then alert user on desktop mode.
At the same time I want to check devtools is open. The reason for this is that I don’t want users to use mobile mode to pass the test.

It’s working better when mobile/tablet and desktop but the script not working when users use mobile mode on DevTools. This is my problem. I have found [https://github.com/david-fong/detect-devtools-via-debugger-heartstop][1] and demo: [https://david-fong.github.io/detect-devtools-via-debugger-heartstop/][1]. it works fine for me. However, I don’t know how to use it on hosting file php. Can someone help me? Sorry for my English is very bad.

this is my script

<?php
$user_agent = $_SERVER['HTTP_USER_AGENT'];

if (strpos($user_agent, 'Mobile') !== false || strpos($user_agent, 'Tablet') !== false) {
    header("Location: example.com");
} else {
    echo "Desktop Mode";
}

echo "<script>";
echo "console.log(Object.defineProperties(new Error, {";
echo "toString: {value() {(new Error).stack.includes('toString@') && alert('Safari devtools')}},";
echo "message: {get() {window.close()}}";
echo "}));";
echo "</script>";
?>

In ECHARTS how to setOptions for a specific serie (selecting it by name name)

I got some series in a ECHARTS graph.

Now talking about the y axis it’s like this

yAxis: [
    {
        scale: true,
        splitArea: { show: true, },
    },
    {
        scale: true,
        gridIndex: 0,
        splitNumber: 2,
        axisLabel: { show: false, },
        axisLine: { show: false, },
        axisTick: { show: true, },
        splitLine: { show: false, },
        max: 8,
    },
    { scale: true, splitArea: { show: true, }, },
]

and series are like this

series: [
    {
        name: 'A',
        type: 'line',
        lineStyle: { width: 4, },
        showSymbol: false,
    },
    {
        name: 'B',
        type: 'line',
    },
    {
        name: 'serie_x',
        type: 'line',
        xAxisIndex: 0,
        yAxisIndex: 0,
        data: dynamicCalculator(),
        smooth: true,
        large: true,
    },
]

Now, if I want to change series symbolSize the command is setOption.

But if I do like this to change exactly serie_x

chart.setOption({
    series: [{
        name : 'serie_x',
        symbolSize: isChecked ? 5 : 1,
    }]

the first serier seems to change name, so the command has to be

chart.setOption({},{},{
    series: [{
        name : 'serie_x',
        symbolSize: isChecked ? 5 : 1,
    }]

adding 2 empty elements before the serie needed.

Now see the problem. The real question:

If there’s a dynamic number of series how to setOption on the serie where the name it’s serie_x??

create a custom vega.transform in vega-lite

I’d like to extend Vega’s transform map with a new transform class, but I’m running into some difficulties. Here is what I have so far. I’ve sketched out my intended roadmap in the comments, but I’m having some difficulty even loading the Vega transform into Vega-lite. I’ve found Vega-lite’s typescript interface, but I’m not sure how to register my transform.

<!doctype html>
<html>
  <head>
    <title>Too Much Data</title>
    <meta charset="utf-8" />

    <!--
    <script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
    -->

    <script src="https://cdn.jsdelivr.net/npm/[email protected]/build/vega.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/build/vega-lite.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/build/vega-embed.js"></script>

    <style media="screen">
    h1 {
        text-align: center;
        font-family: Georgia, serif
    }
    #vis {
        width: 100%;
    }
    </style>
  </head>
  <body>
    <h1>Too Much Data</h1>
    <!-- Container for the visualization -->
    <div id="vis"></div>

    <script>
      // Assign the specification to a local variable vlSpec.
      var vlSpec =
        { $schema: "https://vega.github.io/schema/vega-lite/v5.json"
        , data:
          {"values":
            [{"time": "2023-08-31 15:12:40", "data": 265.1037232391961, "category": 1}, {"time": "2023-08-31 15:15:26", "data": 989.2391954577464, "category": 1}, {"time": "2023-08-31 15:15:29", "data": 426.3748533977788, "category": 0}, {"time": "2023-08-31 15:18:11", "data": 563.7725296786067, "category": 1}, {"time": "2023-08-31 15:21:25", "data": 322.4493083566362, "category": 0}, {"time": "2023-08-31 15:24:54", "data": 822.6771646740021, "category": 1}, {"time": "2023-08-31 15:28:10", "data": 294.37404484299054, "category": 1}, {"time": "2023-08-31 15:28:22", "data": 838.7462086185608, "category": 0}, {"time": "2023-08-31 15:35:58", "data": 961.3893188770259, "category": 0}, {"time": "2023-08-31 15:36:07", "data": 241.45631836625802, "category": 0}, {"time": "2023-08-31 15:49:33", "data": 191.96326506124362, "category": 0}, {"time": "2023-08-31 15:51:15", "data": 450.50733664623965, "category": 1}, {"time": "2023-08-31 15:56:35", "data": 390.5921971631632, "category": 1}, {"time": "2023-08-31 15:57:52", "data": 829.8364876130439, "category": 1}, {"time": "2023-08-31 16:01:06", "data": 996.0349700996576, "category": 0}, {"time": "2023-08-31 16:02:36", "data": 78.24722444300802, "category": 0}, {"time": "2023-08-31 16:14:05", "data": 942.3350040849994, "category": 0}, {"time": "2023-08-31 16:14:56", "data": 860.58714895142, "category": 1}, {"time": "2023-08-31 16:15:08", "data": 515.199102407516, "category": 1}, {"time": "2023-08-31 16:23:20", "data": 166.05721829849873, "category": 1}, {"time": "2023-08-31 16:30:05", "data": 439.73137493646266, "category": 0}, {"time": "2023-08-31 16:32:31", "data": 869.245076742056, "category": 0}, {"time": "2023-08-31 16:35:48", "data": 480.50968063008304, "category": 1}, {"time": "2023-08-31 16:37:50", "data": 476.877035209344, "category": 1}, {"time": "2023-08-31 16:39:36", "data": 733.3017448826324, "category": 0}, {"time": "2023-08-31 16:44:17", "data": 636.686519092496, "category": 1}, {"time": "2023-08-31 16:45:08", "data": 694.5261775005811, "category": 0}, {"time": "2023-08-31 16:51:36", "data": 695.7401884245502, "category": 0}, {"time": "2023-08-31 16:55:29", "data": 570.0935946720598, "category": 1}, {"time": "2023-08-31 16:57:05", "data": 277.22052647262717, "category": 0}, {"time": "2023-08-31 16:58:27", "data": 480.36926264607274, "category": 1}, {"time": "2023-08-31 17:02:34", "data": 893.3698570026319, "category": 1}, {"time": "2023-08-31 17:05:32", "data": 236.71895124154685, "category": 1}, {"time": "2023-08-31 17:08:46", "data": 573.0841835923452, "category": 0}, {"time": "2023-08-31 17:14:37", "data": 191.7254918774728, "category": 0}, {"time": "2023-08-31 17:16:43", "data": 94.93763899240804, "category": 1}, {"time": "2023-08-31 17:24:40", "data": 936.4038465823089, "category": 0}, {"time": "2023-08-31 17:31:09", "data": 390.84825100994567, "category": 1}, {"time": "2023-08-31 17:35:35", "data": 14.48187309843274, "category": 0}, {"time": "2023-08-31 17:35:47", "data": 443.05398617944593, "category": 1}, {"time": "2023-08-31 17:40:44", "data": 30.0828399028229, "category": 0}, {"time": "2023-08-31 17:48:33", "data": 768.0549896500464, "category": 1}, {"time": "2023-08-31 17:53:29", "data": 71.57068127924227, "category": 0}, {"time": "2023-08-31 18:04:56", "data": 594.7138236213322, "category": 0}, {"time": "2023-08-31 18:06:44", "data": 29.21370270526036, "category": 0}, {"time": "2023-08-31 18:28:22", "data": 852.7093808483378, "category": 1}, {"time": "2023-08-31 18:30:01", "data": 576.9728506525139, "category": 1}, {"time": "2023-08-31 18:31:41", "data": 968.1882202042807, "category": 1}, {"time": "2023-08-31 18:31:51", "data": 185.6873327854428, "category": 1}, {"time": "2023-08-31 18:33:31", "data": 258.211113709635, "category": 0}, {"time": "2023-08-31 18:36:36", "data": 641.264570256715, "category": 1}, {"time": "2023-08-31 18:39:52", "data": 717.6143367808544, "category": 1}, {"time": "2023-08-31 18:39:52", "data": 191.4611806426172, "category": 1}, {"time": "2023-08-31 18:41:38", "data": 136.9116350629923, "category": 0}, {"time": "2023-08-31 18:57:48", "data": 62.11343548023751, "category": 1}, {"time": "2023-08-31 18:58:26", "data": 529.5089127094398, "category": 0}, {"time": "2023-08-31 19:07:54", "data": 153.13269404700824, "category": 1}, {"time": "2023-08-31 19:09:17", "data": 705.4049459845114, "category": 0}, {"time": "2023-08-31 19:11:07", "data": 300.90132125121005, "category": 1}, {"time": "2023-08-31 19:20:25", "data": 946.4725291504993, "category": 1}, {"time": "2023-08-31 19:23:48", "data": 319.04133613813724, "category": 1}, {"time": "2023-08-31 19:24:25", "data": 464.2923297748929, "category": 1}, {"time": "2023-08-31 19:28:02", "data": 836.436678063193, "category": 1}, {"time": "2023-08-31 19:28:08", "data": 5.992853044164859, "category": 1}, {"time": "2023-08-31 19:40:01", "data": 873.6847072580948, "category": 1}, {"time": "2023-08-31 19:43:41", "data": 431.0286183407737, "category": 1}, {"time": "2023-08-31 19:51:22", "data": 396.43260404732825, "category": 0}, {"time": "2023-08-31 19:54:08", "data": 575.9715221353141, "category": 0}, {"time": "2023-08-31 19:55:53", "data": 44.016217670442614, "category": 0}, {"time": "2023-08-31 19:58:14", "data": 988.9639046666363, "category": 1}, {"time": "2023-08-31 20:05:53", "data": 742.2798696276691, "category": 0}, {"time": "2023-08-31 20:07:13", "data": 982.7119961613008, "category": 0}, {"time": "2023-08-31 20:15:20", "data": 976.3381077100345, "category": 1}, {"time": "2023-08-31 20:20:15", "data": 498.5276910780252, "category": 0}, {"time": "2023-08-31 20:22:29", "data": 301.4863894174468, "category": 1}, {"time": "2023-08-31 20:31:03", "data": 232.56452406666895, "category": 1}, {"time": "2023-08-31 20:33:52", "data": 694.171014904713, "category": 1}, {"time": "2023-08-31 20:35:45", "data": 102.79567934930212, "category": 1}, {"time": "2023-08-31 20:47:32", "data": 431.64822699883376, "category": 1}, {"time": "2023-08-31 20:55:19", "data": 683.217576875891, "category": 0}, {"time": "2023-08-31 20:55:36", "data": 879.5945045918183, "category": 1}, {"time": "2023-08-31 21:04:28", "data": 164.6834561802648, "category": 1}, {"time": "2023-08-31 21:06:04", "data": 22.588620229922583, "category": 1}, {"time": "2023-08-31 21:07:10", "data": 757.0796861192514, "category": 1}, {"time": "2023-08-31 21:23:43", "data": 848.456892794343, "category": 1}, {"time": "2023-08-31 21:34:38", "data": 447.89147371830785, "category": 1}, {"time": "2023-08-31 21:45:30", "data": 862.3116375036777, "category": 1}, {"time": "2023-08-31 21:47:00", "data": 967.0312319533795, "category": 0}, {"time": "2023-08-31 21:47:56", "data": 966.4938018703745, "category": 1}, {"time": "2023-08-31 21:49:45", "data": 890.2567189914545, "category": 0}, {"time": "2023-08-31 21:55:40", "data": 362.80312104639677, "category": 1}, {"time": "2023-08-31 21:58:55", "data": 834.7469369912607, "category": 1}, {"time": "2023-08-31 22:01:02", "data": 584.1447613550432, "category": 1}, {"time": "2023-08-31 22:01:06", "data": 82.66592460479994, "category": 1}, {"time": "2023-08-31 22:02:00", "data": 332.67959271479384, "category": 0}, {"time": "2023-08-31 22:02:32", "data": 316.51081491367347, "category": 0}, {"time": "2023-08-31 22:08:31", "data": 336.10098602094985, "category": 1}, {"time": "2023-08-31 22:18:52", "data": 873.7313013506864, "category": 0}, {"time": "2023-08-31 22:19:24", "data": 312.42947148514776, "category": 1}, {"time": "2023-08-31 22:28:48", "data": 582.8096654568776, "category": 1}]
          }
        , params:
          [ {name: "test", expr: "span(grid_time)/1000"}
          ]
        , transform:
          [ {filter: "datum.data > 0"}
          ]
        , title: "Too Much Data"
        , config: { font: "monospace" }
        , width: "container"
        , layer:
          [ { params:
              [ { name: "grid"
                , bind: "scales"
                , select:
                  { type: "interval"
                  , encodings: ["x"]
                  , on: "[mousedown[!event.shiftKey], mouseup] > mousemove"
                  , translate: "[mousedown[!event.shiftKey], mouseup] > mousemove!"
                  }
                }
              , { name: "brush"
                , select:
                  { type: "interval"
                  , encodings: ["x"]
                  , on: "[mousedown[event.shiftKey], mouseup] > mousemove"
                  , translate: "[mousedown[event.shiftKey], mouseup] > mousemove!"
                  }
                }
              ]
            , mark: "point"
            , encoding:
              { x: {field: "time", type: "temporal"}
              , y: {field: "data", type: "quantitative"}
              , color: {field: "category", type: "nominal"}
              }
            }
          , { data: {values: [{}]}
            , mark:
              { type: "rect"
              , x: 10
              , y: 10
              , x2: 182
              , y2: 100
              , fillOpacity: 0.05
              , stroke: "darkgrey"
              , strokeWidth: 2
              , fill: "azure"
              }
            }
          , { data: {values: [{}]}
            , mark:
              { type: "rect"
              , fillOpacity: 0.05
              , stroke: "darkgrey"
              , strokeWidth: 2
              , fill: "azure"
              }
            , encoding:
              { "x": {"value": 200}
              , "y": {"value": 120}
              , "x2": {"value": 240}
              , "y2": {"value": 160}
              }
            }
          , { //data: {values: [{time: 1693521211000}]}
              transform:
              [ { filter: {param: "brush", empty: true}}
              , { window: [{op: "row_number", as: "row_number"}]}
              , { extent: "time", param: "time_extent"}
              , { aggregate:
                  [ {op: "count", as: "count"}
                  //, {op: "values", field: "time", as: "values"}
                  //, {op: "argmax", field: "time", as: "argmax"}
                  //, {op: "argmin", field: "time", as: "argmin"}
                  ]
                }
              //, { type: "default", values: []}
              , { default: []}
              ]
            , mark:
              { type: "text"
              , x: 15
              , y: 15
              , align: "left"
              , baseline: "top"
              , text: {expr: "warn(true ? 'foo' : 'bar')"}
              }
            //, encoding:
            //  { text: {field: "data", type: "nominal"}
            //  , y: {field: "row_number", type: "ordinal", axis: null}
            //  }
            }
          ]
        }

      // Insert a predetermined row only when the dataset is empty.
      // This can happen because aggregate does not understand empty sets,
      // i.e. "count" goes from 3,2,1,<empty dataset> rather than 3,2,1,0.
      class Default extends vega.Transform {
        Definition =
          { type: "Filter"
          , metadata: {changes: true}
          , params:
            [ { name: "values", type: "any", array: true }
            ]
          }

        constructor(params) {
          // todo: provide initial value
          // { count: 0, cache: null } ??
          super(null, params)
        }

        transform(params, pulse) {
          // rough draft (probably wrong):
          // 1. For each add, increment this.value.count
          // 2. For each rem, decrement this.value.count
          // 3. if this.value.count == 0 {
          //      if this.value.cache == null {
          //        // need to lookup null/undefined/==/===
          //        // need to console.log some tuples to learn the
          //        // expected ingest format
          //        this.value.cache = ingest(params.values)
          //      }
          //      pulse.add.push(this.value.cache)
          //    } else {
          //      // pretty sure I have to remove the default, i.e. will
          //      // persist during subsequent pulses
          //      pulse.rem.push(this.value.cache)
          //    }
          // 4. Handle params.modified() ...
          //    reset count to 0 (??) - before step 3, then after step 3:
          //    pulse.visit(pulse.REFLOW, ...) // anything except ADD/REM/MOD
          //    For each, increment this.value.count
          // Will these count strategies actually work? No idea. Need to
          // console.log all changes to count.
          // ???
          const out = pulse.fork(pulse.ALL)
          pulse.visit(pulse.ADD, t => {
            console.log(t)
          })

          return out
        }
      }

      // problem: need to convert the vega interface to the vega-lite interface.
      vega.transforms["default"] = Default

      // Embed the visualization in the container with id `vis`
      vegaEmbed('#vis', vlSpec).then(function(result) {
      // Access the Vega view instance as result.view
      // (https://vega.github.io/vega/docs/api/view/)
      }).catch(console.error);
    </script>
  </body>
</html>

scrape a dropdown list using playwright

I’m struggling to find a way to click on the “All” option in a dropdown list and scrape all the content inside that page. I have come across a few posts but they’re a little different from my situation. My “select” seems to not have id or label, with an empty “name”.

The website I’m scraping is https://www.nba.com/stats/players/traditional?Season=1998-99&SeasonType=Regular+Season

<div class="Pagination_pageDropdown__KgjBU">
 <div class="DropDown_content__Bsm3h">
  <label class="DropDown_label__lttfI">
   <p data-no-label="true"></p>
  <div class="DropDown_dropdown__TMlAR">
   <select name="" class="DropDown_select__4pIg9">
     <option value="-1">All</option>
     <option value="0">1</option>
     <option value="1">2</option>
     <option value="2">3</option
     <option value="3">4</option>
     <option value="4">5</option>
     <option value="5">6</option>
     <option value="6">7</option>
     <option value="7">8</option>
     <option value="8">9</option>
   </select>

My current code looks like this:

import asyncio
from playwright.async_api import async_playwright
from NBA.spiders.nba import NbaScraping

`async def main():
    async with async_playwright() as p:
        browser = await p.chromium.launch(headless=False)
        page = await browser.new_page()
        spider = NbaScraping()
        spider.start_requests()
        for url in spider.start_urls:
            await page.goto(url)
            selector =  page.locator('.Pagination_pageDropdown__KgjBU.DropDown_select__4pIg9')
            await selector.wait_for()
            page.select_option(value='-1')
            page.wait_for_timeout(5999)
        await browser.close()

asyncio.run(main())`

I expect to scrape all the content from the “All” option in the dropdown list. I have spent a week on such problem but I couldn’t find a solution that works. I’m still new to this so forgive me if the question sounds naive to most of you

XMLHttpRequest Get ID from Response

How do I get the ID from this response.

"{"id": "9cf049a8-220a-4103-9f84-354276409390", "info": {"status": "Draft", "created_by": "[email protected]", "location": "615 Bourbon St New Orleans", "order_type": "vbim", "first_delivered_at": null, "created_at": 1725162699.505495, "is_scan_order": true, "total_scanned_area": 0.0, "go2scan": null, "external_id": "R4ER93", "add_info": "Extra info", "style_template": null, "product": {"add_ons": [], "over_limits": [], "package_type": "plus", "purchasable_add_ons": [], "purchasable_package_types": []}}, "address": {"city": "New Orleans", "country": "United States", "full_address": "615 Bourbon St,New Orleans,Louisiana,United States", "latitude": 29.958365, "longitude": -90.066198, "number": "", "postalCode": "70130", "state": "Louisiana", "street": "615 Bourbon St", "suite": ""}, "delivery_assets": {"gla_package": null, "listing_floorplans": null, "home_report": null, "floorplans_3d": null, "video_3d": null, "cad_files": null, "property_data": null, "snapshot": null}}"

Here is my Javascript

var request = new XMLHttpRequest();

request.open('POST', 'https://app.cubi.casa/api/integrate/v3/orders/draft');

request.setRequestHeader('content-type', 'application/json');
request.setRequestHeader('api-key', 'KEY');

request.onreadystatechange = function () {
if (this.readyState === 4) {
console.log('Status:', this.status);
console.log('Headers:', this.getAllResponseHeaders());
console.log('Body:', this.responseText);
}
};

var body = {
'street': '615 Bourbon St',
'suite': '',
'city': 'New Orleans',
'state': 'Louisiana',
'country': 'United States',
'postalCode': '70130',
'info': 'Extra info',
'latitude': 29.958365,
'longitude': -90.066198,
'external_id': 'R4ER93',
'owner_email': 'Email.com',
'package_type': 'plus'
};

request.send(JSON.stringify(body));