Every time I try to retrieve my JavaScript code, I am bombarded with endless prompts that prevent me

Desperate for assistance! I have been using a website called "codepen" for my javascript coding, but I mistakenly triggered infinite prompts every time I open the project. Now, I am unable to access the code and despite my efforts in searching for a solution, I have come up empty-handed. Here's a link to the issue: https://codepen.io/Aibel-Roy/pen/zYPBeEW

//Apologies for the inconvenience, I am unable to share the code due to the endless prompts.

Answer №1

Below is the code provided for you:

// Configuration
var tick = 50;
var fieldOfView = 25;
var Speed = 0.25;
var ZMulti = 4;
var ClearOnDraw = true;

// Variables
var keymap = [];
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
var meshA = [
  "0,0,0",
  "1,0,0",
  "1,1,0",
  "0,1,0",
  "0,0,1",
  "1,0,1",
  "0,1,1",
  "1,1,1"
];
var textures = [
  "http://www.textures4photoshop.com/tex/thumbs/red-sofa-leather-seamless-texture-53.jpg"
];
var cameraData = [0, 0, 0];

// Key mapping
window.addEventListener(
  "keydown",
  (event) => {
    var name = event.key;
    keymap.push(name);
  },
  false
);
window.addEventListener(
  "keyup",
  (event) => {
    var name = event.key;
    if (keymap.includes(name)) {
      keymap.splice(keymap.indexOf(name), 1);
    }
  },
  false
);

// Render image
function draw() {
  if (ClearOnDraw) {
    ctx.clearRect(0, 0, 10000, 1000);
  }
  var img = new Image(); // Texturing
  img.src = textures[0];
  prompt(img.src);
  img.onload = function () {
    var pattern = context.createPattern(imageObj, "repeat");
    ctx.fillStyle = pattern;
    var prevVert;
    for (let i = 0; i <= meshA.length; i++) {
      // Convert 3D vector to 2D
      var vert = meshA[i];
      if (i >= meshA.length) {
        vert = meshA[0];
      }
      var vertPos = vert.split(",");
      var zMag = (vertPos[2] - cameraData[2]) * (fieldOfView / ZMulti);
      var vertPos2D = [
        (vertPos[0] - cameraData[0]) * fieldOfView + zMag,
        (vertPos[1] - cameraData[1]) * fieldOfView + zMag
      ];

      ctx.beginPath();
      ctx.moveTo(vertPos2D[0], vertPos2D[1]);
      for (let i1 = 0; i1 < meshA.length; i1++) {
        var prv = meshA[i1].split(",");
        var PrevzMag = (prv[2] - cameraData[2]) * (fieldOfView / ZMulti);
        var I1VertPos = [
          (prv[0] - cameraData[0]) * fieldOfView + PrevzMag,
          (prv[1] - cameraData[1]) * fieldOfView + PrevzMag
        ];
        ctx.lineTo(I1VertPos[0], I1VertPos[1]);
        ctx.stroke();
      }
      ctx.closePath();
      ctx.fill();
      prevVert = vertPos2D;
    }
  };
}
function Movement() {
  if (keymap.includes("w")) {
    cameraData[2] -= Speed * 2;
  }
  if (keymap.includes("s")) {
    cameraData[2] += Speed * 2;
  }
  if (keymap.includes("d")) {
    cameraData[0] -= Speed;
  }
  if (keymap.includes("a")) {
    cameraData[0] += Speed;
  }
}

draw();
setInterval(function main() {
  draw();
  Movement();
}, tick);

To disable the prompt (if the browser does not provide an option to suppress it), you can follow these steps:

  1. Open the developer tools on the page (Command + Option + I, or F12 on Windows).

  2. Select the correct page in the developer tools, usually identified as CodePen (Hash ID).

  3. Override the prompt function in the console by typing window.prompt = () => {}.

  4. Modify your code, save it, and refresh the page.

There may be alternative methods to achieve this, but disabling JavaScript could render the code section non-functional.

Answer №2

Within your function draw(), there is a prompt located here:

function draw() {
  // Trimmed
  prompt(img.src);
  
  // Trimmed
}

In addition, you are using setInterval to call draw() at specific intervals defined in tick (with a value of 50ms):

setInterval(function main() {
  draw();
  Movement();
}, tick);

This leads to draw() being executed every 50ms, causing an infinite loop due to the repeated prompt(img.src).

You will need to revise the implementation within the setInterval() function.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Exporting variables in Angular's Ahead of Time (AoT) compiler is

I recently attempted to incorporate dynamic configuration into my project, following a guide I found in this insightful post. While everything functions smoothly with the JiT compiler, I encountered the following error when attempting to build using the A ...

Utilizing a d.ts Typescript Definition file for enhanced javascript intellisene within projects not using Typescript

I am currently working on a TypeScript project where I have set "declaration": true in tsconfig.json to generate a d.ts file. The generated d.ts file looks like this: /// <reference types="jquery" /> declare class KatApp implements IKatApp ...

Calculate the number of arrays in an object and then substitute them

Currently, I have an object that is returning the following data: Object {1: 0, 2: Array[2], 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0, 10: 0, 11: 0, 12: 0} My goal is to replace the "Array[2]" with just the number "2" (indicating how many records are in ...

What causes the console.log function to behave in this manner?

When using the node.js interpreter, if you run the code: console.log("A newline character is written like \"\\ n \"."); //output will be:- // A newline character is written like "\ n ". However, if you just enter the following in ...

Resetting the internal state in Material UI React Autocomplete: A step-by-step guide

My objective is to refresh the internal state of Autocomplete, a component in Material-UI. My custom component gets rendered N number of times in each cycle. {branches.map((branch, index) => { return ( <BranchSetting key={ind ...

Loading a new view within AngularJS using the ng-view directive opens up a fresh

I am currently working on integrating Angular with a REST API for the login process. After successfully setting up Angular with my REST calls, I aim to redirect to a new page upon successful login. In my success handler, I have implemented the following ...

Enhancing functionality through the press of a button

I wrote a script that, upon button click, finds the closest location to your current position by searching through an array. It then locates the corresponding entry in another array and adds a number to that entry. However, I encountered a problem with app ...

Tips on storing a blob (AJAX response) in a JSON file on your server, not on the user's computer

After researching extensively on creating a URL from or downloading a blob in a computer, I require a unique solution: (1) Save a blob in own server into a JSON file, (2) Optimize the way to update a database using the data stored in the JSON. My attemp ...

Issue: 040A1079 - Failure in RSA Padding Check with PKCS1 OAEP MGF1 Decoding Error Detected on Amazon Web Services

Utilizing the crypto package, I execute the following tasks: Using crypto.generateKeyPairSync() to create publicKey and privateKey The keys are generated only once and stored in the .env file Applying crypto.publicEncrypt() to encrypt data before savin ...

What role does @next/react-dev-overlay serve in development processes?

Currently, I am diving into a NextJs project. Within the next.config.js file, there is this code snippet: const withTM = require('next-transpile-modules')([ 'some package', 'some package', 'emittery', ...

JavaScript HTTP Requests

I came across this AJAX example in Stoyan Stefanov's book Object Oriented JavaScript on page 275. The example involves requesting three different files. I have a few questions that I was hoping someone could help me with! What does the line xhr.se ...

What is the best way to set up CORS in IE11 using C# with JQuery.ajax?

Having some trouble with CORS functionality in IE11. I need to perform ajax requests using jquery (or whatever the browser supports natively), without any additional libraries. These requests are cross-domain and function perfectly in Chrome and Firefox. ...

How to Access a PHP Variable within a JavaScript Function Argument

.php <?php $timeArray = [355,400,609,1000]; $differentTimeArray = [1,45,622, 923]; ?> <script type="text/javascript"> var i=0; var eventArray = []; function generateArray(arrayName){ eventVideoArray = <?php echo json_encode(arrayName); ...

Type property is necessary for all actions to be identified

My issue seems to be related to the error message "Actions must have a type property". It appears that the problem lies with my RegisterSuccess action, but after searching on SO, I discovered that it could be due to how I am invoking it. I've tried so ...

`Angular Image Upload: A Comprehensive Guide`

I'm currently facing a challenge while attempting to upload an image using Angular to a Google storage bucket. Interestingly, everything works perfectly with Postman, but I've hit a roadblock with Angular Typescript. Does anyone have any suggesti ...

Is there a way in jqGrid to invoke a function once the subGridRowCollapsed operation finishes?

I'm currently working with jqGrid's subgrids and I need a solution for invoking a specific method after collapsing a subgrid. Currently, my implementation is as follows: subGridRowCollapsed: function (subgrid_id, row_id) { adjust_slider_posi ...

Node.js Apple in-app purchase (IAP) receipt validation

Trying to implement Node.js from this repository for my IAP Receipt Validation, but encountering an error in the server's log: "The data in the receipt-data property was malformed." Seeking assistance on properly sending a base64 string to Node.js an ...

Encountering an illegal invocation error in jQuery

Recently delving into the world of jQuery, I am attempting to call a C# function from JavaScript using AJAX and jQuery. Additionally, I need to pass some parameters while making the call to the C# function. Here is how I am attempting to achieve this: var ...

Maximizing efficiency with JavaScript object reduction

let students = [ { name: "john", marks: 50, }, { name: "mary", marks: 55, }, { name: "peter", marks: 75, }, ]; I need to find the total sum of marks using the reduce method. Here is my att ...

Guide on shifting an element into a different one with the help of jQuery

I'm attempting to relocate an element within another in order to enable a css :hover effect. <ul> <li id="menu-item"> //move into here </li> </ul> <div class="tomove">...</div> 'tomove' is set to dis ...