What about bundling your external JavaScript files into one file, using a bundling tool (like webpack) and, write one script tag for the bundled file?
Shmuel Zang
Posts
-
Is there a basic HTML scripts bundle for VS code and none serve application? -
How to send the 'Connection' header using HttpListenerResponseHello all.
While trying to implement a web-socket handshake, I encountered a weird behavior. It looks like the
HttpListenerResponse
class doesn't send the 'Connection' header.Here is an example for explaining what I mean:
public void TestWebSocketHttpHandshake()
{
int port = 9444;
ManualResetEvent serverStartedEvent = new ManualResetEvent(false);
ManualResetEvent clientClosedEvent = new ManualResetEvent(false);// HTTP server that gets a web-socket handshake request and, // send back a web-socket handshake response. async Task RunHttpServer() { HttpListener hl = new HttpListener(); hl.Prefixes.Add($"http://+:{port}/"); hl.Start(); serverStartedEvent.Set(); HttpListenerContext hlc = await hl.GetContextAsync(); string secWebSocketKeyHeader = hlc.Request.Headers\["Sec-WebSocket-Key"\]?.Trim(); string secWebSocketAcceptHeader = Convert.ToBase64String( System.Security.Cryptography.SHA1.Create().ComputeHash( Encoding.UTF8.GetBytes(secWebSocketKeyHeader + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11") ) ); hlc.Response.StatusCode = (int)HttpStatusCode.SwitchingProtocols; // 101 hlc.Response.StatusDescription = "Switching Protocols"; hlc.Response.ProtocolVersion = new Version("1.1"); hlc.Response.AddHeader("Upgrade", "websocket"); **hlc.Response.AddHeader("Connection", "Upgrade");** hlc.Response.AddHeader("Sec-WebSocket-Accept", secWebSocketAcceptHeader); hlc.Response.Close(); // Wait for the client to close. clientClosedEvent.WaitOne(); hl.Stop(); } // Tcp Client that sends a web-socket handshake request and, // writes the received web-socket handshake response. async Task RunTcpClient() { const string eol = "\\r\\n"; // HTTP/1.1 defines the sequence CR LF as the end-of-line marker // Wait for the server to start. serverStartedEvent.WaitOne(); using (TcpClient tc = new TcpClient()) { tc.Connect("localhost", port); using (NetworkStream ns = tc.GetStream()) { string wsRequest = $"GET /chat HTTP/1.1{eol}Host: localhost:{port}{eol}"+ $"Upgrad
-
Javascript , a devil spawn language.I can understand your frustration. Maybe you want to take a look on TypeScript.
-
Why positioning is not working?Maybe your elements' position is
relative
. Try to change it toabsolute
. Something like:<img src="images/logo.jpg" style=" margin-top: 0; margin-left: 0px; position: absolute;">
<img src="images/my_account.png" style="margin-top: 0; margin-left: 500px; position: absolute;"> -
functionsThese links can give you an overview about JavaScript functions basics:
-
Object cloningMaybe a std::shared_ptr can be helpful for you.
You can use it as follows:
#include <memory>
using namespace std;
class Person
{
shared_ptr<Person> parent;public:
Person(shared_ptr<Person> p) {parent = p;}};
void DoSomething(shared_ptr<Person> p)
{
// Do something here
}int main()
{
shared_ptr<Person> grandfather = make_shared<Person>(nullptr);
shared_ptr<Person> father = make_shared<Person>(grandfather);
shared_ptr<Person> son = make_shared<Person>(father);DoSomething(father); return 0;
}
-
How to add Scrollviewer inside Dragdockpanel?If you want to scroll the elements of your panel, you can wrap it with a
ScrollViewer
.If yow want to wrap an inner part of the control with a
ScrollViewer
, you can do it by changing the ControlTemplate of the control.