|
First, you need to set up functions to return the day and month names, since the JS Date object doesn't include them:
Date._dayNames = new Array(
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday");
Date._dayNamesA = new Array(
"Sun",
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat");
Date.prototype.getDayName = function(abbreviate)
{
if (isNaN(this))
return "";
else if (true == abbreviate)
return Date._dayNamesA[this.getDay()];
else
return Date._dayNames[this.getDay()];
}
Date._monthNames = new Array(
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December");
Date._monthNamesA = new Array(
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"June",
"July",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec");
Date.prototype.getMonthName = function(abbreviate)
{
if (isNaN(this))
return "";
else if (true == abbreviate)
return Date._monthNamesA[this.getMonth()];
else
return Date._monthNames[this.getMonth()];
}
Then, you need to use a regular expression to parse the format string and substitute the real values:
Date._reFormat = /(\\{0,1})(dddd|ddd|dd|d|MMMM|MMM|MM|M|yyyy|yy|y|gg|g|hh|h|ss|f+|tt|t|zzz|zz|z)/gi;
Date.prototype.format = function(format)
{
if (isNaN(this)) return this.toString();
if (!format || 0 == format.length) return this.toString();
var value = this;
return format.replace(Date._reFormat, function($0, $1, $2)
{
var fmt = $2;
if (!fmt || 0 == fmt.length) return "";
var ret = "";
if ("\\" == $1)
{
ret = fmt.charAt(0);
fmt = fmt.substr(1);
if (0 == fmt.length) return ret;
}
switch(fmt.toLowerCase())
{
case "dddd":
{
ret += value.getDayName();
break;
}
case "ddd":
{
ret += value.getDayName(true);
break;
}
case "dd":
{
var d = value.getDate();
if (d < 10) ret += "0";
ret += d;
break;
}
case "d":
{
ret += value.getDate();
break;
}
case "mmmm":
{
ret += value.getMonthName();
break;
}
case "mmm":
{
ret += value.getMonthName(true);
break;
}
case "mm":
{
if ("MM" == fmt)
{
var m = value.getMonth() + 1;
if (m < 10) ret += "0";
ret += m;
}
else if ("mm" == fmt)
{
var m = value.getMinutes();
if (m < 10) ret += "0";
ret += m;
}
else
{
ret += fmt;
}
break;
}
case "m":
{
if ("M" == fmt)
{
var m = value.getMonth() + 1;
ret += m;
}
else
{
ret += value.getMinutes();
}
break;
}
case "yyyy":
{
ret += value.getFullYear();
break;
}
case "yy":
{
ret += value.getFullYear().toString().substr(2);
break;
}
case "y":
{
var y = value.getFullYear().toString().substr(2);
if ("0" == y.charAt(0)) y = y.substr(1);
ret += y;
break;
}
case "gg":
case "g":
{
var y = value.getFullYear();
if (y >= 0)
ret += "AD";
else
ret += "BC";
break;
}
case "hh":
{
if ("HH" == fmt)
{
var h = value.getHours();
if (h < 10) ret += "0";
ret += h;
}
else if ("hh" == fmt)
{
var h = value.getHours();
if (0 == h)
h = 12;
else if (h > 12)
h -= 12;
if (h < 10) ret += "0";
ret += h;
}
else
{
ret += fmt;
}
break;
}
case "h":
{
if ("H" == fmt)
{
var h = value.getHours();
if (h < 10) ret += "0";
ret += h;
}
else
{
var h = value.getHours();
if (0 == h)
h = 12;
else if (h > 12)
h -= 12;
ret += h;
}
break;
}
case "ss":
{
var s = value.getSeconds();
if (s < 10) ret += "0";
ret += s;
break;
}
case "tt":
{
var h = value.getHours();
if (12 <= h)
ret += "PM";
else
ret += "AM";
break;
}
case "t":
{
var h = value.getHours();
if (12 <= h)
ret += "P";
else
ret += "A";
break;
}
case "zzz":
{
var off = -value.getTimezoneOffset();
if (off < 0)
{
ret += "-";
off = -off;
}
else
{
ret += "+";
}
var offH = Math.round(off / 60);
off -= 60 * offH;
if (offH < 10) ret += "0";
ret += offH;
ret += ":"
if (off < 10) ret += "0";
ret += off;
break;
}
case "zz":
{
var off = -Math.round(value.getTimezoneOffset() / 60);
if (off < 0)
{
ret += "-";
off = -off;
}
else
{
ret += "+";
}
if (off < 10) ret += "0";
ret += off;
break;
}
case "z":
{
var off = -Math.round(value.getTimezoneOffset() / 60);
if (off < 0)
{
ret += "-";
off = -off;
}
else
{
ret += "+";
}
ret += off;
break;
}
default:
{
if (/^f+$/gi.test(fmt))
{
var f = value.getMilliseconds() / 1000;
var div = Math.pow(10, fmt.length);
f = Math.round(f * div);
ret += f;
}
else
{
ret += fmt;
}
}
}
return ret;
});
}
Finally, call the new format function to format your date:
var dte = new Date("Thu Jan 10 00:00:00 UTC+0800 2002");
alert(dte.format("dd-MM-yyyy hh:mm:ss"));
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|
|
Hello All,
I'm trying to setup some form of webproxy server. The proxy will be frontend and internet gateway for 2 seperate servers in the backend. Unfortuntely I'm a newbie when it comes to network programming in windows. Here is the logic, the proxy will be the first point for all incoming web traffic. The task is an efficient method of scaning incoming traffic on the http port(80) and ftp port(21) for a particular file format such as Word document(*.doc) or xml(*.xml) "Posted" or "Uplaoded" to the server. If any of these for file formats are detected it will be saved directly onto the proxy server, otherwise it will be redirected immediately to any of the 2 backend servers without saving it 1st onthe proxy server (if this is possible). I'll appreciate a better insight into how this might be done. Also suggestion of web links to resources for this task will be appreciated also.
Thanks
|
|
|
|
|
Hi everybody!
1. I have a pointer to IHTMLDocument, displayed in IE.
2. HTML Document contains scripts
3. How can I order execution of certain jscript functions in that document?
Thanks for you help.
|
|
|
|
|
Does anybody know if a web application that is running inside an iframe is able to take over the whole screen without hitting some button on the web application that contains the iframe. I'm using the iframe to create tab control of 8 different tabs. One of them is suppose to take over the whole screen when a certain button is clicked and the others would like to take over the whole screen when certain errors occur that would require the application to call the login screen to start over.
Any help would be appreciated.
Mike
|
|
|
|
|
You could just make the button open a new browser window
--
Help me! I'm turning into a grapefruit!
Phoenix Paint - back from DPaint's ashes!
|
|
|
|
|
I wanna open an html source with php which was generated by a cgi (which source I dont know)
the function fopen () is not so good with URL's, the "free" webpages allows its not.
Muad-Dib
mailto:adamo_piar@freemail.hu
Made in Hungary
|
|
|
|
|
I'm not entirely sure having never tried it, but there's the style attribute that you can place other CSS commands in, so you may have some luck with that.
--
Paul
"Put the key of despair into the lock of apathy. Turn the knob of mediocrity slowly and open the gates of despondency - welcome to a day in the average office."
- David Brent, from "The Office"
MS Messenger: paul@oobaloo.co.uk
Download my PGP public key
|
|
|
|
|
Hello Folks,
I want to add a checkbox element before anchor tag on a webpage on the fly without any manual intervention.
I have tried IHTMLElement2::insertAdjacentElement and also IHTMLDOMNode::insertBefore function but I am not able to do the same.
Code:
1st Approach
IHTMLElement *pInputElement;
hr = m_ctrlWeb.m_pHtmlDoc->createElement(L"INPUT", &pInputElement);
IHTMLDOMNode *pDOMNode;
hr = pAnch->QueryInterface(__uuidof( IHTMLDOMNode),(void**)&pDOMNode);
IHTMLDOMNode *pNewDOMNode;
hr = pInputElement->QueryInterface(__uuidof( IHTMLDOMNode),(void**)&pNewDOMNode);
pDOMNode->insertBefore(pNewDOMNode, vIndex, &pNewDOMNode);
//here vIndex is the postion of the pAnch(IHTMLAnchorElement)
//I am not very sure of the third parameter as to what has to be given there.
2nd Approach
IHTMLElement *pInputElement;
hr = m_ctrlWeb.m_pHtmlDoc->createElement(L"INPUT", &pInputElement);
IHTMLElement2 *elem3;
hr = pDisp->QueryInterface(IID_IHTMLElement2, (void**) &elem3);
hr = elem3->insertAdjacentElement(L"beforeBegin", pInputElement, &pInputElement);
//Here also I am not sure as to what the 3rd parameter has to be provided.
Please let me know if theres any specific approach to be followed.
Thanks in advance,
Swati
|
|
|
|
|
how to a:hover inline
I know how to do it in the header.
I know how to do it in an external css file.
But looking online for examples to make the hover effect
inline in a tag does not seem to work, most people show examples
and they say this should work, and they also says, but it does not.
Anyone know how to make the hover effect of an anchor inline work?
cdmlb
|
|
|
|
|
try this link
http://www.webmasterworld.com/forum83/4061.htm
|
|
|
|
|
I am running code to connect to a database that stores theme data for a video game. This is the code I am running:
import java.sql.*; //import all the JDBC classes
import java.sql.*;
import java.io.IOException;
public class GetAccessToDatabase {
static Connection conn;
final String URL = "game.mdb";
public boolean OpenConnection() throws SQLException, IOException
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch (Exception e)
{
System.out.println("Could not load the driver.");
e.printStackTrace();
return false;
}
try
{
conn = DriverManager.getConnection
("jdbc:odbc:" + URL, "", "");
return true;
}
catch (Exception e) {
System.err.println("Problems with get connection sent to "+URL+
": "+e.getMessage());
}
return false;
}
public void CloseConnection() throws SQLException
{
conn.close();
}
public static void main(String args[])
{
try
{
GetAccessToDatabase connect = new GetAccessToDatabase();
if(connect.OpenConnection())
{
Statement stmt = conn.createStatement();
/*
stmt.executeUpdate("INSERT INTO student "
+ "(name, studentNumber, class, major) "
+ "VALUES ('Smith', '17', 1, 'CS')");
*/
// more database statements
connect.CloseConnection();
}
}
catch (Exception e) {
System.err.println("problems with SQL sent from "+"static main function"+
": "+e.getMessage());
}
}
}
And this is the message I receive from the exception thrown:
Problems with get connection sent to game.mdb: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
Basically, it doesn't see the game.mdb which I have placed in the local directory. I believe it is expecting some type of table in SQL, but how do I do that in MS Windows from Access? Any and all help would be greatly appreciated.
Thank you,
Red Sunday
-----------------
http://www.zachcalvert.com
|
|
|
|
|
You need to register an ODBC datasource and pass the name of that to the getConnection() method rather than the name of the access file.
Store your favourite bookmarks online: my-faves.co.uk
|
|
|
|
|
can unix server support asp and jsp?
includeh10
|
|
|
|
|
JSP =~ ASP, but JSP is Java
Java should be platform independent so normally, nooo problem man.
don't know about asp.
hope this helps.
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
you can get asp.net (but not asp) working with apache using the mono project. on unix based systems there's a mono module for apache. have a look at www.go-mono.com
--
Raoul Snyman
Saturn Laboratories
e-mail: raoul.snyman@saturnlaboratories.co.za
web: http://www.saturnlaboratories.co.za/
linux user: #333298
|
|
|
|
|
|
i have multiple html pages which contain same html code to diaplay same info.
I want to put this part of code in one html page then inclluded or imported by other pages --- is it possible? if yes, how to do?
thank
includeh10
|
|
|
|
|
This is indeed possible and quite common. You need to use the following:
<!--#include file="thefile.ext" -->
|
|
|
|
|
Hi friends, am currently making an online booking system which accepts customers name, ID no. and credit card number among other details. This data is then sent to the remote database via the internet. Please help me with the server-side validation code using Perl scripting language. You can also advise me accordingly. thanx friends.
Micom
micom village
|
|
|
|
|
As a general rule of thumb web database security usually goes something like principle of least privilege.
1) Strip out any non essential characters
2) Check the format/validate
3) Check the length of data (although i'm sure languages like Perl and PHP or MySQL use dynamic memory allocation, so i'm not sure why length checking is important, except for just incase theres a bug, type situations.)
4) You may have to escape special characters (single quote, etc)
Use regex to quickly and easily strip non-required characters and check the format of the input.
See Regex Library[^] to save yourself some work.
Cheers
How do I print my voice mail?
|
|
|
|
|
I have a problem with asp page, i have this statement:
" con.execute("insert into members ( first_name, last_name, mobile, email, username, password) values('"&firstname&"','"&lastname&"','"&mobile&"','"&email&"','"&username&"','"&password&"')")"
and i use access database
when i run this page i have an error that told me to make "updatetable query" and i don't know how to do this
could any one help me please
|
|
|
|
|
Check the permissions on the access .mdb file. If the iusr_machine account does not have write/modify access on the database, you cannot perform any updates. Also, because you have to modify these permissions, if possible move the access database outside of your IIS root folders.
|
|
|
|
|
1-Check your access database file .You must write,update permissions on it.
2-Try to open open database in write,update mode by code.
'---- LockTypeEnum Values ----
Const adLockReadOnly = 1
Const adLockPessimistic = 2
Const adLockOptimistic = 3
Const adLockBatchOptimistic = 4
--junior coder--
|
|
|
|
|
I have a need to do an ASP form for authenticating users against an LDAP server. Once the user has successfully authenticated, I need to programmatically set the REMOTE_USER environment variable to faciliate later access to a third party application.
Is there anyway to manually set the REMOTE_USER ServerVariable from server side ASP?
|
|
|
|
|
hi
I need to logout a user when he goes to a page external to the site.
help please?
Chaitanya
|
|
|
|
|