Accessing Private Members In Extensions

Mar 2, 2011

I'm trying to create an extensible class with private members.

Suppose I have the following:

Code:

Obviously, only "y" should be available to instantiations:

Code:

But how can I now extend this class and still access the private properties inside the extension?

Code:

How do I access x there? The someOtherFunction extension is part of the prototype, so it should be in the same scope as someFunction, no?

View 1 Replies


ADVERTISEMENT

Public Static Method Accessing Private Method

Aug 3, 2006

I'm trying to do something, but I don't know if it's possible.
Basically, I want to have a public static class method that could
access a private object's method. I would like to be able to do :

Class.method(InstanceOfClass);

The method would then access a private function from Class by doing
something like

function method(param) {
param.privateMethodOfClass();
}

I've done a lot research and experimentations but just can't come up
with a solution... I don't even know if what I'm trying to do is
possible.

View 4 Replies View Related

JavaScript Native Extensions

Nov 6, 2007

I'd like to announce release 1.0.7 of JNEXT (JavaScript Native
Extensions). JNEXT is an open source framework for securely accessing
the full range of native OS resources (files, databases, sockets etc.)
by using JavaScript from within a Web Page. It is light weight, cross
platform, cross browser and designed with simplicity in mind....

View 3 Replies View Related

Firefox Extensions Tutorial

Aug 18, 2005

Does anybody know of a good firefox extension tutorial?

Basically I have an XML list of things

<term>bleh</term>
<replacement>blehsky</replacement>

and I want to make the extension replace every occurance of bleh on the webpage with blehsky.

I can handle the javascript to do this, but I don't know where to start in making it into an extension.

View 6 Replies View Related

Search To Return Only .html Extensions

Feb 7, 2006

I"m trying to do a search on a folder that contains both word docs and
html pages. I want the search to only return back the html pages.
Does anyone know the code for that?

View 3 Replies View Related

Function To Load Files - With .txt Extensions

Mar 16, 2009

i have a function to load text files.

function load(n){textfile=n;if(n.indexOf("#")!=-1){theleft=n.indexOf("#")+1;textfile=(n.substring(theleft))}
document.mycall.load(textfile+'.txt');origString=textfile;

and it only loads a files with .txt extensions. how to change this function to load files with .doc and .nfo extensions also.

View 2 Replies View Related

String Prototype Extensions - Post Your Best!

Apr 27, 2004

I couldn't find a single thread with the creme de la creme of String prototype extension methods, so I figured I'd start one. Here we go!

String.prototype.lTrim = function () {
return this.replace(/^s+/gm, "");
}

String.prototype.rTrim = function () {
return this.replace(/s+$/gm, "");
}

String.prototype.trim = function () {
return this.rTrim().lTrim();
}Obviously, this one's easy to understand. I'm using multi-line mode so as only to get rid of spaces and tabs before and after words. Single-line mode would replace any newline/carriage return characters as well.


String.prototype.capitalize = function () {
return this.replace(/[a-z]/g, function (str, n) { return str.toUpperCase(); });
}

String.prototype.toCamelCase = function () {
return this.replace(/s[a-z]/g, function (str, n) { return str.toUpperCase(); });
}

String.prototype.unCamelCase = function () {
return this.replace(/[A-Z]/g, function (str, n) { return " " + str.toUpperCase(); });
}This is something I needed today, to turn a camelCased variable value into its Header Format. While I was at it, I wrote the un-do-er.

View 8 Replies View Related

CGI - Frontpage Extensions; Online Forms

Dec 17, 2000

I have been using Frontpage to design web sites and know that online-forms can be created using Frontpage, but the host must have Frontpage Server Extensions installed...

...I was wondering if the online forms were simply CGI scripts??

If so, could i not get DreamWeaver Ultra Dev and write the CGI scripts in there? - I think DreamWeaver is capable of this?

Therefore, if a server supported CGI scripts and i had to pay extra for FRONTPAGE EXT. then i could bypass this problem by using CGI scripts...

...does this make sense? If not, why not?

View 1 Replies View Related

Check File Extensions On Multiple Uploads

Sep 10, 2009

Script works on the first attachment but not the other two?
<script type="text/javascript" language="JavaScript"><!--
function ExtensionsOkay() {
var extension = new Array();
var fieldvalue = new Array();
fieldvalue[0] = document.customApp.attachment_1.value;
fieldvalue[1] = document.customApp.attachment_2.value;
fieldvalue[2] = document.customApp.attachment_3.value;
extension[0] = ".doc";
extension[1] = ".docx";
extension[2] = ".txt";
extension[3] = ".pdf";

// No other customization needed.
for(var f = 0; f < fieldvalue.length; f++) {
var thisext = fieldvalue[f].substr(fieldvalue[f].lastIndexOf('.'));
for(var i = 0; i < extension.length; i++) {
if(thisext == extension[i]) { return true; }}
alert("Your upload field " + f + " contains an unapproved file name.");
return false;
}}
//--></script>

View 4 Replies View Related

Passing Parameters To Custom Element Extensions

Feb 12, 2003

When introducing custom functionality to HTML elements we either use existing attributes to pass configuration parameters (like beetle's fValidate (http://www.peterbailey.net/fValidate/)) or invent our own (like my Tooltips (http://www.vladdy.net/webdesign/ToolTips.html)). While this method is ok for small amount of configuration information, it is not that flexible (you need to edit DTD) and becomes combersome when large amount of configuration parameters is needed.

I figured a more convinient way is to use a CSS like string to pass configuration parameters:
<div myextension="parameter1: value1; parameter2-subparameter1: value2.1; parameter2-subparameter2: value2.2"> </div>

Then initialization routine would contain:
if(myExtensionParameters = divElement.getAttribute('myExtension'))
divElement.myExtension = new myExtensionObject(divElement,myExtensionParameters);


Definition of possible parameters and their values can be done using an array of regular expressions:
myExtensionParamDefenitions = new Array();
myExtensionParamDefenitions['choiceparameter'] = /^s*(value1a|value1b|value1c)s*$/;
myExtensionParamDefenitions['stringparameter'] = /^s*(w+)s*$/;
myExtensionParamDefenitions['integerparameter'] = /^s*(d+)s*$/;

Constructor for the myExtensionObject would containd a parseParameters function:
function myExtensionObject(divElement,myExtensionParameters)
{ this.params=new Array();
parseParameters(this.params,myExtensionParamDefenitions,myExtensionParameters);
//Verify parameter initialization, if you like
str=''
for(e in this.params) str+= e + ': ' + this.params[e] + '
'
alert(str);
//Do whatever you have to do...
}


Function parseParameters has the following code:
function parseParameters(object,definitions,parameters)
{ paramEntries = parameters.split('');
for(var i=0; i<paramEntries.length; i++)
{ paramEntry = paramEntries[i].split(':');
if(paramEntry.length == 2)
{ paramName = paramEntry[0].replace(/^s*([w-]+)s*$/,'$1');
if(definitions[paramName])
{ res = definitions[paramName].exec(paramEntry[1]);
if(res[1])
object[convertCSSName(paramName)] = res[1];
}
}
}
}

Where convertCSSName function converts CSS type name (background-image) to javascript name (backgroundImage)
function convertCSSName(cssName)
{ sn = cssName.split('-');
rs = sn[0];
for(var i=1; i<sn.length; i++)
rs += sn[i].replace(/^(w)(w*)$/,function(str,p1,p2,offset,s){return p1.toUpperCase() + p2;})
return rs;
}

As a result you have params array of myExtensionObject object populated with validated entries. Changes and expansion is done by simply editing myExtensionParamDefenitions array.

PS: The functions are coded more for clarity rather than for brevity - I'm certain there are ways to improve the implementation.

View 3 Replies View Related

Members Of The Error Class/object

Apr 18, 2006

What're the members of the error class/object? Is there a complete reference to all JavaScript objects available on the Web?

View 6 Replies View Related

How To Get The Private Key For Digital Signature?

Mar 31, 2007

My web application does user authentication through X.509 digital
certificates in combination with user name and password.

When the user applies for a digital certificate from my certification
authority (CA), I have a VBScript code that generates a public/private
key pair with the RSA algorithm, as well as the certificate signing
request (CSR) in PKCS#10 format. I assume that the key pair should be
maintained by the browser (my application support Internet Explorer
only at this moment). Am I right?

Now, when the user tries to log into his account, I would like to have
my web application receive a digitally signed token from the client.
The token can be the client's username signed with his/her private
key.

Since this signing process will happen on the client side, it can only
be handled by client side script, for example, JavaScript.

But, how do we get access to the private key with JavaScript?

View 2 Replies View Related

JQuery :: Sequencing Operation On Members Of An Array?

Sep 23, 2011

I have an array of divs, and can do a style change on them:

var Ray = new Array("first", "second", "nth");
function bluRay() {
$('#' + Ray.join(',#')).animate({color: '#00f'}, 600);}

( The divs don't share a class, and it'd be code-heavy to add classes for all the necessary variations on this function. )

How to make the operation on the divs sequential, at say, 500ms intervals?

View 2 Replies View Related

Using Code On A Webpage That Lists The Site Members?

May 6, 2011

I am currently using this code on a webpage that lists the site members.

function toggleMenu(objID) {
if (!document.getElementById) return;
var ob = document.getElementById(objID).style;

[code]....

View 3 Replies View Related

Storing Element References As Public Object Members

Sep 20, 2006

I've spent several days trying to work this out. Maybe I'm just
searching for the wrong keywords/phrases.

I have some code that looks like:

[-- snippet starts --]
Console = new Object();
Console.init = function() {
this.STDIN = document.getElementById('console0_stdin');
this.STDOUT = document.getElementById('console0_stdout');

// set styles on the element references, eg:
this.STDIN.style.width = ï`%'
this.STDOUT.style.width = ï`%'
}

Console.focus = function() {
this.STDIN.focus();
}

Console.writeln = function(buffer) {
this.STDOUT.value += "
" + buffer;
}

[-- snippet ends --]

I'm not sure why, but the Console.focus() and Console.writeln() methods
just don't seem to be able to use the DOM references stored in
Console.STDIN and Console.STDOUT. Everything's fine in the
constructor, but other methods can't seem to use them.

View 8 Replies View Related

Function To Add Members Rearranging Array List When Entered?

Jun 17, 2009

I have a form that is done in php I'm converting it to .NET but the java script has an error. I posted all the code but the error is in the "saveOtherSurvivorValues" function i think. What happens is when you click the "add survivor" link to add a the first survivor and then fill out the information for the first survivor then click add survivor a second time for a second survivor it moves the data from the 1st survivor into different fields to produce in accurate data.

Here is a link to the live form.

[URL]

using System;
using System.Collections;
using System.Configuration;
using System.Data;

[Code]....

View 7 Replies View Related

Function To Add Members Rearranging Array List When Entered - ASP.NET?

Jun 17, 2009

I have a form that is done in php I'm converting it to .NET but the java script has an error. I posted all the code but the error is in the "saveOtherSurvivorValues" function i think. What happens is when you click the "add survivor" link to add a the first survivor and then fill out the information for the first survivor then click add survivor a second time for a second survivor it moves the data from the 1st survivor into different fields to produce in accurate data.

using System;
using System.Collections;
using System.Configuration;

[code].....

View 7 Replies View Related

Would Emulating Private Variables Like This Be Wrong?

Jan 26, 2007

What do you think about emulating private variables for a class this
way?

function Something() {
var private;
Something.prototype.getPrivate = function() { return private; }
Something.prototype.setPrivate = function(newPrivate) { private =
newPrivate; }
}

var some = new Something("My private");
alert(some.getPrivate());
alert(some.setPrivate("Nyah nyah"));
alert(some.getPrivate());

That way the accessor methods instances are shared among instances of
Something. What do you think?

View 7 Replies View Related

Set A Specific Property On A Private Object?

Feb 16, 2009

I want to be able to set a property on a private object by giving the not notation path to the value. The difficulty is that this object is within closure so I can't access it directly to set the value the normal way (eg. dot.notation.path = 'new value'). This seems weird but I can't think of the obvious way.

Example:

// setter function
function set(path, change){
var privateObject = {
a: 'a',

[Code]....

View 1 Replies View Related

Private Method Recursion With JSON

Oct 8, 2007

I am using the module pattern and private/public methods. I'm having a problem where the private method is using setTimeout() to call itself recursively, but I can't get the syntax right. Code:

View 1 Replies View Related

Private Methods In Object Literal?

Aug 18, 2010

i have something like this:

Code:
var o = {
f1:function(a) {

[code]....

View 4 Replies View Related

Dynamic Dropdown List For Sending Messages To Multiple Members

Sep 3, 2011

I am developing a messaging service between members of my site. I am developing this with asp.net mvc. When a user goes to the SendMessage view to send a message to another member, there is a dropdown list which presents the sender with all the members of the site, which he or she will pick as the recipient. However, i don't want it to be a dropdown, i want it to be a text box, where a user types in the first couple of letters of a name, and the dropdown appears then with only the members which have the same couple of letters. This is basically like every email system out there (facebook and gmail have it just like that). And after they chose one, they can select another one in the same textbox, just separated by a comma or something like that. Basically, how do i achieve that in javascript? I'm not even sure what that functionality is called, that's why i had to explain it properly.

View 3 Replies View Related

Object Members That Are Prototyped As Arrays Become Shared By All Class Instances?

Dec 12, 2010

Has anyone noticed this behavior before? This really threw me off... I would have expected prototyped arrays to be private to each class instance rather than shared between all class instances.

HTML Code:
<html>
<head>
<script type="text/javascript">

[Code]....

View 3 Replies View Related

JQuery :: Making A Private Function Public?

Apr 23, 2009

I've got a plugin which is structured as follows:

(function($) {
$.fn.MyFunction = function(o) {
// Here we have some parameters
return this.each(function() {

[Code].....

So what I'm looking for is how to reference MyExternalFunction from my html script. I've tried simply using MyExternalFunction(index) but I get function undefined.

View 6 Replies View Related

JQuery :: How To Make Function Private Or Public

Dec 31, 2011

This question applies to javascript generally as opposed to jQuery specifically. I want to be able to structure my scripts into classes, then create them using the "new" keyword, but here is the important bit: How do I make a js function private (or public for that matter)?

View 4 Replies View Related

Closures / Object References And Private Methods

Aug 22, 2010

I have some confusion about the scripts below:

1) is getRule a local variable or global variable, as it has no var keyword, yet it is an inner function of Validation? So without var, I think global, but being an inner function, I think local. So I'm not sure which.

2) In this line of code: var rule = $.Validation.getRule(types[type]), getRule returns rules, which is just a local variable in Validation. I always see that you return functions, but how does returning a local variable that's just an object literal and not a function be able to return true or false? Now the value of rules is an object literal, and this object returns true or false. So we are basically allowed to use return keyword with local variables that are object literals and not functions?

3) In this line, is foo(age) being called, or is it just being assigned to bar OR is it being called and THEN assigned to bar: var bar = foo(age);

4) Now for the most confusing: age is obviously an object reference as opposed to a literal in the example. Does that make a difference in regards to closures?
Note that I read a number of books, including JavaScript Programmer Reference and Object Oriented JavaScript and jQuery cookbook, which compare primitives vs reference types and how primitive types store directly in memory whereas reference tpyes reference memory, so if one reference changes, they all change where primitive remains ingrained. But when assigning a function as a reference like this, how does that affect the object "age" when passed into bar?

Code:
(function($) {
/*Validation Singleton*/
var Validation = function() {
var rules = {
email : {
check: function(value) {
if(value)
return testPattern(value,".+@.+..+");
return true;
}, .....
$.Validation = new Validation();
})(jQuery);

Code:
function foo(x) {
var tmp = 3;
return function (y) {
alert(x + y + tmp);
x.memb = x.memb ? x.memb + 1 : 1;
alert(x.memb);
}}
var age = new Number(2);
var bar = foo(age); // bar is now a closure referencing age.
bar(10);

View 3 Replies View Related







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