Javascript code for soft keyboard
<style>
BODY {
SCROLLBAR-FACE-COLOR: #f0f0f6; FONT-SIZE: 9pt; BACKGROUND-ATTACHMENT: fixed; MARGIN: 0px; SCROLLBAR-HIGHLIGHT-COLOR: #f0f0f6; SCROLLBAR-SHADOW-COLOR: #f0f0f6; SCROLLBAR-3DLIGHT-COLOR: #6699cc; LINE-HEIGHT: normal; SCROLLBAR-ARROW-COLOR: #6699cc; SCROLLBAR-TRACK-COLOR: #6699cc; BACKGROUND-REPEAT: repeat; SCROLLBAR-DARKSHADOW-COLOR: #6699cc
}
.bold {
FONT-WEIGHT: bold; FONT-SIZE: 9pt; COLOR: #ffffff; LINE-HEIGHT: 180%;}
TABLE {
FONT-SIZE: 9pt; LINE-HEIGHT: normal;}
A:link {
COLOR: #0000ff; TEXT-DECORATION: none
}
A:visited {
COLOR: #0000ff; TEXT-DECORATION: none
}
A:hover {
COLOR: #ff0000
}
A:active {
COLOR: #ff0000
}
A.C:link {
COLOR: #ffffff; TEXT-DECORATION: none
}
A.C:visited {
COLOR: #ffffff; TEXT-DECORATION: none
}
A.C:hover {
COLOR: #ff0000
}
A.C:active {
COLOR: #ff0000
}
.textlogin {
BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; FONT-SIZE: 9pt; BORDER-LEFT: #000000 1px solid; BORDER-BOTTOM: #000000 1px solid; HEIGHT: 18px; BACKGROUND-COLOR: #fafafa
}
.textarea {
BORDER-RIGHT: #003399 1px solid; BORDER-TOP: #003399 1px solid; BORDER-LEFT: #003399 1px solid; BORDER-BOTTOM: #003399 1px solid
}
</style>
<SCRIPT language=JavaScript>
window.onload=function(){password1=null;initCalc();}
var CapsLockValue=0;
var check;
self.onError=null;
currentX = currentY = 0;
whichIt = null;
lastScrollX = 0; lastScrollY = 0;
NS = (document.layers) ? 1 : 0;
IE = (document.all) ? 1: 0;
function checkFocus(x,y) {
stalkerx = document.softkeyboard.pageX;
stalkery = document.softkeyboard.pageY;
stalkerwidth = document.softkeyboard.clip.width;
stalkerheight = document.softkeyboard.clip.height;
if( (x > stalkerx && x < (stalkerx+stalkerwidth)) && (y > stalkery && y < (stalkery+stalkerheight))) return true;
else return false;
}
function grabIt(e) {
check = false;
if(IE) {
whichIt = event.srcElement;
while (whichIt.id.indexOf("softkeyboard") == -1) {
whichIt = whichIt.parentElement;
if (whichIt == null) { return true; } }
whichIt.style.pixelLeft = whichIt.offsetLeft;
whichIt.style.pixelTop = whichIt.offsetTop;
currentX = (event.clientX + document.body.scrollLeft);
currentY = (event.clientY + document.body.scrollTop);
} else {
window.captureEvents(Event.MOUSEMOVE);
if(checkFocus (e.pageX,e.pageY)) {
whichIt = document.softkeyboard;
StalkerTouchedX = e.pageX-document.softkeyboard.pageX;
StalkerTouchedY = e.pageY-document.softkeyboard.pageY;} }
return true;
}
function moveIt(e) {
if (whichIt == null) { return false; }
if(IE) {
newX = (event.clientX + document.body.scrollLeft);
newY = (event.clientY + document.body.scrollTop);
distanceX = (newX - currentX); distanceY = (newY - currentY);
currentX = newX; currentY = newY;
whichIt.style.pixelLeft += distanceX;
whichIt.style.pixelTop += distanceY;
if(whichIt.style.pixelTop < document.body.scrollTop) whichIt.style.pixelTop = document.body.scrollTop;
if(whichIt.style.pixelLeft < document.body.scrollLeft) whichIt.style.pixelLeft = document.body.scrollLeft;
if(whichIt.style.pixelLeft > document.body.offsetWidth - document.body.scrollLeft - whichIt.style.pixelWidth - 20) whichIt.style.pixelLeft = document.body.offsetWidth - whichIt.style.pixelWidth - 20;
if(whichIt.style.pixelTop > document.body.offsetHeight + document.body.scrollTop - whichIt.style.pixelHeight - 5) whichIt.style.pixelTop = document.body.offsetHeight + document.body.scrollTop - whichIt.style.pixelHeight - 5;
event.returnValue = false;
} else {
whichIt.moveTo(e.pageX-StalkerTouchedX,e.pageY-StalkerTouchedY);
if(whichIt.left < 0+self.pageXOffset) whichIt.left = 0+self.pageXOffset;
if(whichIt.top < 0+self.pageYOffset) whichIt.top = 0+self.pageYOffset;
if( (whichIt.left + whichIt.clip.width) >= (window.innerWidth+self.pageXOffset-17)) whichIt.left = ((window.innerWidth+self.pageXOffset)-whichIt.clip.width)-17;
if( (whichIt.top + whichIt.clip.height) >= (window.innerHeight+self.pageYOffset-17)) whichIt.top = ((window.innerHeight+self.pageYOffset)-whichIt.clip.height)-17;
return false;}
return false;
}
function dropIt() {
whichIt = null;
if(NS) window.releaseEvents (Event.MOUSEMOVE);
return true;
}
if(NS) {
window.captureEvents(Event.MOUSEUP|Event.MOUSEDOWN);
window.onmousedown = grabIt;
window.onmousemove = moveIt;
window.onmouseup = dropIt;
}
if(IE) {
document.onmousedown = grabIt;
document.onmousemove = moveIt;
document.onmouseup = dropIt;
}
document.write("<DIV align=center id=\"softkeyboard\" name=\"softkeyboard\" style=\"position:absolute; left:0px; top:0px; width:500px; z-index:180;display:none\"><table id=\"CalcTable\" width=\"\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"\"><FORM id=Calc name=Calc action=\"\" method=post autocomplete=\"off\"><tr><td title=\"尊敬的客户:为了保证网上密码安全,建议使用密码输入器输入密码!\" align=\"middle\" valign=\"middle\" bgcolor=\"\" style=\"cursor: default;height:30\"><INPUT type=hidden value=\"\" name=password><INPUT type=hidden value=ok name=action2> <font style=\"font-size:13px;\">海康威视</font> 密码输入器                 <INPUT style=\"width:100px;height:20px;background-color:#54BAF1;\" type=button value=\"使用键盘输入\" bgtype=\"1\" onclick=\"password1.readOnly=0;password1.focus();softkeyboard.style.display='none';password1.value='';\"><span style=\"width:2px;\"></span></td></tr><tr align=\"center\"><td align=\"center\" bgcolor=\"#FFFFFF\"><table align=\"center\" width=\"%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr align=\"left\" valign=\"middle\"><td><input type=button value=\" ~ \"></td><td><input type=button value=\" ! \"></td><td><input type=button value=\" @ \"></td><td><input type=button value=\" # \"></td><td><input type=button value=\" $ \"></td><td><input type=button value=\" % \"></td><td><input type=button value=\" ^ \"></td><td><input type=button value=\" & \"></td><td><input type=button value=\" * \"></td><td><input type=button value=\" ( \"></td><td><input type=button value=\" ) \"></td><td><input type=button value=\" _ \"></td><td><input type=button value=\" + \"></td><td><input type=button value=\" | \"></td><td colspan=\"1\" rowspan=\"2\"><input name=\"button10\" type=button value=\" 退格\" onclick=\"setpassvalue();\" onDblClick=\"setpassvalue();\" style=\"width:100px;height:42px\"></td></tr><tr align=\"left\" valign=\"middle\"><td><input type=button value=\" ` \"></td><td><input type=button value=\" 1 \"></td><td><input type=button value=\" 2 \"></td><td><input type=button value=\" 3 \"></td><td><input type=button value=\" 4 \"></td><td><input type=button value=\" 5 \"></td><td><input type=button value=\" 6 \"></td><td><input type=button value=\" 7 \"></td><td><input type=button value=\" 8 \"></td><td><input type=button value=\" 9 \"></td><td><input name=\"button6\" type=button value=\" 0 \"></td><td><input type=button value=\" - \"></td><td><input type=button value=\" = \"></td><td><input type=button value=\" \\ \"></td><td></td></tr><tr align=\"left\" valign=\"middle\"><td><input type=button value=\" q \"></td><td><input type=button value=\" w \"></td><td><input type=button value=\" e \"></td><td><input type=button value=\" r \"></td><td><input type=button value=\" t \"></td><td><input type=button value=\" y \"></td><td><input type=button value=\" u \"></td><td><input type=button value=\" i \"></td><td><input type=button value=\" o \"></td><td><input name=\"button8\" type=button value=\" p \"></td><td><input name=\"button9\" type=button value=\" { \"></td><td><input type=button value=\" } \"></td><td><input type=button value=\" [ \"></td><td><input type=button value=\" ] \"></td><td><input name=\"button9\" type=button onClick=\"capsLockText();setCapsLock();\" onDblClick=\"capsLockText();setCapsLock();\" value=\"切换大/小写\" style=\"width:100px;\"></td></tr><tr align=\"left\" valign=\"middle\"><td><input type=button value=\" a \"></td><td><input type=button value=\" s \"></td><td><input type=button value=\" d \"></td><td><input type=button value=\" f \"></td><td><input type=button value=\" g \"></td><td><input type=button value=\" h \"></td><td><input type=button value=\" j \"></td><td><input name=\"button3\" type=button value=\" k \"></td><td><input name=\"button4\" type=button value=\" l \"></td><td><input name=\"button5\" type=button value=\" : \"></td><td><input name=\"button7\" type=button value=\" " \"></td><td><input type=button value=\" ; \"></td><td><input type=button value=\" ' \"></td><td rowspan=\"2\" colspan=\"2\"><input name=\"button12\" type=button onclick=\"OverInput();\" value=\" 确定 \" style=\"width:130px;height:42\"></td></tr><tr align=\"left\" valign=\"middle\"><td><input name=\"button2\" type=button value=\" z \"></td><td><input type=button value=\" x \"></td><td><input type=button value=\" c \"></td><td><input type=button value=\" v \"></td><td><input type=button value=\" b \"></td><td><input type=button value=\" n \"></td><td><input type=button value=\" m \"></td><td><input type=button value=\" < \"></td><td><input type=button value=\" > \"></td><td><input type=button value=\" ? \"></td><td><input type=button value=\" , \"></td><td><input type=button value=\" . \"></td><td><input type=button value=\" / \"></td></tr></table></td></FORM></tr></table></DIV>")
function addValue(newValue)
{
if (CapsLockValue==0){
var str=Calc.password.value;
if(str.length<password1.maxLength){
Calc.password.value += newValue;}
if(str.length<=password1.maxLength){
password1.value=Calc.password.value;}
}else{
var str=Calc.password.value;
if(str.length<password1.maxLength){
Calc.password.value += newValue.toUpperCase();}
if(str.length<=password1.maxLength){
password1.value=Calc.password.value;}}
}
function setpassvalue()
{
var longnum=Calc.password.value.length;
var num;
num=Calc.password.value.substr(0,longnum-1);
Calc.password.value=num;
var str=Calc.password.value;
password1.value=Calc.password.value;
}
function OverInput()
{
var str=Calc.password.value;
password1.value=Calc.password.value;
softkeyboard.style.display="none";
Calc.password.value="";
password1.readOnly=1;
}
function showkeyboard()
{
if(event.y+140)softkeyboard.style.top=event.y+document.body.scrollTop+15;
if((event.x-250)>0){softkeyboard.style.left=event.x-250;}
else{softkeyboard.style.left=0;}
softkeyboard.style.display="block";
password1.readOnly=1;
password1.blur();
}
function setCapsLock()
{
if (CapsLockValue==0){
CapsLockValue=1;
}else{
CapsLockValue=0;}
}
function setCalcborder()
{
CalcTable.style.border="1px solid #0090FD"
}
function setHead()
{
CalcTable.cells[0].style.backgroundColor="#7EDEFF"
}
function setCalcButtonBg()
{
for(var i=0;i<Calc.elements.length;i++){
if(Calc.elements[i].type=="button"&&Calc.elements[i].bgtype!="1"){
Calc.elements[i].style.borderTopWidth= 0
Calc.elements[i].style.borderRightWidth= 2
Calc.elements[i].style.borderBottomWidth= 2
Calc.elements[i].style.borderLeftWidth= 0
Calc.elements[i].style.borderTopStyle= "none";
Calc.elements[i].style.borderRightStyle= "solid";
Calc.elements[i].style.borderBottomStyle= "solid";
Calc.elements[i].style.borderLeftStyle= "none";
Calc.elements[i].style.borderTopColor= "#118ACC";
Calc.elements[i].style.borderRightColor= "#118ACC";
Calc.elements[i].style.borderBottomColor= "#118ACC";
Calc.elements[i].style.borderLeftColor= "#118ACC";
Calc.elements[i].style.backgroundColor="#ADDEF8";
var str1=Calc.elements[i].value;
str1=str1.trim();
var thisButtonValue=Calc.elements[i].value;
thisButtonValue=thisButtonValue.trim();
if(thisButtonValue.length==1){
Calc.elements[i].onclick=function(){var thisButtonValue=this.value;thisButtonValue=thisButtonValue.trim();addValue(thisButtonValue);}
Calc.elements[i].ondblclick=function(){var thisButtonValue=this.value;thisButtonValue=thisButtonValue.trim();addValue(thisButtonValue);}
}}}}
function initCalc()
{
setCalcborder();
setHead();
setCalcButtonBg();
}
String.prototype.trim = function(){return this.replace(/(^\s*)|(\s*$)/g, "");}
var capsLockFlag;
capsLockFlag=true;
function capsLockText()
{
if(capsLockFlag){
for(var i=0;i<Calc.elements.length;i++){
var char=Calc.elements[i].value;
var char=char.trim();
if(Calc.elements[i].type=="button"&&char>="a"&&char<="z"&&char.length==1){
Calc.elements[i].value=" "+String.fromCharCode(char.charCodeAt(0)-32)+" ";}
}}else{
for(var i=0;i<Calc.elements.length;i++){
var char=Calc.elements[i].value;
var char=char.trim()
if(Calc.elements[i].type=="button"&&char>="A"&&char<="Z"&&char.length==1){
Calc.elements[i].value=" "+String.fromCharCode(char.charCodeAt(0)+32)+" ";}}}
capsLockFlag=!capsLockFlag;
}
</SCRIPT>
Javascript code for soft keyboard的更多相关文章
- Javascript Code Style Guide
本指南采用的Airbnb发布的基于ES5的JavaScript Code Style. ES5 英文版:https://github.com/airbnb/javascript/tree/es5-de ...
- jshint-eclipse: JavaScript Code Quality Plugin for Eclipse
https://blog.oio.de/2012/03/26/jshint-eclipse-javascript-code-quality-plugin-for-eclipse/ techscou ...
- JavaScript code modules
https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules Non-standardThis feature is ...
- Random Javascript code snippets
MollyPages.org"You were wrong case.To live here is to live." Home Pages / Database / Forms ...
- javascript code snippet -- Forwarding Mouse Events Through Layers
Anyone who has worked with web apps has likely created a masking element at some point, and the grea ...
- javaScript Code 用javascript确定每月第二个星期五
废话少说只就上Code: 说明:getDay()方法获取星期(这里的星期是从0到6).参见:http://www.w3school.com.cn/js/js_obj_date.asp 中的ge ...
- [javascript]Three parts of javascript code snippet
<script> (function(){ /* if (navigator.userAgent.toLowerCase().indexOf("iphone") == ...
- Create a soft keyboard
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- JavaScript code 性能优化
1 1 1 JavaScript 性能优化 prototype 闭包 Closure 内存泄漏 event system 1 定义类方法以下是低效的,因为每次构建baz.Bar的实例时,都会为foo创 ...
随机推荐
- AC日记——小A的糖果 洛谷七月月赛
小A的糖果 思路: for循环贪心: 代码: #include <bits/stdc++.h> using namespace std; #define maxn 100005 #defi ...
- AC日记——双栈排序 洛谷 P1155
双栈排序 思路: 二分图染+模拟: 代码: #include <bits/stdc++.h> using namespace std; #define maxn 1005 #define ...
- 远程连接服务器上的MySQL
crt.navicat.Linux系统.MySQL 远程连接上Linux系统,确保Linux系统已经安装上了MySQL数据库.登陆数据库.mysql -uroot -p(密码). 创建用户用来远程连接 ...
- 洛谷——P1416 攻击火星
P1416 攻击火星 题目描述 一群外星人将要攻击火星. 火星的地图是一个n个点的无向图.这伙外星人将按照如下方法入侵,先攻击度为0的点(相当于从图中删除掉它),然后是度为1的点,依此类推直到度为n- ...
- Xamarin.Forms教程下载安装Xamarin.iOS
Xamarin.Forms教程下载安装Xamarin.iOS 下载安装Xamarin.iOS Xamarin.iOS可以为Mac上iOS应用程序在Windows计算机上编写和测试网络提供构建和部署服务 ...
- ES5 Object.create 方法
Object.create(proto[, propertiesObject])The Object.create() method creates a new object with the spe ...
- UML类图—机房收费系统
UML类图:显示了系统的静态结构,而系统的静态结构构成了系统的概念基础.类图用于对系统中的各种概念进行建模,并描绘他们之间的关系.在类图中,一共包含了一下集中模型元素,分别是:类.接口.依赖关系.关联 ...
- 【树形dp】Distance in Tree
[CF161.D] Distance in Tree time limit per test 3 seconds memory limit per test 512 megabytes A tree ...
- Codeforces Round #344 (Div. 2) B. Print Check 水题
B. Print Check 题目连接: http://www.codeforces.com/contest/631/problem/B Description Kris works in a lar ...
- CentOS 6.9下KVM虚拟机快照创建、删除、恢复(转)
使用文件快照的方式实现文件备份,但单说快照(snapshot)的话,他是某一时间点(版本)你能看到的该时间点备份文件状态的全貌,通过文件的快照(全貌)你能恢复到特定时间点(版本)的文件状态. 创建虚拟 ...