Vue Router incompatible with Laravel 8

I have a problem with Vue Router with Laravel. It always says error 404 even though I already setup routes. I am struggling for several hours now. How can I provide solutions to this problem?

Here is my router,

import { createRouter, createWebHistory } from "vue-router";

// components
import SignIn from '../pages/SignIn.vue'
import SignUp from '../pages/SignUp.vue'
import Home from '../pages/Home.vue'

const routes = [
    { path: '/accounts/signin', component: SignIn},
    { path: '/accounts/signup', component: SignUp},
    { path: '/', component: Home},
]

const router = createRouter({
    history: createWebHistory(),
    routes
})

export default router

and the web routes in Laralvel,

Route::get('/', function() {
    return view('welcome');
});


Route::prefix('accounts')->group(function(){
    Route::post('register', [AuthController::class, 'register'])->name('register');
    Route::post('login', [AuthController::class, 'login'])->name('login');
    Route::get('/accounts/{any}',[AuthController::class, 'index'])->where('any','.*');
});

It prevents for adding /route-name prefix here. If I add, it will return an error.

Thanks! Your help will be much appreciated.

I’m rather confused by how content scripts and background scripts in chrome ext interact, as I am able to make each work individually but not together

I have simplified and shortened my code so that it may be clear

manifest.json

{
  "manifest_version": 3,
  "action": {
    "default_popup": "popup.html"
  },
  "content_scripts": [
    {
      "matches": ["<all_urls>"],
      "js": ["contentscript.js"]
    }
  ],
  "background": {
    "js": "scroll.js"
  },
  "permissions": ["activeTab","tabs"]
}

contentscript.js

var scrollDirection = '';

// A way to read background.js

if(scrollDirection=='up'){
  scrollToTop();
}
else if(scrollDirection=='down'){
  scrollToBottom();
}

function scrollToTop() {
  console.log('u');
  setInterval(function() {
    window.scrollBy(0, 1);
  }, 10);
}

function scrollToBottom() {
  console.log('d');
  setInterval(function() {
    window.scrollBy(0, -1);
  }, 10);
}

scroll.js

var btnu = document.getElementById("ScrollU");
var btnd = document.getElementById("ScrollD");
var scrollDirection = '';

btnu.addEventListener('click', function() {
  scrollDirection = 'up';
  // A way to send a message to content.js
});

btnd.addEventListener('click', function() {
  scrollDirection = 'down';
  // A way to send a message to content.js
});

popup.html

<!DOCTYPE html>
<html lang="en">
  <head>
  </head>
  <body>
    <button id="ScrollU">Scroll Up</button>
    <button id="ScrollD">Scroll Down</button>    
    <script src="scroll.js"></script>
    <script src="contentscript.js"></script>
  </body>
</html>

Any Help would be appreciated 🙂 but I need to send a (chrome.tab message) or (window.message) (I tried both but they didn’t really work) or so and any formatting error or structural error you see. Thank you !

I know that my contentscript.js file can scroll a page, I know that my scroll.js can read button clicks, so it must be some sort off structural issue prohibiting the message between the two (assuming you can send one from contentscript to background) Like I said any help would be greatly appreaciated 🙂

JSON file problem pulling a single property at a time

I have a list of json objects

[
    {
        "Quest": "questlist.txt",
        "Path": "Quests/questlist.txt"
    },
    {
        "Quest": "questlistfolder.txt.bat",
        "Path": "Quests/questlistfolder.txt.bat"
    },
    {
        "Quest": "A Fairy Tale I",
        "Path": "Quests/A Fairy Tale I/AFairyTale1Info.txt"
    },
    {
        "Quest": "A Fairy Tale II",
        "Path": "Quests/A Fairy Tale II/AFairyTalePart2Info.txt"
    },
    {
        "Quest": "A Fairy Tale III",
        "Path": "Quests/A Fairy Tale III/AFairyTalePart3Info.txt"
    },
    {
        "Quest": "A Shadow over Ashdale",
        "Path": "Quests/A Shadow over Ashdale/AShadowOverAshdaleInfo.txt"
    }
]

and I am fetching the list like the usual with the variables
const questStepJSON = "/QuestList.json";

and an async function

const fetchStepList = async () => {
        try {
            const response = await fetch(questStepJSON);
            const file = await response.json();
            console.log(file);
        } catch (error) {
            console.error("Error fetching quest list:", error);
        }
    };

========================
RESULTS
(261) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, …]

const fetchStepList = async () => {
        try {
            const response = await fetch(questStepJSON);
            const file = await response.json();
            console.log(file[1]);
        } catch (error) {
            console.error("Error fetching quest list:", error);
        }
    };

========================
RESULTS
{Quest: ‘questlistfolder.txt.bat’, Path: ‘Quests/questlistfolder.txt.bat’}

I am unable to access either my Quest nor Path properties in my json file. I am stumped

in other words I cannot do

quest = file.path[1]

Select box appears as 2 when using select2 js

I have included the CSS & Javascript files for select2 JS included with the “OREO ADMIN TEMPLATE” (Google it). I am getting 2 select boxes. The top one is the select2 js selectbox which works like it should and the bottom is regular multiple select that comes with the OREO admin template. It’s like its duplicating. And I am not sure why or how.

enter image description here

Select box code in form:

<select class="form-control show-tick ms select2" id="countries" name="countries[]" multiple data-placeholder="Select GEO Target">
                                    @foreach($countries as $c)
                                        <option value="{{ $c->id }}">{{ $c->name }}</option>
                                    @endforeach
                                </select>

And I also included CSS at the top of the page:

<!-- Select2 -->
<link rel="stylesheet" href="/assets/plugins/select2/select2.css" />

And Javascript at the bottom. Yes, the jQuery 3.7.1 file is there.

<script src="/assets/plugins/select2/select2.min.js"></script> <!-- Select2 Js -->

I have checked and all files are in the correct location in the picture included you can see the styles are working.

I used this code to fire the select2:

<script>
    $(".select2").select2();
</script>

When i tried putting it in this format:

$(document).ready(function() {
        $(".select2").select2(); 
    });

It caused issues so I left it without the document-ready function.

Any clues?

Issue with MUI datagrid and dropdown component: Selected row always shows the last row

`I am junior developer, its first time I want to customize and use the MUI datagrid in deeply way and I have the following issue:
I am facing an issue with the Material-UI (MUI) datagrid and a dropdown component I have implemented. In my datagrid, I have action buttons in each row, and when I click on them, the selected row always shows as the last row, even though the console logs the correct clicked row data. However, when I remove the dropdown component and directly access the params, it works correctly.

Here is the relevant code snippet:

const Index = () => {
 
  const [anchorEl2, setAnchorEl2] = useState(null);
 
 
  const [selectedRow, setSelectedRow] = useState(null);



  const handleOpen = () => {
    setAddOpen(true);
  };

  const handleClick2Index = (event) => {
    setAnchorEl2(event.currentTarget);
  };

  const handleEdit = (params) => {
    console.log(params);
    setEditOpen(true);
    setSelectedRow({ name: params?.row?.name, description: params?.row?.description });
    setAnchorEl2(null);
  };
  const handleDelete = (params) => {
    console.log(params);
    setDeleteOpen(true);
    setSelectedRow({ name: params?.row?.name, description: params?.row?.description });
    setAnchorEl2(null);
  };

  const columns = [
    {
      field: 'name',
      headerName: 'Name',
      width: 200,
    },
    {
      field: 'description',
      headerName: 'Description',
      width: 200,
    },
    {
      field: 'action',
      headerName: 'Action',
      width: 100,
      renderCell: (params) => (
        <div>
          <button
            sx={{ width: '4', height: '4', borderRadius: '100%' }}
            onClick={handleClick2Index}
          >
            <IconDots />
          </button>
          {/* it is a dropdown(the issue) */}
          <Dropdown anchorEl2={anchorEl2} params={params} setAnchorEl2={setAnchorEl2}>
            {/* key error */}
            <ListItem onClick={() => handleEdit(params)}>
              <ListItemIcon>
                <IconEdit width={20} />
              </ListItemIcon>
              <ListItemText>Update</ListItemText>
            </ListItem>
            <ListItem onClick={() => handleDelete(params)}>
              <ListItemIcon>
                <IconTrash width={20} />
              </ListItemIcon>
              <ListItemText>Delete</ListItemText>
            </ListItem>
          </Dropdown>
        </div>
      ),
    },
  ];

  if (isFetching) return <Loader />;
  return (
    <PageContainer title="Categories" subtitle="Page">
      {addOpen && <AddCategory onOpen={addOpen} setOnOpen={setAddOpen} />}
      {editOpen && <EditCategory onOpen={editOpen} setOnOpen={setEditOpen} data={selectedRow} />}
      <DashboardCard
        headtitle="Categories List"
        title="Categories Management"
        subtitle="Page"
        cardheading="true"
        action={
          <Button
            variant="button"
            sx={{
          backgroundColor: 'primary.main',
          color: 'white',
          ':hover': { backgroundColor: 'primary.light', color: 'black' },
        }}
        onClick={handleOpen}
      >
        Add New
      </Button>
    }
  >
    <StyledMUIDataGrid data={data} columns={columns} />
  </DashboardCard>
</PageContainer>

);
};

export default Index;

I am selecting action buttons of the first row
but it shows the data of the last row
I suspect that the issue might be related to how I am using the params in the Dropdown component. The params parameter I being used to get the value of the current row, but it seems to be retaining the value of the last row clicked instead of the current row.

I have tried logging the params object, and it correctly shows the data for the clicked row. However, when I pass the params to the handleEdit or handleDelete functions, the selectedRow state variable is always set as the last row, not the current one.

I have also noticed that if I remove the dropdown component and directly access the params, everything works as expected.

Can someone help me identify the issue and suggest a solution? I believe the problem lies in how I am using the prams, but I’m not sure how to fix it.

Thank you in advance for your assistance.

is it possible to drag the entire parent div in to child div. Dragula jQuery

I created an HTML page with Dragula jQuery plugin. in this page there is 2 parent-div with peach color and each parent-div includes a child-div with blue color. is it possible to drag the entire parent-div in to another child-div. Currently the parent div not moving inside to a child div. looking for a solution.

[jsfiddle](https://jsfiddle.net/unni2003pj/2h5Lks0d/18/)

in this fiddle the parent-div and child-div are adding dynamically by button click.

[Dragula Documentation](https://github.com/bevacqua/dragula)
[references](https://codepen.io/gabouh/pen/ZXrMzW)
[references](https://codepen.io/trzmaxim/pen/GppXGE)
[references](https://codepen.io/zeedoti/pen/wgpxPV)

JS:

// item drag and drop

// Initialize Dragula on the container
var dragulaContainer = [].slice.apply(document.querySelectorAll('.bloc'));
var drake;

function itemDrag() {
    drake = dragula([].slice.apply(document.querySelectorAll('.bloc')), {
        direction: 'horizontal'
    });
}

function destroyitemDrag() {
    drake.destroy();
}

function dragulaInt() {
    dragula([document.querySelector('.container')], {
        moves: function(el, container, handle) {
        return !handle.classList.contains('bloc--inner');
        }
    }); 
}

(function() {
    
    dragulaInt()
    //itemDrag();
})();
  
// Add Column
  
var i=0;
var j=0;

let newColNode = null;

function addRow() {    
    const row = document.createElement('div');
    row.className = 'bloc';
    row.id = "b" + ++i;
    document.getElementById('contentBox').append(row);
    itemDrag()

    row.addEventListener('click', function (event) {
        console.log(newColNode)
        console.log(row)
        if(newColNode != null ){
           
            destroyitemDrag()
            itemDrag()
            
        }
        row.appendChild(newColNode);        
        newColNode = null
    });
}
  
// Column Addition

function addCol() {
    const col = document.createElement('div');
    col.className = 'bloc--inner';
    col.id = "c" + ++j;
    col.textContent = `Column ${j}`;
    newColNode = col;
}

HTML:

<div class="wrapper">


  <div class="main-content">

    <div class="header">
      <button class="add-row" onclick="addRow()">Add Row +</button>
      <button class="add-column" onclick="addCol()">Add Column +</button>
    </div>

    <div class="content-box" >

      <div class="container" id="contentBox">
      </div>
      
      <p>
      Note: Click add row then to add column, click add column button and select a added row box at bottom
      </p>
    </div>

  </div>
</div>

CSS:

* {
    box-sizing: border-box;
}

.wrapper {
    float: left;
    width: 100%;
    height: 100vh;
}

body {
    padding: 0;
    margin: 0;
    position: relative;
}
.main-content {
    float: left;
    width: calc(100%);
    height: 100%;
    background: #fafafa;
}
.header {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 20px;
}
.content-box {
    width: 100%;
    height: calc(100% - 60px);
    padding: 15px;
}
button {
    background: #000;
    border: 0;
    padding: 0 20px;
    height: 40px;
    margin-left: 10px;
    font-weight: 600;
    color: white;
    cursor: pointer;
}
.row-block {
    width: 100%;
    border: 2px dashed #848484;
    padding: 20px;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
    margin-bottom: 20px;

}
.row-block:hover {
    border-color: #2654d1;
}
.column-block {
    position: relative;
    width: 100%;
    min-height: 1px;
    padding-right: 10px;
    padding-left: 10px;
    margin: 0 10px;
    -ms-flex-preferred-size: 0;
    flex-basis: 0;
    -webkit-box-flex: 1;
    -ms-flex-positive: 1;
    flex-grow: 1;
    max-width: 100%;
    border: 2px dashed #848484;

    background-color: #dedede;
    padding: 20px;
}
.column-block:first-child {
    margin-left: 0;
}
.column-block:last-child {
    margin-right: 0;
}
.row-block .each-draggable-item {
    position: relative;
    width: 100%;
    min-height: 1px;
    padding-right: 10px;
    padding-left: 10px;
    -ms-flex-preferred-size: 0;
    flex-basis: 0;
    -webkit-box-flex: 1;
    -ms-flex-positive: 1;
    flex-grow: 1;
    max-width: 100%;
    margin-bottom: 0;
}
.gu-mirror {
    cursor: grabbing;
}
.container .ex-moved {
    background-color: #e74c3c;
}
.container.ex-over {
    background-color: rgba(255, 255, 255, 0.3);
}
.handle {
    background-color: rgba(0, 0, 0, 0.4);
    cursor: move;
    margin-right: 5px;
    padding: 0 5px;
}
.column-block h5 {
    margin: 0;
}
.gu-transit {
    opacity: 0.4;
    -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=20)";
    filter: alpha(opacity=20);
    transition: .3s ease-out;
}

.container {
    width: 100%;
}
.bloc {
    width: 100%;
    border: 2px dashed #848484;
    background: #ffefef;
    margin-bottom: 20px;
    padding: 20px;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
}
 .bloc--inner {
    margin: 0 10px;
    -ms-flex-preferred-size: 0;
    flex-basis: 0;
    -webkit-box-flex: 1;
    -ms-flex-positive: 1;
    flex-grow: 1;
    max-width: 100%;
    border: 2px dashed #848484;
    background-color: #d4ecff;
    padding: 20px;
}
.bloc--inner:first-child {
    margin-left: 0;
}
.bloc--inner:last-child {
    margin-right: 0;
}
.bloc--inner .bloc {
    margin: 0;
}

Pop Up Contact icon

How can i add pop up icon/message/button on a html, css, js website, which on click leads to the contact form page of website.
I’m not saying popup contact form just, pop up button which comes after a set interval of time ?

I made icon and attached link to contact form but unable to make it pop-up

Javascript with namespace in R Shiny

Does any one know how to put Javascript with namespace in R Shiny?
I create a Shiny module to add draggable text to Sankey plot, right click at the text will give an option to remove it from the plot. Everything works well except the add text button. I guess it’s due to the namespace issue. Can anyone find a solution for this?

I tried different ways without being able to resolve it

mod_graph_sankey_ui <- function(id) {
  ns <- NS(id)
  
  tabItem(
    id,
    
    shinydashboardPlus::box(
        width = 12,
        title = "File Upload (Node ID variable must be successive integers start from 0)",
        collapsible = TRUE,
        dropdownMenu = reset_dropdown(ns("reset_file")),
        fluidRow(
          column(6, fileInput(ns("sankey"), "Choose an input file", 
                              accept = file_accept))
        ),
        fluidRow(
          column(2, selectInput(ns("sankey_node"),   "Node",    NULL)),
          column(2, selectInput(ns("sankey_node_id"), "Node ID", NULL)),
          column(2, selectInput(ns("sankey_source"), "Source",  NULL)),
          column(2, selectInput(ns("sankey_target"), "Target",  NULL)),
          column(2, selectInput(ns("sankey_value"),  "Value",   NULL))
        )
        
    ),
    shinydashboardPlus::box(width = 12,
        title = "Plot Parameter",
        collapsible = TRUE,
        fluidRow(
          column(3, numericInput(ns('height'), "Plot Height", 400, min=400, max=8000, step=100)),
          column(3, numericInput(ns('width'), "Plot Width", 900, min=400, max=2000, step=100)),
          column(3, numericInput(ns('node_weight'), "Node Weight", 10, min=1, max=20, step=1)),
          column(3, numericInput(ns('pad'), "Node Pad", 15, min=5, max=30, step=1)),
          column(3, numericInput(ns('transparency'), "Transparency", 0.6, min=0.1, max=1, step=0.1)),
          column(9, textInput(ns('title'), "Title", NULL))
        )
    ),
    shinydashboardPlus::box(width = 12,
                            collapsible = TRUE,
                            title = 'Customize the Colors for Sources',
                            fluidRow(
                              column(12, uiOutput(ns("color_input")))
                            )
    ),
    
    
    tags$head(
      tags$script(HTML('
      Shiny.addCustomMessageHandler("#{ns("addDraggableText")}", function(message) {
      console.log("Updating text:", newText.id);
Plotly.update(newText.id, { textfont: { size: newSize } });
        var text = message.text;
        var x = message.x;
        var y = message.y;
        var id = message.id;
        
        var newText = document.createElement("div");
        newText.style.position = "absolute";
        newText.style.left = x + "px";
        newText.style.top = y + "px";
        newText.style.cursor = "move";
        newText.innerText = text;
        newText.id = id;
        
        newText.addEventListener("mousedown", function(e) {
          var posX = e.clientX;
          var posY = e.clientY;
          document.onmousemove = function(e) {
            var dx = e.clientX - posX;
            var dy = e.clientY - posY;
            posX = e.clientX;
            posY = e.clientY;
            newText.style.left = (newText.offsetLeft + dx) + "px";
            newText.style.top = (newText.offsetTop + dy) + "px";
          }
          document.onmouseup = function() {
            document.onmousemove = document.onmouseup = null;
          }
        });

        // Add context menu
        newText.addEventListener("contextmenu", function(e) {
          e.preventDefault();
          var menu = document.createElement("div");
          menu.id = "contextMenu";
          menu.style.position = "absolute";
          menu.style.left = e.clientX + "px";
          menu.style.top = e.clientY + "px";
          
          var fontSizeOption = document.createElement("div");
          fontSizeOption.innerText = "Change Font Size";
          fontSizeOption.addEventListener("click", function() {
            var newSize = prompt("Enter new font size:");
            if (newSize !== null) {
              Plotly.update(newText.id, {textfont: {size: newSize}});
            }
            menu.remove();
          });

          var removeOption = document.createElement("div");
          removeOption.innerText = "Remove Text";
          removeOption.addEventListener("click", function() {
            newText.remove();
            menu.remove();
          });

          menu.appendChild(fontSizeOption);
          menu.appendChild(removeOption);
          document.body.appendChild(menu);
        });

        document.getElementById("#{ns("sankey_plot")}").appendChild(newText);
      });

    '))
    ),
    
    titlePanel("Draggable Text on Graph"),
    sidebarLayout(
      sidebarPanel(
        textInput(ns("text"), "Enter Text"),
        actionButton(ns("addText"), "Add Text to Graph"),
        textOutput(ns("removeInstruction")),
      ),
    
      shinydashboardPlus::box(width = 12,
                              title = "Sankey Plot",
                              plotlyOutput(ns("sankey_plot"))
      )
    )
  )
}



mod_graph_sankey_server <- function(id) {
  moduleServer(id, function(input, output, session) {
    ns <- session$ns
      
      rv <- reactiveValues(
        df_sankey = NULL,
      )
      

      #Function to create Tepee plot
      sankey <- function(indata)
      {
        #var1 <- input$sankey_node
        #print(var1)

        #input_data <- indata
        input_data <- indata %>%
          mutate(node := !!sym(input$sankey_node)) %>%
          mutate(node_id := !!sym(input$sankey_node_id)) %>%
          mutate(source := !!sym(input$sankey_source)) %>%
          mutate(target := !!sym(input$sankey_target)) %>%
          mutate(value := !!sym(input$sankey_value))          

        input_data <- select(input_data, node, node_id, source, target, value)

        
        #######################################################################################
        ##################################### Create plot #####################################
        #######################################################################################

        # input_data$source contains integers which represent node, need to get node names to be displayed in
        # color selection section, so user knows which node he/she is choosing color for
        node_name <- input_data %>%
                     select(node_id, node) %>%
                     subset(node!='' & !is.na(node)) %>%
                     arrange(node_id)

        # This data frame contains all node which may not be source
        source_name <- rename(node_name, source=node_id)

        # After merge, this data frame contains only the node which can be source
        source_name <- merge(source_name, select(input_data, source), by='source')

        
        source_name_dedup <- source_name %>% 
          distinct(source, .keep_all = TRUE) %>%
          arrange(source)

        # Node can relate to different Node ID, this happens when a therapy (represented by node) can be displayed at
        # the 1st LOT, 2nd LOT, etc. In this case, links flow from them will use the same color. 
        funs <- unique(source_name$node)
        

        
        default_color <- colors()
        cols <- reactive({
          lapply(seq_len(length(funs)), function(i) {
            column(3, colourInput(ns(paste("col", i, sep="_")), funs[i], default_color[i])   )     
          })
        })
        
        output$color_input <- renderUI({cols()})  
        
        # Put all the input in a vector
        colors2 <- reactive({
          lapply(seq_len(length(funs)), function(i) {
            input[[paste("col", i, sep="_")]]
          })
        })
        
        updated_color <- unlist(colors2())
        req(updated_color)
        
        default_color <- updated_color
        if (length(default_color) != length(funs)) {default_color<-colors()}
        
        
        updated_color2 <- paste(sapply(updated_color, function(x) 
                                       {paste0("rgba(", paste(c(col2rgb(x), input$transparency), collapse = "," ), ")") }
                                ), collapse = ", ")
        
        updated_color3 <- vector(length = length(funs))
        test <- strsplit(updated_color2, split=', ')
        for (i in 1:length(funs)) {
          updated_color3[i] <- test[[1]][i]
        }

        color_data <- data.frame(node=unique(source_name$node),
                                 link_color=updated_color3)
        # Due to the fact that node can relate to different Node ID, in the above data frame, we use
        # node=unique(source_name$node) instead of source=unique(source_name$source)
        # Now, need to merge back to get source (which are integers)
        color_data <- merge(color_data, source_name_dedup, by='node')

        input_data <- merge(input_data, select(color_data, -c('node')), by='source', all.x=T)

        
        # Create plot
        p <- plot_ly(
          type = "sankey",
          domain = c(
            x =  c(0,1),
            y =  c(0,1)
          ),
          orientation = "h",
          valueformat = ".0f",
          valuesuffix = " ",
          
          node = list(
            label = node_name$node,
            color = 'black',
            pad = input$pad,
            thickness = input$node_weight,
            line = list(
              color = "black",
              width = 0.5
            )
          ),
          
          link = list(
            source = input_data$source,
            target = input_data$target,
            value =  input_data$value,
            color =  input_data$link_color
          )
        ) %>% 
          layout(
            title = input$title,
            height = input$height,
            width = input$width,
            font = list(
              size = 12
            ),
            xaxis = list(showgrid = F, zeroline = F, showticklabels = F),
            yaxis = list(showgrid = F, zeroline = F, showticklabels = F)
          )
        
        # ggplotly(p, height=input$height)
          p
      }
      #End of the plot function
      
      
      observe({
        req(input$sankey)
        rv$df_sankey <- upload_file(input$sankey)
      })
      
      # Reset fileInputs
      observeEvent(input$reset_file, {
        rv$df_sankey <- NULL
        reset("sankey")
      })
      
      main1 <- reactive({
        req(rv$df_sankey)
        process_file(rv$df_sankey)
      })
      
      observeEvent(input$sankey, {
        var_name <- names(rv$df_sankey)
        default_node      <- grep("^la", var_name, TRUE, value = TRUE)
        default_node_id   <- grep("^lid", var_name, TRUE, value = TRUE)
        default_source    <- grep("^s", var_name, TRUE, value = TRUE)
        default_target    <- grep("^t", var_name, TRUE, value = TRUE)
        default_value     <- grep("^v", var_name, TRUE, value = TRUE)
        
        updateSelectInput(session, "sankey_node",    choices = var_name, selected=default_node)
        updateSelectInput(session, "sankey_node_id", choices = var_name, selected=default_node_id)
        updateSelectInput(session, "sankey_source",  choices = var_name, selected=default_source)
        updateSelectInput(session, "sankey_target",  choices = var_name, selected=default_target)
        updateSelectInput(session, "sankey_value",   choices = var_name, selected=default_value)
      })
        
      output$removeInstruction <- renderText({
        "Right-click on the text to access the context menu for additional options."
      })
      
      ##############################################################################################################
      ###Generate Plot Parameter Input Box (X-axis range, step by value) depend on which efficacy data you upload###
      ##############################################################################################################
      observe({
        output$sankey_plot <- renderPlotly({
          sankey_data <- main1()
          req(sankey_data)
          sankey(indata=sankey_data)
        })
      })
      
      observeEvent(input$addText, {
        text <- input$text
        x <- 0
        y <- 0
        id <- paste0("text_", format(Sys.time(), "%H%M%S"))
        
        print(text)
        print(x)
        print(y)
        print(id)
        
        if (nchar(text) > 0) {
          session$sendCustomMessage("addDraggableText", list(text = text, x = x, y = y, id = id))
        }
      })
    })
}

A simplified version without using namespace works well:

library(shiny)
library(plotly)

ui <- fluidPage(
  tags$head(
    tags$script(HTML('
      Shiny.addCustomMessageHandler("addDraggableText", function(message) {
        var text = message.text;
        var x = message.x;
        var y = message.y;
        var id = message.id;
        
        var newText = document.createElement("div");
        newText.style.position = "absolute";
        newText.style.left = x + "px";
        newText.style.top = y + "px";
        newText.style.cursor = "move";
        newText.innerText = text;
        newText.id = id;
        
        newText.addEventListener("mousedown", function(e) {
          var posX = e.clientX;
          var posY = e.clientY;
          document.onmousemove = function(e) {
            var dx = e.clientX - posX;
            var dy = e.clientY - posY;
            posX = e.clientX;
            posY = e.clientY;
            newText.style.left = (newText.offsetLeft + dx) + "px";
            newText.style.top = (newText.offsetTop + dy) + "px";
          }
          document.onmouseup = function() {
            document.onmousemove = document.onmouseup = null;
          }
        });

        // Add context menu
        newText.addEventListener("contextmenu", function(e) {
          e.preventDefault();
          var menu = document.createElement("div");
          menu.id = "contextMenu";
          menu.style.position = "absolute";
          menu.style.left = e.clientX + "px";
          menu.style.top = e.clientY + "px";
          
          var fontSizeOption = document.createElement("div");
          fontSizeOption.innerText = "Change Font Size";
          fontSizeOption.addEventListener("click", function() {
            var newSize = prompt("Enter new font size:");
            if (newSize !== null) {
              Plotly.update(newText.id, {textfont: {size: newSize}});
            }
            menu.remove();
          });

          var removeOption = document.createElement("div");
          removeOption.innerText = "Remove Text";
          removeOption.addEventListener("click", function() {
            newText.remove();
            menu.remove();
          });

          menu.appendChild(fontSizeOption);
          menu.appendChild(removeOption);
          document.body.appendChild(menu);
        });

        document.getElementById("plot").appendChild(newText);
      });

    '))
  ),
  titlePanel("Draggable Text on Sankey Diagram"),
  sidebarLayout(
    sidebarPanel(
      textInput("text", "Enter Text"),
      actionButton("addText", "Add Text to Sankey"),
      textOutput("removeInstruction")
    ),
    mainPanel(
      plotlyOutput("plot")
    )
  )
)

server <- function(input, output, session) {
  output$removeInstruction <- renderText({
    "Right-click on the text to access the context menu for additional options."
  })
  
  output$plot <- renderPlotly({
    # Sample Sankey diagram
    fig <- plot_ly(
      type = "sankey",
      domain = c(
        x =  c(0,1),
        y =  c(0,1)
      ),
      orientation = "h",
      node = list(
        label = c("A", "B", "C", "D", "E")
      ),
      link = list(
        source = c(0, 1, 0, 2, 3),
        target = c(2, 3, 4, 4, 4),
        value = c(8, 4, 2, 8, 4)
      )
    )
    
    fig
  })
  
  observeEvent(input$addText, {
    text <- input$text
    x <- 100  # X-coordinate for initial position
    y <- 100  # Y-coordinate for initial position
    id <- paste0("text_", format(Sys.time(), "%H%M%S"))
    
    print(text)
    print(x)
    print(y)
    print(id)
    
    
    if (nchar(text) > 0) {
      session$sendCustomMessage("addDraggableText", list(text = text, x = x, y = y, id = id))
    }
  })
  
}

shinyApp(ui, server)

enter image description here

How do I use javascript to insert text into a text element inside svg element in html?

I am a javascript newbie and have been using document.getElementById(“someID”).innerHTML to insert text into

elements.
Now I have an svg image inside which contains a element into which I want to insert text. The following shows what I have tried, but which does not work.

` `
` `
` `// some script stuff
` `document.getElementById(“textID”).innerHTML = “Hello World!”;
` `// more script stuff
` `
` `
` `
` `// some stuff
` `
` `// svg stuff
` `
` `// more svg stuff
` `
` `
`

Any suggestions on how I can use javascript to get text into the text element?

I included what I tried in the body of the question. I was expecting the getElementById text to appear in the appropriate place in the svg image.

About a popup on the map in OpenLayers

I have a question about OpenLayers.
I want to display a popup on a map as shown in the figure.
Then I scroll to the right side and after one round of the globe, the popup is no longer displayed.
The icon is still displayed.
Is this a specification?
Or am I making it the wrong way?
enter image description here

Venom Bot – Problem With SendFiles, “Error to processFiles”

In the code below I’m trying to send a PDF, it’s giving me the following error
node version: 20.9.0
venom-bot version: 5.0.22

app.post('/send-pdf',[
 body('number').notEmpty(),
 ], async (req, res) => {
 const errors = validationResult(req).formatWith(({
 msg
 }) => {
 return msg
 })
    if(!errors.isEmpty()){
        return res.status(422).json({
            status: false,
            message: errors.mapped()
        });
    }
    
    const number = req.body.number;
    const path ='./curso.pdf'
    const fileName = 'Curso';
    const description = 'curso auto';

    //client.sendText(number,message);
    client.sendFile(number,path,fileName,description).then(response => {
        res.status(200).json({
            status: true,
            message: 'Mensagem enviada',
            response: response
        });
    }).catch(err => {
        res.status(500).json({
            status: false,
            message: 'Mensagem não enviada',
            response: err.text
        });
    });
    //res.send('Mensagem enviada');
})  


ERRO:

"me": {
    "id": {
        "server": "c.us",
        "user": "557788890834",
        "_serialized": "[email protected]"
    },
    "displayName": null,
    "verifiedName": null,
    "searchName": null,
    "pushname": "Igor",
    "notifyName": null,
    "isBusiness": null,
    "formattedUser": null,
    "tag": "1697060691",
    "eurl": "https://pps.whatsapp.net/v/t61.24694-                                             24/384857814_1377715469846899_8485044292930854182_n.jpg?ccb=11-4&oh=01_AdT3wwl9xqvMsS_lDs-      wuzxjh0uuIY4Bndu0dXyrhCBLyA&oe=65651B11&_nc_sid=e6ed6c&_nc_cat=105",
    "previewEurl": "https://pps.whatsapp.net/v/t61.24694-24/384857814_1377715469846899_8485044292930854182_n.jpg?stp=dst-jpg_s96x96&ccb=11-4&oh=01_AdQ2wlC95WTnG1oztzgpqA_3UuuUCFtqLN8RT8h21QuLWQ&oe=65651B11&_nc_sid=e6ed6c&_nc_cat=105",
    "fullDirectPath": "/v/t61.24694-24/384857814_1377715469846899_8485044292930854182_n.jpg?ccb=11-4&oh=01_AdT3wwl9xqvMsS_lDs-wuzxjh0uuIY4Bndu0dXyrhCBLyA&oe=65651B11&_nc_sid=e6ed6c&_nc_cat=105",
    "previewDirectPath": "/v/t61.24694-24/384857814_1377715469846899_8485044292930854182_n.jpg?stp=dst-jpg_s96x96&ccb=11-4&oh=01_AdQ2wlC95WTnG1oztzgpqA_3UuuUCFtqLN8RT8h21QuLWQ&oe=65651B11&_nc_sid=e6ed6c&_nc_cat=105",
    "filehash": "M6RwDPMQ9u1O5XnuoQI2MKNgSYdHqdTkTYfpxH1Zilg=",
    "stale": false,
    "eurlStale": false,
    "timestamp": 1700268717737,
    "hostRetryCount": 0,
    "lastHostUsed": {
        "hostname": "media-for1-1.cdn.whatsapp.net",
        "ips": [
            {
                "ip4": "157.240.216.60",
                "ip6": "2a03:2880:f259:c8:face:b00c:0:167"
            }
        ],
        "type": "primary",
        "class": "pop",
        "downloadBuckets": [
            0
        ],
        "_supportedDownloadTypes": {},
        "_supportedUploadTypes": {},
        "fallback": {
            "hostname": "media-gig4-2.cdn.whatsapp.net",
            "ips": [
                {
                    "ip4": "31.13.91.60",
                    "ip6": "2a03:2880:f27c:1cd:face:b00c:0:167"
                }
            ],
            "type": "fallback",
            "class": "pop",
            "downloadBuckets": [
                0
            ],
            "_supportedDownloadTypes": {},
            "_supportedUploadTypes": {},
            "fallback": null
        },
        "selectedBucket": 102
    }
},
"to": {
    "server": "c.us",
    "user": "557781107704",
    "_serialized": "[email protected]"
},
"erro": true,
"text": "Error to processFiles",
"status": 404

}
}

Error to processFiles, it’s a pdf it’s working, the file is in this path ‘D:portifa/venom/curso.pdf’, but for some reason it’s not being able to process, and I couldn’t find a possible solution anywhere(I’ve tried to insert the path, in different ways), I was able to send buttons and messages on other routes, but for some reason this file and no other are being processed

Has anyone ever had this problem?

I tried to send a PDF, following the steps in the reference documentation, but for some reason it cannot be processed, I tried with other files and the result was the same.

Referencing an imported font URL from a script

I am trying to use the pdfmake package in an app; in order to load fonts, a list of URLs is provided at initialization. But my fonts are managed by npm and Vite, so do not have fixed URLs. Here’s where I’ve gotten so far:

npm install @fontsource/source-sans-pro

In app.js:

import pdfMake from "pdfmake/build/pdfmake";
import "@fontsource/source-sans-pro/latin-400.css"
import "@fontsource/source-sans-pro/latin-400-italic.css"
import "@fontsource/source-sans-pro/latin-700.css"
import "@fontsource/source-sans-pro/latin-700-italic.css"

pdfMake.fonts = {
    SourceSans: {
        normal: "", // need to provide URLs for the WOFF files
        bold: "",
        italics: "",
        bolditalics: ""
    },
};

When I run npm run build I get this in the output:

✓ 636 modules transformed.
public/build/manifest.json                                               6.12 kB
public/build/assets/source-sans-pro-latin-400-italic-500f8aaf.woff2     14.16 kB
public/build/assets/source-sans-pro-latin-700-italic-fae9ee8d.woff2     14.20 kB
public/build/assets/source-sans-pro-latin-700-normal-0d0a6262.woff2     14.71 kB
public/build/assets/source-sans-pro-latin-400-normal-7b348b30.woff2     14.89 kB
public/build/assets/source-sans-pro-latin-700-italic-1933b21f.woff      17.68 kB
public/build/assets/source-sans-pro-latin-400-italic-c3707996.woff      17.76 kB
public/build/assets/source-sans-pro-latin-700-normal-bcc2a2ed.woff      18.39 kB
public/build/assets/source-sans-pro-latin-400-normal-69491b82.woff      18.42 kB

So the fonts are easily accessible at, e.g. https://example.com/build/assets/source-sans-pro-latin-400-normal-69491b82.woff but of course this is a dynamic URL.

How can I get that URL for use by my script?

Infinite Scrolling creates pagination sublink as I scroll

I’ve finally worked out Infinite Scrolling thanks to what lharby has commented on my last post.
Thank you so much!
The problem is that the script creates a new pagination link as I exceeded scrolling for 15 posts (the amount of posts-per-page that I set for my Tumblr)
f.e : assets.txmblr.com =======> assets.txmblr.com /page/(2;3;4;…)
Thank you for the help !

Code (line 210 -> line 225)

        <script>
window.onload = function() {
var elem = document.getElementById('content');
let infScroll = new InfiniteScroll(elem, {
path: '.pagination__next',
append: '.post'
});
}
</script>
</head>

<body>
{block:NextPage}
<a href="{NextPage}" class="pagination__next"></a>
{/block:NextPage}

Bootstrap Classes are undefined in Javascript

I am using Bootstrap 5.3.0 and have imported it via CDN links into my JS script. However, when I try to create a an object I get an error that the bootstrap class does not exist. Here is my code to initialize the new instance of the class:

  const bsContactMenu = new bootstrap.Offcanvas('#contactMenu');

Here is the error from the dev tools in the browser:

Uncaught TypeError: Cannot read properties of undefined (reading 'Offcanvas')
    at AllInOne (<anonymous>:176:39)
    at <anonymous>:611:17

However if you look at this exact class in the developer Tools->Watch, it is defined so I know the bootstrap class definitions were imported correctly from CDN link. Why then am I getting an error showing it as undefined?

Watch from Developer Tools

Watch from Developer Tools

I expect that the bootstrap.Offcanvas class should be resolved in the browser since the developer tools show that it is defined in the DOM.