Posts by Klaider • 2,509 points
154 posts
-
2
votes2
answers3336
viewsA: How to drag an element freely on the page with pure javascript?
To drag an element I use the events onmousedown, onmousemove and onmouseup (I declare the last two in window), if necessary more events can be used. To drag the element from any point it is…
javascriptanswered Klaider 2,509 -
0
votes1
answer125
viewsA: How to hide two Divs inside each other with Javascript?
Obs: getComputedStyle(el) will return the current styles of the element, which makes it better to get the display of the element. The problem is why you’re declaring "#guaraparivirtualsuperpopupbtn"…
-
1
votes2
answers84
viewsA: script only in a div
Add an attribute of 'id' (with a name, of course) for your div and use the method document.getElementById to capture her. Therefore, you will not have the property links in its element and will have…
-
2
votes4
answers5899
viewsA: PHP ask for confirmation before deleting
First of all I want to say that this line in the block of else </script>"; is wrong and would cause an interpretation error in the code. You had to have put the quote before the first byte…
-
1
votes1
answer33
viewsQ: How to declare functions in an array declared in a class block?
At least I tried, but PHP plays a syntax error: Parse error: syntax error, Unexpected 'Function' (T_FUNCTION) In short, I cannot declare functions in my array. When I create my array $ast outside…
-
0
votes1
answer39
viewsA: Menu of canvas Help
Just call toggleMenu when the page is loaded. Note: the function init should be executed when the page was loaded as well, depending on the position of its element script, events may not be added to…
-
1
votes2
answers553
viewsA: Change image when selecting radio in form
Code explained: // Seu formulário var form = document.getElementsByTagName('form')[0], // Todos input[type=radio] com o nome "gol" goalkeeper = form.gol, // Todos input[type=radio] com o nome "tec"…
-
4
votes2
answers312
viewsQ: Is it possible to define a class within an array in earlier versions of PHP 7?
Is it possible? If so, how? In PHP 7 it is possible to create anonymous classes, which can be defined in any variable/property, but I do not know if it is possible to do this in previous versions,…
-
0
votes2
answers494
viewsA: Result of calculation in JS returning R$ Nan
Add the || (or) on that line (where you call the parseFloat): return parseFloat( money )*100; Example: return (parseFloat( money ) || 0) * 100; Now, if the parseFloat( money ) return NaN, will be…
javascriptanswered Klaider 2,509 -
1
votes3
answers230
viewsA: Extract data separately from a date in string format
Here is what you asked to +. Now you can convert 2 correct style dates 2016-07-20T15:01:01-02:00 and style Wed Jul 20 2016 14:01:01 GMT-0300 (BRT). Date.toBrazilianFormat = (function() { // Dias da…
-
1
votes3
answers230
viewsA: Extract data separately from a date in string format
I think there is no native method to convert this date into Javascript, but it is possible to do this manually. Edit: After seeing the reply of @Ivanferrer I realized that there is already native…
-
0
votes1
answer1416
viewsA: Change text according to slide image
You meant "content," not "text," right? The best way to do this is by creating containers for each image sequentially, which can be hidden or expanded, as in your code: <div class="large-5…
-
0
votes3
answers129
viewsA: Javascript start code from a certain line
The problem is not the *.ofx file header, it is because the file does not have the XML header. If the XML header is not declared in the file, it is not interpreted. According to this page you can…
-
0
votes2
answers471
viewsA: How to create a mobile menu button with this effect? (preferably without js)
You can do this effect with edges, even with elements, but this site used box-shadow, applying a white shadow inside the element. As you can see moved 1 pixel horizontally, and 1 pixel vertically.…
-
0
votes3
answers649
viewsA: Limit characters in div with contenteditable
To do this just take the property .innerHTML of div, check if the character size is greater than the limit, then use the function substring to cut the string and add an HTML class to the last part…
-
1
votes1
answer294
viewsA: Manipulate an image before adding it to a canvas element
canvas does not recognize HTML properties, so there is no point in modifying the image element styles. To rotate the image by its own axis it is sufficient to declare the central positions of the…
-
0
votes2
answers260
viewsA: Put popup content in a div
Simple! Remove the relative’s statement #quote-popup of the element #quote-popup-content in CSS, removing the properties left, top and position: #quote-popup-content { -webkit-border-radius: 2px;…
-
2
votes2
answers215
viewsA: How is the reading of sentences with comma in Javascript?
What’s in front of return is an expression string, and the last expression (where the identifier has been declared u) will be returned to the statement itself return. An expression sequence goes to…
-
4
votes1
answer448
viewsA: File in JSON format
You create a *.json file the way you create any text file. In a *.json can be declared any type of value that is accepted, such as null, object expression {}, expression of Array [], numerical…
-
0
votes1
answer48
viewsA: Exchanging image with event onmousehover does not return
The source (the src declared in the event block onmouseout) is different from the one stated at the beginning... <?php $initial_img = $this->helper('catalog/image') ->init($_product,…
-
2
votes2
answers6230
viewsA: javascript multidimensional array
To join all values and their respective images you will have to go through each element of each array and pull to the array resultado. var resultado = []; for(var i = 0, ln = valores.length; i <…
-
1
votes1
answer111
viewsA: Add class with a span when there is @/#
You will need to memorize the starting position of the selection in the text, then modify the HTML and then move the selection cart from the text to the old position. To get the position of the cart…
-
2
votes1
answer662
viewsA: Position scroll - Jquery - JS
Index the method scrollTop within its element #main. It will return to vertical position. You can index the scrollLeft if you want the horizontal position. var $main = $('#main'); $main.scrollTop();…
-
0
votes1
answer88
viewsA: Javascript - Run multiple times
The probable errors are: 1 . Define the same attribute of id for each image and modal. 2 . Modifying only an image and a modal. 3 . You are not going through all created images and modals. To make…
-
0
votes2
answers142
viewsA: Help to create an AJAX event
With jQuery you can simply use the method post to request your *.php file to receive the data from it. You will have to separate your *.php file and respond to the client-side with some sort of…
javascriptanswered Klaider 2,509 -
1
votes1
answer35
viewsA: In JS label.removeClass(); will you do what I want?
It will, but not because you’re confusing the handle label with the elements label in HTML. In this case you would have to use DOM methods to get all elements label and then modify them. There are…
javascriptanswered Klaider 2,509 -
0
votes2
answers312
viewsA: How do I prevent my firebase application from being used on other websites?
It is possible to obfuscate the code with several Javascript obfuscators and compressors to prevent the code from being readable or editable, but the most accurate is to "reinforce" the code, which…
-
0
votes5
answers19859
viewsA: Is it possible to include a Javascript file within another Javascript file?
Not while not implementing a method or statement. It is "ok" that is possible, in Javascript: 1 . create an element script; 2 . assign the src of script; 3 . add the script for HTML; Thus the…
javascriptanswered Klaider 2,509 -
0
votes2
answers864
views -
0
votes3
answers1764
viewsA: Compare two numbers and pick the biggest
Use Math.max.apply to compare the numbers. To solve the comparison, try to base yourself on this specific code: $('.item').each(function() { var item = $(this); var flag = item.find('.flag'); /*…
-
1
votes4
answers1058
viewsA: Get the first 2 user names
You can break the full name by spaces contained with the function explode and then only join the first two names obtained by PHP. /* Separa o nome pelos os espaços na string */ $arr = explode(' ',…
-
2
votes4
answers1965
viewsA: How can I detect the visibility of an element (without jQuery)?
If you are changing the visibility of the element only with the property display (inline) CSS, so you can make this condition to check if the element is visible: var box =…
javascriptanswered Klaider 2,509 -
1
votes2
answers2002
viewsA: How can I position a tree-shaped image in html and css?
Try creating lists for each image within a centralized list, then change the position of the images with left & top as you wish after assigning the relative position (position: relative).…
-
1
votes1
answer644
viewsA: Screen size browser window without scroll
To take out the scroll hide what is outside with overflow: hidden in CSS, as below: html, body { overflow: hidden; width: 100% height: 100%; } And if you refer to the screen resolution size then…
-
1
votes3
answers290
viewsA: How to change text of <Legend> without knowing the id?
Do not take an element with the "test" class again inside it. Currently, the list.getElementsByClassName("teste")[0] returns Undefined in its code, since there is no other element with the "test"…
-
0
votes1
answer52
viewsA: If script condition does not recognize returned value
The success function of $.post has to be declared inside the same object where the request settings go, in the property success. There is also another error: you have declared all posting data on…
-
0
votes1
answer63
viewsA: How can I set a "delimiter" area for my javascript draggable object?
If you modify the drag function: Before you update the position of the "draggable" object you just need to check if: X will be greater than or equal to X of X of the area; the X + width will be…
javascriptanswered Klaider 2,509 -
1
votes1
answer1994
viewsA: When Javascript takes src from an image returns absolute path
This does not occur, it is native. Index src will not return the image attribute. But if you take the attribute src of the image, will return what you typed in the attribute src - Javascript does…
-
2
votes3
answers97
viewsA: POST ajax and combo box problem
I saw a lot of syntax errors in your code, but I saved you from them. $(document).ready(function() { $("select[name=predata]").change(function() { $("select[name=prehora]").html('<option…
-
1
votes1
answer56
viewsA: PHP and AJAX, what am I doing wrong?
You don’t seem to be using the method POST. Simplify using $.post: $.post({ 'url': "atualiza-cor.php", 'data': { 'descricao_cor': $("#descricao_cor").val(), 'hexadecimal': $("#hexadecimal").val() },…
-
3
votes1
answer83
viewsQ: Are the scoped variables deleted even in Javascript?
In Javascript, whenever the block of a variable scope runs, all its variables are deleted (as they say around the site)... (function() { var a = false; })() But then why when I call setTimeout to…
javascriptasked Klaider 2,509 -
1
votes1
answer93
viewsA: Javascript - How do "IF and Else" work together with "Returns"?
Your conditions are being executed before the request ends. The only thing you need to do is move these conditions to the condition block from where the request ends (e.g., if(xmlreq.readyState ===…
-
1
votes1
answer195
viewsA: Run php and javascript at the same time
Make a request Ajax for the file '*. php' through Javascript. To requisicionar there are 2 native objects: XMLHttpRequest and ActiveXObject. The ActiveXObject is supported by IE <= 6. Example of…
-
1
votes0
answers68
viewsQ: One transition affects the opacity of the other by redefining 'globalAlpha' in the canvas
I’m making a game and I’m currently building a screen where there would be an opacity transition (fade in) and, upon completion, initiate another opacity transition. The problem is when the first…
-
1
votes1
answer102
viewsQ: A comparison between 2 char(s) is wrong
I’m manipulating a string with a loop for... which generates a new string of the same, starting and ending from a certain position (would be "Hello" in that case). When comparing the return of the…
-
1
votes3
answers2834
viewsA: Run action after 2 minutes without moving the mouse
Unused add-ons, you can make a block of commands like this: (function() { var mouse = {}; // mouse.timer --> tempo para ação // mouse.moved --> callback quando o mouse é movido // mouse.action…
-
2
votes1
answer57
viewsQ: Is there an interpreter that returns an enlarged AST?
I’m using an interpreter that returns a AST I don’t know how I’ll read. { clauses: [ { body: [/* ...*/], condition: {/* ...*/}, type: "IfClause" } ], type: "IfStatement" } I have to make a unique…
javascriptasked Klaider 2,509 -
3
votes1
answer1565
viewsQ: How does it work and what is the syntax of the machine code?
I need to understand how the machine code works, for example, the statements of the instructions and how it can become readable like Assembly, where I can see instruction like mov, "interpret".…
-
0
votes1
answer209
viewsQ: How to interpret binary content, . dat?
I need to interpret files .dat, for example. I suppose this is the content of it: ³Å¸ÎÔ|, which would be equivalent to "Davis" as a text. In Javascript, using XMLHttpRequest for a file . dat of…
-
1
votes5
answers1943
viewsA: Is it possible to program to web with Lua?
Answer to the primary question: If Lua is inside a string it can be interpreted and transformed into Abstract syntax Tree, then the code tree can be transformed into a string that presents…