Jump to content
UBot Underground

I Need Help From a Javascript Pro


Recommended Posts

I'm trying to trigger a flash button on buzzfeed.com to upload an image. I have been at it now for a few hrs and really don't know what to do here, So I'm hoping someone can help me by looking at the code below. Thanks!

 

 

 

<script type="text/javascript">

// hide spinner
if (parent.document.getElementById('user-loading')) parent.document.getElementById('user-loading').style.display = 'none';

	// register even for image cancel
	var cElement = document.getElementById("image-cancel"); 
	YAHOO.util.Event.addListener(cElement, "click", function(e) { 
		YAHOO.util.Event.stopEvent(e);
		var iframe = parent.document.getElementById('user-image-edit-iframe'); 
		iframe.src="/static/images/public/spinners/big_on_eee.gif";			 
		parent.document.getElementById('user-image-edit').style.display = 'none'; 
	});		

	var hasReqestedVersion = DetectFlashVer(9, 0, 45);
	//alert(hasReqestedVersion);
	if(hasReqestedVersion) {
		YAHOO.widget.Uploader.SWFURL = "/static/js/yui2.6/uploader/assets/uploader.swf";
		var uploader = new YAHOO.widget.Uploader( "toBeReplaced", 'http://s-ak.buzzfed.com/static/images/uploader/select.png' ); 	
		user_image.init(uploader);
	} else {
		document.getElementById("toBeReplaced").style.display = 'block';
	}	


</script>

Link to post
Share on other sites

My javascript skills are pretty rubbish, so can't help that much, but if you can get the ID of the control you want to fire, you can use something like

 

var fireThis = document.getElementById('**ELEMENT HERE**');
if( document.createEventObject ) {
fireThis.fireEvent('click');
}

 

replace **ELEMENT HERE** for the element ID you want

you can replace 'click' for any JS event, so onchange, mouseup, mousedown etc etc

  • Like 1
Link to post
Share on other sites

Have been trying to test it out in buzzfeed, but cannot get the flash thing to work at all. Just get a black box with a save and cancel button. From what I can tell, the code you have posted above is not relevant but tbh I don't really know. Will have another look next time reboot machine to see if that helps me run the flash.

Link to post
Share on other sites

Have been trying to test it out in buzzfeed, but cannot get the flash thing to work at all. Just get a black box with a save and cancel button. From what I can tell, the code you have posted above is not relevant but tbh I don't really know. Will have another look next time reboot machine to see if that helps me run the flash.

 

I sure do appreciate the effort, and also the code you shared. Yeah, I'm not sure that the script i posted helps at all. Thanks again.

Link to post
Share on other sites

Well, mine would be a little more extreme. Instead of using flash as a gateway to upload the file, write a html page that will do exactly the same thing. This will save a lot of headache. Of course, another way would be tampering around with the javascript, which takes up hella lotsa time. Again, once you figure out which function does this and which functions pass the variable back to processing script, you can create another static html or custom javascript that does the same thing.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...