| Subcribe via RSS

javascript reference

May 28th, 2008 | No Comments | Posted in anything under the moonlight, javascript by dreamluverz


Here’s a good site for javascript reference:

http://users.dickinson.edu/~braught/courses/cs131s99/jsRef.html

Tags:

prototype window

May 28th, 2008 | Comments Off | Posted in anything under the moonlight, javascript by dreamluverz

I discovered this thing from a friend and it’s a cool stuff. Haven’t tried it though but really excited to give it a shot.

Overview



This javascript class allows you to add window in a HTML page.

This class is based on Prototype. The code is inspired by the powerful script.aculo.us library. You can even use all script.aculo.us effects to show and hide windows if you include effects.js file , but it’s not mandatory.

It has been tested on Safari, Camino, Firefox and IE6, Opera looks fine.

Features

  • Valid HTML/XHTML generated code
  • Resizable windows
  • Minimize/Maximize
  • Modal dialogs
  • Visual effects
  • Skinnable
  • And more…

How to Use

It's easy to use, just include two javascripts and one css (more if you want different skins).


<script type="text/javascript" src="/javascripts/prototype.js"> </script>

<script type="text/javascript" src="/javascripts/window.js"> </script>
<link href=”/stylesheets/themes/default.css” rel=”stylesheet” type=”text/css”/>
<!–  Add this to have a specific theme–>

<link href=”themes/mac_os_x.css” rel=”stylesheet” type=”text/css”/>

To create a window, you just have to instanciate a Window object with some optional parameters, set innerHTML of the window main content and call show() or showCenter() function. Check out the samples tab with more sample codes

win = new Window({className: “mac_os_x”, title: “Sample”, width:200, height:150, destroyOnClose: true, recenterAuto:false});
win.getContent().update("Hello world !!”);
win.showCenter();


source: http://prototype-window.xilinus.com/index.html

Tags: , ,

stopPropagation() and cancelBubble

May 14th, 2008 | No Comments | Posted in javascript by dreamluverz

Another way of doing the cancelBubble:

function dropButtonClick(e) { if( typeof( e ) == "undefined" && typeof( window.event ) != "undefined" ) e = window.event; // do things.... if (typeof( window.event ) != "undefined" ) { // IE e.cancelBubble=true; } else { // Firefox e.stopPropagation(); } }

source: http://blogs.charteris.com/blogs/edwardw/default.aspx

Tags: , ,

cancelBubble

May 14th, 2008 | No Comments | Posted in javascript by dreamluverz

I have this function but something was wrong with firefox. I got undefine value. After taking a closer look in my code I forgot to pass the 'event' parameter on my function.

function dps_cancel_bubble(e)
{
if (!e) var e = window.event;
e.cancelBubble = true;
if (e.stopPropagation) e.stopPropagation();
}

so you need to call it like this.

<img src=”" onlickc=”dps_cancel_bubble(event)”> DONT EVER FORGET TO PASS event or else you’ll get crazy looking for the bug :P I almost did :lol:

Tags: , , , , , ,

array push in javascript

May 14th, 2008 | No Comments | Posted in javascript by dreamluverz

Example:

for(d = 0; d< arr.length; d++){
arr2[arr2.length++] = arr[d];
}

source: http://blog.dreamvib.com/programming/javascript-array_push/

Tags: ,

Jason’s Date Input Calendar

May 12th, 2008 | No Comments | Posted in javascript by dreamluverz

Just check the source of this post below for the js code and sample. Anyway if you got them already You can use the additional info for your quick reference.

Additional Information

Below describes function “DateInput()” in detail, which you need to understand to take full advantage of this script:

DateInput(DateName, Required*, DateFormat*, DefaultDate*)

All parameters with a * are optional, and if not passed in a value, the default value is used.

DateName STRING - required. Name of the hidden form element to store the selected, formatted date  You do NOT need to create this field manually in your form.
Required BOOLEAN - optional. Default = FALSE (TRUE or FALSE). Determines whether user is required to make a date selection. If set to false (default), an extra “blank” field appears at the top of the month select menu (above January), in which selecting it causes nothing to be passed to the form.
DateFormat STRING- optional. Default is set as a global variable in the script (MM/DD/YYYY on this page). The format of the generated Date value. It can be one of the following:

  • YYYYMMDD
  • YYYY-MM-DD *
  • YYYY-DD-MM *
  • YYYY/MM/DD *
  • YYYY/DD/MM *
  • YYYY-DD-MON *   **
  • YYYY-MON-DD *   **
  • MM-DD-YYYY *
  • DD-MM-YYYY *
  • MM/DD/YYYY *
  • DD/MM/YYYY *
  • DD-MON-YYYY *   **
  • MON-DD-YYYY *   **

*   2-digit year can be used instead of 4-digit year
** 3-character month name abbreviation can also be specified as MMM.

DefaultDate STRING- optional. The default date displayed in the drop down menus. If none is specified, today’s date is used.

Source: http://www.dynamicdrive.com/dynamicindex7/jasoncalendar.htm

Tags: , , , ,

javascript: 127.0.0.1:1025/js.cgi?paw&r=

April 7th, 2008 | 2 Comments | Posted in javascript by dreamluverz

I’m getting this on most of the websites I visit. But when I try to visit the same site on different location I don’t have it when viewing the source code.
And since 1025 port is used by some trojans I wonder if my pc is being hacked on under attacked? Please who could tell me what’s going on here…

<script language=‘javascript’ src=‘http://127.0.0.1:1025/js.cgi?pa&r=30106′></script>

I just found this from: http://www.wilderssecurity.com/archive/index.php/t-6735.html
<!– ZoneLabs Privacy Insertion –>
<script language=’javascript’ src=’http://127.0.0.1:1025/js.cgi?paw&r=14893′></script>

so it seems ZAPro does some extra too, but as i’ve seem my IP displayed in other places it’s not hiding all time.

and yes I’m using zone alarm, so I’m gonna check my zone alarm settings…

Tags:

javascript: typeof

March 8th, 2008 | No Comments | Posted in javascript by dreamluverz

typeof returns one of the following strings:

  • number
  • string
  • boolean
  • object
  • function
  • undefined

typeof(typeof(x)) is always string, no matter what x actually is.

IE seems to think that some functions are objects rather than functions: typeof(document.getElementById) returns object.

 

source: http://www.adp-gmbh.ch/web/js/operators/typeof.html

Tags: ,

insertRow() - inserting dynamic rows in javascript

February 13th, 2008 | No Comments | Posted in javascript by dreamluverz

Summary

insertRow inserts a new row in the table.

Syntax

var row = HTMLTableElement.insertRow(index);
  • HTMLTableElement is a reference to a HTML table element.
  • index is the row index of the new row.
  • row is assigned a reference to the new row.
    If index is -1 or equal to the number of rows, the row is appended as the last row. If index is omitted or greater than the number of rows, an error will result.

Example

<table id="TableA">
  <tr>
    <td>Old top row</td>
  </tr>
</table>

<script type="text/javascript">

  function addRow(tableID)
  {

    // Get a reference to the table
    var tableRef = document.getElementById(tableID);

    // Insert a row in the table at row index 0
    var newRow   = tableRef.insertRow(0);

    // Insert a cell in the row at index 0
    var newCell  = newRow.insertCell(0);

    // Append a text node to the cell
    var newText  = document.createTextNode('New top row')
    newCell.appendChild(newText);
  }

// Call addRow() with the ID of a table
addRow('TableA');

</script>
source: http://developer.mozilla.org/en/docs/DOM:table.insertRow
Tags: , ,

checkbox select all function

February 7th, 2008 | 1 Comment | Posted in javascript by dreamluverz

I created some function for selectall checkbox. It works coz i’ve been using this.

obj_chkall - is the object of the checkbox that when you click will check all other checkboxes usually on mails
chkbox_name - is the name of the field of the checkboxes

function dps_chkall(obj_chkall, chkbox_name){
var form_name = obj_chkall.form;

if(typeof(chkbox_name) == 'object'){
obj_chkall.checked = false;
}else{
for(var d = 0; d < form_name.elements.length; d++){
if(form_name.elements[d].name == chkbox_name){
form_name.elements[d].checked = obj_chkall.checked;
}
}
}
}

Tags: , ,