Friday, May 27, 2011

TheMadScript Compressed released

TheMadScript Compressed has been officially released! This version is only 116 bytes smaller than TheMadScript 2.0.0, but if TheMadScript ever grows to be much, much bigger, this'll be a bit useful. The regular version is still available.

The JS file is located at "http://www.themadcomputer.com/themadscript_comp.js".

TheMadScript example page released

http://themadcomputer.com/themadscript/examples.html

Click on the link above to test out some TheMadScript examples. More are coming soon, so keep an eye out.

Thursday, May 26, 2011

TheMadScript reference and tutorial complete!

I know it took me a few days, but I finally got my big project done: updating the reference and tutorial for TheMadScript. I am not updating TheMadScript like this for a long time. So, you may be wondering why I updated TheMadScript to the second version so soon?

TheMadScript 1.0.0 came out with 16 methods and no objects. And the next day, I released TheMadScript 1.0.5, because I removed a useless method, the calculate() method. But TheMadScript wasn't useful enough.

TheMadScript has a lot of methods that you can display text with. For example, the round() method rounds a specified decimal number to the nearest integer, but that method used to only have two options to display the result: in an alert box or overwrite the document with text. Now you can display the result with your own text and the result of the rounding. And also, some methods have changed to objects.

Also, some methods were missing that could make TheMadScript more useful were missing. So I added those.

TheMadScript 2.0.0 is a more useful and convenient library now. It's the way it meant to be: small, simple, and easy to use. Go ahead and learn all the new methods, and you'll see what I mean.

Variables

A variable holds a value and can be accessed from anywhere in the JavaScript coding. Their values can be changed for the page session, and can be used in many cases. Because it is useful to study JavaScript before studying TheMadScript, you should already know this.

Browser support: all
TheMadScript version: 2.0.0

Syntax: v.variablename=value

Keep in mind that any variable, whatever you do with it, wherever it is, must always start with "v.".

userAgent object

The userAgent object returns the user agent headers sent by the server.

Browser support: all
TheMadScript version: 2.0.0

As with all objects, use JavaScript operators (unless there is no other text) to insert the userAgent object into your text-writing coding. This is just one way:

box_alert("User agent headers: "+userAgent);

screen object

The screen object returns the resolution and color depth of the screen.

Browser support: all
TheMadScript version: 2.0.0

Use JavaScript operators to insert the object (or any object) into your text-writing coding. This is just one way:

box_alert("Details on the screen: "+screen);

fullhref object

The fullhref object returns the entire href of the current page, including the query portion.

Browser support: all
TheMadScript version: 2.0.0

Use JavaScript operators to insert the object into your text-displaying coding (unless there is no other content). This is just one way:

box_alert("The entire href of the page is: "+fullhref);

fullDate object

The fullDate object will return the entire date. When you loaded this page, it was this date and time.

Browser support: all
TheMadScript version: 2.0.0

Use JS operators to insert the object (or any object) into the coding unless you don't have any other strings. It will work with any of the text-displaying methods. This is just one way of doing it:

box_alert("The time returned:"+fullDate);

squareRoot() method

The squareRoot() method returns the square root of a specified number. To display the result, add the object "num_sqrt" to your coding line.

Browser support: all
TheMadScript Version: 2.0.0

Syntax: squareRoot(number,result);

The below syntax finds the square root of 16 and displays the result in an alert box:

squareRoot(16,"box_alert(num_sqrt)");

upperCase() and lowerCase() methods

The upperCase() and lowerCase() methods convert a specified string to uppercase or lowercase. Add the object "str_ucase" into your coding to show the result.

Browser support: all
TheMadScript version: 2.0.0

upperCase() Syntax: upperCase(string,result);
lowerCase() Syntax: lowerCase(string,result);

The below syntaxes converts the string "TheMadScript is by TheMadComputer." to upper or lower case and shows the result in an alert box:

upperCase("TheMadScript is by TheMadComputer.","box_alert(str_ucase)");


lowerCase("TheMadScript is by TheMadComputer.","box_alert(str_ucase)");

showLength() method

The showLength() method counts the amount of characters in a specified string. The answer can be returned by adding the object "str_len" to the result coding.

Browser support: all
TheMadScript version: 2.0.0

Syntax: showLength(string,result);


The syntax below will display the length of the sentence "Welcome back!" in an alert box:

showLength("Welcome back!","box_alert('The sentence has '+str_len+' characters.')");

ifMatch() method

The ifMatch() method checks to see if one string matches another (case-sensitive) and then returns a result depending on whether they match or not. It is customizable.

Browser support: all
TheMadScript version: 2.0.0

Syntax: ifMatch(value1,value2,result1,result2)

The syntax below checks if the word "Heat" matches "heat" case-sensitive and alerts you if they match:

ifMatch("Heat","heat","box_alert('They match.')","box_alert('They do not match.')");

Wednesday, May 25, 2011

alertLeave() method

The alertLeave() method displays a popup box with the option to either leave the page or stay on it. It will be displayed only when the page tries to unload.

Browser support: all
TheMadScript Version: 2.0.0

Syntax: alertLeave(message);


The syntax below will tell the browser to alert you when you try to leave the page.

alertLeave("Are you sure you want to leave?");

timer() method

The timer() method executes a script after a specific number of milliseconds.

Browser support: all
TheMadScript Version: 2.0.0

Syntax: timer(milliseconds,result);


The syntax below will set a timer for 4500 milliseconds (4.5 seconds) and then display a welcome message in an alert box:


timer(4500,"box_alert('Welcome! This box displayed for 4.5 seconds!')");

format() method

The format() method formats and styles the content in the "body" element of a page; therefore it styles the document, unless a certain element has it's own styling. It is a much simpler way of formatting your page than using "raw" CSS.


Browser support: all
TheMadScript Version: 2.0.0

Syntax: format(background-color,background-image,font-family,color,font-size,text-align);

The syntax example below will give the body a special style. Refer to the synax above for the parameter actions:

format("yellow","","Verdana","blue","14px","center");

Notice

TheMadScript 2.0.0's reference is currently being worked on, to ensure that you get the latest version of the language. Please be patient while I work on the tutorial. I will announce when the tutorial is ready. Thank you for your support.

Tuesday, May 24, 2011

TheMadScript 2.0.0 Released!

I have officially released TheMadScript 2.0.0!

The reference page is temporarily down, but will be back again soon!

Monday, May 23, 2011

TheMadScript 2.0.0 in the works


Save the Cave is going to go further soon, and so is TheMadScript! I am adding new stuff. Please be patient while I update it.

The new version will feature:

  • More convenient way of getting results from confirm or prompt boxes.
  • More methods
  • Better ways of retrieving values (like the href of a page or the full date)
  • And more!
Please stay tuned for this exciting release. Be prepared for some changes, and get ready to avoid the "result" parameter!

Notice that some methods will be obsolete after this release. Further releases in which a method or object is deprecated, that deprecated method/object should remain available for a little while. But be prepared to take action.

Saturday, May 21, 2011

TheMadScript 1.0.5 being released and deprecation

Please note that TheMadScript has been updated to Version 1.0.5. There is no need to change your URL in your script tag; the library will still be located at: http://www.themadcomputer.com/themadscript.js. The following change(s) are/is:

  • An added parameter in the box_prompt() method
Please be prepared to take action and use the "result" parameter as the fifth parameter in the box_prompt().

Also note that the calculate() method has been officially deprecated. It is also obsolete and will not work.

How come that method has been deprecated? It does the same thing as the writeText() and box_alert() method: writes text. You can basically enter a message into the calculate() method like "Hello, there!", which would make no use of the calculate() method if using the writeText() method or box_alert() method instead.

So for calculations, use the writeText() or box_alert() method.

Friday, May 20, 2011

getScreen() method

The getScreen() method is obsolete. It was used to get the screen resolution and color depth. To get these details, add the "screen" object to your coding.

TheMadScript Version: 1.0.0

Syntax: getScreen(result);

getUserAgent() method

The getUserAgent() method is obsolete. It was used to get the user agent headers sent by the server. Instead, add the "userAgent" object to your coding to display it.

TheMadScript Version: 1.0.0

Syntax: getUserAgent(result);

gethref() method

The gethref() method is obsolete. It was used to display the entire href of a webpage, including the query portion. Insert the "fullhref" object into your coding instead to display the href of a webpage.

TheMadScript Version: 1.0.0

Syntax: gethref(result);

url() method

The url() method replaces the document with the specified URL.

Browser support: all
TheMadScript Version: 1.0.0

Syntax: url(url);

The below syntax will redirect you to my website:

url("http://www.themadcomputer.com/");

goHistory() method

The goHistory() method takes you back or forward the specified amount of pages.

Browser support: all
TheMadScript Version: 1.0.0

Syntax: goHistory(integer);

To go forward, enter a positive number to go forward (for example, 5 will take you forward 5 pages) or negative number to go backwards.

The syntax below takes the user back two pages:

goHistory(-2);

refresh() method

The refresh() method reloads the page.

Browser support: all
TheMadScript Version: 1.0.0

Syntax: refresh();

round() method

The round() method rounds decimal numbers to the nearest integer.

Browser support: all
Original TheMadScript Version: 1.0.0
Newer Version: Version 2.0.0

Syntax: round(integer,result);

Note: You do not have to use quotes for the integer.

The following syntax below displays an alert box that will tell you what 10.6 rounds to.

round(10.6,"box_alert('10.6 rounds to '+num_rnd+'.'");

random() method

The random() method defines a random integer that can be 0 or 1. Or, you can control which integer you want it to be. For example, defining 4 would pick numbers 0-4.

Browser support: all
Original TheMadScript Version: 1.0.0
Newer Version: 2.0.0

Syntax: random(integer,result);

Note: You do not have to use quotes for the integer.

The following syntax below displays an alert box that will show a number that could be anything from 0 to 100:

random(100,"box_alert(num_rand)");

css() method

The css() method is obsolete. It was used for formatting the document. Use the format() method instead.

TheMadScript Version: 1.0.0

Syntax: css(background-color,background-image,font-family,font-color,font-size,text-align);

showDate() method

The showDate method is obsolete. It was used to display the current full date. Instead, insert the "fullDate" object into your coding to show date (a more convenient way of showing the date).

TheMadScript Version: 1.0.0

Syntax: showDate(resultdisplay);

calculate() method

The calculate() method is obsolete. The calculate() method defined a math problem, but was removed the day after TheMadScript was released, because it could do exactly what writeText() or box_alert() could do.

TheMadScript Version: 1.0.0

Syntax: calculate(problem,result);

createWindow() method

The createWindow() method opens a new window. You can control the location and target with the two parameters.

Browser support: all
TheMadScript Version: 1.0.0

Syntax: createWindow(src,target);

The "target" parameter can contain any of the HTML targets used. For example, "_self" would replace the window/tab with a new one.

The following syntax below opens a new window directing to www.themadcomputer.com. It may be in a tab or a new window, depending on your browser:

createWindow("http://www.themadcomputer.com/","_blank");

writeText() method

The writeText() method displays text that overwrites the entire document.

Browser support: all
TheMadScript Version: 1.0.0

Syntax: writeText(text)

The following syntax below will write text and replace the current document with the text "Hello, there! This is text written with TheMadScript.":

writeText("Hello, there! This is text written by TheMadScript.");

box_prompt() method

The box_prompt() method displays a popup box containing a text box. You can use this for certain actions in your site such as the user entering his or her name, or for another purpose. There is a parameter in which you can enter coding to control the result. To display text entered into the prompt box, add the object "str_rslt".

Browser support: all
Original TheMadScript Version: 1.0.0
Newer version: Version 2.0.0

Syntax: box_prompt(message,defaultValue,result);

The following syntax below creates a prompt box that asks for your name and has a default name in the box awhile, and displays a welcome message in an alert box afterwards:

box_prompt("Please enter your name.","John Doe","box_alert('Hello, '+str_rslt+'!");