So Kerm, you've done it again XD forcing me to post my random projects on cemetech.

Alright, here we go. I need a project template because i have NO clue how to operate in languages outside JS and HTML. Here's the deal, I've been coding some simple code on a Role-Play site. Limitations are that i can't use <script> tags, they get removed when displaying the page. If I use javascript in a <button> tag or what not, works flawlessly. Now, on this profile page, I've started creating buttons that show/hide <div> tags accordingly. Hide all, show desired. The current Button im working on, will show a small form to fill out. Asks for your name(text), your gender(4 options), which of my RP characters you want to RP with(6 options), RP length(4 options), and key terms you want in the search(text).

Using a submit button is out of the question. I want everything to be accessible from the page by default. When you click <input type="button"> it should query for a matching (random) RP starter, and post it to <textarea id="results>, hide the form div, and show the results div. the following code works, though the script will have to be edited to work to your code =.=


Code:

<script type="text/javascript">
function poststarter() {
   if (document.getElementById("username").value == "") {
      document.getElementById("results").value = "Please enter a name first!";
      return;
   }
   val ret = "Sorry, No Roleplays with these parameters

could be found!";

   
   document.getElementById("results").value = ret;
}
</script>


<div id="starter" style="display:none;">
<div id="form">
<b>Random Starter Generator:</b><br>
<form name="myForm" method="post">
<b>Your Name:</b> <input type="text" name="fname" id="username"><br>
<b>Gender:</b>
<select id="gender" size="1">
<option value="0">Hidden</option>
<option value="1">Male</option>
<option value="2">Female</option>
<option value="3">Other</option>
</select>
<b>RP Option:</b>
<select id="type" size="1">
<option value="0">No Preference</option>
<option value="1">Human</option>
<option value="4">Human(Cyber)</option>
<option value="2">Meta-Human</option>
<option value="3">Furry</option>
<option value="5">Furry(Cyber)</option>
</select></br>
<b>RP Length:</b>
<select id="type" size="1">
<option value="0">Dynamic</option>
<option value="1">Short</option>
<option value="2">Mid</option>
<option value="3">Long</option>
</select></br>
<b>Key Term(s):</b> <input type="text" name="fkeys"><br>
<input type="button" onclick="poststarter();document.getElementById('form').style.display =

'none';document.getElementById('result').style.display = '';" value="Submit"/>
</form>
</div>
<div id="result" style="display:none;">
<form name="myResults" method="post">
<textarea id="results" name="results" cols="40" rows="5"></textarea></form>
<br>
<input type="button" onclick="document.getElementById('form').style.display =

'';document.getElementById('result').style.display = 'none';" value="Retry"/>
</div>
<br>
<hr />
</div>


The script tag is used off-site for testing purposes, it will eventually be added into the button onclick event. What i need is for someone to write in a code of their choosing (i can host the code on a free page of mine to be called from) and alter the selected source to work with it.

The template you make will need to have at least 2 basic replies, and post them in the message. Best of luck!
Question: why can't it be done in the Javascript framework you've already designed, just shoving the function into a random tag's onclick? Why does it need something more complex than that?
I'm using it with Chatango, which declines the use of <script type="text/javascript"></script> for whatever reason. allows css, but not javascript? ~shrugs. Workarounds are the key here... can probably include javascript from another source, ill have to try it sometime?

Point is still very evident, doing this entirely in Javascript will become quite troublesome. It would be very handy if all the data could be held in an outside source, called with PHP or something, and displayed in the page.

----

Made some modifications around. <script> tags dont work at all for some weird glitch in their systems. however... the following fixed it up ghetto style Very Happy


Code:

 <button
type="button" onclick="document.getElementById('rules').style.display =
'none';document.getElementById('characters').style.display =
'none';document.getElementById('personal').style.display =
'none';document.getElementById('starter').style.display = '';var head= document.getElementsByTagName('head')[0];var script= document.createElement('script');script.type= 'text/javascript';script.src= 'http://www.freewebs.com/covertwebs/data.js';head.appendChild(script);">Starter</button>


Really complicated, but you press the Starter button, and it shows the form, and then loads the script ^.^ Now i can load my code into the javascript elsewhere and modify it on the fly, leaving my page alone from now on Very Happy or until i feel like adding something new to it >.<

errr, im far too tired right now to come up with one, but i'd appreciate someone create a better toggle for this =.= If you press the button multiple times, it keeps loading a new instance of the script. Although not a big resource, this will eventually get fairly large and hog your resources. Need to only toggle this ONCE durring a run? could hide the button and show another button XD you figure it out, i'll check back later
To address your Skype message where you said no one wants to write you code and that's why you don't post on Cemetech, that's the problem: none of us has the patience to do your project for you.
Unless you really need help, I don't think anyone should write code for you, then it wouldn't really be your project anymore. It's understandable if you completely don't know how to do something (like I asked for help on some of my CALCnet Tournament routines), but once you already have a base to work from you should be able to figure it out on your own.
Even with CALCnet Tournament, I provided first conceptual help ("the flow for this routine would be something like, first blah, then blah...") then specific eyeballing of tightly-bound sections of broken code to help you track down bugs. I didn't write code and give it to you; that's what I get paid the dollars to do as a researcher and as a professional. Razz

Does anyone have anything constructive to through in Komak's general direction, now that we got that straight?
I'm perfectly understanding of your situation. My coding is in pseudo languages. I have some better knowledge of Java, but trying to do a project like this in Javascript has become far more than what i know and understand.

In c++ or something, i would create a class structure as such:

Code:

struct Post {
  int chara;
  int gender;
  string post;
};
vector<Post> Starters;

void PopulateList();
Post GetStarter(string uname, int gender, int character, int rplen, string keyterms) {
// some code that matches the different parameters and stores the results in another list
// some randomizer to pick one of the available starters
return Matches[randnum];
// else return the default post
Post def;
def.post = "Sorry, I couldn't come up with a starter for you =.=";
return def;
}


of course there's more to it than that... but that's essentially what I want... GOOD NEWS THOUGH! I did manage to load all the javascript stuff from an outside source, so i can edit it all nice and pretty without mass updating the main site >.>

Point is, the commands for javascript are all very automated =.= and writing code like the above seems rather... difficult =.= I just dont know enough web scripting to do the project I want, and the harder I look, the more pissed i get at not finding the proper functions. This should really be a cake-walk for someone who understands the language and uses it daily. Best I've ever done was to make a simple javascript form do some math/time calculations for an iMacro script so it would play a game for me?

------------------
Here's what i've come up with... and it "sort of" works to an extend. It either returns 10/10 or 0/0 depending on the options I select, and only randomizes to the 10th (last) starter?
'

Code:

var Starters = new Array();

function starter (char, gender, post) {
   this.type = this;
   this.char = char;
   this.gender = gender;
   this.post = post;
   return this;
}

function LoadVariables() {
   var retarray = new Array();
   retarray.push(starter(1,1, "Human male Starter! [0]"));
   retarray.push(starter(1,2, "Human female Starter! [1]"));
   retarray.push(starter(4,1, "Human Cyber male Starter! [3]"));
   retarray.push(starter(4,2, "Human Cyber female Starter! [4]"));
   retarray.push(starter(2,1, "Meta-human male Starter! [5]"));
   retarray.push(starter(2,2, "Meta-human female Starter! [6]"));
   retarray.push(starter(3,1, "Furry male Starter! [7]"));
   retarray.push(starter(3,2, "Furry female Starter! [8]"));
   retarray.push(starter(5,1, "Furry Cyber male Starter! [9]"));
   retarray.push(starter(5,2, "Furry Cyber female Starter! [10]"));
   return retarray;
}

function GetStarter(name, gender, char, rplen, keyterms) {
   var arg = GetStarter.arguments;
   var args = arg.length;
   // filter array of mis-matched gender/profiles
   var results = new Array();
   var i=0;
   for(i=0;i<Starters.length;i++)
   {
      if ((Starters[i].gender == gender) || (gender == 0)) {
         if ((Starters[i].char == char) || (char == 0)) {
            results.push(Starters[i]);
         }
      }
   }
   alert(results.length + "/" + Starters.length + " matches found...");
   var retpost = "Sorry, I haven't filled any posts with this criteria >.> be patient!";
   if (results.length > 0) {
      var rnum=Math.floor(Math.random()*(results.length));
      retpost = results[rnum].post;
   }
   return retpost;
}

function poststarter() {
   Starters = LoadVariables();

   if (document.getElementById("username").value == "") {
      document.getElementById("results").value = "Please enter a name first!";
      return;
   }
   var rpName = document.getElementById("username").value;
   var rpGend = document.getElementById("gender").value;
   var rpType = document.getElementById("type").value;
   var rpLength = document.getElementById("leng").value;
   var rpKeys = document.getElementById("fkeys").value;
   alert("Searching SEX[" + rpGend + "] TYPE[" + rpType + "] LEN[" + rpLength + "]\nKeys: "

+ rpKeys);
   ret = GetStarter(rpName, rpGend, rpType, rpLength, rpKeys);
   document.getElementById("results").value = ret;
}


Let me clarify... All 10 results are Female + Furry (Cyber)... aka the last post... So for whatever reason, my list isn't being updated properly? Isn't push() the proper way to do this?
Finally made some serious progress =.= Outsourced my code so I could shrink the amount of code on my main page =.= they only allow certain lengths on it apparently.

http://www.freewebs.com/covertwebs/starter.htm

Still trying to determine how to estimate RP lengths, shouldn't be that hard. I got to wondering... Being that its freewebs, Is there any free way i can make a submit form to let people send me starter requests and look through them later? I know hosting a SQL server and what not could do it >.> but i cant host it on our network and people are too lazy to visit forums these days... lookin for resources here, not code (unless your in the mood for freebies?)
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement