Best JavaScript code snippet using wpt
logicfunc.js
Source:logicfunc.js
1// AnyChat for Web SDK2/********************************************3 * ä¸å¡é»è¾æ§å¶ *4 *******************************************/5 var curWwwPath = window.document.location.hostname;6 7var mDefaultServerAddr = curWwwPath; 8// é»è®¤æå¡å¨å°å9var mDefaultServerPort = 8906; // é»è®¤æå¡å¨ç«¯å£å·10var mSelfUserId = -1; // æ¬å°ç¨æ·ID11var mTargetUserId = -1; // ç®æ ç¨æ·IDï¼è¯·æ±äºå¯¹æ¹çé³è§é¢ï¼12var mRefreshVolumeTimer; // å®æ¶é³é大å°å®æ¶å¨13// æ¥å¿è®°å½ç±»åï¼å¨æ¥å¿ä¿¡æ¯æ å
æ¾ç¤ºä¸åçé¢è²14var LOG_TYPE_NORMAL = 0;15var LOG_TYPE_API = 1;16var LOG_TYPE_EVENT = 2;17var LOG_TYPE_ERROR = 3;18// éç¥ç±»åï¼å¨æåæ¶æ¯æ å
æ¾ç¤ºä¸åçé¢è²19var NOTIFY_TYPE_NORMAL = 0;20var NOTIFY_TYPE_SYSTEM = 1;21function LogicInit() {22 setTimeout(function () {23 //æ£æ¥æ¯å¦å®è£
äºæ件 24 var NEED_ANYCHAT_APILEVEL = "0"; // å®ä¹ä¸å¡å±éè¦çAnyChat API Level25 var errorcode = BRAC_InitSDK(NEED_ANYCHAT_APILEVEL); //åå§åæ件26 AddLog("BRAC_InitSDK(" + NEED_ANYCHAT_APILEVEL + ")=" + errorcode, LOG_TYPE_API);27 if (errorcode == GV_ERR_SUCCESS) {28 ShowLoginDiv(true);29 AddLog("AnyChat Plugin Version:" + BRAC_GetVersion(0), LOG_TYPE_NORMAL);30 AddLog("AnyChat SDK Version:" + BRAC_GetVersion(1), LOG_TYPE_NORMAL);31 AddLog("Build Time:" + BRAC_GetSDKOptionString(BRAC_SO_CORESDK_BUILDTIME), LOG_TYPE_NORMAL);32 } else { // 没æå®è£
æ件ï¼ææ¯æ件çæ¬å¤ªæ§ï¼æ¾ç¤ºæ件ä¸è½½çé¢33 GetID("prompt_div").style.display = "block";34 SetDivTop("prompt_div", 300);35 if (errorcode == GV_ERR_PLUGINNOINSTALL)36 GetID("prompt_div_line1").innerHTML = "é¦æ¬¡è¿å
¥éè¦å®è£
æ件ï¼è¯·ç¹å»ä¸è½½æé®è¿è¡å®è£
ï¼";37 else if (errorcode == GV_ERR_PLUGINOLDVERSION)38 GetID("prompt_div_line1").innerHTML = "æ£æµå°å½åæ件ççæ¬è¿ä½ï¼è¯·ä¸è½½å®è£
ææ°çæ¬ï¼";39 }40 }, 500);41 //设置æé®42 GetID("setting").onclick = function () {43 if (GetID("setting_div").style.display == "block")44 GetID("setting_div").style.display = "none";45 else46 GetID("setting_div").style.display = "block";47 }48 //ç»å½æé®49 GetID("loginbtn").onclick = function () {50 if (GetID("username").value != "") {51 DisplayLoadingDiv(true);52 var errorcode = BRAC_Connect(GetID("ServerAddr").value, parseInt(GetID("ServerPort").value)); //è¿æ¥æå¡å¨53 AddLog("BRAC_Connect(" + GetID("ServerAddr").value + "," + GetID("ServerPort").value + ")=" + errorcode, LOG_TYPE_API);54 errorcode = BRAC_Login(GetID("username").value, GetID("password").value, 0);55 AddLog("BRAC_Login(" + GetID("username").value + ")=" + errorcode, LOG_TYPE_API);56 // éè设置çé¢57 GetID("setting_div").style.display = "none";58 }59 else {60 GetID("a_error_user").style.color = "red";61 AddLog("The user name can not be empty!", LOG_TYPE_ERROR);62 GetID("username").focus();63 }64 }65 //éåºç³»ç»66 GetID("ExitSystemBtn").onclick = function () {67 var errorcode = BRAC_Logout();68 AddLog("BRAC_Logout()=" + errorcode, LOG_TYPE_API);69 ShowHallDiv(false);70 ShowLoginDiv(true);71 }72 //éåºæ¿é´73 GetID("leaveroom").onclick = function () {74 var errorcode = BRAC_LeaveRoom(-1);75 AddLog("BRAC_LeaveRoom(" + -1 + ")=" + errorcode, LOG_TYPE_API);76 clearInterval(mRefreshVolumeTimer); // æ¸
é¤å®æ¶é³éæ¾ç¤ºè®¡æ¶å¨77 ShowRoomDiv(false); // éèæ¿é´çé¢78 ShowHallDiv(true); // æ¾ç¤ºå¤§å
çé¢79 mTargetUserId = -1;80 }81 //è¿å
¥èªå®ä¹æ¿é´82 GetID("EnterRoomBtn").onclick = function () {83 if (GetID("customroomid").value != "") {84 var re = /^[1-9]+[0-9]*]*$/; //å¤ææ¯å¦çº¯æ°å85 if (re.test(GetID("customroomid").value)) {//纯æ°å86 EnterRoomRequest(parseInt(GetID("customroomid").value));87 } else {88 AddLog("Room ID must be number!", LOG_TYPE_ERROR);89 GetID("customroomid").value = "";90 GetID("customroomid").focus();91 }92 }93 }94 //åéä¿¡æ¯æé®95 GetID("SendMsg").onclick = function () {96 SendMessage();97 }98 //å车é®åéä¿¡æ¯99 GetID("MessageInput").onkeydown = function (e) {100 e = e ? e : window.event; //é®çäºä»¶101 if (e.keyCode == 13 && GetID("MessageInput").value != "") {//å车é®è¢«ç¹å»ä¸åéä¿¡æ¯æ¡ä¸ä¸ºç©º102 SendMessage();103 }104 }105 //ä¸è½½æ件æé®é¼ æ åå
¥ååºæ¶é´106 GetID("prompt_div_btn_load").onmouseover = function () {107 GetID("prompt_div_btn_load").style.backgroundColor = "#ffc200";108 }109 GetID("prompt_div_btn_load").onmouseout = function () {110 GetID("prompt_div_btn_load").style.backgroundColor = "#ff8100";111 }112 //ä¸è½½æ件çé¢å
³éæé®113 GetID("prompt_div_headline2").onclick = function () {114 document.URL = location.href;115 }116 // é¼ æ 移å°æ¥å¿å±ä¸é¢117 GetID("LOG_DIV_BODY").onmousemove = function () {118 GetID("LOG_DIV_BODY").style.zIndex = 100;119 GetID("LOG_DIV_CONTENT").style.backgroundColor = "#FAFADD";120 GetID("LOG_DIV_CONTENT").style.border = "1px solid black";121 }122 // é¼ æ ä»æ¥å¿å±ä¸é¢ç§»å¼123 GetID("LOG_DIV_BODY").onmouseout = function () {124 GetID("LOG_DIV_BODY").style.zIndex = -1;125 GetID("LOG_DIV_CONTENT").style.backgroundColor = "#C4CEDD";126 GetID("LOG_DIV_CONTENT").style.border = "";127 }128 //é«çº§è®¾ç½®çé¢å
³éæé®129 GetID("advanceset_div_close").onclick = function () {130 GetID("advanceset_div").style.display = "none";131 }132 //é«çº§è®¾ç½®133 GetID("advancedsetting").onclick = function () {134 if (GetID("advanceset_div").style.display == "block")135 GetID("advanceset_div").style.display = "none";136 else {137 GetID("advanceset_div").style.display = "block"; // æ¾ç¤ºé«çº§è®¾ç½®çé¢138 // åå§åé«çº§è®¾ç½®çé¢139 InitAdvanced();140 }141 }142}143//计ç®é«åº¦å¹¶è®¾ç½®çé¢ä½ç½®144function SetDivTop(id, TheHeight) {145 var BodyHeight = document.documentElement.clientHeight; //è·å¾æµè§å¨å¯è§åºåé«åº¦146 if (TheHeight < BodyHeight) {//divé«åº¦å°äºå¯è§åºåé«åº¦147 GetID("margintop").style.height = (BodyHeight - TheHeight) / 4 + "px";148 GetID(id).style.marginTop = "0px";149 }150}151//ç³»ç»ä¿¡æ¯æ¡æ»å¨æ¡æ¾é152function DisplayScroll(id) {153 var offset = GetID(id); //éè¦æ£æµçdiv154 if (offset.offsetHeight < offset.scrollHeight) {//divå¯è§é«åº¦å°äºdivæ»å¨æ¡é«åº¦155 GetID(id).style.overflowY = "scroll";//æ¾ç¤ºæ»å¨æ¡156 GetID(id).scrollTop = GetID(id).scrollHeight;//æ»å¨æ¡èªå¨æ»å¨å°åºé¨157 }158 else159 GetID(id).style.overflowY = "hidden";//éèæ»å¨æ¡160}161//åéä¿¡æ¯162function SendMessage() {163 if (GetID("MessageInput").value != "") {//åéä¿¡æ¯æ¡ä¸ä¸ºç©º164 var Msg = GetID("MessageInput").value;165 BRAC_SendTextMessage(0, 0, Msg); //è°ç¨åéä¿¡æ¯å½æ°166 DisplayTextMessage(mSelfUserId, Msg);167 GetID("MessageInput").value = "";168 GetID("MessageInput").focus();169 }170}171// æ¾ç¤ºæåæ¶æ¯172function DisplayTextMessage(fromuserid, message) {173 var namestr = BRAC_GetUserName(fromuserid) + " " + GetTheTime();174 if(fromuserid==mSelfUserId)175 namestr = namestr.fontcolor("#008000");176 else177 namestr = namestr.fontcolor("#000080");178 message = message.fontcolor("#333333");179 var msgdiv = document.createElement("div");180 msgdiv.setAttribute("class", "TheMsgStyle");181 msgdiv.innerHTML = namestr + "ï¼  " + message;182 GetID("ReceiveMsgDiv").appendChild(msgdiv);183 DisplayScroll("ReceiveMsgDiv");184}185// å¨æåæ¶æ¯åºåæ¾ç¤ºéç¥ä¿¡æ¯186function ShowNotifyMessage(message, type) {187 if (type == NOTIFY_TYPE_SYSTEM) {188 message = message.fontcolor("#FF0000");189 } else {190 message = message.fontcolor("#333333");191 }192 var msgdiv = document.createElement("div");193 msgdiv.setAttribute("class", "TheMsgStyle");194 msgdiv.innerHTML = message + " (" + GetTheTime().fontcolor("#999999") + ")";195 GetID("ReceiveMsgDiv").appendChild(msgdiv);196 DisplayScroll("ReceiveMsgDiv");197}198// æ¾ç¤ºç»å½çé¢199function ShowLoginDiv(bShow) {200 if(bShow) {201 GetID("login_div").style.display = "block"; //æ¾ç¤ºç»å½çé¢202 GetID("username").focus();203 SetDivTop("login_div", 195); //ç»å½çé¢åç´å±
ä¸204 GetID("LOG_DIV_BODY").style.display = "block"; //æ¾ç¤ºç³»ç»ä¿¡æ¯æ¡205 GetID("ServerAddr").value = mDefaultServerAddr;206 GetID("ServerPort").value = mDefaultServerPort;207 } else {208 209 }210}211// æ¾ç¤ºå¤§å
çé¢212function ShowHallDiv(bShow) {213 if (bShow) {214 GetID("room_div_userlist").innerHTML = ""; //æ¸
空æ¿é´çé¢å¥½åå表215 GetID("login_div").style.display = "none"; //éèç»å½çé¢216 GetID("hall_div").style.display = "block"; //æ¾ç¤ºå¤§å
çé¢217 GetID("customroomid").value = "";218 SetDivTop("hall_div", 400); //大å
çé¢åç´å±
ä¸219 GetID("customroomid").focus();220 GetID("a_error_user").style.color = "#FAFADD";221 222 GetID("hall_div_td_name").innerHTML = BRAC_GetUserName(mSelfUserId);223 GetID("hall_div_td_id").innerHTML = mSelfUserId;224 GetID("hall_div_td_level").innerHTML = BRAC_GetUserLevel(mSelfUserId);225 GetID("hall_div_td_ip").innerHTML = BRAC_QueryUserStateString(mSelfUserId, BRAC_USERSTATE_LOCALIP);226 } else {227 GetID("hall_div").style.display = "none";228 }229}230// æ¾ç¤ºæ¿é´çé¢231function ShowRoomDiv(bShow) {232 if (bShow) {233 GetID("hall_div").style.display = "none"; //éè大å
çé¢234 GetID("room_div").style.display = "block"; //æ¾ç¤ºæ¿é´çé¢235 SetDivTop("room_div", 610); //æ¿é´çé¢åç´å±
ä¸236 GetID("MessageInput").focus();237 } else {238 GetID("advanceset_div").style.display = "none"; //éèé«çº§è®¾ç½®çé¢239 GetID("ReceiveMsgDiv").innerHTML = ""; //æ¸
空æ¿é´çé¢ä¿¡æ¯æ¥æ¶æ¡240 GetID("room_div").style.display = "none"; //éèæ¿é´çé¢241 }242}243// 请æ±è¿å
¥æå®çæ¿é´244function EnterRoomRequest(roomid) {245 var errorcode = BRAC_EnterRoom(roomid, "", 0); //è¿å
¥æ¿é´246 AddLog("BRAC_EnterRoom(" + roomid + ")=" + errorcode, LOG_TYPE_API);247 if(errorcode == 0)248 DisplayLoadingDiv(true);249}250function GetID(id) {251 if (document.getElementById) {252 return document.getElementById(id);253 } else if (window[id]) {254 return window[id];255 }256 return null;257}258// æå¼æå®ç¨æ·çé³è§é¢259function RequestOtherUserVideo(userid) {260 var userlist = GetID("room_div_userlist");261 // è·å¾ç¨æ·å表ä¸ææ<a>æ ç¾262 var userdivobj = userlist.getElementsByTagName("div");263 for (var i = 0; i < userdivobj.length; i++) {264 userdivobj[i].style.backgroundColor = "White"; 265 }266 // è·åç¨æ·å表ä¸ææ<img>æ ç¾267 var userimgobj = userlist.getElementsByTagName("img");268 for (var j = 0; j < userimgobj.length; j++) {269 if (userimgobj[j].getAttribute("class") == "MicrophoneTag") { // 该å¾ç为 è¯ç å¾ç270 userimgobj[j].src = "./images/advanceset/microphone_false.png";271 userimgobj[j].onclick = ""; // å é¤è¯çæé®ç¹å»äºä»¶272 userimgobj[j].style.cursor = "";273 }274 }275 // å¤ææ¯å¦éè¦å
³éä¹å已请æ±çç¨æ·é³è§é¢æ°æ®276 if (mTargetUserId != -1) {277 BRAC_UserCameraControl(mTargetUserId, 0);278 BRAC_UserSpeakControl(mTargetUserId, 0);279 }280 GetID(userid + "_MicrophoneTag").src = "./images/advanceset/microphone_true.png"; // ç¹äº®è¯çå¾ç281 GetID(userid + "_UserDiv").style.backgroundColor = "#E6E6E6"; //设置被ç¹å»<a>å
ç´ çåä½é¢è²282 mTargetUserId = userid; //设置被ç¹ç¨æ·ID为å
¨å±åé283 BRAC_UserCameraControl(userid, 1); // 请æ±å¯¹æ¹è§é¢284 BRAC_UserSpeakControl(userid, 1); // 请æ±å¯¹æ¹è¯é³285 // 设置è¿ç¨è§é¢æ¾ç¤ºä½ç½®286 BRAC_SetVideoPos(userid, GetID("AnyChatRemoteVideoDiv"), "ANYCHAT_VIDEO_REMOTE");287 MicrophoneOnclick(userid); // 为å½åè§é¢ä¼è¯ç¨æ·è¯çæé®æ·»å ç¹å»äºä»¶288}289// 对å表ä¸çç¨æ·è¿è¡æ·»å ãå é¤æä½290function RoomUserListControl(userid, bInsert) {291 var userlist = GetID("room_div_userlist");292 if (bInsert) {293 var itemdiv = document.createElement("div");294 itemdiv.setAttribute("class", "UserListStyle");295 itemdiv.id = userid + "_UserDiv";296 // å¤æç¨æ·æå头ç¶æ297 if (BRAC_GetCameraState(userid) == 0)298 AddImage(itemdiv, userid + "_CameraTag", "CameraTag", "", userid); // æ·»å æå头å¾ç<img>æ ç¾299 if (BRAC_GetCameraState(userid) == 1)300 AddImage(itemdiv, userid + "_CameraTag", "CameraTag", "./images/advanceset/camera_false.png", userid); // æ·»å æå头å¾ç<img>æ ç¾301 if (BRAC_GetCameraState(userid) == 2)302 AddImage(itemdiv, userid + "_CameraTag", "CameraTag", "./images/advanceset/camera_true.png", userid); // æ·»å æå头å¾ç<img>æ ç¾303 // å¤æå½åIDæ¯å¦ä¸ºèªå·±304 if (userid == mSelfUserId) {305 AddImage(itemdiv, mSelfUserId + "_MicrophoneTag", "mSelfMicrophoneTag", "./images/advanceset/microphone_true.png", userid); // æ·»å è¯çå¾ç<img>æ ç¾306 itemdiv.innerHTML += " " + BRAC_GetUserName(mSelfUserId) + "(èªå·±)";307 } else {308 AddImage(itemdiv, userid + "_MicrophoneTag", "MicrophoneTag", "./images/advanceset/microphone_false.png", userid); // æ·»å è¯çå¾ç<img>æ ç¾309 // æ·»å ç¨æ·å§å<a>æ ç¾310 var a = document.createElement("a");311 a.id = userid + "_UserTag";312 a.title = BRAC_GetUserName(userid);313 a.innerHTML = BRAC_GetUserName(userid);314 a.href = "javascript:RequestOtherUserVideo(" + userid + ")";315 itemdiv.appendChild(a);316 }317 GetID("room_div_userlist").appendChild(itemdiv);318 MicrophoneOnclick(mSelfUserId);319 } else {320 var my = GetID(userid + "_UserDiv");321 userlist.removeChild(my);322 }323 DisplayScroll("room_div_userlist");324}325//divæé®é¼ æ åå
¥ååºææ326function Mouseover(id) {327 GetID(id).style.backgroundColor = "#FFFFCC";328}329//divæé®é¼ æ åå
¥ååºææ330function Mouseout(id) {331 GetID(id).style.backgroundColor = "#E6E6E6";332}333//è·åå½åæ¶é´ (00:00:00)334function GetTheTime() {335 var TheTime = new Date();336 return TheTime.toLocaleTimeString();337}338// æ·»å æ¥å¿å¹¶æ¾ç¤ºï¼æ ¹æ®ä¸åçç±»åæ¾ç¤ºä¸åçé¢è²339function AddLog(message, type) {340 if (type == LOG_TYPE_API) { // APIè°ç¨æ¥å¿ï¼ç»¿è²341 message = message.fontcolor("Green");342 } else if(type == LOG_TYPE_EVENT) { // åè°äºä»¶æ¥å¿ï¼é»è²343 message = message.fontcolor("#CC6600");344 } else if(type == LOG_TYPE_ERROR) { // åºéæ¥å¿ï¼çº¢è²345 message = message.fontcolor("#FF0000");346 } else { // æ®éæ¥å¿ï¼ç°è²347 message = message.fontcolor("#333333");348 }349 GetID("LOG_DIV_CONTENT").innerHTML += message + " " + GetTheTime().fontcolor("#333333") + "<br />";350 DisplayScroll("LOG_DIV_CONTENT");351}352// æ¾ç¤ºçå¾
è¿åº¦æ¡ï¼æ示ç¨æ·æä½æ£å¨è¿è¡ä¸353function DisplayLoadingDiv(bShow) {354 if (bShow) {355 GetID("LOADING_DIV").style.display = "block";356 GetID("LOADING_GREY_DIV").style.display = "block";357 var TheHeight = document.documentElement.clientHeight;358 var TheWidth = document.body.offsetWidth;359 GetID("LOADING_DIV").style.marginTop = (TheHeight - 50) / 2 + "px";360 GetID("LOADING_DIV").style.marginLeft = (TheWidth - 130) / 2 + "px";361 }362 else {363 GetID("LOADING_DIV").style.display = "none";364 GetID("LOADING_GREY_DIV").style.display = "none";365 }366}367//好å æå头 è¯ç å¾æ 368function AddImage(parent_id, img_id, img_class, fir_img, userid) {369 var imgs = document.createElement("img");370 imgs.id = img_id;371 imgs.className = img_class;372 imgs.src = fir_img;373 imgs.style.width = "15px";374 imgs.style.height = "15px";375 parent_id.appendChild(imgs);376}377// 为被ç¹å»ç¨æ·è¯çæé®æ·»å ç¹å»äºä»¶378function MicrophoneOnclick(userid) {379 GetID(userid + "_MicrophoneTag").style.cursor = "pointer"; // é¼ æ å½¢ç¶380 GetID(userid + "_MicrophoneTag").onclick = function () { // è¯çç¹å»äºä»¶381 var ImgPath = GetID(userid + "_MicrophoneTag").src.split('/');382 if (ImgPath[ImgPath.length - 1] == "microphone_true.png") {383 GetID(userid + "_MicrophoneTag").src = "./images/advanceset/microphone_false.png";384 BRAC_UserSpeakControl(userid, 0); // å
³éè¯é³385 }386 else {387 GetID(userid + "_MicrophoneTag").src = "./images/advanceset/microphone_true.png";388 BRAC_UserSpeakControl(userid, 1); // å¼å¯è¯é³389 }390 }...
script.js
Source:script.js
...42 }43 difficulty = num;44 easyBtn.style.border = '';45 for (let i = 1; i <= 81; i++) {46 getId(i).classList.remove('instance');47 }4849 startSudoku();50}5152function startSudoku() {53 clearCells();54 let gameBoard;55 gameBoard = difficulty_level;56 generateBoard(gameBoard);57}5859function generateBoard(gameBoard) {60 clearCells();61 clearDisableInput();6263 if (gameBoard == easy[0]) {64 answer = easy[1];65 }66 if (gameBoard == medium[0]) {67 answer = medium[1];68 }69 if (gameBoard == hard[0]) {70 answer = hard[1];71 }72 clearIncorrect();7374 for (var i = 0; i < 81; i++) {75 let x = gameBoard.charAt(i);76 if (x != '-') {77 getId(i + 1).value = x;78 getId(i + 1).disabled = true;79 getId('cell-' + (i + 1)).classList.add('disable');80 getId(i + 1).classList.remove('input-text');81 higlightedArea();82 } else {83 getId(i + 1).setAttribute('onkeyup', 'checkInput()');84 getId(i + 1).addEventListener('keyup', event => {85 instances(event);86 });87 getId(i + 1).addEventListener('keydown', event => {88 removeInstance(event);89 });90 }91 }92}9394function instances(event) {95 let val = event.target.value;96 for (let i = 1; i <= 81; i++) {97 if (val == getId(i).value && getId(i).value != '') {98 getId(i).classList.add('instance');99 }100 }101}102function removeInstance(event) {103 for (let i = 1; i <= 81; i++) {104 if (event.keyCode == 8) {105 getId(i).classList.remove('instance');106 }107 }108}109function clearCells() {110 for (let i = 1; i <= 81; i++) {111 getId(i).classList.remove('highlight', 'incorrect');112 getId(i).value = '';113 }114}115function higlightedArea() {116 for (let j = 1; j <= 81; j++) {117 getId(j).classList.remove('highlight', 'current-cell');118 }119}120function clearDisableInput() {121 for (var i = 1; i <= 81; i++) {122 getId(i).disabled = false;123 }124}125126const onClick = function () {127 let y = this.id;128129 higlightedArea();130 for (let i = 1; i <= 81; i++) {131 getId(i).classList.remove('instance');132 }133 getId(y).classList.add('current-cell');134135 // Higlighting rows and columns of the celected cell136 for (let q = 0; q < 81; ) {137 let c = y % 9;138 if (c == 0) {139 c = 9;140 }141 let e = q + c;142 getId(e).classList.add('highlight');143 q = q + 9;144 for (let x = 1; x <= 81; x++) {145 for (i = 0; i < 9; i++) {146 let j = i + 1;147 if (y / 9 > i && y / 9 <= j && x / 9 > i && x / 9 <= j) {148 getId(x).classList.add('highlight');149 }150 }151 }152 }153154 // (function for selecting 3x3 grid)155 box(y);156157 //getId(y).classList.remove("current-cell");158};159for (let l = 1; l <= 81; l++) {160 getId(l).onclick = onClick;161}162163function clearIncorrect() {164 for (let j = 1; j <= 81; j++) {165 getId(j).classList.remove('incorrect');166 }167}168function sudokuSolver() {169 var s = 0;170 for (var i = 1; i <= 81; i++) {171 getId(i).value = answer.charAt(s);172 s++;173 }174}175function box(y) {176 for (let i = 1; i <= 81; i++) {177 let d = y % 9;178 let s = i % 9;179 if (d == 1 || d == 2 || d == 3) {180 if (s == 1 || s == 2 || s == 3) {181 if (y <= 21 && i <= 21) {182 getId(i).classList.add('highlight');183 } else if (y > 21 && y <= 48 && i > 21 && i <= 48) {184 getId(i).classList.add('highlight');185 } else if (y > 48 && y <= 75 && i > 48 && i <= 75) {186 getId(i).classList.add('highlight');187 }188 }189 }190 if (d == 4 || d == 5 || d == 6) {191 if (s == 4 || s == 5 || s == 6) {192 if (y <= 24 && i <= 24) {193 getId(i).classList.add('highlight');194 } else if (y > 24 && y <= 51 && i > 24 && i <= 51) {195 getId(i).classList.add('highlight');196 } else if (y > 51 && y <= 78 && i > 51 && i <= 78) {197 getId(i).classList.add('highlight');198 }199 }200 }201 if (d == 7 || d == 8 || d == 0) {202 if (s == 7 || s == 8 || s == 0) {203 if (y <= 27 && i <= 27) {204 getId(i).classList.add('highlight');205 } else if (y > 27 && y <= 54 && i > 27 && i <= 54) {206 getId(i).classList.add('highlight');207 } else if (y > 54 && y <= 81 && i > 54 && i <= 81) {208 getId(i).classList.add('highlight');209 }210 }211 }212 }213}214215function checkRow() {216 for (let x = 1; x <= 81; x++) {217 for (let y = 1; y <= 81; y++) {218 if (x % 9 == y % 9 && x != y) {219 if (getId(x).value == getId(y).value) {220 getId(x).classList.add('incorrect');221 getId(y).classList.add('incorrect');222 }223 }224 }225 }226}227228function checkColumn() {229 for (let x = 1; x <= 81; x++) {230 for (let y = 1; y <= 81; y++) {231 for (let i = 0; i < 9; i++) {232 let j = i + 1;233 if (x / 9 <= j && y / 9 <= j && x / 9 > i && y / 9 > i && x != y) {234 if (getId(x).value == getId(y).value) {235 getId(x).classList.add('incorrect');236 getId(y).classList.add('incorrect');237 }238 }239 }240 }241 }242}243function checkBox() {244 let val = '';245 var idx = [];246 var a = 0;247 for (var i = 1; a < 3; i += 9) {248 a++;249 if (getId(i).value != '') {250 val += getId(i).value;251 idx.push(i);252 } else {253 val += '-';254 idx.push(i);255 }256 if (getId(i + 1).value != '') {257 val += getId(i + 1).value;258 idx.push(i + 1);259 } else {260 val += '-';261 idx.push(i + 1);262 }263 if (getId(i + 2).value != '') {264 val += getId(i + 2).value;265 idx.push(i + 2);266 } else {267 val += '-';268 idx.push(i + 2);269 }270 }271272 for (var j = 0; j < val.length; j++) {273 var check = val[j];274 if (check == '-') continue;275 for (var k = 0; k < val.length && k != j; k++) {276 if (val[k] == check) {277 console.log(idx[j], idx[k]);278279 getId(idx[j]).classList.add('incorrect');280 getId(idx[k]).classList.add('incorrect');281 }282 }283 }284285 //2nd box286 val = '';287 var idx = [];288 var a = 0;289 for (var i = 4; a < 3; i += 9) {290 a++;291 if (getId(i).value != '') {292 val += getId(i).value;293 idx.push(i);294 } else {295 val += '-';296 idx.push(i);297 }298 if (getId(i + 1).value != '') {299 val += getId(i + 1).value;300 idx.push(i + 1);301 } else {302 val += '-';303 idx.push(i + 1);304 }305 if (getId(i + 2).value != '') {306 val += getId(i + 2).value;307 idx.push(i + 2);308 } else {309 val += '-';310 idx.push(i + 2);311 }312 }313314 for (var j = 0; j < val.length; j++) {315 var check = val[j];316 if (check == '-') continue;317 for (var k = 0; k < val.length && k != j; k++) {318 if (val[k] == check) {319 console.log(idx[j], idx[k]);320321 getId(idx[j]).classList.add('incorrect');322 getId(idx[k]).classList.add('incorrect');323 }324 }325 }326 //3rd box327 val = '';328 var idx = [];329 var a = 0;330 for (var i = 7; a < 3; i += 9) {331 a++;332 if (getId(i).value != '') {333 val += getId(i).value;334 idx.push(i);335 } else {336 val += '-';337 idx.push(i);338 }339 if (getId(i + 1).value != '') {340 val += getId(i + 1).value;341 idx.push(i + 1);342 } else {343 val += '-';344 idx.push(i + 1);345 }346 if (getId(i + 2).value != '') {347 val += getId(i + 2).value;348 idx.push(i + 2);349 } else {350 val += '-';351 idx.push(i + 2);352 }353 }354355 for (var j = 0; j < val.length; j++) {356 var check = val[j];357 if (check == '-') continue;358 for (var k = 0; k < val.length && k != j; k++) {359 if (val[k] == check) {360 console.log(idx[j], idx[k]);361362 getId(idx[j]).classList.add('incorrect');363 getId(idx[k]).classList.add('incorrect');364 }365 }366 }367 //4th box368 val = '';369 var idx = [];370 var a = 0;371 for (var i = 28; a < 3; i += 9) {372 a++;373 if (getId(i).value != '') {374 val += getId(i).value;375 idx.push(i);376 } else {377 val += '-';378 idx.push(i);379 }380 if (getId(i + 1).value != '') {381 val += getId(i + 1).value;382 idx.push(i + 1);383 } else {384 val += '-';385 idx.push(i + 1);386 }387 if (getId(i + 2).value != '') {388 val += getId(i + 2).value;389 idx.push(i + 2);390 } else {391 val += '-';392 idx.push(i + 2);393 }394 }395396 for (var j = 0; j < val.length; j++) {397 var check = val[j];398 if (check == '-') continue;399 for (var k = 0; k < val.length && k != j; k++) {400 if (val[k] == check) {401 console.log(idx[j], idx[k]);402403 getId(idx[j]).classList.add('incorrect');404 getId(idx[k]).classList.add('incorrect');405 }406 }407 }408 //5th box409 val = '';410 var idx = [];411 var a = 0;412 for (var i = 31; a < 3; i += 9) {413 a++;414 if (getId(i).value != '') {415 val += getId(i).value;416 idx.push(i);417 } else {418 val += '-';419 idx.push(i);420 }421 if (getId(i + 1).value != '') {422 val += getId(i + 1).value;423 idx.push(i + 1);424 } else {425 val += '-';426 idx.push(i + 1);427 }428 if (getId(i + 2).value != '') {429 val += getId(i + 2).value;430 idx.push(i + 2);431 } else {432 val += '-';433 idx.push(i + 2);434 }435 }436437 for (var j = 0; j < val.length; j++) {438 var check = val[j];439 if (check == '-') continue;440 for (var k = 0; k < val.length && k != j; k++) {441 if (val[k] == check) {442 console.log(idx[j], idx[k]);443444 getId(idx[j]).classList.add('incorrect');445 getId(idx[k]).classList.add('incorrect');446 }447 }448 }449 //6th box//450 val = '';451 var idx = [];452 var a = 0;453 for (var i = 34; a < 3; i += 9) {454 a++;455 if (getId(i).value != '') {456 val += getId(i).value;457 idx.push(i);458 } else {459 val += '-';460 idx.push(i);461 }462 if (getId(i + 1).value != '') {463 val += getId(i + 1).value;464 idx.push(i + 1);465 } else {466 val += '-';467 idx.push(i + 1);468 }469 if (getId(i + 2).value != '') {470 val += getId(i + 2).value;471 idx.push(i + 2);472 } else {473 val += '-';474 idx.push(i + 2);475 }476 }477478 for (var j = 0; j < val.length; j++) {479 var check = val[j];480 if (check == '-') continue;481 for (var k = 0; k < val.length && k != j; k++) {482 if (val[k] == check) {483 console.log(idx[j], idx[k]);484485 getId(idx[j]).classList.add('incorrect');486 getId(idx[k]).classList.add('incorrect');487 }488 }489 }490 //7th box//491 val = '';492 var idx = [];493 var a = 0;494 for (var i = 55; a < 3; i += 9) {495 a++;496 if (getId(i).value != '') {497 val += getId(i).value;498 idx.push(i);499 } else {500 val += '-';501 idx.push(i);502 }503 if (getId(i + 1).value != '') {504 val += getId(i + 1).value;505 idx.push(i + 1);506 } else {507 val += '-';508 idx.push(i + 1);509 }510 if (getId(i + 2).value != '') {511 val += getId(i + 2).value;512 idx.push(i + 2);513 } else {514 val += '-';515 idx.push(i + 2);516 }517 }518519 for (var j = 0; j < val.length; j++) {520 var check = val[j];521 if (check == '-') continue;522 for (var k = 0; k < val.length && k != j; k++) {523 if (val[k] == check) {524 console.log(idx[j], idx[k]);525526 getId(idx[j]).classList.add('incorrect');527 getId(idx[k]).classList.add('incorrect');528 }529 }530 }531 //8th box//532 val = '';533 var idx = [];534 var a = 0;535 for (var i = 58; a < 3; i += 9) {536 a++;537 if (getId(i).value != '') {538 val += getId(i).value;539 idx.push(i);540 } else {541 val += '-';542 idx.push(i);543 }544 if (getId(i + 1).value != '') {545 val += getId(i + 1).value;546 idx.push(i + 1);547 } else {548 val += '-';549 idx.push(i + 1);550 }551 if (getId(i + 2).value != '') {552 val += getId(i + 2).value;553 idx.push(i + 2);554 } else {555 val += '-';556 idx.push(i + 2);557 }558 }559560 for (var j = 0; j < val.length; j++) {561 var check = val[j];562 if (check == '-') continue;563 for (var k = 0; k < val.length && k != j; k++) {564 if (val[k] == check) {565 console.log(idx[j], idx[k]);566567 getId(idx[j]).classList.add('incorrect');568 getId(idx[k]).classList.add('incorrect');569 }570 }571 }572 //9th box//573 val = '';574 var idx = [];575 var a = 0;576 for (var i = 61; a < 3; i += 9) {577 a++;578 if (getId(i).value != '') {579 val += getId(i).value;580 idx.push(i);581 } else {582 val += '-';583 idx.push(i);584 }585 if (getId(i + 1).value != '') {586 val += getId(i + 1).value;587 idx.push(i + 1);588 } else {589 val += '-';590 idx.push(i + 1);591 }592 if (getId(i + 2).value != '') {593 val += getId(i + 2).value;594 idx.push(i + 2);595 } else {596 val += '-';597 idx.push(i + 2);598 }599 }600601 for (var j = 0; j < val.length; j++) {602 var check = val[j];603 if (check == '-') continue;604 for (var k = 0; k < val.length && k != j; k++) {605 if (val[k] == check) {606 console.log(idx[j], idx[k]);607608 getId(idx[j]).classList.add('incorrect');609 getId(idx[k]).classList.add('incorrect');610 }611 }612 }613}614function checkInput() {615 clearIncorrect();616 checkRow();617 checkColumn();618 checkBox();619}620621function validate() {622 let count = 0;623 for (let i = 0; i < 81; i++) {624 if (answer.charAt(i) == getId(i + 1).value) {625 count++;626 }627 }628629 if (count == 81) {630 alert('Yes! Great Work ');631 clearCells();632 clearDisableInput();633 } else alert('Something Incorrect!! Try Again');634}635636//helper functions/637function getId(id) {638 return document.getElementById(id);639}640function query(selector) {641 return document.querySelector(selector);642}643function queryAll(selector) {644 return document.querySelectorAll(selector);
...
GlossaryList.js
Source:GlossaryList.js
2let id = 0 3const getId = () => ++id4const GlossaryList= [5 {6 id: getId() ,7 word: "ad nauseam",8 definition: "referring to something that has been done or repeated so often that it has become annoying or tiresome.", 9 },10 {11 id: getId() ,12 word: "bratwurst",13 definition: "a type of fine German pork sausage that is typically fried or grilled.", 14 },15 {16 id: getId() ,17 word: "conniving",18 definition: "given to or involved in conspiring to do something immoral, illegal, or harmful.", 19 },20 {21 id: getId() ,22 word:"deign" ,23 definition: "do something that one considers to be beneath one's dignity.", 24 },25 {26 id: getId() ,27 word: "dun",28 definition: "of a dull grayish-brown color.", 29 },30 {31 id: getId() ,32 word:"feign" ,33 definition: "pretend to be affected by (a feeling, state, or injury)." , 34 },35 {36 id: getId() ,37 word: "gnarled" ,38 definition: "knobbly, rough, and twisted, especially with age." , 39 },40 {41 id: getId() ,42 word: "gnat" ,43 definition: "a small two-winged fly that resembles a mosquito. Gnats include both biting and nonbiting forms, and they typically form large swarms." , 44 },45 {46 id: getId() ,47 word: "gnathic" ,48 definition: "relating to the jaws." , 49 },50 {51 id: getId() ,52 word: "gnaw" ,53 definition: "bite at or nibble something persistently." , 54 },55 {56 id: getId() ,57 word: "gneiss" ,58 definition: "a metamorphic rock with a banded or foliated structure, typically coarse-grained and consisting mainly of feldspar, quartz, and mica." , 59 },60 {61 id: getId() ,62 word: "gnome" ,63 definition: "a legendary dwarfish creature supposed to guard the earth's treasures underground." , 64 },65 {66 id: getId() ,67 word: "gnomon" ,68 definition: "The projecting piece on a sundial that shows the time by the position of its shadow." , 69 },70 {71 id: getId() ,72 word: "gnostic" ,73 definition: "relating to knowledge, especially esoteric mystical knowledge." , 74 },75 {76 id: getId() ,77 word: "gnu" ,78 definition: "a large dark African antelope with a long head, a beard and mane, and a sloping back." , 79 },80 {81 id: getId() ,82 word: "grog" ,83 definition: "spirits (originally rum) mixed with water. informally: alcoholic drink, especially beer." , 84 },85 {86 id: getId() ,87 word: "knack" ,88 definition: "an acquired or natural skill at performing a task." , 89 },90 {91 id: getId() ,92 word: "knackwurst" ,93 definition: "a type of short, fat, highly seasoned German sausage." , 94 },95 {96 id: getId() ,97 word: "knapsack" ,98 definition: "a bag with shoulder straps, carried on the back, and typically made of canvas or other weatherproof material." , 99 },100 {101 id: getId() ,102 word: "knapweed" ,103 definition: "a tough-stemmed Eurasian plant that typically has purple thistle-like flower heads, occurring chiefly in grassland and on roadsides." , 104 },105 {106 id: getId() ,107 word: "knave" ,108 definition: "a dishonest or unscrupulous man." , 109 },110 {111 id: getId() ,112 word: "knawel" ,113 definition: "a low-growing inconspicuous plant of the pink family, growing in temperate regions of the northern hemisphere." , 114 },115 {116 id: getId() ,117 word: "knead" ,118 definition: "massage or squeeze with the hands." , 119 },120 {121 id: getId() ,122 word: "knell" ,123 definition: "the sound of a bell, especially when rung solemnly for a death or funeral." , 124 },125 {126 id: getId() ,127 word: "knickers" ,128 definition: "loose-fitting trousers gathered at the knee or calf." , 129 },130 {131 id: getId() ,132 word: "knish" ,133 definition: "a dumpling of dough that is stuffed with a filling and baked or fried." , 134 },135 {136 id: getId() ,137 word: "knobby" ,138 definition: "having or covered with small knobs; knobbly." , 139 },140 {141 id: getId() ,142 word: "knoll" ,143 definition: "a small hill or mound." ,144 source: 'Dictionary.com' 145 },146 {147 id: getId() ,148 word: "knots" ,149 definition: "a unit of speed equivalent to one nautical mile per hour, used especially of ships, aircraft, or winds." , 150 },151 {152 id: getId() ,153 word: "kobold" ,154 definition: "(in Germanic mythology) a spirit that haunts houses or lives underground in caves or mines." , 155 },156 {157 id: getId() ,158 word: "malign" ,159 definition: "evil in nature or effect; malevolent." , 160 },161 {162 id: getId() ,163 word: "nape" ,164 definition: "the back of a person's neck." , 165 },166 {167 id: getId() ,168 word: "naught" ,169 definition: "nothing." , 170 },171 {172 id: getId() ,173 word: "nausea" ,174 definition: "a feeling of sickness with an inclination to vomit." , 175 },176 {177 id: getId() ,178 word: "navel" ,179 definition: "a rounded knotty depression in the center of a person's belly caused by the detachment of the umbilical cord after birth; the umbilicus." , 180 },181 {182 id: getId() ,183 word: "nether" ,184 definition: "lower in position." , 185 },186 {187 id: getId() ,188 word: "neume" ,189 definition: "(in plainsong) a note or group of notes to be sung to a single syllable." , 190 },191 {192 id: getId() ,193 word: "niche" ,194 definition: "a specialized segment of the market for a particular kind of product or service. ALSO place (something) in a niche or recess." , 195 },196 {197 id: getId() ,198 word: "nicker" ,199 definition: "(of a horse) give a soft, low, breathy whinny." , 200 },201 {202 id: getId() ,203 word: "niger" ,204 definition: "Latin for 'black' " , 205 },206 {207 id: getId() ,208 word: "nimbus" ,209 definition: "a large gray rain cloud.' " , 210 },211 {212 id: getId() ,213 word: "nomad" ,214 definition: "a person who does not stay long in the same place; a wanderer.' " , 215 },216 {217 id: getId() ,218 word: "nosh" ,219 definition: "food." , 220 },221 {222 id: getId() ,223 word: "notch" ,224 definition: "an indentation or incision on an edge or surface. To score or achieve (something)." , 225 },226 {227 id: getId() ,228 word: "nub" ,229 definition: "Unknown. Used akin to tap, nab, or brush like 'grandma' nimbly squeezing my cheeks. " , 230 },231 {232 id: getId() ,233 word: "pell mell" ,234 definition: "recklessly hasty or disorganized; headlong.' " , 235 },236 {237 id: getId() ,238 word: "pneumatic" ,239 definition: "containing or operated by air or gas under pressure. " , 240 },241 {242 id: getId() ,243 word: "rune" ,244 definition: "a mark or letter of mysterious or magic significance. " , 245 },246 {247 id: getId() ,248 word: "vignette" ,249 definition: "a brief evocative description, account, or episode. " , 250 },251 ];...
JSManterAtividade.js
Source:JSManterAtividade.js
...41<script type="text/javascript">42function preencheProxComboCnae( inPosicao ){43 document.frm.stCtrl.value = 'preencheProxComboCnae'; 44 document.frm.target = "oculto";45 document.frm.action = '<?=$pgOcul;?>?<?=Sessao::getId();?>&inPosicao='+inPosicao;46 document.frm.submit();47 document.frm.action = '<?=$pgProc;?>?<?=Sessao::getId();?>';48}49function preencheCombosCnae(){50 document.frm.stCtrl.value = 'preencheCombosCnae';51 document.frm.target = "oculto";52 document.frm.action = '<?=$pgOcul;?>?<?=Sessao::getId();?>';53 document.frm.submit();54 document.frm.action = '<?=$pgProc;?>?<?=Sessao::getId();?>';55}56function preencheProxCombo( inPosicao ){57 document.frm.stCtrl.value = 'preencheProxCombo';58 document.frm.target = "oculto";59 document.frm.action = '<?=$pgOcul;?>?<?=Sessao::getId();?>&inPosicao='+inPosicao;60 document.frm.submit();61 document.frm.action = '<?=$pgProc;?>?<?=Sessao::getId();?>';62}63function preencheCombosAtividade(){64 document.frm.stCtrl.value = 'preencheCombosAtividade';65 document.frm.target = "oculto";66 document.frm.action = '<?=$pgOcul;?>?<?=Sessao::getId();?>';67 document.frm.submit();68 document.frm.action = '<?=$pgProc;?>?<?=Sessao::getId();?>';69}70function preencheProxComboServico( inPosicaoServico ){71 document.frm.stCtrl.value = 'preencheProxComboServico';72 document.frm.target = "oculto";73 document.frm.action = '<?=$pgOcul;?>?<?=Sessao::getId();?>&inPosicaoServico='+inPosicaoServico;74 document.frm.submit();75 document.frm.action = '<?=$pgProc;?>?<?=Sessao::getId();?>';76}77function preencheCombosServico(){78 document.frm.stCtrl.value = 'preencheCombosServico';79 document.frm.target = "oculto";80 document.frm.action = '<?=$pgOcul;?>?<?=Sessao::getId();?>';81 document.frm.submit();82 document.frm.action = '<?=$pgProc;?>?<?=Sessao::getId();?>';83}84function preencheServicoVigencia(){85 document.frm.stCtrl.value = 'preencheServicoVigencia';86 document.frm.target = "oculto";87 document.frm.action = '<?=$pgOcul;?>?<?=Sessao::getId();?>';88 document.frm.submit();89 document.frm.action = '<?=$pgProc;?>?<?=Sessao::getId();?>';90}91function preencheVigencia(){92 var d = document.frm;93 d.stCtrl.value = 'preencheVigencia';94 d.target = "oculto";95 d.action = '<?=$pgOcul;?>?<?=Sessao::getId();?>';96 d.submit();97 d.target = "";98 d.action = '<?=$pgProc;?>?<?=Sessao::getId();?>';99}100function buscaCodigoVigencia(){101 var d = document.frm;102 var stTarget = d.target;103 d.stCtrl.value = 'buscaCodigoVigencia';104 d.target = "oculto";105 d.action = '<?=$pgOcul;?>?<?=Sessao::getId();?>';106 d.submit();107 //d.target = "";108 d.target = stTarget;109 d.action = '<?=$pgProc;?>?<?=Sessao::getId();?>';110}111function incluirServico(){112 var mensagem = validarServico();113 if ( mensagem == '' ){114 buscarValor('MontaServico');115 } else {116 alertaAviso(mensagem,'form','erro','<?=Sessao::getId();?>');117 return false;118 }119}120function buscarValor(tipoBusca){121 var stTarget = document.frm.target;122 var stAction = document.frm.action;123 document.frm.stCtrl.value = tipoBusca;124 document.frm.action = '<?=$pgOcul;?>?<?=Sessao::getId();?>';125 document.frm.submit();126 document.frm.action = '<?=$pgProc;?>?<?=Sessao::getId();?>';127 document.frm.action = stAction;128 document.frm.target = stTarget;129}130function buscarCnae(){131 var stTarget = document.frm.target;132 var stAction = document.frm.action;133 document.frm.stCtrl.value = 'buscaCnae';134 document.frm.target = "oculto";135 document.frm.action = '<?=$pgOcul;?>?<?=Sessao::getId();?>';136 document.frm.submit();137 document.frm.action = '<?=$pgProc;?>?<?=Sessao::getId();?>';138 document.frm.action = stAction;139 document.frm.target = stTarget;140}141function validarServico(){142 var mensagem = '';143 var d = document.frm;144 if ( d.stChaveServico.value == 0) {145 mensagem += "@Campo Servico inválido!( )";146 }147 return mensagem;148}149function limparSelectMultiplo(stSelecionado, stDisponivel){150 passaItem(stSelecionado, stDisponivel, 'tudo' );151}152function Limpar(){153 limpaFormulario();154 document.frm.reset();155 limparSelectMultiplo('inCodElementosSelecionados', 'inCodElementosDisponiveis');156 limparSelectMultiplo('inCodResponsaveisSelecionados', 'inCodResponsaveisDisponiveis');157 limparServicoGeral();158}159function limparServicoGeral() {160 var stTarget = document.frm.target;161 var stAction = document.frm.action;162 document.frm.stCtrl.value = 'limparServicoGeral';163 document.frm.action = '<?=$pgOcul;?>?<?=Sessao::getId();?>';164 document.getElementById("spnServicoCadastrado").innerHTML = '';165 document.frm.submit();166 document.frm.action = '<?=$pgProc;?>?<?=Sessao::getId();?>';167 document.frm.action = stAction;168 document.frm.target = stTarget;169}170function limparServico() {171 var stTarget = document.frm.target;172 var stAction = document.frm.action;173 document.frm.stCtrl.value = 'limparServico';174 document.frm.action = '<?=$pgOcul;?>?<?=Sessao::getId();?>';175 //document.getElementById("spnServicoCadastrado").innerHTML = '';176 document.frm.submit();177 document.frm.action = '<?=$pgProc;?>?<?=Sessao::getId();?>';178 document.frm.action = stAction;179 document.frm.target = stTarget;180}181function excluiDado(stControle, inId){182 var stTarget = document.frm.target;183 var stAction = document.frm.action;184 document.frm.stCtrl.value = stControle;185 document.frm.action = '<?=$pgOcul;?>?<?=Sessao::getId();?>&inId=' + inId;186 document.frm.submit();187 document.frm.action = '<?=$pgProc;?>?<?=Sessao::getId();?>';188 document.frm.action = stAction;189 document.frm.target = stTarget;190}191function Cancelar(){192<?php193$link = Sessao::read( "link" );194$stLink = "&pg=".$link["pg"]."&pos=".$link["pos"];195?>196 document.frm.target = "telaPrincipal";197 document.frm.action = "<?=$pgList.'?'.Sessao::getId().$stLink;?>";198 document.frm.submit();199}...
be.common.js
Source:be.common.js
1integratedCKEDITOR('description-page', height = 200);2integratedCKEDITOR('description-page-introduce',height=200);3if ($('#btnBrowseImage').length) {4 var button1 = document.getElementById('btnBrowseImage');5 button1.onclick = function () {6 selectFileWithKCFinder('pathImage', 'showHinh');7 }8}9$('.ulti-copy').click(function () {10 var selected = [];11 $('input[type=checkbox][name=id\\[\\]]').each(function () {12 if ($(this).is(":checked")) {13 selected.push($(this).val());14 }15 });16 if (selected.length != 0) {17 $('input[name=listID]').val(selected);18 alert('Äã lÆ°u sản phẩm');19 }20 else {21 alert('Má»i bạn chá»n sản phẩm');22 }23 console.log(selected);24 // alert(id[0]);25});26$('.ulti-paste').click(function () {27 if (!$('input[name=listID]').val()) {28 alert('Bạn chÆ°a Sao Chép Hoặc ChÆ°a chá»n sản phẩm');29 }30 else {31 $('#formPaste').submit();32 }33});34// SEO35$("input[name='seo_keywords']").keyup(function () {36 var getidTitle = $("#seo-part .content .show-pattern .title");37 var getidDescription = $("#seo-part .content .show-pattern .description");38 var strKeyword = $(this).val();39 strKeyword = replace_special_character_by_comma(strKeyword);40 if (strKeyword.length > 3) {41 if (strKeyword.substr(strKeyword.length - 1)===strKeyword.substr(strKeyword.length - 2,1)) {42 strKeyword=strKeyword.substr(0,strKeyword.length - 1);43 }44 }45 $(this).val(strKeyword);46 showErrorSEO(strKeyword.toLowerCase(), getidTitle, getidDescription);47})48$("input[name='seo_title']").keyup(function () {49 var getidTitle = $("#seo-part .content .show-pattern .title");50 var getidDescription = $("#seo-part .content .show-pattern .description");51 var strKeyword = $("input[name='seo_keywords']").val();52 showErrorSEO(strKeyword.toLowerCase(), getidTitle, getidDescription);53 var getid = $("#seo-part .content .show-pattern .title");54 getid.html($(this).val());55 var titleWidth = getid.width();56 if (titleWidth > 600) {57 cutString(getid);58 var temp = getid.html().lastIndexOf(' ');59 getid.html(getid.html().substring(0, temp + 1) + '...');60 }61 resetSentence();62});63$("input[name='seo_title']").bind("paste", function (e) {64 var getid = $("#seo-part .content .show-pattern .title");65 var pasteText = e.originalEvent.clipboardData.getData('text');66 getid.html(pasteText);67 var titleWidth = getid.width();68 if (titleWidth > 600) {69 cutStringTitle(getid);70 var temp = getid.html().lastIndexOf(' ');71 getid.html(getid.html().substring(0, temp + 1) + '...');72 }73});74$("textarea[name='seo_description']").keyup(function () {75 var getid = $("#seo-part .content .show-pattern .description");76 var getidTitle = $("#seo-part .content .show-pattern .title");77 var getidDescription = $("#seo-part .content .show-pattern .description");78 var strKeyword = $("input[name='seo_keywords']").val();79 showErrorSEO(strKeyword.toLowerCase(), getidTitle, getidDescription);80 getid.html($(this).val());81 var descriptionLength = getid.html().length;82 if (descriptionLength > 150) {83 cutStringDescription(getid);84 var temp = getid.html().lastIndexOf(' ');85 getid.html(getid.html().substring(0, temp + 1) + '...');86 }87 resetSentence();88});89$("input[name='title']").keyup(function () {90 var link = change_alias($(this).val());91 link = link.replace(/\s/g, "-");92 $("span.link").html(getBaseURL() + link);93 resetSentence();94});95function cutStringTitle(element) {96 var widthStr = element.width();97 var newString = '';98 if (widthStr > 600) {99 newString = element.html().substring(0, element.html().length - 1);100 element.html(newString);101 cutStringTitle(element);102 }103}104function cutStringDescription(element) {105 var descriptionLength = element.html().length;106 if (descriptionLength > 150) {107 element.html(element.html().substring(0, element.html().length - 1));108 cutStringDescription(element);109 }110}111function showErrorSEO(strKeyword, getidTitle, getidDescription) {112 var li = "";113 $("ul.error-notice").css("display", 'block');114 if (strKeyword.length > 3) {115 var listKeywords = strKeyword.trim().split(',');116 listKeywords.forEach(function (i, idx, array) {117 if (!isNullOrEmpty(i)) {118 if (getidTitle.html().toLowerCase().indexOf(i.trim()) != -1) {119 var checkText = getidTitle.html().substring(0, i.length).toLowerCase();120 if (checkText.indexOf(i.trim()) == -1) {121 li += '<li class="near">Từ khóa [' + i.trim() + '] chứa trong title nhÆ°ng không nằm Äầu câu<li>';122 return false;123 } else {124 li += '<li class="right">Từ khóa [' + i.trim() + '] chứa trong title<li>';125 return false;126 }127 return false;128 } else {129 li += '<li class="wrong">Từ khóa [' + i.trim() + '] không chứa trong title<li>';130 return false;131 }132 }133 });134 listKeywords.forEach(function (i, idx, array) {135 if (!isNullOrEmpty(i)) {136 if (getidDescription.html().toLowerCase().indexOf(i.trim()) == -1) {137 li += '<li class="wrong">Từ khóa [' + i.trim() + '] không chứa trong description<li>';138 } else {139 li += '<li class="right">Từ khóa [' + i.trim() + '] chứa trong description<li>';140 }141 }142 });143 $("ul.error-notice").html(li);144 } else {145 $("ul.error-notice").html('');146 }147}148function change_alias(alias) {149 var str = alias;150 str = str.toLowerCase();151 str = str.replace(/à |á|ạ|ả|ã|â|ầ|ấ|áº|ẩ|ẫ|Ä|ằ|ắ|ặ|ẳ|ẵ/g, "a");152 str = str.replace(/è|é|ẹ|ẻ|ẽ|ê|á»|ế|á»|á»|á»
/g, "e");153 str = str.replace(/ì|Ã|á»|á»|Ä©/g, "i");154 str = str.replace(/ò|ó|á»|á»|õ|ô|á»|á»|á»|á»|á»|Æ¡|á»|á»|ợ|á»|ỡ/g, "o");155 str = str.replace(/ù|ú|ụ|ủ|Å©|Æ°|ừ|ứ|á»±|á»|ữ/g, "u");156 str = str.replace(/ỳ|ý|ỵ|á»·|ỹ/g, "y");157 str = str.replace(/Ä/g, "d");158 str = str.replace(/!|@|%|\^|\*|\(|\)|\+|\=|\<|\>|\?|\/|,|\.|\:|\;|\'|\"|\&|\#|\[|\]|~|\$|_|`|-|{|}|\||\\/g, " ");159 str = str.replace(/ + /g, " ");160 str = str.trim();161 return str;162}163function replace_special_character_by_comma(alias) {164 var str = alias;165 str = str.replace(/!|@|%|\^|\*|\(|\)|\+|\=|\<|\>|\?|\/|,|\.|\:|\;|\'|\"|\&|\#|\[|\]|~|\$|_|`|-|{|}|\||\\/g, ",");166 return str;167}168function resetSentence() {169 var getidTitle = $("#seo-part .content .show-pattern .title");170 var getidDescription = $("#seo-part .content .show-pattern .description");171 var getidLink = $("#seo-part .content .show-pattern .link");172 if (getidTitle.html().length == 0) {173 getidTitle.html("Quick Brown Fox and The Lazy Dog - Demo Site")174 }175 if (getidDescription.html().length == 0) {176 getidDescription.html("The story of quick brown fox and the lazy dog. An all time classic children's fairy tale that is helping people with typography and web design.")177 }178 if (getidLink.html().length == 0) {179 getidLink.html("example.com/the-quick-brown-fox")180 }181 if ($("input[name='title']").length == 0) {182 getidLink.html("example.com/the-quick-brown-fox")183 }184}185function isNullOrEmpty(s) {186 return (s == null || s === "");...
JSManterServidor.js
Source:JSManterServidor.js
...40?>41<script type="text/javascript">42function incluirFoto(){43 document.frm.stCtrl.value = 'incluirFoto';44 document.frm.action = '<?=$pgOculIdentificacao;?>?<?=Sessao::getId();?>';45 document.frm.submit();46 document.frm.action = '<?=$pgProc;?>?<?=Sessao::getId();?>';47}48function excluirFoto(){49 document.frm.stCtrl.value = 'excluirFoto';50 document.frm.action = '<?=$pgOculIdentificacao;?>?<?=Sessao::getId();?>';51 document.frm.submit();52 document.frm.action = '<?=$pgProc;?>?<?=Sessao::getId();?>';53}54function buscaValor(tipoBusca,Aba){55 document.frm.stCtrl.value = tipoBusca;56 var stTraget = document.frm.target;57 var stAction = document.frm.action;58 document.frm.target = "oculto";59 switch( Aba ){60 case 1:61 document.frm.action = '<?=$pgOculIdentificacao;?>?<?=Sessao::getId();?>';62 break63 case 2:64 document.frm.action = '<?=$pgOculDocumentacao;?>?<?=Sessao::getId();?>';65 break66 case 3:67 document.frm.action = '<?=$pgOculContrato;?>?<?=Sessao::getId();?>';68 break69 case 4:70 document.frm.action = '<?=$pgOculPrevidencia;?>?<?=Sessao::getId();?>';71 break72 case 5:73 document.frm.action = '<?=$pgOculDependentes;?>?<?=Sessao::getId();?>';74 break75 case 6:76 document.frm.action = '<?=$pgOculAtributos;?>?<?=Sessao::getId();?>';77 break78 default:79 document.frm.action = '<?=$pgOcul;?>?<?=Sessao::getId();?>';80 break81 }82 document.frm.submit();83 document.frm.action = stAction;84 document.frm.target = stTraget85}86function alterarDado( stAcao, Aba, inLinha ){87 document.frm.stCtrl.value = stAcao;88 var stTraget = document.frm.target;89 document.frm.target = "oculto";90 var stAction = document.frm.action;91 switch( Aba ){92 case 1:93 document.frm.action = '<?=$pgOculIdentificacao;?>?<?=Sessao::getId();?>&inLinha='+inLinha;94 break95 case 2:96 document.frm.action = '<?=$pgOculDocumentacao;?>?<?=Sessao::getId();?>&inLinha='+inLinha;97 break98 case 3:99 document.frm.action = '<?=$pgOculContrato;?>?<?=Sessao::getId();?>&inLinha='+inLinha;100 break101 case 4:102 document.frm.action = '<?=$pgOculPrevidencia;?>?<?=Sessao::getId();?>&inLinha='+inLinha;103 break104 case 5:105 document.frm.action = '<?=$pgOculDependentes;?>?<?=Sessao::getId();?>&inLinha='+inLinha;106 break107 case 6:108 document.frm.action = '<?=$pgOculAtributos;?>?<?=Sessao::getId();?>&inLinha='+inLinha;109 }110 document.frm.submit();111 document.frm.action = stAction;112 document.frm.target = stTraget;113}114function executaFuncaoAjax( funcao, parametrosGET, sincrono ) {115 if( parametrosGET ) {116 stPag = '<?=$pgOcul;?>?<?=Sessao::getId();?>'+parametrosGET;117 } else {118 stPag = '<?=$pgOcul;?>?<?=Sessao::getId();?>';119 }120 if( sincrono ) {121 ajaxJavaScriptSincrono( stPag, funcao, '<?=Sessao::getId();?>' );122 } else {123 ajaxJavaScript( stPag, funcao );124 }125}...
test-jetpack-id.js
Source:test-jetpack-id.js
1/* This Source Code Form is subject to the terms of the Mozilla Public2 * License, v. 2.0. If a copy of the MPL was not distributed with this3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */4"use strict";5var getID = require("jetpack-id/index");6exports["test Returns GUID when `id` GUID"] = assert => {7 var guid = "{8490ae4f-93bc-13af-80b3-39adf9e7b243}";8 assert.equal(getID({ id: guid }), guid);9};10exports["test Returns domain id when `id` domain id"] = assert => {11 var id = "my-addon@jetpack";12 assert.equal(getID({ id: id }), id);13};14exports["test allows underscores in name"] = assert => {15 var name = "my_addon";16 assert.equal(getID({ name: name }), `@${name}`);17};18exports["test allows underscores in id"] = assert => {19 var id = "my_addon@jetpack";20 assert.equal(getID({ id: id }), id);21};22exports["test Returns valid name when `name` exists"] = assert => {23 var id = "my-addon";24 assert.equal(getID({ name: id }), `@${id}`);25};26exports["test Returns null when `id` and `name` do not exist"] = assert => {27 assert.equal(getID({}), null)28}29exports["test Returns null when no object passed in"] = assert => {30 assert.equal(getID(), null)31}32exports["test Returns null when `id` exists but not GUID/domain"] = assert => {33 var id = "my-addon";34 assert.equal(getID({ id: id }), null);35}36exports["test Returns null when `id` contains multiple @"] = assert => {37 assert.equal(getID({ id: "my@addon@yeah" }), null);38};39exports["test Returns null when `id` or `name` specified in domain format but has invalid characters"] = assert => {40 [" ", "!", "/", "$", " ", "~", "("].forEach(sym => {41 assert.equal(getID({ id: "my" + sym + "addon@domain" }), null);42 assert.equal(getID({ name: "my" + sym + "addon" }), null);43 });44};45exports["test Returns null, does not crash, when providing non-string properties for `name` and `id`"] = assert => {46 assert.equal(getID({ id: 5 }), null);47 assert.equal(getID({ name: 5 }), null);48 assert.equal(getID({ name: {} }), null);49};...
useTodos.js
Source:useTodos.js
1import update from "immutability-helper"2export function getDefaultTodos({ getId } = {}) {3 return [4 {5 ...(getId && { id: getId() }),6 text: "Complete online JavaScript course",7 completed: true,8 },9 {10 ...(getId && { id: getId() }),11 text: "Jog around the park 3x",12 completed: false,13 },14 {15 ...(getId && { id: getId() }),16 text: "10 minutes meditation",17 completed: false,18 },19 {20 ...(getId && { id: getId() }),21 text: "Read for 1 hour",22 completed: false,23 },24 {25 ...(getId && { id: getId() }),26 text: "Pick up groceries",27 completed: false,28 },29 {30 ...(getId && { id: getId() }),31 text: "Complete Todo App on Frontend Mentor",32 completed: false,33 },34 ]35}36export function useTodos(state, { getId } = {}) {37 const [todos, setTodos] = state38 if (!todos || !setTodos) {39 const noop = () => {}40 return [todos, noop, noop, noop, noop, noop]41 }42 const addTodo = ({ text }) => {43 setTodos([44 ...todos,45 { ...(getId && { id: getId() }), text, completed: false },46 ])47 }48 const moveTodo = ({ oldIndex, newIndex }) => {49 if (newIndex !== oldIndex) {50 const newTodos = update(todos, {51 $splice: [52 [oldIndex, 1],53 [newIndex, 0, todos[oldIndex]],54 ],55 })56 setTodos(newTodos)57 }58 }59 const updateTodo = ({ index, completed }) => {...
Using AI Code Generation
1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3wpt.getLocations(function(err, data) {4 if (err) return console.error(err);5 console.log(data);6});
Using AI Code Generation
1var wpt = require('wpt');2var wpt = new WebPageTest('www.webpagetest.org');3wpt.getId(function(err, data) {4 console.log(data);5});6### new WebPageTest([host], [apiKey])7### WebPageTest#runTest(url, options, callback)8### WebPageTest#getLocations(callback)9### WebPageTest#getStatus(callback)10### WebPageTest#getResults(testId, callback)11### WebPageTest#getPageSpeedResults(testId, callback)12### WebPageTest#getPageSpeedTimeline(testId, callback)13### WebPageTest#getVideo(testId, callback)14### WebPageTest#getScreenshot(testId, callback)15### WebPageTest#getHar(testId, callback)16### WebPageTest#getTesters(callback)17### WebPageTest#getTesters(callback)18### WebPageTest#getLocations(callback)19### WebPageTest#getStatus(callback)
Using AI Code Generation
1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org', 'A.9a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p');3wpt.getLocations(function(err, data) {4 if (err) return console.error(err);5 console.log(data);6});7* `getLocations([callback])`8* `getTesters([callback])`9* `getTestStatus(testId, [callback])`10* `getTestResults(testId, [callback])`11* `getTestResults(testId, options, [callback])`12* `runTest(url, [callback])`13* `runTest(url, options, [callback])`14### `getLocations([callback])`15### `getTesters([callback])`16### `getTestStatus(testId, [callback])`17### `getTestResults(testId, [callback])`18### `getTestResults(testId, options, [callback])`
Using AI Code Generation
1var wpt = require('./wpt.js');2 console.log(id);3});4var wpt = require('./wpt.js');5 console.log(results);6});7var wpt = require('./wpt.js');8 console.log(screenshot);9});10var wpt = require('./wpt.js');11 console.log(waterfall);12});13var wpt = require('./wpt.js');14 console.log(video);15});16var wpt = require('./wpt.js');17 console.log(har);18});19var wpt = require('./wpt.js');20 console.log(pagespeed);21});22var wpt = require('./wpt.js');23wpt.getTesters(function(testers) {24 console.log(testers);25});26var wpt = require('./wpt.js');27wpt.getLocations(function(locations) {
Using AI Code Generation
1var wpToolkit = require('wptoolkit');2var wp = new wpToolkit();3wp.getId(function (err, id) {4 if (err) {5 console.log(err);6 } else {7 console.log(id);8 }9});10### getId(callback)11### getPosts(callback)12### getPost(id, callback)13### getPages(callback)
Using AI Code Generation
1const wptools = require('wptools');2wptools.getId('Barack Obama', function(err, response) {3 console.log(response);4});5[ { id: 'Barack_Obama',6 extract: 'Barack Hussein Obama II ( ˈbɑːrək huːˈseɪn oʊˈbɑːmə ( listen); born August 4, 1961) is an American politician and attorney who served as the 44th President of the United States from 2009 to 2017. A member of the Democratic Party, he was the first African American to be elected to the presidency. He previously served as a U.S. Senator from Illinois from 2005 to 2008 and an Illinois state senator from 1997 to 2004. Born in Honolulu, Hawaii, Obama is a graduate of Columbia University and Harvard Law School, where he was president of the Harvard Law Review. He was a community organizer in Chicago before earning his law degree. He worked as a civil rights attorney and taught constitutional law at the University of Chicago Law School from 1992 to 2004. He served three terms representing the 13th District in the Illinois Senate from 1997 until 2004, when he ran for the U.S. Senate. ...',7 extract_raw: 'Barack Hussein Obama II ( ˈbɑːrək huːˈseɪn oʊˈbɑːmə ( listen); born August 4, 1961) is an American politician and attorney who served as the 44th President of the United States from 2009 to 2017. A member of the Democratic Party, he was the first African American to be elected to the presidency. He previously served as a U.S. Senator from Illinois from 200
Using AI Code Generation
1var wpt = require('webpagetest');2var api = new wpt('A.9c6e8d8d1c1a4a6e4d6e8b6d1b6e9b6');3 if (err) return console.error(err);4 console.log('Test submitted to WebPagetest for %s', data.data.url);5 console.log('Poll the test status at %s/jsonResult.php?test=%s', data.data.xmlUrl, data.data.testId);6 api.getTestResults(data.data.testId, function(err, data) {7 if (err) return console.error(err);8 console.log('Test completed for %s', data.data.url);9 console.log('First View (i.e. Load) Render Time: %dms', data.data.average.firstView.render);10 console.log('Repeat View (i.e. Load) Render Time: %dms', data.data.average.repeatView.render);11 });12});
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!