Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
karms
Jan 22, 2006

by Nyc_Tattoo
Yam Slacker

Lumpy posted:

Ah, OK, so it's like Adobe AIR, but windows-only.

You have absolutely no clue what AIR is! :bravo:

edit: I stand by my point since you argue that all the extra "stuff" (i/o, state, etc) that AIR provides to Flex is somehow comparable to a few static html files bundled together. And if you want to use all that extra "stuff" you're going to have to go with a more complex language like C#.

That makes no sense at all because that's exactly what AIR does: gives you functionality that would be pretty drat useful if you wish to write a true application in flash.

karms fucked around with this message at 16:27 on Mar 11, 2009

Adbot
ADBOT LOVES YOU

karms
Jan 22, 2006

by Nyc_Tattoo
Yam Slacker
Actionscript :rimshot:.

There's always Rhino.

karms
Jan 22, 2006

by Nyc_Tattoo
Yam Slacker
Why not call initializationStuff yourself? No need to muck about with events because the DOM has already been initialized.

karms
Jan 22, 2006

by Nyc_Tattoo
Yam Slacker
I don't know if it would help if you'd fix it, but your setinterval is wrongly defined.

code:
<body onLoad="IntervalID = setInterval (ajaxFunction, 20000)">
I know that setinterval/settimer aren't guaranteed to fire at the specified time, it could take a bit longer. But your weird fluxuation in firing times is not really easily explainable.

edit: to clarify it's not wrong per se, but not very good practice.

karms fucked around with this message at 00:03 on Mar 6, 2010

karms
Jan 22, 2006

by Nyc_Tattoo
Yam Slacker
php:
<?
<select id="a">
    <option>1</option>
    <option>2</option>
    <option>3</option>
</select>
<script>
obj = function()
{
    this.change_now = function()
    {
        console.log('Where does /this/ point to?');
        console.log(this);
        
        this.say_hooray(); // hj;alp
    }
    this.say_hooray = function()
    {
        alert('Hooray!');
    }
}

an_object = new obj();

document.getElementById("a").onchange = an_object.change_now;
</script>?>
I've got an object that has a function, an_object.change_now(). You can see that I call this function from an onChange event on the select element. I want to be able to call say_hooray() from change_now() but as you can see, this isn't easy. The reference to the object has become the reference to the select element.

I know I could do an_object.say_hooray(), but in the real world that doesn't work since I don't know the variable name beforehand.

Is there a way to grab a reference to the original instance of obj even if this points to something else?

karms fucked around with this message at 14:54 on May 21, 2010

karms
Jan 22, 2006

by Nyc_Tattoo
Yam Slacker
Gah! :rolleye:

karms
Jan 22, 2006

by Nyc_Tattoo
Yam Slacker

Lumpy posted:

You can also use private methods which will execute in the scope of the parent and avoid using "this" altogether if say_hooray is only accessed interally.

That's even cooler! Hmm, letss see if crockford can give me some great examples of this..

karms
Jan 22, 2006

by Nyc_Tattoo
Yam Slacker
code:
$(document).ready(function()
{
	$(".checkbox input")
	.bind("change", function() { return checkBoxToggle(this); })
	.change();
}
edit: I think that works, but if it does not:

code:
$(document).ready(function()
{
	$(".checkbox input")
	.bind("change", function() { return checkBoxToggle(this); })
	.each(function() { checkBoxToggle(this); });
}

karms fucked around with this message at 16:01 on Aug 4, 2010

karms
Jan 22, 2006

by Nyc_Tattoo
Yam Slacker
If you have to ask, it already is.

karms
Jan 22, 2006

by Nyc_Tattoo
Yam Slacker
How about embedding js in a png and execute it? http://www.pouet.net/prod.php?which=59298

karms
Jan 22, 2006

by Nyc_Tattoo
Yam Slacker
There's always crockford's java script:the good parts and his website.

karms
Jan 22, 2006

by Nyc_Tattoo
Yam Slacker
Show code.

karms
Jan 22, 2006

by Nyc_Tattoo
Yam Slacker
It could be that ecmascript standard defines variables with more bits than the css' standard does for the rgba function.

karms
Jan 22, 2006

by Nyc_Tattoo
Yam Slacker
edit: nvm.

karms
Jan 22, 2006

by Nyc_Tattoo
Yam Slacker
Don't even try to do something based on that ofuscated piece of jibber jabber. Use your browser's development tools (Chrome: press F12, firefox: install firebug then F12, IE: install another browser since its devel tools are balls) and figure out a way to get at the inputs you want.

Because filling in a form though js is primarily navigating the DOM tree I'd use jQuery to make that part way easier, but it's up to you.

karms
Jan 22, 2006

by Nyc_Tattoo
Yam Slacker

gandlethorpe posted:

The environment is created by an external company (Oracle Corp). My job, as a lowly data entry operator, is to assist with testing databases, usually by entering lots of test (fake) data. In the past, I've had to enter 100 identical subjects into a database, which I accomplished with a crude AutoHotkey script. I'd like to learn how to create a more sophisticated script.

Good!

gandlethorpe posted:

Might be tricky, since supposedly the interface is only supported by IE, although I think I was able to log in on Chrome in the past. Either way, I'll have to wait until I go home to try a different browser than IE. If I am able to, how would I go about de-obfuscating it?

Don't worry about the existing javascript. Anything it does to change the site it has to go though the DOM (aka the site's structure), which your javascript has access to just the same. The biggest problem you're facing is viewing the DOM after the oracle js has its way with it. Doing a view > source just shows you the before picture, which is not useful in the least.

IE's developer console is definitely the worst out of the bunch because it likes to go slow as balls and/or crash for no reason at all at random intervals, but it still enables you to view the DOM as it is right now. The HTML tab is where that information lies. The Console tab allows you to input (single) lines of javascript and see its results immediately. Also, if your external javascript has a console.log(PUT SOMETHING HERE); it will show its output in this tab. Very useful.

karms
Jan 22, 2006

by Nyc_Tattoo
Yam Slacker

Wardende posted:

Hi all,

I'm new to JavaScript and I want to use it to build a Spotify app. I need to be able to access a database of some kind with my back-end code. All my previous JS experience (such as it is) has been limited to client-side stuff, so I don't know what the best way of going about this is. I know that node.js is designed to be a back-end implementation of JS but this is a small project so it doesn't seem to me that using node is warranted. Or is it? Does anyone have any suggestions about how to go about interfacing JS and a database? Thanks!

You don't? I don't see anything beyond "use our js stuff on an html page"?

karms
Jan 22, 2006

by Nyc_Tattoo
Yam Slacker

Bognar posted:

JavaScript code:
$("script").each(function() {
    var src = $(this).attr("src");
    doStuff(src);
});
Edit: Note that checking for which scripts have loaded is unreliable in almost all cases. Scripts can remove themselves from the document after being run. Also, scripts injected using innerHTML are in the DOM but not executed, so you would get a false positive. If you're looking for a specific script, it's best to check for some side effect of that script having loaded and executed (e.g. testing for window.jQuery).

Also to my knowledge you can't know if the file has been ajax'd in and eval()'d.

karms
Jan 22, 2006

by Nyc_Tattoo
Yam Slacker

Raskolnikov2089 posted:

Newbie javascript here.

I'm wrapping <a href="java script:void(0)" class="randomclass1"></a> in a div tag. Upon clicking the link, the class changes. Is java script:void(0) in this instance an event handler, or is it likely that the undefined value is just passed to a boolean that leads to the class change?

I'm trying to ape what happens to the Male/Female cutouts on http://slaveryfootprint.org/survey/#gender_and_age

java script:void(0) does literally zilch. What you're after is clickWoman in /static/js/views.js that gets attached to the actual dom object when a new instance of GenderView is instantiated. That page is made with a javascript framework and I highly suggest you step very far away from that particular train wreck (ed note: the negative view on js frameworks is the sole personal opinion of the author and does not reflect the professional opinion of this publication).

If you still want that behavior, it's far easier to get some jquery and a tiny little smidgen of js to do what you want. An example:

code:
.red {background-color:red;}
.blue {background-color:blue;}

#target {
display:block;
width: 100px;
height: 100px;
background-color:gray;
margin-top:50px;
}

.button {
display:block;
width: 50px;
height: 50px;
margin: 25px;
padding: 5px;
border: 3px solid black;
}
JavaScript code:
jQuery( document ).ready(function($){
  
  $('#blue_button').click(function(){
    $('#target').removeClass('red').addclass('blue');
    return false;
  });

  $('#red_button').click(function(){
    $('#target').removeClass('blue').addclass('red');
    return false;
  });


});
HTML code:
<a href="" class="button" id="red_button">MAKE IT RED</a>
<a href="" class="button" id="blue_button">MAKE IT BLUE</a>
<div id="target">What color am I?</div>

I wrote it here, untested, see how far you come with making this work for you!

karms
Jan 22, 2006

by Nyc_Tattoo
Yam Slacker

stoops posted:

64799 358.500 89.500 800.325 271.256 66.543
64800 359.500 89.500 800.370 271.257 66.551


Does one pixel position equal one line of text, or is it possible that it has more? How do the two columns correspond to the x/y coordinates of the image?

karms
Jan 22, 2006

by Nyc_Tattoo
Yam Slacker

stoops posted:

Yes it does. Awesome thanks, I'll try that.


Yes, one pixel position equals only one line of text. The x/y i'm passing are the lon(second column) and lat(3rd column)


JavaScript code:
data = "1 0.500 -89.500 725.330 88.743 -66.551
2 1.500 -89.500 725.359 88.744 -66.543
64799 358.500 89.500 800.325 271.256 66.543
64800 359.500 89.500 800.370 271.257 66.551";


var coords = [];
var data_array = data.split('\n').map(
    function(line) {
        line_array = line.split(' ');
        var lon = line_array[1];
        var lat = line_array[2];
        if (coords[lon] == undefined) coords[lon] = [];
        coords[lon][lat] = line;
    });
At this point you'll have a coords array that you could use to pull out the right line, instead of making a request to an php script. I'd rather put the x/y mouse positions in the coords array instead of the lat/lon, but I don't the conversion on that.

Any questions?

karms
Jan 22, 2006

by Nyc_Tattoo
Yam Slacker
Nope, that's pretty much it. :)

karms
Jan 22, 2006

by Nyc_Tattoo
Yam Slacker

CuddleChunks posted:

Thanks to everyone who peeked at this. I was going nuts trying to get it to work and am too new to this JSON stuff to know the difference between my own messup and the remote site.

Sheesh. "Here's our API! You can totally use it duders!" HOW???? I'll send them a message. Thanks again for the info everyone.

Save this as passthrough.php in the same folder you have your html:
php:
<?
echo file_get_contents('http://www.macvendorlookup.com/api/v2/'.
                       preg_replace('/[^a-z0-9\:\-\.]/i', '', $_GET['mac']));

?>
And change the javascript url statement to this:
JavaScript code:
    var url = "passthough.php?mac=";
    url += "00026f123456";
Tada. I'm guessing that your host has php enabled, but that's a pretty safe bet.

karms
Jan 22, 2006

by Nyc_Tattoo
Yam Slacker
Maybe set maxWindow to be slightly bigger than what maps thinks it needs to be?

karms
Jan 22, 2006

by Nyc_Tattoo
Yam Slacker

HappyHippo posted:

That's right, toUpperCase returns a new string and leaves the old one alone

You can read the MDN documentation here:

Note: even if toUpperCase did change Stuff in-place, the array still wouldn't be updated because Stuff points to a copy.

karms
Jan 22, 2006

by Nyc_Tattoo
Yam Slacker
edit: nm

karms
Jan 22, 2006

by Nyc_Tattoo
Yam Slacker
That would be stupendously simple if arguments was an array. So let's make it one with Array.apply:

function merge(){return Array.apply(null, arguments).join()}

Boom. To be submitted you really need to check if an arguement can be converted into a string so you don't end up with a bunch of [Object object]s (and NaN's probably?) but at least its not using a nested loop to copy over one length strings one by one. :psyduck:

edit: or be fancy like the guy above me.

Adbot
ADBOT LOVES YOU

karms
Jan 22, 2006

by Nyc_Tattoo
Yam Slacker

qntm posted:

You've both misunderstood the prompt. Look at the example output darthbob88 supplied, your code doesn't do that.

You're right. Yeah, I don't see an easier way of doing it then, my bad.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply