Lone Wolf Development Forums  

Go Back   Lone Wolf Development Forums > Realm Works Forums > Realm Works Discussion
Register FAQ Community Today's Posts Search

Notices

Reply
 
Thread Tools Display Modes
mirtos
Senior Member
 
Join Date: Oct 2011
Posts: 865

Old August 10th, 2014, 07:12 PM
Unfortunately, it appears that the RW Javascript engine is based on IE, but isnt neccesarilly the one of your IE. I know this because i wrote a more complex script, using things like document.getElementByID().getElementsByClassName()

It works in IE, no errors, but not in RW. Im guessing the document model isnt available to the inline RW.


I'm unable to get it to works with RW, but it looks like you cant trust that it works in the browser of IE to work with RW. That fact that RW uses the same UserAgent is one thing, but it might have a different Javascript engine. dont know enough about it. Or it might be more sensitive t something im missing... could be my markup (HTML) dont know.

EDIT: Here is another version, that doesnt use the document model, but basic form, with two fields instead of one. Im wondering if its failing due to either a markup issue, or maybe something to do with multiple statements on one action. Again, this works in both chrome and IE, but now RW. Not sure.

Code:
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<TITLE>Varisia Caravan Encounters</TITLE>
</HEAD>
<BODY>

<script language="JavaScript">

// Some Arrays


rnd.today=new Date();
rnd.seed=rnd.today.getTime();

function rnd() {
rnd.today=new Date();
rnd.seed=rnd.today.getTime();
rnd.seed = (rnd.seed*9301+49297) % 233280;
return rnd.seed/(233280.0);
}

function rand(number) {
return Math.ceil(rnd()*number);
}

function tableResults(argument, sectionIdentifier) {

var varisiaArray = [];

varisiaArray.push({"max": 15, "name": "Bad Weather", "content": "Fog, rain, high winds, or some other form of bad weather slows the caravan, reducing its overall speed by half for the day unless the caravan makes a DC 12 Security check." });
varisiaArray.push({"max": 30, "name": "Bandit Ambush (CR 2)", "content": "The caravan must make a DC 15 Security check to notice this ambush in time to react; if this check fails, the caravan takes a –2 penalty to its Armor Class and on attack rolls for the first round of combat. The ambushers could be a group of bandits, a gang of highwaymen, or even a small tribe of Nolander barbarians. Regardless of their makeup, the ambushers’ stats and aggression are identical (AC 14; hp 20; Attack +4; Damage 2d6+3). They fight to the death. If defeated, 1 cargo unit of treasure worth 250 gp can be recovered."});
varisiaArray.push({"max": 50, "name": "Goblin Raiders (CR 1/2)", "content": "A shrieking band of goblins wielding dogslicers and broken branches attacks the caravan (AC 11; hp 10; Attack +1; Damage 1d8). If the PCs have a horse train, the goblins are more timid than normal and take a –2 penalty on attack rolls. If defeated, a search of the goblins reveals a single cargo unit of treasure worth 125 gp."});
varisiaArray.push({"max": 55, "name": "Ogre Assault (CR 3)", "content": "A small band of ogres lumbers out of the surrounding foliage to attack the caravan (AC 15; hp 30; Attack +6; Damage 3d4+6). The ogres flee if reduced below 10 hit points. If they are slain, looting produces 2 cargo units of treasure worth 400 gp each."});
varisiaArray.push({"max": 65, "name": "Treacherous Road", "content": "The road conditions become hazardous. They might be muddy, partially flooded, or even blocked by a fallen tree. The caravan must make a DC 14 Security check or lose 2d6 miles of progress for the day as the situation is dealt with."});
varisiaArray.push({"max": 100,"name": "Varisian Caravan", "content": "The PCs encounter another Varisian caravan heading in the opposite direction. With a DC 12 Resolve check, the PCs can befriend the other caravan. If this encounter occurs during the day, the caravan can give the PCs advice as to what lies ahead, reducing the chance of an encounter to 5% per day for the next 1d6 days. If the encounter occurs during the evening, the caravan agrees to share their camp, allowing the PCs to trade with them. The caravan can purchase up to 2,000 gp in objects, and can offer anything worth 600 gp or less for sale."});



var allArrays = {
"varisia": varisiaArray,
};

var randomNum = rand(100) + 1;
var arrayOfChoices = allArrays[argument];
var error = "";
if (!arrayOfChoices) {
	error =  "no such set: " + argument;
}


var content = "";
var name = "";
for (var itemIndex in arrayOfChoices) {
	var item = arrayOfChoices[itemIndex];
	if (randomNum <= item.max) {
		content = item.content;
		name = item.name
		break;
	} 
}

  var results = [];
  if (error) {
     results.name = "";
	 results.content = error;
  } else {     
     results.name = name;
	 results.content = content;
  }
  return results;
 
}

</script>

<div id="error"></div>
<form>
      <input type="button" name="Button1" value="Varisia Caravan Encounters" onClick="var x = tableResults('varisia');this.form.name.value=x.name;this.form.content.value = x.content;" size="" />
	  <input name="name" style="font-weight:bold;"></input>
	  <textarea name="content" cols="40" rows="10" wrap="soft"></textarea>
	  
</form>

Last edited by mirtos; August 10th, 2014 at 07:55 PM.
mirtos is offline   #31 Reply With Quote
davidp
Senior Member
Lone Wolf Staff
 
Join Date: Jun 2011
Posts: 1,090

Old August 10th, 2014, 09:28 PM
Quote:
Originally Posted by mirtos View Post
Unfortunately, it appears that the RW Javascript engine is based on IE, but isnt neccesarilly the one of your IE. I know this because i wrote a more complex script, using things like document.getElementByID().getElementsByClassName()
I believe the embedded browser behaves in a compatibility mode such that it behaves like IE 6 or something similarly old. You can put into the HTML page an override to get more up-to-date parsing:

http://stackoverflow.com/questions/4...into-standards

I believe the intent is that when a program with an embedded browser control (such as Realm Works) runs on different computers that have different versions of IE installed, they will behave the same and you won't have differences in behavior. But it also means it sets things to a lowest common denominator type of setting.
davidp is offline   #32 Reply With Quote
mirtos
Senior Member
 
Join Date: Oct 2011
Posts: 865

Old August 11th, 2014, 05:28 AM
makes sense that they would do that, though from what i imagine, it would be very surprised if it behaved as IE 6. Microsoft stopped supporting that a long time ago, and is very adamant about getting people off of it, and I doubt they would want any other software to be using it. Its probably an IE 8 or something like that.
mirtos is offline   #33 Reply With Quote
davidp
Senior Member
Lone Wolf Staff
 
Join Date: Jun 2011
Posts: 1,090

Old August 11th, 2014, 06:02 AM
Quote:
Originally Posted by mirtos View Post
makes sense that they would do that, though from what i imagine, it would be very surprised if it behaved as IE 6. Microsoft stopped supporting that a long time ago, and is very adamant about getting people off of it, and I doubt they would want any other software to be using it. Its probably an IE 8 or something like that.
Ok, I was probably too pessimistic. But I believe it is IE7 rendering mode that it does. So to get IE 8 or greater behavior, extra steps have to be used.
davidp is offline   #34 Reply With Quote
mirtos
Senior Member
 
Join Date: Oct 2011
Posts: 865

Old August 11th, 2014, 08:25 AM
Quote:
Originally Posted by Parody View Post
Realm Works (likely via the .NET WebBrowser control) uses the engine from the main version of IE installed on your machine. I have IE11 and the User Agent for Realm Works is:


It'll navigate to other websites and run plugins if you want. I wouldn't recommend using external resources but you likely can. At that point, though, why not just link to a page on the Internet? The "local" page won't work without Internet access anyway.
According to Parody it is correctly finding the UserAgent of IE 11, if it is showing this:


Quote:
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/7.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)

Seems odd to be using a different rendering mode. But anyway, we arent talking about rendering mode, i dont think anyway, just what JS methods are available. Im going to do a test when i get home, see if a jquery page will work. (granted that will require internet access as Parody mentions)
mirtos is offline   #35 Reply With Quote
davidp
Senior Member
Lone Wolf Staff
 
Join Date: Jun 2011
Posts: 1,090

Old August 11th, 2014, 08:30 AM
Quote:
Originally Posted by mirtos View Post
Seems odd to be using a different rendering mode. But anyway, we arent talking about rendering mode, i dont think anyway, just what JS methods are available.
I would think it would affect the JS methods available as they could affect how things are rendered.

Quote:
Originally Posted by mirtos View Post
Im going to do a test when i get home, see if a jquery page will work. (granted that will require internet access as Parody mentions)
One thing you might be able to do, to prevent the need for Internet access, is once you have created your page, save it as a web archive file. I believe that will bundle all of the resources together into a single file.
davidp is offline   #36 Reply With Quote
mirtos
Senior Member
 
Join Date: Oct 2011
Posts: 865

Old August 11th, 2014, 09:12 AM
You're generally right about USer Agents affecting JS engines, but I was using pretty basic stuff. Still, I dont know for sure if its an IE 7 thing. Unfortunately my version of IE doesnt let me emulate IE 7 for testing.

The web archive thing is a very interesting thought... ill give that a try. loading in the jquery library would make things a lot easier as it handles most browser checks (It would make the storage in the database very big, though it would add 100K to each web page.).

I assume its impossible to get RealmsWorks to show JS errors? (its more of curiosity thing for me than a need thing)
mirtos is offline   #37 Reply With Quote
Parody
Senior Member
 
Join Date: Jan 2013
Location: Rochester, MN
Posts: 1,516

Old August 11th, 2014, 04:27 PM
Some of this probably duplicates everyone else's research, but:

Poking around it appears that the default for the WebBrowser control is to tell IE to handle everything like IE 7. So there's things like this StackOverflow question that shows how to do getElementsByClassName() in IE7 and IE8.

You can override this via the registry, if you know exactly which version of IE you want.

You can also override it in your own pages by using a meta right after <head>. This one makes it run your page using the latest version of IE on your system:
Code:
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
That made document.getElementsByClassName() work in RW in a quick test for me.

Unfortunately, we don't know which version of IE will be installed on the system; IE7 is possible on both XP and Vista, and IE8 on 7. So you're still stuck working around things. At least we have a baseline?

Parody is offline   #38 Reply With Quote
mirtos
Senior Member
 
Join Date: Oct 2011
Posts: 865

Old August 11th, 2014, 04:39 PM
this is why i was thinking that something like a jquery library would be the best. It handles all of that much better than most of us could on our own. On the other hand, it means each web page you do will be 100K bigger...

its also much more readable when doing multiple parent levels.

but i feel stupid for not doing the meta tag.. i know that. doh.

IE 7 javascript sucks. IE 8 and more are so much better. I wonder why my last script didnt work though. I wasnt doing getElementsByClassname.. just assigning multiple variables in a onclick ... i wonder if IE 7 cant deal with that. (its been over 12 months since ive had to deal with pre IE 8 issues... so glad my company no longer supports it)
mirtos is offline   #39 Reply With Quote
Parody
Senior Member
 
Join Date: Jan 2013
Location: Rochester, MN
Posts: 1,516

Old August 11th, 2014, 05:30 PM
Quote:
Originally Posted by mirtos View Post
IE 7 javascript sucks. IE 8 and more are so much better. I wonder why my last script didnt work though. I wasnt doing getElementsByClassname.. just assigning multiple variables in a onclick ... i wonder if IE 7 cant deal with that. (its been over 12 months since ive had to deal with pre IE 8 issues... so glad my company no longer supports it)
The websites I work on aren't that complicated (some server-side code but almost no interactive) so I haven't had to deal with javascript issues between browsers/versions. Another thing I'm glad I missed, for the most part.

Parody is offline   #40 Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 06:20 AM.


Powered by vBulletin® - Copyright ©2000 - 2024, vBulletin Solutions, Inc.
wolflair.com copyright ©1998-2016 Lone Wolf Development, Inc. View our Privacy Policy here.