Portable Dictionary Class

Aug 23, 2007

Can you show me an example of a working dictionary object that is
portable? I would like to have something like:

d = new PortableDict()


subd = new PortableDict()

d.hasKey('a') // true
d.hasKey('c') // false
d.hasKey(subd) // true
d.getValue('a') // 12


Alternatively, is there a programming scheme that allows me to assign
custom properties/attributes to DOM elements? I can do it with
FireFox, but not with IE - it throws an error telling that the given
attribute is not supported. Which is strange because AFAIK in
JavaScript you can freely modify objects, add attributes and methods
on the fly. But it looks like that in IE, HTML DOM elements are not
real JavaScript objects.

View 8 Replies


Dictionary Class

Sep 18, 2002

here's something like an associative array implementation...

File: Dictionary.js
Version: 1.0
Last modified: 09.17.2002
Author: Alexandar Minkovsky (a_minkovsky@hotmail.com ; URL: http://www24.brinkster.com/alekz)
Copyright: Left
Type: Class
Exports: Dictionary class.
Dependencies: None.
Similar to ASP "Scripting.Dictionary" Object, or an associative array
with somewhat limited functionality. There's a few differences:
- "item" property is replaced by two methods getVal and setVal.
- "key" property is replaced by the setKey method.
As the value of an item can be virtually anything, even another Dictionary object,
the Dictionary Class might be usefull.
If someone have a suggestion or wants the Dictionary class to be extended some way,
feel free to drop me an e-mail.
Tested with: IE4; IE5; IE5.5; IE6; NS4.78; NS6.0; NS6.1; NS6.2; NS7.0; Mozilla 1.0; Mozilla 1.1; Opera 6.0
Dictionary Class
- Instanciating
oDict = new Dictionary();

- Properties
~ Public
(int) count - Number of keys in the Dictionary. Default: 0. Read only, do never manually set this property!
~ Private
(Object) Obj - the object actually containing the data. Do never use it directly.

- Methods - look at the function descriptions for detailed explanation.
~ Public
(BOOL) exists(sKey)
(BOOL) add (sKey,aVal)
(BOOL) remove(sKey)
(void) removeAll()
(Array) values()
(Array) keys()
(Array) items()
(Any) getVal(sKey)
(void) setVal(sKey,aVal)
(void) setKey(sKey,sNewKey)
//Dictionary Object
function: Dictionary
Parameters: None
Returns: A new Dictionary object.
Actions: Constructor.
function Dictionary(){
this.count = 0;
this.Obj = new Object();
this.exists = Dictionary_exists;
this.add = Dictionary_add;
this.remove = Dictionary_remove;
this.removeAll = Dictionary_removeAll;
this.values = Dictionary_values;
this.keys = Dictionary_keys;
this.items = Dictionary_items;
this.getVal = Dictionary_getVal;
this.setVal = Dictionary_setVal;
this.setKey = Dictionary_setKey;
//Method implementations
function: Dictionary_exists
implements: Dictionary.exists
(String) sKey - Key name being looked for.
Returns: (BOOL) - true if sKey is found ; false if it is not.
Actions: Iterates through all Dictionary keys and checks for sKey.
function Dictionary_exists(sKey){
return (this.Obj[sKey])?true:false;
function: Dictionary_add
implements: Dictionary.add
(String) sKey - Key name to be added.
(Any) aVal - Value to be associated with sKey.
Returns: (BOOL) - true if sKey is created ; false if it is not (because of a duplicate Key name).
Actions: Adds a new Key=Value pair to the Dictionary.
function Dictionary_add(sKey,aVal){
var K = String(sKey);
if(this.exists(K)) return false;
this.Obj[K] = aVal;
return true;
function Dictionary_remove
implements: Dictionary.remove
(String) sKey - Key to be removed.
Returns: (BOOL) - true if sKey has been removed ; false if it has not (did not exist).
Actions: Removes a specified key from the Dictionary.
function Dictionary_remove(sKey){
var K = String(sKey);
if(!this.exists(K)) return false;
delete this.Obj[K];
return true;
function: Dictionary_removeAll
implements: Dictionary.removeAll
Parameters: None
Returns: Nothing
Actions: Removes all key=value pairs from a Dictionary object.
function Dictionary_removeAll(){
for(var key in this.Obj) delete this.Obj[key];
this.count = 0;
function: Dictionary_values
implements: Dictionary.values
Parameters: None
Returns: Returns an Array containing all the item values in a Dictionary object.
Actions: Iterates through the Dictionary name=value pairs and builds an Array of all values.
function Dictionary_values(){
var Arr = new Array();
for(var key in this.Obj) Arr[Arr.length] = this.Obj[key];
return Arr;
function: Dictionary_keys
implements: Dictionary.keys
Parameters: None
Returns: Returns an Array containing all existing keys in a Dictionary object.
Actions: Iterates through the Dictionary name=value pairs and builds an Array of all keys.
function Dictionary_keys(){
var Arr = new Array();
for(var key in this.Obj) Arr[Arr.length] = key;
return Arr;
function: Dictionary_items
implements: Dictionary.items
Parameters: None
Returns: Returns a bidimensional Array containing all existing keys=value pairs in a Dictionary object.
- Iterates through the Dictionary key=value pairs and builds a bidimensional Array.
- First index contains the key name ; second index contains the value:
ex. Arr[0][0] is the key name of the first Dictionary item
Arr[0][1] is the value of the first Dictionary item
function Dictionary_items(){
var Arr = new Array();
for(var key in this.Obj){
var A = new Array(key,this.Obj[key]);
Arr[Arr.length] = A;
return Arr;
function: Dictionary_getVal
implements: Dictionary.getVal
(String) sKey
Returns: Item value for the passed sKey.
Actions: Retrieves the Dictionary item value corresponding to sKey.
function Dictionary_getVal(sKey){
var K = String(sKey);
return this.Obj[K];
function: Dictionary_setVal
implements: Dictionary.setVal
(String) sKey
(Any) aVal
Returns: Nothing.
- Sets the Dictionary item value corresponding to sKey to aVal.
- If The key is not found in the dictionary it is created.
function Dictionary_setVal(sKey,aVal){
var K = String(sKey);
this.Obj[K] = aVal;
function: Dictionary_setKey
implements: Dictionary.setKey
(String) sKey
(String) sNewKey
Returns: Nothing.
- Changes sKey to sNewKey
- if sKey is not found, creates a new item with key=sNewKey and value=null
- if sKey is not found, but sNewKey is found - does nothing.
- if sKey and sNewKey both exist - does nothing.
function Dictionary_setKey(sKey,sNewKey){
var K = String(sKey);
var Nk = String(sNewKey);
else if(!this.exists(Nk)) this.add(Nk,null);

View 2 Replies View Related

Portable Apps And Javascript

Jan 2, 2006

The portable versions of Firefox, Thunderbird and Sunbird for use with
USB drives seems like a great idea and one I could make a helluva lot of
use of at work - but before I drive down that particular road, does
anyone know how good / bad / indifferent the implementation of
Javascript is on these apps? Code:

View 3 Replies View Related

Portable IDE For HTML / Script?

Aug 22, 2009

I seen an IDE a while ago that stated that you do not need to install or require Admin Priviliges to use on any PC.

I can no longer find it. Does anyone know of such an IDE?

View 3 Replies View Related

Dictionary Bookmarklet To Open In New Window

Aug 6, 2010

How could I make this useful dictionary bookmarklet open in a new window?

javascript:var%20t=((window.getSelection&&window.getSelection())||(document.getSelection&&document.getSelection())||(document.selection&&document.selection.createRange&&document.selection.createRange().text));var%20e=(document.charset||document.characterSet);if(t!=''){ location.href='http://translate.google.com/translate_t?text='+t+'&hl=en&langpair=auto|en&tbb=1&ie='+e;}else{location.href='http://translate.google.com/translate?u='+escape(location.href)+'&hl=en&langpair=auto|en&tbb=1&ie='+e;};

Its the "To English" bookmarklet as featured on lifehacker (http://lifehacker.com/5168984/to-english-bookmarklet-quickly-easily-translates-any-text-with-one-click).

View 1 Replies View Related

Can Javascript Add Items To ASP/VBScript Dictionary Object?

Jul 23, 2005

I got two ASP pages. One is ASP email form (I'm using Persist ASP
Email component). Another one has all file links in it. For example,
when user click Outlook course hyperlink. It will pop up another
window with outlook course PDF file. (All PDF files are already in the

What I am trying to do is: When user click the "Add Email" hyperlink,
it will add that course name and filepath into ASP/VBScript Dictioanry
Object. After the user finish and click "Attach to email" button. All
the files will be attached in the email as an attachment.

Because I am not familar with VBScript. So, can Javascript add items
to ASP Dictionary Object?

View 3 Replies View Related

Double-click Online Dictionary Definition Script?

Sep 3, 2009

I've always wanted to help second-language English speakers access my site better, by offering a 'double-click on a word' definition in other languages. I had a useful script for some years which was rather dated, and ceased to work if there was an iframe on the page for some reason. Anyway, I found a very good solution at [URL]However, this opens the definition in a new tab/window.

Having experimented with it opening in a popup, I found problems in getting the popup to regain focus if someone had not closed it before looking for another definition. And anyway, popups can get blocked. So I found a nice layer/iframe solution at [URL] though their positioning of the layer is poor, at least in FF because it slides too far down below the bottom of the page. Their script is: [URL]I have modified that to work with dictionarist and stripped out their own floating part of the script, so that it works with position fixed for everything except IE6. But for IE6, I need to still change this from position fixed to position absolute, and then use a script to float the box.I have been trying the script I use successfully elsewhere in a vaguely similar context:


/* Script by: www.jtricks.com
* Version: 20060303
* Latest version:


which has a call to startFloat(); near the end, which is based on their own floating script nearer the top of [URL] which I have removed. (Doubtless the references to Netscape (RIP) can be removed.)

View 4 Replies View Related

Dictionary Page - Display Definition Of Word OnClick

Oct 9, 2009

I am doing a distionary page with javascript and I am trying to get it so that the definitions come up when the word they are for is clicked on.

Here is my javascript
Javascript Document
var filename = "dictionary.js";
function loaded(which){
alert(which + " loaded");
function showInfo(which){
var placeholder = document.getElementById("definition");
var source = whichInfo.getAttribute("href");
alert("showInfo called");
return false;
}function prepareList(){
if (!document.getElementsByTagName || !document.getElementById)
return false;
var words = document.getElementById("words");
if (!words) return false;
var links = words.getElementsByTagName("a");
for(var i = 0; i < links.length; i++) {
links[i].onclick = function(){
return false;
alert("prepare list done");
}function init(){
window.onload = init;

Here is my html
<!DOCTYPE html PUBLIC "-W3CDTD XHTML 1.0 StrictEN" "[URL]">
<html xmlns="[URL]">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Dictionary DOM Scripting</title>
<link href="../styles/main.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="dictionaryScripts/dictionary.js"> </script>
<div class="page">
<div class="nav"><ul>
<li><a href="../home.html">Home</a></li>
<li><a href="../form/form.html">Form</a></li>
<li><a href="dictionaryCSS.html">Dictionary with CSS</a></li>
<li><a href="dictionaryDOM.html">Dictionary with DOM scripting</a></li>
<li><a href="discussionPage.html">Discussion</a></li>
</ul></div><div class="header">
<h1>Dictionary with DOM Scripting</h1></div>
<div class="mainContent">
<div id="words"><h2>L</h2>
<p>Click on the word to get a definition</p>
<dt><a href="lecturer.html">LECTURER, n.</a></dt>
<dt><a href="learning.html">LEARNING, n</a></dt>
<dt><a href="liar.html">LIAR, n.</a></dt>
<dt><a href="love.html">LOVE, n.</a></dt></div>
<div id="definition">Choose a definition</div>

View 5 Replies View Related

JQuery :: Select Class Which Is In The Same Class Of Class, On Which Clicked?

Jun 3, 2010

My code: [URL]... When I click on UpraviÅĨ in class edit I need add some HTML code to begin and to end of class entry how to I can select class entry in the same class post on which I clicked?

View 1 Replies View Related

JQuery :: Assigning A Click To A Class Selector - Once Clicked The Class Is Removed - Does This Work

May 5, 2011

I have a huge blob of code but the main part I am focusing on is this

$('.billboard_click').click(function () {
//this remove class

1. Execute a click event when the div with the class 'billboard_click' is clicked

2. Once clicked, remove the class from that very div to avoid another click from happening

3. Execute a series of events such as animations, etc

4. add the class back to the clicker div

The code does not seem to work as expected but I am wondering if I am having issues elsewhere at this point and wonder if this actually is known to work

View 7 Replies View Related

Accessing Class Member Using This Inside An Anonymous Function Call In A Class Method?

Mar 28, 2010

I'm using jquery to make it easy for AJAX calls.

So I create a class: function cMap(mapID){//vars and stuff}

I go and prototype a function: cMap.prototype.loadMap = function(){ //jquery AJAX call }

Now in the jquery $.ajax({...}); call, I use an anonymous function on the "success:" call: success: function(data){ this.member = data; }

My problem is that inside this anonymous function call I'm trying to call a class member of my cMap class to store the data in from the AJAX call, but it's out of scope. So the JS console in FF/Chrome throws errors about bad value/doesn't exist.

How can I access this class member from inside an anonymous function? Or at least what's a good way to go about doing all this?

View 2 Replies View Related

JQuery :: Firebug Shows The Updated Class Of An Element But Live() Function Takes The Old Class?

Jul 2, 2009

I am new to this discussion but hope you would post reply for my query and encourage me to keep in touch with this discussion. Well here is my problem. I have made an edit in place form in which we can add and remove the elements. I have used jquery.jeditable.mini.js and jquery.duplicate-remove.js plugins for edit in place and add and remove action. I have live() function to access the dynamically ganerated elements like this. $(".addressDiv span").live("mouseover", function(){
clickable function here...


View 1 Replies View Related

If A Person Selects A Friday Class But Not A Saturday Class The Total Cost Field Will Automatically Enter $99?

Sep 27, 2011

CONDITIONS:If a person selects a Friday Class but not a Saturday Class the Total Cost Field will automatically enter $99.If a person selects a Saturday Class but not a Friday Class the Total Cost Field will automatically enter $99 as well.If a person selects both a Friday & Saturday Class the Total Cost field will automatically be $159.I found the following code and so far only have it changing when a Friday class is entered. I have no idea where to go from here

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">


View 10 Replies View Related

JQuery :: Class To Be Added Only If DIV Does Not Have Class Named 'Disabled'

Dec 29, 2011

I am adding a CSS class to a DIV as follows:$div.addClass("Hover");But I would like the class to be added only if the DIV does not have a class named "Disabled".

View 2 Replies View Related

JQuery :: Add Class / Remove Class With Live() And/or Livequery()?

Dec 22, 2010

I have this filter in a results table that also reflect in a ui datepicker day styling (ex:available unavailable) . Everything fine till i change month or year in datepicker . Maybe i have to use live() or livequery() but can see the way .This is the code:

var filtro=$("#filterSelect").val();


View 1 Replies View Related

JQuery :: Selector Speed - Class Only Versus Tag With Class

Mar 9, 2011

I'm trying to figure out which selector is faster (assuming that the class 'foo' only appears on input tags)...


From what I've seen online, it seems that people recommend $('input.foo'), but in some limited testing it appears that $('.foo') is much faster in both FF and Chrome. In IE, both methods seem to produce similar results. Here is a fiddle with a simple example...


Have browsers started implementing native ways to find all elements with a given class name? Would that explain why $('.foo') seems to be faster?

View 1 Replies View Related

JQuery :: Select Items With One Class, But Not Second Class?

Nov 25, 2010

<input type="text" class="class1">
<input type="text" class="class3">
<input type="text" class="class2">
<input type="text" class="class2 class1">
<input type="text" class="class1 class3">
<input type="text" class="class1">

Given the above, how would I select those that HAVE class1, but NOT class2, don't care about class3

So what I want are the items on lines 1,5 & 6 How could the below be modified to achieve what I want, or do I need something completely different?

View 1 Replies View Related

JQuery :: Usage Of .class.class Selector?

Dec 24, 2011

[URL] The above webpage lists the selector .class.class without an example. I can't find this usage in jQuery document either. I made the following example, but it doesn't work. Could anybody let me know who to use the .class.class selector?

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>


View 3 Replies View Related

Override Onmouseover In A Class, Now I Can't Get My Class Attributes.

Sep 15, 2006

I'm currently working with Javascript to build some "dynamic" tabs. Basicly, the tab "onmouseover" and "onmouseout" event have been overriden to change the tab's css class.

Here's the class:

function HtmlTab(id)
this.id = id;
this.tab = document.getElementById(id);
this.cssover = "over";
this.cssout = "out";

this.tab.onmouseover = function()

this.className = this.cssover; // NOT WORKING
this.tab.onmouseout = function()
this.className = "gen";
My problem is, I cannot access my HtmlTab class attributes from the this.tab.onmouseover function.

Anyone knows a way to fix this?

View 4 Replies View Related

JQuery :: Turn On An 'inactive-state' CSS Class For A Group Of Divs, Then Reset One Div To The 'active-state' Class?

Feb 2, 2011

I am attempting to make a menu that has a background image that changeswhen you rollover or click a menuitem. I've got the hover effect working fine with CSS, but am trying to implement the click event via jquery with the following:

{ background-image: url('/images/departments/commdev/sustainability/menu_tab.jpg');

My process is to reset the entire menu to the inactive state, then switch on the active state for the item that was clicked. Eventually, the item that was clicked will display its corresponding body section as well. I've tried using the CSS pseudo-class "active", but since the entire div is the link, that is unavailable. I've also tried multiple variations of addClass/removeClass, toggleClass, and setAttribute/removeAttributebut nothing hasworked so far.

View 2 Replies View Related

Jquery: Class / Fade - Menu Link "active" Class Not Working

Dec 5, 2009

I have a script that fades links on load and im trying to get this to work on everything but the menu link that has the "active" class

<div id="menu">
<ul><li id="Home"><a title="Home" href="/" style="opacity: 0.6;">Home</a></li>
<li class="active" id="projects"><a title="projects" href="/projects/" style="opacity: 0.6;">projects</a></li>
<li class="last" id="Contact"><a title="Contact" href="/contact" style="opacity: 0.6;">Contact</a></li>

View 4 Replies View Related

JQuery :: Css Class As Variable - Change The Css Class Of Li Element From Name Hidden To Variable FilterVal

May 26, 2010

I just donīt know the right syntax for this:

I want to change the css class of the li element from the name hidden to the variable filterVal, but i donīt know the right syntax.

View 1 Replies View Related

JQuery :: Add A Class Then Do Something To The Class?

Mar 19, 2009

I want to add a class to an element when you hover over (so it can be targeted with the next bit) it then do something to that element (animate, fade etc) then the class is removed ready to be applied to another similar element.But it all needs to happen on the initial hover (apart from the class being removed obviously)This is what I have so far that is adding and removing the class...

Code JavaScript:
$(document).ready(function () {
$("p#jtest a").mouseover(function () {[code].....

View 6 Replies View Related

JQuery :: Click Swap Image Gallery - Turn Off The "hover" Class And The "show" Class Of The Others When You Click One?

Mar 23, 2011

This is what I'm trying to do: I want a simple image container to swap the image inside it by clicking the nav buttons on the right like 1, 2, 3.Here's my code:

Code HTML4Strict:
<div id="item1">
<div class="img-container shadow" style="background-image:url(images/gallery/tcg1.jpg)">[code].....

My jQuery code is not right. I want it to turn off the "hover" class and the "show" class of the others when you click one. I think I need some kind of if..else? how to write it? I have a bg image set on the container div so there's an initial image to view.I also need multiple of these on the same page!

View 1 Replies View Related

Set A Td Class On The Fly

Jul 23, 2005

I have td(s) set up like this

<td id="1">Blah</td>
<td id="2">Blah blah</td>

Then in my script I am trying to do this...
for(var k = 0; k < tdArr.length; k++) {
if (something) {
tdArr[k].class = "myH2"

But this does not set the class for the td cell...

The javascript console says the error is:
"missing name after . operator"

What am I doing wrong? Can a class be assigned to a td like this?

View 4 Replies View Related

Class Problem

Jul 23, 2005

I have a problem with classes in javascript. When I define my class and
make an instance more than one time, it does not contian their own

var Counter = (function() {
var counter = 0;

function Constructor() {

Constructor.prototype.fncInit = function() {

var counter1 = new Counter();
var counter2 = new Counter();
var counter3 = new Counter();

The counter increases by one each time, but it should always be 1.

View 2 Replies View Related

Copyrights 2005-15 www.BigResource.com, All rights reserved