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.
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....
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?
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.
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.
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...
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>
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.
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?
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.
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;
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;
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',
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:
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.
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">
(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.
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)?
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 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);