Scroll to newly added row in RadGrid

After I add a row to my RadGrid, I want to select that row, which is always at the bottom of the RadGrid. This isn’t working for mysterious reasons.

I’m adding the record using my own procedure, so I can validate it before updating:

' Select the newly-added route
AvailableRoutesList.DataBind()
For Each routeInList As GridDataItem In AvailableRoutesList.MasterTableView.Items
    If routeInList.Item("Route").Text = route Then
        routeInList.Selected = True
        Dim index As Integer = routeInList.ItemIndex
        ScriptManager.RegisterStartupScript(Me, Me.GetType(), "ScrollToRoute",
                                String.Format("scrollToRoute('{0}', '{1}');",
                                                index, AvailableRoutesList.ClientID),
                                True)
        Exit For
    End If
Next

The intention is to use the Javascript scrollToRoute function to scroll to that selected route:

function scrollToRoute(gridId, radGridClientID) {
    var grid = document.getElementById(radGridClientID);
    var selectedItem = grid.get_selectedItems()[0];
    if (selectedItem) {
        var scrollableElement = grid.get_element();
        var selectedItemElement = selectedItem.get_element();
        var scrollTop = selectedItemElement.offsetTop - scrollableElement.offsetTop;
        scrollableElement.scrollTop = scrollTop;
    }
}

This is currently failing on get_element() which it says isn’t a property of my grid. It seems grid is being selected as a div element instead of the RadGrid.

As I researched online, I tried to use $find instead, but $find(radGridClientID) returns null, even though document.getElementById(radGridClientID) returns the div element.

I don’t understand how I’m supposed to select the RadGrid from Javascript so that the scrolling function will work. Any ideas?

how to merge same object arrays based on same key’s value in array of object ,incase of multiple matches found then merge based on priority using Js

how to merge same object arrays based on same key’s value in array of object ,incase of multiple matches found then merge based on priority

consider
a=[{x:”all”,y:”tablename”,z:”schema”},{x:”all1″,y:”tablename”,z:”schema”},{x:”all2″,y:”tablename”,z:”schema”},{x:”al52″,y:”tablename”,z:”schema”}];

b=[{x1:”all”,y1:”tablename”,z1:”schema”},{x1:”all”,y1:”tablename1″,z1:”schema1″},{x1:”all1″,y1:”tablename1″,z1:”schema1″},{x1:”all”,y1:”tablename3″,z1:”schema”},{x1:”all1″,y1:”tablename2″,z1:”schema1″}]

priority=[{y1:”tablename3″,z1:”schema”},{y1:”tablename1″,z1:”schema1″},{y1:”tablename2″,z1:”schema”},{y1:”tablename”,z1:”schema”}]

expected=[{x:”all”,y:”tablename”,z:”schema”,x1:”all”,y1:”tablename3″,z1:”schema”},{x:”all1″,y:”tablename1″,z:”schema1″,x1:”all1″,y1:”tablename1″,z1:”schema1″}]

in above object array ‘a’ will always have x as unique value.
I have tried below

Actual=[{x:”all”,x1:”all”,y:”tablename”,y1:”tablename”,z:”schema”,z1:”schema”},{x:”all1″,x1:”all1″,y:”tablename”,y1:”tablename1″,z:”schema”,z1:”schema1″}]
Which is wrong Please advise how to resolve this

var c = [];
for (var i = 0; i < a.length; i++) {
  for (var j = 0; j < b.length; j++) {
    if (a[i].x === b[j].x1) {
      var combinedObj = {
        x: a[i].x,
        y: a[i].y,
        z:a[i].z,
        x1:b[j].x1,
        y1: b[j].y1,
        z1:b[j].z1
      };
      c.push(combinedObj);
      break;
    }
  }
}
console.log(c)

Template literal(` `) doesn’t work…! :( [closed]

script code is below

$.ajax({
        ~~~~
      }).done((data)=>{
        console.log('data success');
        data.forEach(obj=>{
          console.log(obj.roomName);
let htmlTarget= 
`
<div>
  ${obj.roomName}
</div>
`;
$('#blah').html(htmlTarget);

If I print out console.log(obj.roomName);, It clearly represents value. If I use console.log(typeof(obj.roomName)), It clearly says “string” type. But, If I use template literals to append HTML, It won’t work. If I change ${obj.roomName} into random String varialbes such as “stackoverfow”, then it works.

I don’t know why…

  • I used template literals to solve it…It doesn’t work though…

What is a easy way to scrape a website using javascript?

I everyone

I’m trying to get the links of all the articles from a search result on the The Telegraph’s website (I have the subscription). However, by using BeautifulSoup, I cannot get any results.

Here’s what I’m using :

from bs4 import BeautifulSoup

url = 'https://www.telegraph.co.uk/search/?q=Facebook&p=0&sortby=date'

html = urlopen(url)

bsObj = BeautifulSoup(html.read())

item = bsObj.find("ul",{'class':{'cst-results__list '}})

and I don’t have anything in the item. I have read that it may be because a part of the website is scripted with Java, but I can’t find anything to help with this. Does anyone know a way to overcome his issue ?

how to show fatched data in div from laravel controller using ajax

I am making custom chat system using laravel ajax.my data is coming successfully in console.I want to show this data in my div.
here is my ajax code…
$.ajax({
type:”GET”,
url:”/home/admin_comment_get”,
data:{
“_token”: “{{ csrf_token() }}”,
seventh_id:seventhid
},
dataType:’json’,
success: function (res){
// console.log(res.comments)
let html = “”;
$.each(res.comments, function (key, value){

                }); 
            }
        });

and here is my view blade

                  <div class="outgoing_msg" id="outgoing">
                    <div class="sent_msg">
                      <p class="message"></p>
                      <span class="time_date"></span> 
                    </div>
                  </div>
                  
                  <div class="incoming_msg">
                    <div class="incoming_msg_img"> 
                      <img src="https://ptetutorials.com/images/user-profile.png" alt="sunil"> 
                    </div>
                    <div class="received_msg">
                      <div class="received_withd_msg">
                        <p>sfsdfsdfs</p>
                        <span class="time_date"> 444</span>
                      </div>
                    </div>
                  </div>

              </div>

I want to loop this fatch_comment..
and if status is 1 then it show in outgoing
and if status is 0 it show in incoming_msg

Server stop working : [nodemon] app crashed – waiting for file changes before starting… Link for my github in descripton. Thanks

I’m building a messaging app, but I’m encountering an error. When I click the send message button, the message drops to the database, but the server returns the following error:

ERROR CODE ON PHOTOenter image description here;

and I have to run the server again.

When I send it via postman it works fine.
I’ve been trying to solve the error for about 3 days but failed every time

GitHub Link: github.com/umitahmed/Chat

Creating Electron executable from Angular local web application

I’ve this problem: I wanted to create a desktop app with a executable file, but i can’t do it right, whatever i try. I successfully created the executable with electron-packager, i builted the app into the dist folder with those four minimized files (main, styles, runtime and polyfills) and the index.html, but when I run the executable the only thing I see is white screen.

I was thinking about two ways of handling this:

  1. starting the app on localhost:4200 in… some way, exactly when I run the executable, but I don’t know how to do it
  2. reading those files in the dist folder, but i keep getting errors that say “to load resource: net::ERR_FILE_NOT_FOUND” at row 1 of each file

I’ll leave here the three files that I believe are most important in this problem.

angular.json

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "library-frontend": {
      "projectType": "application",
      "schematics": {},
      "root": "",
      "sourceRoot": "src",
      "prefix": "app",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist/library-frontend",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": [
              "zone.js"
            ],
            "tsConfig": "tsconfig.app.json",
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "@angular/material/prebuilt-themes/indigo-pink.css",
              "src/styles.css"
            ],
            "scripts": []
          },
          "configurations": {
            "production": {
              "budgets": [
                {
                  "type": "initial",
                  "maximumWarning": "3MB",
                  "maximumError": "5MB"
                },
                {
                  "type": "anyComponentStyle",
                  "maximumWarning": "2kb",
                  "maximumError": "4kb"
                }
              ],
              "outputHashing": "all"
            },
            "development": {
              "buildOptimizer": false,
              "optimization": false,
              "vendorChunk": true,
              "extractLicenses": false,
              "sourceMap": true,
              "namedChunks": true
            }
          },
          "defaultConfiguration": "production"
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "configurations": {
            "production": {
              "browserTarget": "library-frontend:build:production"
            },
            "development": {
              "browserTarget": "library-frontend:build:development"
            }
          },
          "defaultConfiguration": "development"
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "library-frontend:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "polyfills": [
              "zone.js",
              "zone.js/testing"
            ],
            "tsConfig": "tsconfig.spec.json",
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "@angular/material/prebuilt-themes/indigo-pink.css",
              "src/styles.css",
              "node_modules/bootstrap/dist/css/bootstrap.min.css",
              "node_modules/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css"
            ],
            "scripts": [
              "node_modules/jquery/dist/jquery.min.js",
              "node_modules/bootstrap/dist/js/bootstrap.min.js",
              "node_modules/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js"
            ]
          }
        }
      }
    }
  }
}

package.json

{
  "name": "library-frontend",
  "version": "1.0.4",
  "main": "electron.main.js",
  "scripts": {
    "ng": "ng",
    "serve": "ng serve",
    "start": "concurrently "ng serve" "npm run electron"",
    "build": "ng build",
    "watch": "ng build --watch --configuration development",
    "test": "ng test",
    "electron": "electron ./electron.main",
    "electron-build": "ng build && electron ./electron.main",
    "electron-win": "electron-packager . --platform=win32"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^16.0.0 || ^17.0.0",
    "@angular/cdk": "^16.0.1",
    "@angular/common": "^16.0.2",
    "@angular/compiler": "^16.0.2",
    "@angular/forms": "^16.0.2",
    "@angular/material": "^16.0.1",
    "@angular/material-moment-adapter": "^16.0.1",
    "@angular/platform-browser": "^16.0.2",
    "@angular/platform-browser-dynamic": "^16.0.2",
    "@angular/router": "^16.0.2",
    "node-windows": "^1.0.0-beta.8",
    "rxjs": "~7.8.0",
    "tslib": "^2.5.1",
    "zone.js": "~0.13.0"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^16.0.2",
    "@angular/cli": "~16.0.0",
    "@angular/compiler-cli": "^16.0.2",
    "@types/jasmine": "~4.3.0",
    "@types/jquery": "^3.5.16",
    "@types/node": "^12.11.1",
    "concurrently": "^8.0.1",
    "electron": "^24.0.0",
    "electron-packager": "^17.1.1",
    "jasmine-core": "~4.5.0",
    "karma": "~6.4.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.2.0",
    "karma-jasmine": "~5.1.0",
    "karma-jasmine-html-reporter": "~2.0.0",
    "typescript": "~4.9.4"
  }
}

electron.main.js

const { app, BrowserWindow } = require('electron');
const path = require('path');
const url = require('url');

let win;

const createWindow = () => {
    setTimeout(() => {
        win = new BrowserWindow({
            width: 800,
            height: 600,
            icon: './src/favicon.ico'
        });

        const appUrl = url.pathToFileURL(path.join(__dirname, 'dist/library-frontend/index.html')).toString();
        win.loadURL(appUrl);

        win.on('closed', () => {
            win = null;
        });
    }, 10000);
}

app.on('ready', createWindow);

app.on('window-all-closed', () => {
    if (process.platform !== 'darwin') {
        app.quit();
    }
});

app.on('activate', () => {
    if (win === null) {
        createWindow();
    }
});

These files are all in the root of the project, the same level as src folder, which contains index.html and all other components.

The first solution I wrote before is probably wrong, but what I want is exactly what happens when I run my “npm run start” command, which runs concurrently ng serve and npm run electron

Calculating maximum hour and minute options for a dependent time collector field

I have two fields that are “Time Collectors”, where you can select the hour and minute separately:

Here’s a picture how it looks
Time Collector dropdown picture

The values ​​of these fields are strings like “–:–“

The second field may have an hour less than or equal to the hour in the first field.
The jump between hours is 30 minutes.

For example:
If the time in the first field is “02:00”, then in the second field you can select up to “00:00”, “00:30”, “01:00”, “01:30”, “02:00” and “02:00”. When the second field is “01:30”, it is no longer possible to enter “02” in front because “02:30” is greater than “02:00”

Maximum time in first field is “08:30”.

For example:
If the first field is “02:00”, then the hours [01,02] and minutes [00,30] are available in the second field, but when you enter the hour “00:30” in the second field, the available hours should be be [01]

If we reduce the amount of time in the first field, the second should also change if it is too much.

I need a JS function that will calculate the maximum hour and maximum minute for the second field based on the first field value.

Thank you in advance for your help.

parse is undefined even after specifying require statement

I am using code from this page with my sample code:

var jsp = require("uglify-js").parser;
var pro = require("uglify-js").uglify;

var orig_code = `
    function myfn(msg, abcd){
        print abcd 
        }
    function secondfn ( msg2, "xyz"){
        print  second 
        }
    let abc = "ABCD"; var pqr = "PQRS"; const pi = 3.14159; let xyz="XYZ";
    const ten=10; use abc; myfn(); secondfn(); secondfn(); myfn(); use pqr; use pi; use pqr; 
`;
var options = {
    mangle: true
};

var ast = jsp.parse(orig_code); // parse code and get the initial AST
ast = pro.ast_mangle(ast, options); // get a new AST with mangled names
ast = pro.ast_squeeze(ast); // get an AST with compression optimizations
var final_code = pro.gen_code(ast); // compressed code here

console.log(final_code); 

However, when I run this file with command node mysrc.js, I get following error:

var ast = jsp.parse(orig_code); // parse code and get the initial AST
              ^

TypeError: Cannot read property 'parse' of undefined

Where is the problem and how can it be solved?

Why my website in windows or android is normal, but on mac or apple product, my website is broken? [closed]

This is my Website (On Development) : https://nawadya.gembiraloka.cloud
I Build only with Front end (HTML, CSS, JS) and use Bootstrap v5.3.0 (30 May Release) for CSS Framework.

This is a new experience for me, because in previous development I never had this problem.

On Windows or Android

Windows Capture

Safari Capture

Anyone can you help me?

Thank You!

This problem is specially on Safari but in Android or Windows is clear.

Javascript: Windows alert won’t work because of function [duplicate]

So this is for a project for uni. I’m trying to create a form with a username and password and when you click on the connect button, it’s supposed to pop up a window alert but it won’t work because of my function “myAlert()”. I know the if is wrong but i can’t figure it out, I’m using my professor’s instructions.

<?php

$name=$password="";
if ($_SERVER["REQUEST_METHOD"] == "POST") { 
    $name = test_input($_POST["name"]);
    $password = test_input($_POST["password"]); 
}

function test_input($data) {
    $data = trim($data);
    $data = stripslashes($data); 
    $data = htmlspecialchars($data); 
    return $data;
   } 
   ?>
    <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<div class="container">
<div class="text">
Κωδικός Υπαλλήλου: <br> <input type="text" name="name">
 <br><br> 
Κωδικός: <br> <input type="text" name="password"> 
<br><br>
<button class="connect" onclick="myAlert()">Σύνδεση</button> 
<script> 
function myAlert() {
 if (empty($_POST["name"])) && (empty($_POST["password"])) { 
alert("Δεν συμπληρώσατε τους κωδικούς"); 
} else { 
alert("Επιτυχής σύνδεση"); } 
} 
</script> 
</div> 
</form>

How can I receive the information from the form and depending on the answer, pop up a different message? Do i have to rewrite it?

Click event is occured when Drag and Drop object on another object

script

const onDrag = (e) =>{
  
}
const onStop = (e) ==>{
   setIsDragging(false);
}
const onStart = (e) =>{
   setIsDragging(true);
}
const click = (e) =>{
    console.log("click")
    //do something here
}
const dummyclick = (e) =>{

}

html

{shelfs.map((items,i) =>( 
<Draggable onStart={handleStart} onDrag={handleDrag} onStop={handleStop}>
<div id="parent">
    <div id="child" onClick={isDragging ?  dummyclick:click} style={{width:"100px"}}>
    button
    </div>
</div>
<Draggable>
))}

There are a few div items.
What I am doing is , drag ObjectA & drop ObjectA on ObjectB to swith the position.(This code is simplified)

My strategy is while dragging, objects click is switched to dummyclick and click should be invalid.

However it works like this,

drag start on ObjectA (onStart) -> isDragging become false -> drop objectA on ObjectB (onDrop) -> isDragging become true -> ObjectB’s click is occured.

I just wonder why this happens, and how can I prevent click is occured?

I am using react-draggable

How to obtain such minified code with unreadable variables and constructs?

In this snippet of minified code, it’s apparent that variable names and constructs are not human-readable. How can one obtain such code, and is it possible to transform it into a more readable format?

! function() {
"use strict";

function t(e) {
    return function(t) {
        return n = typeof(t = t), (null === t ? "null" : "object" == n && (Array.prototype.isPrototypeOf(t) || t.constructor && "Array" === t.constructor.name) ? "array" : "object" == n && (String.prototype.isPrototypeOf(t) || t.constructor && "String" === t.constructor.name) ? "string" : n) === e;
        var n
    }
}
var o, B = tinymce.util.Tools.resolve("tinymce.PluginManager"),
    I = tinymce.util.Tools.resolve("tinymce.util.VK"),
    u = t("string"),
    a = t("array"),
    K = function(t) {
        return o === t
    }, z = n("boolean"),
    j = n("function"),
    s = function() {}, V = function(t, n) {
        return t === n
    }, l = i(!1),
    c = i(!(o = null)),
    f = {
        fold: function(t, n) {
            return t()
        },
        isSome: l,
        isNone: c,
        getOr: e,
        getOrThunk: m,
        getOrDie: function(t) {
            throw new Error(t || "error: getOrDie called on none.")
        },
        getOrNull: i(null),
        getOrUndefined: i(void 0),
        or: e,
        orThunk: m,
        map: r,
        each: s,
        bind: r,
        exists: l,
        forall: c,
        filter: function() {
            return f
        },
        toArray: function() {
            return []
        },
        toString: i("none()")
    };

how can I choose one option when I use foreach in laravel

enter image description here

this is code in html :

<div class="col-9">
    <form>
        <div class="multiselect">
            <div class="selectBox" onclick="showCheckboxes()">
                <select>
                    <option placeholder="www"></option>
                </select>
                <div class="overSelect"></div>
            </div>
            <div id="checkboxes">
                @foreach ($subjects as $subject)
                <label for="itemform">
                    <input type="radio" value="{{ $subject->id }}"/>{{ $subject->name }}
                </label>
                @endforeach
            </div>


            @error('subjects')
            <small class="form-text text-danger">{{ $message }}</small>
            @enderror
        </div>
    </form>
</div>

and this is code in java script :

<script>

    var expanded = false;

    function showCheckboxes() {
        var checkboxes = document.getElementById("checkboxes");
        if (!expanded) {
            checkboxes.style.display = "block";
            expanded = true;
        } else {
            checkboxes.style.display = "none";
            expanded = false;
        }
    }
</script>

My question is how can I choose to select only one item from the list given that I used the type is radio