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
Polio Vax Scene
Apr 5, 2009



Is what I'm trying to do possible? I have a file hosted on a sharepoint server and want to read the contents remotely.
code:
		var url="http://server/file.doc"
		
		if (window.XMLHttpRequest) { 
			request = new window.XMLHttpRequest();
		} else {
			request = new ActiveXObject("MSXML2.XMLHTTP.3.0");
		}
		
		request.onreadystatechange=function() {
			if (request.readyState==4) {
				if (request.status==200) {
					//not working; request.responseBody is undefined
					alert(request.responseBody);
				} else {
					alert("The file could not be opened for reading.);
				}
			}
		}
		
		request.open("GET",url,true);
		request.send();
request.responseBody is undefined, but I'm getting the 200 response back ok.

Adbot
ADBOT LOVES YOU

Polio Vax Scene
Apr 5, 2009



What do you guys think is the best way to handle this situation:

The framework for some software my company is using has a ton of calls to retrieve a form field and then interact with it in some way, like this:

getField(fieldName).interaction();

Unfortunately we want the customer to be able to remove any fields they want. This means that getField() will return null if the field isn't present. Considering I've been told not to mess with getField(), what would you do?

My plan was to wrap it in a new function, sort of like this:
code:
interactWithField( fieldName ) {
 if (getField(fieldName) == null) {
  if (someDebugScenario) {alert("Field "+fieldName+" does not exist");}
  return false;
 }
 return getField(fieldName).Interaction();
}
Sloppy but you get the idea. Is this the best course of action?

Oh, I should also mention we want that debug scenario in there, which is why I don't just do if (getField()) {getField().interaction()}.

Polio Vax Scene fucked around with this message at 17:29 on Jun 13, 2012

Polio Vax Scene
Apr 5, 2009



I want to let the user save their game but I'm not sure of what would be the best way to do this.

I have three things which need to be saved: The current level name, a list of objects which persist between levels, and a list of objects which are permanently removed. Currently I'm saving this to a cookie but even with just a small amount of data I'm already over 1kb. I'm afraid that eventually I'll reach some cookie size limit and this will break it. I've done pretty much everything I can to make the save data as concise as possible. Is there some other method I can use for saving/loading? Saving a file on the server is out of the question.

Polio Vax Scene
Apr 5, 2009



That works perfectly and is easier than cookies even. Thanks!

Polio Vax Scene
Apr 5, 2009



Isn't results[0].geometry.location the same as results[0]['geometry']['location']?

Polio Vax Scene
Apr 5, 2009



Do you want help formatting the date or help writing the javascript?

http://msdn.microsoft.com/en-us/library/ff743760(v=vs.94).aspx

Basically each part of the string in printd's first argument is replaced based on what letter you use.

For your syntax remove the single quotes around sDate and you have a double quote in the first argument of printd().

Polio Vax Scene
Apr 5, 2009



HClChicken posted:

code:
function timestamp()
{var f = this.getField("today") var sDate = util.printd('dd mmm yyyy HH:MM tt', new Date());
f.value='Print date:'+sDate;
}
This is what I changed. What do you mean "what letter you use."

Beaten to it already but you'll also want a semicolon after ("today").

Polio Vax Scene
Apr 5, 2009



When are we getting a safe navigation operator for javascript? I'm so tired of null checking every part of a path / including a library as a dependency just for this.

Polio Vax Scene
Apr 5, 2009



I want to use Notifications in my site, but some dumb script is overwriting the Notification object as defined by the browser. What can I do about this if I can't remove the script?

Polio Vax Scene
Apr 5, 2009



The Fool posted:

Have you done any custom development for Dynamics 365?

I have. We use postMessage() to communicate between the D365 window and the cross-domain frame inside of it.
https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage

HappyHippo posted:

If they're modifying the elements within the iframe, then it isn't cross domain, no?

In D365 you can configure iFrames on the page to have a src that is a different domain so it's possible it's cross-domain to start with.

Polio Vax Scene
Apr 5, 2009



Volguus posted:

This is good. Ugly as hell, but good.

Lumpy posted:

It's already powering 12,874 e-commerce sites.

Jazerus posted:

please do not put my code into production.

Honestly all three of these are great

Polio Vax Scene
Apr 5, 2009



Trying to detect GSM-7 extension characters in a string using regexp.
https://en.wikipedia.org/wiki/GSM_03.38#GSM_7-bit_default_alphabet_and_extension_table_of_3GPP_TS_23.038_.2F_GSM_03.38
Regex gods, what am I missing here?:

code:
	//stolen from mdn
	var escapeRegExp = function (string) {
		return string.replace(/[.*+\-?^${}()|[\]\\]/g, '\\$&');
	}

	var testString = "should[match]|nonGSM-7^";
	var gsmRegExp = new RegExp(escapeRegExp("€|^{}[~]\\"), "g");
	var escapes = (testString.match(gsmRegExp) || []).length;
	console.writeLine(escapes); // 0??
v I knew it was something simple I was missing, thanks! The writeLine isn't in the actual code, I just fried my brain trying to figure this out beforehand.

Polio Vax Scene fucked around with this message at 14:06 on Jun 18, 2020

Polio Vax Scene
Apr 5, 2009



I must be missing something about module imports.
In this page the green square is pulled towards or repelled away from your mouse when you hold left click or right click.
This is done by checking MouseHandler.leftClicked and MouseHandler.rightClicked. here is the source code.
The class TestBlock extends GameObject, and GameObject is intended to draw a yellow or red outline on the square based on the same mouse events.
However, that part isn't working - the MouseHandler values in TestBlock are different from the values in GameObject for some reason.
I'm still very new to modules, if I had to guess, it has something to do with importing the same module in both classes' js files.

Polio Vax Scene
Apr 5, 2009



thank you. I ended up making the MouseHandler a non-static prop of GameHandler and passing it to the game objects as they are updated/rendered. I'm not sure if this is the best way to do it, but it at least gives consistent state to the TestBlock and its super.

Polio Vax Scene
Apr 5, 2009



tuples were a mistake

Polio Vax Scene
Apr 5, 2009



its probably been so widely used now that changing it in any way would cause chaos

Adbot
ADBOT LOVES YOU

Polio Vax Scene
Apr 5, 2009



Given I have a bunch of rectangular coordinates for blocks of text, what would be the best way to add them as selectable text blocks to a page and ensure their text content fits within the coordinates best it can?

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