document.addEventListener(‘webOSLaunch’, function(inData) {}) not triggering in WebOS 4.x TVs

  1. I am developing a webOS TV app in react.js called appA.
  2. I have a partner TV app called appB which hosts the contents of appA.
  3. When the user clicks my content in appB, it launches my appA along with the details of the content clicked.
  4. In my appA, I have used “document.addEventListener(‘webOSLaunch’)” listener in index.html’s in the body section to listen to this event like shown below:
document.addEventListener("webOSLaunch", function (inData) {
        console.log("WebOSLaunch event triggered.");
        if(inData.detail){
          //rest of the code to call API with the data received
        }
      })
  1. This works fine in WebOS TV 5 and above.
  2. In WebOS TV 4.x the eventListener is not triggered at all. There is no errors thrown in the console. What could be the reason?

I tried logging, setting breakpoints, but does not work.

Django admin doesn’t load Static files but folder is there in Azure cloud

I deployed a Django project in an Azure web App which doesn’t load the styles and static files in admin interface.
According to this posts Django doesn’t serve static files in production (when Debug is false), it suggests to configure the web server to the static files (Apache or Nginx).

The thing is, how to show the django admin static files in an Azure web App?
Thanks.

how to reset function when value changes?

#line2 {
      display: flex;
      margin-bottom: 1.4vh;
      width: 10vh;
      background-color: aquamarine;
      overflow: hidden;
      white-space: nowrap;
      clip-path: inset(0% 0%);
    }

<p id="line2"><span class="test-text">this is the original text.</span></p>

var testText = $('.test-text');
function wallpaperMediaPropertiesListener(event) {
// event.title receives a random string at a random time.
  if (!event.title) {
    testText.text('u200B');
  } else {
    testText.text(event.title);

    var textWidth = testText.outerWidth();
    let gapSize = 30;
    
    if (textWidth > $('#line2').width()) {
      var testTextCopy = $('<div></div>')
        .addClass('test-text-copy')
        .css({
          'margin-left': gapSize,
        })
        .insertAfter(testText)
        .text(testText.text());


      function animateText() {
        setTimeout(function() {
          testText.animate({ 'margin-left': -(textWidth + gapSize)}, {
            duration: textWidth * 30,
            easing: 'linear',
            complete: function() {
              testText.css('margin-left', 0);
              animateText();
            }
          });
        }, 1000);
      }

      animateText();
    }
  }
}
window.wallpaperRegisterMediaPropertiesListener(wallpaperMediaPropertiesListener);

If event.title receives a new string even if the animation is in progress, I want animation to be interrupted and restarted with the new string (check if (textWidth > $(‘#line2’).width()) for new string, width and copy are of the new string too).

I need to transpose some columns in Google Sheet

I have the following Google Sheet:
https://docs.google.com/spreadsheets/d/1QyGZQEAuY6_YMtPGR3oUykjArTiQ6OK82A-YCrnEuxI/edit#gid=0

Every month I add a new month’s data in the first sheet and I need to automate the structure to make it look like the 2nd sheet somehow. The month columns need to turn into rows so I could visualise it properly in Looker Studio.

I am open to slightly restructure the first sheet, use any formulas out there or use an app script.

Would you please guide me? thanks.

I tried to transpose it but it just switched the columns with rows

Why does FCM’s onMessage() need to be wrapped in a Promise?

Can someone explain the reason that FCM’s onMessage() does not behave in a similar manner to Firestore’s onSnapshot() or Auth’s onAuthStateChanged()?

The latter two start up a “listener” that remains running and when data arrives each invokes their callback, and the listeners keep going until they are shutdown. But it seems that to get onMessage() to run properly it needs to be re-invoked after each message is received?

Or maybe I’m just not properly understanding the reason that to be successful it seems I need to wrap a call to onMessage in a Promise or an async IIFE:

(async () => {
    return onMessage(getMessaging(), (payload: MessagePayload) => {
        console.log(`App() - onMessage() - got payload:`, payload);
        setNotificationPayload([{ data: payload, open: true }]);
    });
})()

or a similar pattern I see in various tutorials/blogs is:

export const onMessageListener = () =>
  new Promise((resolve) => {
    messaging.onMessage((payload) => {
      resolve(payload);
    });
  });

Where I am confused is that these calls are being put directly into components so that they re-run with every render of the component, whereas the other listeners in Firebase-land seem to be started, stopped and protected against re-execution by use of a useEffect().

Or maybe I’m just massively confused right now…

How to listen for changes in the input choice set of an adaptive card?

I have been making a teams bot using Bot framework sdk 4.0 and Node JS.
i have this adaptive card with an image and input selection choices as a drop down and selecting and clicking the update button (which is an action.submit button) will update the image in the adaptive card.
enter image description here

I want to make it so that instead of having to click the update button i want it to trigger the update function when the selection is made from the dropdown list.

How do i listen for the selection in the dropdown list in the bot?

Cannot read properties of undefined (reading ‘commit’)

I believe I did everything right, this is killing me!!!
I’m learning Vue2 rn, this is a part of a login system practice project I’m working on.
Basically after entering username and password, when hitting the button, this warning jumps out.

enter image description here

Here is the methods segment of src/views/Login/Login.vue

methods: {
  login() {
    this.$refs.loginForm.validate(async (valid) => {
      if (!valid) return;
      const {
        data: { userId: res },
      } = await this.$http.get(
        'https://jsonplaceholder.typicode.com/posts/1'
      );
      console.log(res);
      if (res === 1) {
        this.$message.success('Success!');
        this.$store.commit('user/updateToken', res);
        this.$router.push('/main');
      }
    });
  },
},

here is the src/store/index.js

import Vue from 'vue';
import Vuex from 'vuex';

import user from './user';
Vue.use(Vuex);

export default new Vuex.Store({
  state: {},
  getters: {},
  mutations: {},
  actions: {},
  modules: {
    user,
  },
});

Here is the src/store/user.js

export default {
  namespaced: true,
  state: {
    token: '',
  },
  mutations: {
    updateToken(state, res) {
      state.token = res;
      localStorage.setItem('token', res);
    },
  },
  actions: {},
  getters: {},
};

Here is src/router/index.js

import Vue from 'vue';
import VueRouter from 'vue-router';
import Reg from '../views/Reg/Reg.vue';
import Login from '../views/Login/Login.vue';
import Main from '../views/Main/Main.vue';
Vue.use(VueRouter);

const routes = [
  {
    path: '/',
    redirect: '/login',
  },
  {
    path: '/reg',
    component: Reg,
  },
  {
    path: '/login',
    component: Login,
  },
  {
    path: '/main',
    component: Main,
  },
];

const router = new VueRouter({
  routes,
});

export default router;

Here is the src/main.js

import Vue from 'vue';
import App from './App.vue';
import router from './router';
import store from './store';
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import './assets/global.less';
import axios from 'axios';

//安裝elementUi
Vue.use(ElementUI);

//將axios掛在到原型prototype上,全局使用
Vue.prototype.$http = axios;

Vue.config.productionTip = false;
new Vue({
  router,
  store,
  render: (h) => h(App),
}).$mount('#app');

I tried asking chatGPT, I sent all my codes to it, and it didn’t seem to be capable of finding the problem. So I have to turn to you guys, who’s obviously more intelligent and experienced!

Simplify Element Class Toggling

I have this line of code in javascript to select multiple classes to toggle dark mode theme:

let header = document.querySelector('header'),
    mobile = document.querySelector('.mobile'),
    themeButton = document.querySelector('.theme'),
    navbar = document.querySelector('.navbar'),
    videoContainer = document.querySelector('.video-container'),

themeButton.addEventListener('click', () => {
  header.classList.toggle('dark-mode');
  mobile.classList.toggle('dark-mode');
  navbar.classList.toggle('dark-mode');
  videoContainer.classList.toggle('dark-mode');
});

can I simplifiy it so it doesnt take too long? This is my github links if you’re interested: text

How do I check if CSS @layer is supported in CSS and Javascript?

So I know that @support and CSS.supports can be used to check if certain features is available but I cannot in anyway make it works to detect if CSS @layer is available or not. I am 100% sure my browser supports it but the following checks all return false:

console.log(CSS.supports("@layer"))
console.log(CSS.supports("layer"))
console.log(CSS.supports("layer: 1"))
console.log(CSS.supports("layer", 1))
p {
  color: rebeccapurple;
}

@layer type {
  .box p {
    font-weight: bold;
    font-size: 1.3em;
    color: green;
  }
}
<div class="box">
  <p>Hello, world!</p>
</div>

The above text shows as purple for me so I know @layer works and DevTools’ CSS Layer button shows up. However all the tests are false.

What is the correct prompt for this check?

How come the scroll feature does not work?

I’m still very new to coding so I’m not really experienced enough to see exactly what the problem is.

Part 1 of 3:

First, allow me to share with you, how the scrolling feature DOES work. This is the scrolling feature’s CSS, JavaScript, and HTML:

document.addEventListener("DOMContentLoaded", function() {
  const scrollElement = document.querySelector('.LoopingScrollv3');
  let originalContent = scrollElement.innerHTML;
  let contentToAdd = originalContent;

  scrollElement.addEventListener('scroll', function() {
    let atRightEnd = (scrollElement.scrollWidth - scrollElement.scrollLeft - scrollElement.clientWidth) < 50;

    if (atRightEnd) {
      scrollElement.innerHTML += contentToAdd;
    }
  });
});
.parent {
  background: mediumpurple;
  padding: 1rem;
}

.child {
  border: 1px solid indigo;
  padding: 1rem;
}

.inline-block-child {
  display: inline-block;
}

.FR {
  float: right;
}

.LoopingScrollv3 {
  overflow-x: auto;
  white-space: nowrap;
  max-width: 250px;
}

#GeneralTextBox01 {
  background: #DDD;
  display: inline-block;
  height: 100px;
  padding: 15px;
  vertical-align: bottom;
  width: 100px;
}
<!doctype html>
<html lang="en">
 <head>
  <title>??????? </title>
  <link rel="stylesheet"
   href="style.css">
 </head>
 <body>

<div class='parent'>
  <div class='child inline-block-child'><h1>Welcome! </h1></div> 
  <div class="child inline-block-child FR" align="center"><h2>Testing A</h2>
  <table class="table"> 
    <thead>
      <tr class="active">
        <th class="LoopingScrollv3"> Image01 Image02 Image03 Image04 Image05 Image06 Image07 Image08 Image09 Image10 Image11 Image12 Image13 Image14 Image15 Image16 Image17 Image18 Image19 Image20 Image21</th> 
      </tr> 
    </thead> 
</table>
</div>
</div>


  <script src="script.js">
  </script>
 </body>
</html>

Part 2 of 3: Now here is the Scrolling Feature when plugged in to its proper home (“within entry of Testing06.01”):

<!DOCTYPE html>
<html lang="en">
<head>

  <title>WHY IS THIS NOT WORKING!?</title>
  <meta charset="utf-8"> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">     
</head>
  <body>     

<div class="container"> 
  <div class="row">
    <div class="col-sm-3"><center>Testing 01</center></div> 
    <div class="col-sm-6"><center>Testing 02</center></div>
    <div class="col-sm-3"><center>Testing 03</center></div>
  </div>

  <div class="row">
    <div class="col-sm-3"><center>Testing 04</center></div>
    <div class="col-sm-2 GeneralTextBox01"><center>Testing05</center></div>
    <div class="col-sm-4"><center>Testing06</center>
            <div class="child inline-block-child FR" align="center"> <h2>Testing06.01</h2>
              <table class="table"> 
                <thead>
                  <tr class="active">
                    <th class="LoopingScrollv3"> Image01 Image02 Image03 Image04 Image05 Image06 Image07 Image08 Image09 Image10 Image11 Image12 Image13 Image14 Image15 Image16 Image17 Image18 Image19 Image20 Image21</th>  <!-- Why is this not implementing the scroll? -->
                  </tr> 
                </thead> 
            </table>
            </div>
    </div>
    <div class="col-sm-3"><center>Testing 07</center></div>
  </div>

  <div class="row">
    <div class="col-sm-3"><center>Testing 08</center></div> 
    <div class="col-sm-6"><center>Testing 09</center></div>
    <div class="col-sm-3"><center>Testing 10</center></div>
  </div>

  <script src="script.js">
  </script>
 </body>

</html>

Part 3 of 3: i am not sure what i’m doing wrong. Does anyone know why the scrolling feature that appeas in part 1 of 3, on why it is not showing up on part 2 of 3? For here is how it shows up: https://i.stack.imgur.com/hZMuW.jpg

There is a problem with mapbox display and hiding

I am currently using mapbox, a js library, for development. There are multiple layers in my source data. One of the layers has layout[‘visibility’] = ‘none’. After I render it, I modify it through setLayoutProperty. is ‘visible’ but the layer is not displayed

I tried reloading the map after modifying the properties, but it didn’t work.I hope someone can help me solve it, I will be very grateful.

How to plot a matrix chart in Javascript?

I want to draw a matrix chart that should look like thisenter image description here

Is there any javascript library that can draw a chart like this or do I need to make it custom? If so how and where should I start? Any advice will be helpful. Thanks

I tried searching for a library that can draw a matrix chart like the picture shown but failed to find one.

SignalR JS Events not Firing

Bit of a strange one this, I have signalR installed and I am getting all the network messages (by examining them with chrome dev tools), even the ‘ping / pong’ messages keeping the connection alive, but I cant for the life of me get the events to fire in jquery.
I have tried 2 different ways:

var chat = $.connection.chatHub;
$.connection.hub.logging = true;
$.connection.hub.error(function (error) {
console.log('SignalR error:', error)
chat.client.ReceiveMessage = function (name, message, count) {
    console.log("proto message");
    console.log(count + " " + name + ": " + message);
} 
chat.on("ReceiveMessage", (user, message, count) => {
    console.log(count);
    var encodedUser = $("<div />").text(user).html();
    var encodedMessage = $("<div />").text(message).html();
    var li = "<li><strong>" + encodedUser + "</strong>: " + encodedMessage + "</li>";
    $("#messages").append(li);
});
    $.connection.hub.start({ transport: ['webSockets', 'longPolling'] }).done(function () {
    console.log("connected");
    console.log($.connection.hub);
});

I put another parameter onto the MessageReceived function to give a message count, just to see if I was actually communicating.
Here is my hub:

Module ChatCount
    Public count As Integer = 0
End Module
Public Class ChatHub : Inherits Hub
    Public Async Function SendMessage(ByVal user As String, ByVal message As String) As Task
        If message = "reset" Then count = 0
        Await Clients.All.SendAsync("ReceiveMessage", user, message, count.ToString)
        ChatCount.count += 1
    End Function
End Class

And my Startup Class (works with or without the Configuration):

<Assembly: OwinStartup(GetType(Startup))>
Public Class Startup
    Public Sub Configuration(ByVal app As IAppBuilder)
        Dim h As New HubConfiguration With {
                .EnableDetailedErrors = True,
                .EnableJavaScriptProxies = True
            }
        app.MapSignalR()
        'app.MapSignalR(h)
    End Sub
End Class

Finally… Assemblies/Versions:

signalR.AspNet.Core 2.4.3
jquery-3.7.1.min.js
jquery.signalr-2.3.0.min.js

It’s been frustrating me for over a week, so I thought somebody else might have had the same issue. I get the connected message in the console, but nothing else.
Looking at the transport logs I get this message back after every sent message, and if I put ‘reset’ as the message, it zeros the count as it should.

{
    "C": "d-9728E6BF-B,2A|c,0|d,1",
    "M": [
        {
            "H": "ChatHub",
            "M": "SendAsync",
            "A": [
                "ReceiveMessage",
                "psychuk",
                "testing",
                "41"
            ]
        }
    ]
}

I am thinking it’s most definitely a JS/JQ issue, those events are just not hooking as they should, although I cant find a way to check this, I am 99% sure signalR is working as it should.
Any help would be appreciated (even if someone could just check the returned message format for me so I know it’s correctly typed).

How to display the most recent clipboard content when I right click on chrome using a chrome extension?

When I right click on Chrome, I want one of the menu items to contain my most recent clipboard content. So, I can quickly glance at what is copied, without pasting it anywhere. Basically I want the extension to do this(good even if it doesn’t go to a submenu):I already downloaded this, this feature doesn’t work like intended
I’m very new to creating extensions, I haven’t made a lot of progress, please help. And if other alternatives exist let me know.

current manifest.json file

{
  "manifest_version": 3,
  "name": "Clipboard Keeper",
  "version": "1.0",
  "description": "Stores the most recent clipboard content",
  "permissions": [
    "clipboardRead",
    "activeTab"
  ]
}

current background file:

chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
  if (message.type === "getClipboardContent") {
    const clipboardContent = navigator.clipboard.readText();
    sendResponse({ content: clipboardContent });
  }
});

Current content.js


chrome.contextMenus.create({
  id: "clipboardMenu",
  title: "Most Recent Clipboard Content",
  contexts: ["selection"]
});

chrome.contextMenus.onClicked.addListener((info, tab) => {
  if (info && info.menuItemId === "clipboardMenu") {
    // Read the most recent clipboard content
    const clipboardContent = navigator.clipboard.readText();

    // Display the content in the context menu
    const menuItem = chrome.contextMenus.create({
      id: "clipboardContent",
      title: clipboardContent,
      parentId: "clipboardMenu"
    });
  }
});

Please note these are all very badly put together and doesn’t work at all like I would like