Best JavaScript code snippet using stryker-parent
OriginalTimer.js
Source:OriginalTimer.js
1//=============================================================================2// OriginalTimer.js3// ----------------------------------------------------------------------------4// Copyright (c) 2016 fftfantt5// This software is released under the MIT License.6// http://opensource.org/licenses/mit-license.php7// ----------------------------------------------------------------------------8// Version9// 0.1.0 2016/2/15 βç10// 1.0.0 2016/2/21 åç11// 1.0.1 2016/2/21 TimerSaveãYESã§ãåå®è¡ãããªãä¸å
·åä¿®æ£12// 1.0.2 2016/2/21 åæåé¢é£ã®å¦çã®è¦ç´ã13// 1.0.3 2016/3/26 ã¿ã¤ãã¼ã¹ã¿ã¼ãæã«å³æã§ã«ã¦ã³ãããªãããå¤æ´14// 1.0.4 2016/4/03 æ¦éçµäºå¾ã«ã¨ã©ã¼ã«ãªã£ã¦ãã¾ãä¸å
·åã解æ¶15// 1.1.0 2016/4/03 ã¿ã¤ãã¼ã®çµäºå¾ã«æå®ã®ã¹ã¤ãããONã«ããã³ãã³ã追å 16// 1.2.0 2016/4/03 ã¿ã¤ãã¼ã®ã«ã¦ã³ãããªã»ããããã³ãã³ã追å 17// 1.2.1 2016/4/03 ã¿ã¤ãã¼å¤ã®åå¾ã§è¨å®å¤ãåããªãä¸å
·åä¿®æ£18// 1.3.0 2016/6/09 è¨å®æéæä½ãå®æéæä½ã®ã³ãã³ã追å 19// ----------------------------------------------------------------------------20// [HomePage]: https://googledrive.com/host/0BxiSZT-B8lvFOUFhVTF6VjNnUGc/index.html 21// [Twitter] : https://twitter.com/fftfantt/22// [GitHub] : https://github.com/fftfantt/23//=============================================================================24/*:25 * @plugindesc ãªãªã¸ãã«ã¿ã¤ãã¼26 * @author fftfantt27 *28 * @param TimerSave29 * @desc ã¿ã¤ãã¼ã®å¤ãã»ã¼ããã¼ã¿ã«å«ããã YES or NO30 * @default NO31 * @help32 * 33 * â 説æ34 * ãã®ãã©ã°ã¤ã³ã¯1æ¥ãã1/100ç§åä½ã§ã«ã¦ã³ãã§ãããªãªã¸ãã«ã¿ã¤ãã¼ãå®è£
ãã¾ãã35 * ã«ã¦ã³ããã¦ã³ã®ã»ããã«ã¦ã³ãã¢ããã«ã対å¿ãã¦ãã¾ãã36 * åçããã¹ã表示é¨åã®ãã¸ãã¯ã«ã¤ãã¦ã¯ãããªã¢ã³ã³ã¿ã³æ§ã®ãDTextPicture.jsã37 * ãåèã«ããã¦ããã ãã¦ããã¾ãããã®å ´ããåããã¦æè¬ç³ãä¸ãã¾ãã38 *39 * â å©ç¨è¦ç´40 * å½ãã©ã°ã¤ã³ã¯MITã©ã¤ã»ã³ã¹ã®ãã¨ã§å
¬éããã¦ãã¾ãã41 * https://osdn.jp/projects/opensource/wiki/licenses%2FMIT_license42 * ãããã¼ã®ã©ã¤ã»ã³ã¹è¡¨è¨ã®ã¿æ®ãã¦ãã ããã43 * åç¨å©ç¨ãå¹´é½¢å¶éã®ããã²ã¼ã ã¸ã®ä½¿ç¨ãæ¹å¤ãå¯è½ã§ãã44 * ã¯ã¬ã¸ããã¯ä¸è¦ã§ãã45 * å½ãã©ã°ã¤ã³ã®ä¸å
·åã«æ害ã®è²¬ä»»ã«ã¤ãã¦ããMITã©ã¤ã»ã³ã¹ã®è¡¨è¨ã©ããã§ãã46 *47 * â 使ãæ¹ã®æ¦è¦48 * ã¤ãã³ãã®ã³ãã³ã追å ãããã©ã°ã¤ã³ã³ãã³ããé¸æãã以ä¸ã®ãããªãã©ã°ã¤ã³49 * ã³ãã³ãã§ã¿ã¤ãã¼ãè¨å®å¾éå§ãã¦ãã ããã50 * ãã¡ãã«ã詳ãã使ãæ¹ãè¨è¼ããã¦ãã¾ãã51 * https://github.com/fftfantt/RPGMakerMV/wiki/OriginalTimer.js52 * 53 * â ã¿ã¤ãã¼ã®è¨å®54 * ãâãã©ã¡ã¼ã¿55 * ããå¼æ°1ï¼ã¿ã¤ãã¼ã®è¨å®ãè¡ãå ´åã®å¼æ° [è¨å® or SET]56 * ããå¼æ°2ï¼ã¿ã¤ãã¼ã®ç¨®é¡[ã¢ãã or ãã¦ã³ or UP or DOWN] 57 * ããå¼æ°3ï¼è¨å®æé (1d1h1m1s1x1c ã®ããã«è¨è¼)[æ¥ or d æé or h å or m ç§ or s x(1/10ç§) c(1/100ç§)]58 * ããå¼æ°4ï¼ãã¯ãã£çªå·[1ï½100]59 * ããå¼æ°5ï¼ãã©ã³ããµã¤ãº60 * ããå¼æ°6ï¼ç»é¢ï¼¸61 * ããå¼æ°7ï¼ç»é¢ï¼¹62 * ããå¼æ°8ï¼è¡¨ç¤ºã¢ã¼ã[表示 or é表示 or DISPLAY or HIDE]63 * ããå¼æ°9ï¼è¡¨ç¤ºå½¢å¼[Dæ¥ HHæMMåSS.XCç§ ã HH:MM:SS:XC ã§èªç±ã«]64 * ãâã³ãã³ãä¾65 * ãããªãªã¸ãã«ã¿ã¤ãã¼ è¨å® ãã¦ã³ 2d1h30m 99 24 10 10 表示 Dæ¥ HHæMMåSS.XCç§66 * ããORIGINALTIMER SET DOWN 1h30m 99 24 10 10 DISPLAY HH:MM:SS:XC67 * ãããªãªã¸ãã«ã¿ã¤ãã¼ è¨å® ã¢ãã 1h30m 10 24 630 10 é表示 HH:MM:SS.XC68 * ããORIGINALTIMER SET UP 1h30m 10 24 630 10 HIDE HH:MM:SS.XC69 * 70 * â ã¿ã¤ãã¼ã®éå§71 * ãâãã©ã¡ã¼ã¿72 * ããå¼æ°1ï¼ã¿ã¤ãã¼ãéå§ãããã¯åéããå ´åã®å¼æ° [éå§ or åé or START]73 * ãâã³ãã³ãä¾74 * ãããªãªã¸ãã«ã¿ã¤ãã¼ éå§75 * ããORIGINALTIMER START76 * 77 * â ã¿ã¤ãã¼ã®åæ¢78 * ãâãã©ã¡ã¼ã¿79 * ããå¼æ°1ï¼ã¿ã¤ãã¼ãåæ¢ããå ´åã®å¼æ° [åæ¢ or STOP]80 * ãâã³ãã³ãä¾81 * ãããªãªã¸ãã«ã¿ã¤ãã¼ åæ¢82 * ããORIGINALTIMER STOP83 * 84 * â ã¿ã¤ãã¼ã®è¡¨ç¤º85 * ãâãã©ã¡ã¼ã¿86 * ããå¼æ°1ï¼ã¿ã¤ãã¼ã表示ããå ´åã®å¼æ° [表示 or DISPLAY]87 * ãâã³ãã³ãä¾88 * ãããªãªã¸ãã«ã¿ã¤ã㼠表示89 * ããORIGINALTIMER DISPLAY90 * 91 * â ã¿ã¤ãã¼ã®é表示92 * ãâãã©ã¡ã¼ã¿93 * ããå¼æ°1ï¼ã¿ã¤ãã¼ãé表示ã«ããå ´åã®å¼æ° [é表示 or HIDE]94 * ãâã³ãã³ãä¾95 * ãããªãªã¸ãã«ã¿ã¤ãã¼ é表示96 * ããORIGINALTIMER HIDE97 * 98 * â ã¿ã¤ãã¼ã®åæå99 * ããå¼æ°1ï¼ã¿ã¤ãã¼ãåæåããå ´åã®å¼æ° [åæå or INITIALIZE]100 * ãâã³ãã³ãä¾101 * ãããªãªã¸ãã«ã¿ã¤ãã¼ åæå102 * ããORIGINALTIMER INITIALIZE103 * 104 * â ã¿ã¤ãã¼å¤ã®åå¾105 * ããå¼æ°1ï¼ã¿ã¤ãã¼ã«é¢ããå¤ãåå¾ããå ´åã®å¼æ° [åå¾ or GET]106 * ããå¼æ°2ï¼åå¾ããå¤ã®ç¨®é¡ [ç¶æ
or STATE or å¤ or VALUE etc]107 * ããå¼æ°3ï¼å¤ãæ ¼ç´ããå¤æ°108 * ãâã³ãã³ãä¾109 * ãããªãªã¸ãã«ã¿ã¤ãã¼ åå¾ ç¶æ
1110 * ããORIGINALTIMER GET STATE 1111 * ãããªãªã¸ãã«ã¿ã¤ãã¼ åå¾ å¤ 1112 * ããORIGINALTIMER GET VALUE 1113 * ãããªãªã¸ãã«ã¿ã¤ãã¼ åå¾ æ¥ 1114 * ããORIGINALTIMER GET DAY 1115 * ãããªãªã¸ãã«ã¿ã¤ãã¼ åå¾ æ 1116 * ããORIGINALTIMER GET HR 1117 * ãããªãªã¸ãã«ã¿ã¤ãã¼ åå¾ å 1118 * ããORIGINALTIMER GET MIN 1119 * ãããªãªã¸ãã«ã¿ã¤ãã¼ åå¾ ç§ 1120 * ããORIGINALTIMER GET SEC 1121 * ãããªãªã¸ãã«ã¿ã¤ãã¼ åå¾ ã³ã³ãç§ 1122 * ããORIGINALTIMER GET HSEC 1123 * 124 * â ã¿ã¤ãã¼çµäºå¾ã®ã¹ã¤ããæä½125 * ããå¼æ°1ï¼ã¿ã¤ãã¼çµäºå¾ã«ã¹ã¤ãããæä½ããå ´åã®å¼æ° [ã¹ã¤ãã or SWITCH]126 * ããå¼æ°2ï¼æä½ã®ç¨®é¡ [ãªã³ or ON or ãªã or OFF or ãªãã¼ã¹ or REVERSE]127 * ããå¼æ°3ï¼æä½ããã¹ã¤ããçªå·128 * ãâã³ãã³ãä¾129 * ãããªãªã¸ãã«ã¿ã¤ãã¼ ã¹ã¤ãã ãªã³ 1130 * ããORIGINALTIMER SWITCH ON 1131 * ãããªãªã¸ãã«ã¿ã¤ãã¼ ã¹ã¤ãã ãªã 2132 * ããORIGINALTIMER SWITCH OFF 2133 * ãããªãªã¸ãã«ã¿ã¤ãã¼ ã¹ã¤ãã ãªãã¼ã¹ 3134 * ããORIGINALTIMER SWITCH REVERSE 3135 * 136 * â ã¿ã¤ãã¼ã«ã¦ã³ãã®ãªã»ãã137 * ããå¼æ°1ï¼ã¿ã¤ãã¼ã«ã¦ã³ãã®ãªã»ãããè¡ãå ´åã®å¼æ° [ãªã»ãã or RESET]138 * ãâã³ãã³ãä¾139 * ãããªãªã¸ãã«ã¿ã¤ãã¼ ãªã»ãã140 * ããORIGINALTIMER RESET141 * 142 *143 * â ã¿ã¤ãã¼è¨å®æéã®æä½144 * å¼æ°1ï¼ã¿ã¤ãã¼è¨å®æéã®æä½ãè¡ãå ´åã®å¼æ° [è¨å®æéæä½ or LIMITCHANGE]145 * å¼æ°2ï¼è¨å®æéã®å¢æ¸[å¢å or æ¸å° or UP or DOWN] 146 * å¼æ°3ï¼è¨å®æé (1d1h1m1s1x1c ã®ããã«è¨è¼)[æ¥ or d æé or h å or m ç§ or s x(1/10ç§) c(1/100ç§)]147 * ãâã³ãã³ãä¾148 * ãªãªã¸ãã«ã¿ã¤ãã¼ è¨å®æéæä½ å¢å 3m149 * ãªãªã¸ãã«ã¿ã¤ãã¼ è¨å®æéæä½ æ¸å° 10s150 * ããORIGINALTIMER LIMITCHANGE UP 3m151 * ããORIGINALTIMER LIMITCHANGE DOWN 3m152 * 153 * â ã¿ã¤ãã¼å®æéã®æä½154 * å¼æ°1ï¼ã¿ã¤ãã¼å®æéã®æä½ãè¡ãå ´åã®å¼æ° [å®æéæä½ or TIMECHANGE]155 * å¼æ°2ï¼å®æéã®å¢æ¸[é²è¡ or éè¡ or UP or DOWN] 156 * å¼æ°3ï¼è¨å®æé (1d1h1m1s1x1c ã®ããã«è¨è¼)[æ¥ or d æé or h å or m ç§ or s x(1/10ç§) c(1/100ç§)]157 * ãâã³ãã³ãä¾158 * ãªãªã¸ãã«ã¿ã¤ãã¼ å®æéæä½ é²è¡ 3m159 * ãªãªã¸ãã«ã¿ã¤ãã¼ å®æéæä½ éè¡ 10s160 * ããORIGINALTIMER TIMECHANGE UP 3m161 * ããORIGINALTIMER TIMECHANGE DOWN 3m162 * 163 */164(function () {165 166 var parameters = PluginManager.parameters('OriginalTimer');167 var TimerSave = parameters['TimerSave'].toUpperCase();168 169 var OriginalTimer = null;170 var SetFlag = false;171 var RunFlag = false;172 var DisplayMode = '';173 var Count = 0;174 var CountUnit = 0;175 var CountTime = 0;176 var CommndType = '';177 var TimerType = '';178 var TimerLimit = 0;179 var day = 0;180 var hr = 0;181 var min = 0;182 var sec = 0;183 var Hsec = 0;184 var TimerText = '';185 var ShowText = '';186 187 var pictureId = 0;188 var fontsize = 32; 189 var name = '';190 var origin = 0;191 var x = 0;192 var y = 0;193 var scaleX = 100;194 var scaleY = 100;195 var opacity = 255;196 var blendMode = 0;197 198 var SwitchState = '';199 var SwitchNumber = 0;200 var prevMsec = 0;201 function getCurrentMsec(){202 return SceneManager._currentTime || Date.now();203 }204 //=============================================================================205 // Game_Interpreter_pluginCommand206 // ãã©ã°ã¤ã³ã³ãã³ããå®è¡ãããã¨ãã«å¦çããã¾ã207 //=============================================================================208 209 var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;210 Game_Interpreter.prototype.pluginCommand = function(command, args) {211 _Game_Interpreter_pluginCommand.call(this, command, args);212 213 if (command === "ãªãªã¸ãã«ã¿ã¤ãã¼" || command.toUpperCase() === "ORIGINALTIMER" ) {214 if ($gameTimer !== null){215 if (!Object.prototype.hasOwnProperty.call($gameTimer, '_fftfanttOriginalTimer_Run')){216 if (TimerSave == 'YES') Game_Timer.prototype.fftfanttOriginalTimer_Initialize();217 }218 }219 CommndType = args[0];220 221 if (CommndType == 'è¨å®' || CommndType.toUpperCase() == 'SET'){222 if (RunFlag){223 console.log('ãªãªã¸ãã«ã¿ã¤ãã¼ã¯å®è¡ä¸ã§ã');224 return;225 }226 SetFlag = true;227 if (TimerSave == 'YES'){228 Game_Timer.prototype.fftfanttOriginalTimer_Initialize();229 $gameTimer._fftfanttOriginalTimer_Set = true;230 }231 TimerSet(args);232 }233 if (CommndType == 'éå§' || CommndType == 'åé' || CommndType.toUpperCase() == 'START'){234 if (RunFlag){235 if ($gameTemp.isPlaytest()) console.log('ãªãªã¸ãã«ã¿ã¤ãã¼ã¯å®è¡ä¸ã§ã');236 return;237 }238 if (!SetFlag){239 if (!$gameTemp.isPlaytest()) console.log('ã¿ã¤ãã¼ãè¨å®ããã¦ãã¾ãã');240 return;241 }242 RunFlag = true;243 if (TimerSave == 'YES') $gameTimer._fftfanttOriginalTimer_Run = true;244 prevMsec = getCurrentMsec();245 TimerRun();246 OriginalTimer = setInterval(TimerRun,CountUnit);247 }248 249 if (CommndType == 'åæ¢' || CommndType.toUpperCase() == 'STOP'){250 clearInterval(OriginalTimer);251 RunFlag = false;252 if (TimerSave == 'YES') $gameTimer._fftfanttOriginalTimer_Run = false;253 }254 255 if (CommndType == '表示' || CommndType.toUpperCase() == 'DISPLAY'){256 opacity = 255257 if (TimerSave == 'YES') $gameTimer._fftfanttOriginalTimer_DisplayMode = '表示';258 return;259 }260 261 if (CommndType == 'é表示' || CommndType.toUpperCase() == 'HIDE'){262 opacity = 0;263 if (TimerSave == 'YES') $gameTimer._fftfanttOriginalTimer_DisplayMode = 'é表示';264 return;265 }266 267 if (CommndType == 'åæå' || CommndType.toUpperCase() == 'INITIALIZE'){268 if (TimerSave == 'YES'){269 Game_Timer.prototype.fftfanttOriginalTimer_Initialize();270 }271 TimerInitialize();272 return;273 }274 if (CommndType == 'åå¾' || CommndType.toUpperCase() == 'GET'){275 TimerGet(args);276 }277 278 if (CommndType == 'ã¹ã¤ãã' || CommndType.toUpperCase() == 'SWITCH'){279 if (!SetFlag){280 if (!$gameTemp.isPlaytest()) console.log('ã¿ã¤ãã¼ãè¨å®ããã¦ãã¾ãã');281 return;282 }283 SwitchState =args[1]284 switch (args[1]) {285 case 'ãªã³':286 SwitchState = 'ON';287 break;288 case 'ãªã':289 SwitchState = 'OFF';290 break;291 case 'ãªãã¼ã¹':292 SwitchState = 'REVERSE';293 break;294 }295 SwitchNumber = parseInt(args[2], 10);296 if (TimerSave == 'YES'){297 $gameTimer._fftfanttOriginalTimer_SwitchState = SwitchState298 $gameTimer._fftfanttOriginalTimer_SwitchNumber = SwitchNumber299 }300 }301 302 if (CommndType == 'ãªã»ãã' || CommndType.toUpperCase() == 'RESET'){303 if (!SetFlag){304 if (!$gameTemp.isPlaytest()) console.log('ã¿ã¤ãã¼ãè¨å®ããã¦ãã¾ãã');305 return;306 }307 Count = 0;308 if (!RunFlag && pictureId !== 0) $gameScreen.erasePicture(pictureId);309 }310 311 if (CommndType == 'è¨å®æéæä½' || CommndType.toUpperCase() == 'LIMITCHANGE'){312 if (!SetFlag){313 if (!$gameTemp.isPlaytest()) console.log('ã¿ã¤ãã¼ãè¨å®ããã¦ãã¾ãã');314 return;315 }316 var timer_tmp_array = args[2].match(/((\d+)(d|æ¥))?((\d+)(h|æé))?((\d+)(m|åé?))?((\d+)(s|ç§é?))?((\d+)(x))?((\d+)(c))?/);317 if (args[1] == 'å¢å ' || args[1] == 'UP'){318 if (timer_tmp_array[2]) TimerLimit = TimerLimit + parseInt(timer_tmp_array[2],10) * 8640000;319 if (timer_tmp_array[5]) TimerLimit = TimerLimit + parseInt(timer_tmp_array[5],10) * 360000;320 if (timer_tmp_array[8]) TimerLimit = TimerLimit + parseInt(timer_tmp_array[8],10) * 6000;321 if (timer_tmp_array[11]) TimerLimit = TimerLimit + parseInt(timer_tmp_array[11],10) * 100;322 if (timer_tmp_array[14]) TimerLimit = TimerLimit + parseInt(timer_tmp_array[14],10) * 10;323 if (timer_tmp_array[17]) TimerLimit = TimerLimit + parseInt(timer_tmp_array[17],10);324 }325 else if (args[1] == 'æ¸å°' || args[1] == 'DOWN'){326 if (timer_tmp_array[2]) TimerLimit = TimerLimit - parseInt(timer_tmp_array[2],10) * 8640000;327 if (timer_tmp_array[5]) TimerLimit = TimerLimit - parseInt(timer_tmp_array[5],10) * 360000;328 if (timer_tmp_array[8]) TimerLimit = TimerLimit - parseInt(timer_tmp_array[8],10) * 6000;329 if (timer_tmp_array[11]) TimerLimit = TimerLimit - parseInt(timer_tmp_array[11],10) * 100;330 if (timer_tmp_array[14]) TimerLimit = TimerLimit - parseInt(timer_tmp_array[14],10) * 10;331 if (timer_tmp_array[17]) TimerLimit = TimerLimit - parseInt(timer_tmp_array[17],10);332 if (TimerLimit < 0) TimerLimit = 0;333 }334 if (!RunFlag && pictureId !== 0) $gameScreen.erasePicture(pictureId); 335 }336 337 if (CommndType == 'å®æéæä½' || CommndType.toUpperCase() == 'TIMECHANGE'){338 if (!SetFlag){339 if (!$gameTemp.isPlaytest()) console.log('ã¿ã¤ãã¼ãè¨å®ããã¦ãã¾ãã');340 return;341 }342 var timer_tmp_array = args[2].match(/((\d+)(d|æ¥))?((\d+)(h|æé))?((\d+)(m|åé?))?((\d+)(s|ç§é?))?((\d+)(x))?((\d+)(c))?/);343 if (args[1] == 'é²è¡' || args[1].toUpperCase() == 'UP'){344 if (timer_tmp_array[2]) Count = Count + parseInt(timer_tmp_array[2],10) * 8640000;345 if (timer_tmp_array[5]) Count = Count + parseInt(timer_tmp_array[5],10) * 360000;346 if (timer_tmp_array[8]) Count = Count + parseInt(timer_tmp_array[8],10) * 6000;347 if (timer_tmp_array[11]) Count = Count + parseInt(timer_tmp_array[11],10) * 100;348 if (timer_tmp_array[14]) Count = Count + parseInt(timer_tmp_array[14],10) * 10;349 if (timer_tmp_array[17]) Count = Count + parseInt(timer_tmp_array[17],10);350 if (Count > TimerLimit) Count = TimerLimit;351 }352 else if (args[1] == 'éè¡' || args[1].toUpperCase() == 'DOWN'){353 if (timer_tmp_array[2]) Count = Count - parseInt(timer_tmp_array[2],10) * 8640000;354 if (timer_tmp_array[5]) Count = Count - parseInt(timer_tmp_array[5],10) * 360000;355 if (timer_tmp_array[8]) Count = Count - parseInt(timer_tmp_array[8],10) * 6000;356 if (timer_tmp_array[11]) Count = Count - parseInt(timer_tmp_array[11],10) * 100;357 if (timer_tmp_array[14]) Count = Count - parseInt(timer_tmp_array[14],10) * 10;358 if (timer_tmp_array[17]) Count = Count - parseInt(timer_tmp_array[17],10);359 if (Count < 0) Count = 0;360 }361 if (!RunFlag && pictureId !== 0) $gameScreen.erasePicture(pictureId); 362 }363 364 }365 };366 //=============================================================================367 // TimerInitialize368 // ãã©ã°ã¤ã³ã³ãã³ãã§æå®ãããå¤ãã»ãããã¾ã369 //=============================================================================370 371 function TimerInitialize(){372 OriginalTimer = null;373 SetFlag = false;374 RunFlag = false;375 DisplayMode = '';376 Count = 0;377 CountUnit = 0;378 CountTime = 0;379 CommndType = '';380 TimerType = '';381 TimerLimit = 0;382 day = 0;383 hr = 0;384 min = 0;385 sec = 0;386 Hsec = 0;387 TimerText = '';388 ShowText = '';389 pictureId = 0;390 fontsize = 32; 391 name = '';392 origin = 0;393 x = 0;394 y = 0;395 scaleX = 100;396 scaleY = 100;397 opacity = 255;398 blendMode = 0;399 SwitchState = '';400 SwitchNumber = 0;401 if (pictureId !== 0) $gameScreen.erasePicture(pictureId);402 };403 404 405 //=============================================================================406 // TimerSet407 // ãã©ã°ã¤ã³ã³ãã³ãã§æå®ãããå¤ãã»ãããã¾ã408 //=============================================================================409 410 function TimerSet(args){411 if (pictureId !== 0) $gameScreen.erasePicture(pictureId);412 TimerType = args[1];413 var timer_tmp_array = args[2].match(/((\d+)(d|æ¥))?((\d+)(h|æé))?((\d+)(m|åé?))?((\d+)(s|ç§é?))?((\d+)(x))?((\d+)(c))?/);414 TimerLimit = 0;415 if (timer_tmp_array[2]) TimerLimit = TimerLimit + parseInt(timer_tmp_array[2],10) * 8640000;416 if (timer_tmp_array[5]) TimerLimit = TimerLimit + parseInt(timer_tmp_array[5],10) * 360000;417 if (timer_tmp_array[8]) TimerLimit = TimerLimit + parseInt(timer_tmp_array[8],10) * 6000;418 if (timer_tmp_array[11]) TimerLimit = TimerLimit + parseInt(timer_tmp_array[11],10) * 100;419 if (timer_tmp_array[14]) TimerLimit = TimerLimit + parseInt(timer_tmp_array[14],10) * 10;420 if (timer_tmp_array[17]) TimerLimit = TimerLimit + parseInt(timer_tmp_array[17],10);421 pictureId = parseInt(args[3],10);422 fontsize = parseInt(args[4],10);423 x = parseInt(args[5],10);424 y = parseInt(args[6],10);425 DisplayMode = args[7];426 if (DisplayMode == 'é表示' || DisplayMode.toUpperCase() == 'HIDE'){427 opacity = 0;428 if (TimerSave == 'YES') $gameTimer._fftfanttOriginalTimer_DisplayMode = 'é表示';429 }else{430 opacity = 255;431 if (TimerSave == 'YES') $gameTimer._fftfanttOriginalTimer_DisplayMode = '表示';432 }433 TimerText = args[8];434 if (args.length > 8){435 for (var i=9;i<args.length; i++) {436 TimerText = TimerText + ' ' + args[i];437 }438 }439 TimerText = TimerText.toUpperCase();440 Count = 0;441 CountUnit = 1000;442 if (~TimerText.indexOf('X') || ~args[2].indexOf('x')) CountUnit = 100;443 if (~TimerText.indexOf('C') || ~args[2].indexOf('x')) CountUnit = 10;444 if (TimerSave == 'YES'){445 $gameTimer._fftfanttOriginalTimer_TimerType = TimerType;446 $gameTimer._fftfanttOriginalTimer_TimerLimit = args[2];447 $gameTimer._fftfanttOriginalTimer_TimerText = TimerText;448 $gameTimer._fftfanttOriginalTimer_PctureId = pictureId;449 $gameTimer._fftfanttOriginalTimer_FontSize = fontsize;450 $gameTimer._fftfanttOriginalTimer_X = x;451 $gameTimer._fftfanttOriginalTimer_Y = y;452 $gameTimer._fftfanttOriginalTimer_DisplayMode = DisplayMode;453 $gameTimer._fftfanttOriginalTimer_TimerText = TimerText;454 $gameTimer._fftfanttOriginalTimer_Set = true;455 }456 }457 //=============================================================================458 // TimerRun459 // ã¿ã¤ãã¼å®è¡æã®å¦ç460 //=============================================================================461 462 function TimerRun(){463 if (Count >= TimerLimit) {464 RunFlag = false;465 if (SwitchNumber > 0){466 if (SwitchState = 'ON') SwitchState = true;467 if (SwitchState = 'OFF') SwitchState = false;468 if (SwitchState = 'REVERSE'){469 console.log(SwitchState)470 if ($gameSwitches._data[SwitchNumber] == null) SwitchState = false;471 SwitchState = !$gameSwitches._data[SwitchNumber]472 }473 $gameSwitches.setValue(SwitchNumber,SwitchState);474 }475 if (pictureId !== 0) $gameScreen.erasePicture(pictureId);476 if (TimerSave == 'YES') $gameTimer._fftfanttOriginalTimer_Run = false;477 }478 if (!RunFlag){479 clearInterval(OriginalTimer);480 return;481 }482 var now = getCurrentMsec();483 // NB: SceneManager.updateMain ã¨åãå¤å®ã§ããäº484 var fTime = (now - prevMsec) / 1000;485 if (fTime > 0.25) fTime = 0.25;486 Count = Count + Math.max(0, fTime * 100);487 prevMsec = now;488 if (TimerType == 'ã¢ãã' || TimerType.toUpperCase() == 'UP'){489 CountTime = Math.round(Count);490 }else{491 CountTime = TimerLimit - Math.round(Count);492 }493 day = parseInt(Math.floor(CountTime / 8640000),10);494 hr = parseInt((CountTime % 8640000) / 360000,10);495 min = parseInt((CountTime % 360000) / 6000,10);496 sec = parseInt((CountTime % 6000)/100,10);497 Hsec = CountTime % 100;498 ShowText = TimerText;499 ShowText = ShowText.replace("D",day);500 ShowText = ShowText.replace("HH",("0"+hr).slice(-2));501 ShowText = ShowText.replace("H",hr);502 ShowText = ShowText.replace("MM",("0"+min).slice(-2));503 ShowText = ShowText.replace("M",min);504 ShowText = ShowText.replace("SS",("0"+sec).slice(-2));505 ShowText = ShowText.replace("S",sec);506 ShowText = ShowText.replace("X",("0"+Hsec).slice(-2).substr(0,1));507 ShowText = ShowText.replace("C",("0"+Hsec).slice(-2).substr(1,1));508 name = 'OriginalTimer' + Date.now().toString();509 $gameScreen.showPicture(pictureId, name, origin, x, y, scaleX, scaleY, opacity, blendMode);510 if (TimerSave == 'YES') $gameTimer._fftfanttOriginalTimer_Count = Count;511 };512 //=============================================================================513 // TimerGet514 // ãã©ã°ã¤ã³ã³ãã³ãã§æå®ãããã¿ã¤ãã¼ã®å¤ãåå¾ãã¾ã515 //=============================================================================516 function TimerGet(args){517 var GetType = args[1].toUpperCase518 if (args[1] == '表示å¤' || args[1].toUpperCase() == 'DISPLAYVALUE'){519 $gameVariables._data[parseInt(args[2],10)] = ShowText;520 return;521 }522 if (args[1] == 'å¤' || args[1].toUpperCase() == 'VALUE'){523 $gameVariables._data[parseInt(args[2],10)] = parseInt(CountTime,10);524 return;525 }526 if (args[1] == 'ã»ããå¤' || args[1].toUpperCase() == 'SETVALUE'){527 $gameVariables._data[parseInt(args[2],10)] = parseInt(TimerLimit,10);528 return;529 }530 if (args[1] == 'æ¥' || args[1].toUpperCase() == 'DAY' || args[1].toUpperCase() == 'D'){531 $gameVariables._data[parseInt(args[2],10)] = parseInt(day,10);532 return;533 }534 if (args[1] == 'æ' || args[1].toUpperCase() == 'HR' || args[1].toUpperCase() == 'H'){535 $gameVariables._data[parseInt(args[2],10)] = parseInt(hr,10);536 return;537 }538 if (args[1]== 'å' || args[1].toUpperCase() == 'MIN' || args[1].toUpperCase() == 'M'){539 $gameVariables._data[parseInt(args[2],10)] = parseInt(min,10);540 return;541 }542 if (args[1] == 'ç§' || args[1].toUpperCase() == 'SEC' || args[1].toUpperCase() == 'S'){543 $gameVariables._data[parseInt(args[2],10)] = parseInt(sec,10);544 return;545 }546 if (args[1] == 'ã³ã³ãç§' || args[1].toUpperCase() == 'HSEC' || args[1].toUpperCase() == 'XC'){547 $gameVariables._data[parseInt(args[2],10)] = parseInt(Hsec,10);548 return;549 }550 if (args[1] == 'ç¶æ
'){551 if (RunFlag) {552 $gameVariables._data[parseInt(args[2],10)] = 'å®è¡ä¸';553 } else {554 $gameVariables._data[parseInt(args[2],10)] = 'åæ¢ä¸'555 }556 return;557 }558 if (args[1].toUpperCase() == 'STATE'){559 if (RunFlag) {560 $gameVariables._data[parseInt(args[2],10)] = 'RUN';561 } else {562 $gameVariables._data[parseInt(args[2],10)] = 'STOP';563 }564 return;565 }566 }567 //=============================================================================568 // Sprite_Picture569 // ç»åã®åççæã追å å®ç¾©ãã¾ãã570 //=============================================================================571 var _Sprite_Picture_loadBitmap = Sprite_Picture.prototype.loadBitmap;572 Sprite_Picture.prototype.loadBitmap = function() {573 if (this.picture()._name == name) {574 this.fftfanttOriginalTimer_UpdateShowText();575 } else {576 _Sprite_Picture_loadBitmap.call(this);577 }578 };579 Sprite_Picture.prototype.fftfanttOriginalTimer_UpdateShowText = function(bitmap) {580 this.bitmap = new Bitmap(ShowText.length * fontsize + x ,(fontsize + y) *1.0 ) ;581 this.bitmap.fontSize = fontsize;582 this.bitmap.clear();583 this.bitmap.drawText(ShowText, x, y,0 ,0, "left");584 };585 //=============================================================================586 // Scene_Save587 // TimerSaveãNOã®å ´åãã»ã¼ãåã«ãªãªã¸ãã«ã¿ã¤ãã¼ã®ãªãã¸ã§ã¯ããåé¤ãã¾ã588 //=============================================================================589 590 var _Scene_Save_onSavefileOk = Scene_Save.prototype.onSavefileOk;591 Scene_Save.prototype.onSavefileOk = function() {592 if (pictureId !== 0) $gameScreen.erasePicture(pictureId);593 if (TimerSave !== 'YES'){594 delete $gameTimer._fftfanttOriginalTimer_Count;595 delete $gameTimer._fftfanttOriginalTimer_Set;596 delete $gameTimer._fftfanttOriginalTimer_Run;597 delete $gameTimer._fftfanttOriginalTimer_Display;598 delete $gameTimer._fftfanttOriginalTimer_TimerType;599 delete $gameTimer._fftfanttOriginalTimer_TimerLimit;600 delete $gameTimer._fftfanttOriginalTimer_PctureId;601 delete $gameTimer._fftfanttOriginalTimer_FontSize;602 delete $gameTimer._fftfanttOriginalTimer_X;603 delete $gameTimer._fftfanttOriginalTimer_Y;604 delete $gameTimer._fftfanttOriginalTimer_DisplayMode;605 delete $gameTimer._fftfanttOriginalTimer_TimerText;606 delete $gameTimer._fftfanttOriginalTimer_SwitchState;607 delete $gameTimer._fftfanttOriginalTimer_SwitchNumber;608 }609 _Scene_Save_onSavefileOk.call(this);610 };611 //=============================================================================612 // Scene_Base613 // æ¦éçµäºå¾ã«ãã¯ãã£ãå¼ã³åºããªãã¨ã©ã¼ãåé¿ãã¾ã614 //=============================================================================615 var _Scene_Base_prototype_isReady = Scene_Base.prototype.isReady;616 Scene_Base.prototype.isReady = function() {617 if (pictureId !== 0) $gameScreen.erasePicture(pictureId);618 return _Scene_Base_prototype_isReady.call(this);619 };620 //=============================================================================621 // Scene_Load622 // ãã¼ãæã«ã¿ã¤ãã¼ãåå®è¡ããããã®å¦ç追å å®ç¾©ãã¾ã623 //=============================================================================624 var _Scene_Load_onLoadSuccess = Scene_Load.prototype.onLoadSuccess;625 Scene_Load.prototype.onLoadSuccess = function() {626 _Scene_Load_onLoadSuccess.call(this);627 Game_Timer.prototype.fftfanttOriginalTimer_Reinitiation();628 };629 630 //=============================================================================631 // Game_Timer632 // ãªãªã¸ãã«ã¿ã¤ãã¼ç¨ã®ã¡ã½ããã追å å®ç¾©ãã¾ã633 //=============================================================================634 635 Game_Timer.prototype.fftfanttOriginalTimer_Initialize = function() {636 if (TimerSave !== 'YES') return;637 if (pictureId !== 0) $gameScreen.erasePicture(pictureId);638 this._fftfanttOriginalTimer_Count = 0;639 this._fftfanttOriginalTimer_Set = false;640 this._fftfanttOriginalTimer_Run = false;641 this._fftfanttOriginalTimer_TimerType = '';642 this._fftfanttOriginalTimer_TimerLimit = 0;643 this._fftfanttOriginalTimer_PctureId = 0;644 this._fftfanttOriginalTimer_FontSize = 0;645 this._fftfanttOriginalTimer_X = 0;646 this._fftfanttOriginalTimer_Y = 0;647 this._fftfanttOriginalTimer_DisplayMode = '';648 this._fftfanttOriginalTimer_TimerText = '';649 this._fftfanttOriginalTimer_SwitchNumber = 0;650 this._fftfanttOriginalTimer_SwitchState = '';651 };652 653 Game_Timer.prototype.fftfanttOriginalTimer_Reinitiation = function() {654 if (TimerSave !== 'YES') return;655 if ($gameTimer == null) return;656 if (!Object.prototype.hasOwnProperty.call($gameTimer, '_fftfanttOriginalTimer_Set')) return;657 if (!$gameTimer._fftfanttOriginalTimer_Set) return;658 var args = [];659 args[0] = 'è¨å®';660 args[1] = $gameTimer._fftfanttOriginalTimer_TimerType;661 args[2] = $gameTimer._fftfanttOriginalTimer_TimerLimit;662 args[3] = $gameTimer._fftfanttOriginalTimer_PctureId;663 args[4] = $gameTimer._fftfanttOriginalTimer_FontSize;664 args[5] = $gameTimer._fftfanttOriginalTimer_X;665 args[6] = $gameTimer._fftfanttOriginalTimer_Y;666 args[7] = $gameTimer._fftfanttOriginalTimer_DisplayMode;667 args[8] = $gameTimer._fftfanttOriginalTimer_TimerText;668 SetFlag = $gameTimer._fftfanttOriginalTimer_Set669 RunFlag = $gameTimer._fftfanttOriginalTimer_Run670 SwitchState = $gameTimer._fftfanttOriginalTimer_SwitchState671 SwitchNumber = $gameTimer._fftfanttOriginalTimer_SwitchNumber672 TimerSet(args);673 Count = $gameTimer._fftfanttOriginalTimer_Count674 if (!RunFlag) return;675 clearInterval(OriginalTimer);676 prevMsec = getCurrentMsec();677 OriginalTimer = setInterval(TimerRun,CountUnit);678 };679 ...
timer.js
Source:timer.js
1var today = new Date();2var timer = function() {};3timer.countdownDate = new Date();4// set date to 10 days in the future for testing purposes5timer.countdownDate.setDate( timer.countdownDate.getDate() + 10 );6/*7* Get thing started8*/9timer.init = function() {10 timer.getReferences();11 12 13 timer.getTimes();14 setInterval(function() { timer.update() }, 1000);15}16/*17* Save references of timer section18*/19timer.getReferences = function() {20 timer.timer = document.getElementById("timer");21 timer.days = timer.timer.querySelectorAll(".days .timer__number")[0];22 timer.hours = timer.timer.querySelectorAll(".hours .timer__number")[0];23 timer.minutes = timer.timer.querySelectorAll(".minutes .timer__number")[0];24 timer.seconds = timer.timer.querySelectorAll(".seconds .timer__number")[0];25}26/*27* remember time units for later use28*/29timer.getTimes = function() {30 timer.times = {};31 timer.times.second = 1000;32 timer.times.minute = timer.times.second * 60;33 timer.times.hour = timer.times.minute * 60;34 timer.times.day = timer.times.hour * 24;35}36/*37* Update the countdown38*/39timer.update = function() {40 if ( timer.timer.style.opacity !== 1 ) {41 timer.timer.style.opacity = 1;42 }43 44 timer.currentDate = new Date();45 timer.difference = timer.countdownDate - timer.currentDate;46 47 timer.days.innerHTML = timer.getTimeRemaining(timer.times.day, 1);48 timer.hours.innerHTML = timer.getTimeRemaining(timer.times.hour, 24);49 timer.minutes.innerHTML = timer.getTimeRemaining(timer.times.minute, 60);50 timer.seconds.innerHTML = timer.getTimeRemaining(timer.times.second, 60);51}52/*53* calculate remaining time based on a unit of time54*/55timer.getTimeRemaining = function( timeUnit, divisor ) {56 var n;57 if ( divisor == 1 ) {58 n = Math.floor(timer.difference / timeUnit );59 }60 else {61 n = Math.floor((timer.difference / timeUnit) % divisor );62 }63 64 if ( String(n).length < 2 ) {65 n = "0" + n;66 }67 68 return n;69}70window.addEventListener("load", function() {71 timer.init();...
Using AI Code Generation
1var strykerParent = require('stryker-parent');2strykerParent.timer.mark('test');3var strykerParent = require('stryker-parent');4strykerParent.timer.mark('test');5var strykerParent = require('stryker-parent');6strykerParent.timer.mark('test');7var strykerParent = require('stryker-parent');8strykerParent.timer.mark('test');9var strykerParent = require('stryker-parent');10strykerParent.timer.mark('test');11var strykerParent = require('stryker-parent');12strykerParent.timer.mark('test');13var strykerParent = require('stryker-parent');14strykerParent.timer.mark('test');15var strykerParent = require('stryker-parent');16strykerParent.timer.mark('test');17var strykerParent = require('stryker-parent');18strykerParent.timer.mark('test');19var strykerParent = require('stryker-parent');20strykerParent.timer.mark('test');21var strykerParent = require('stryker-parent');22strykerParent.timer.mark('test');23var strykerParent = require('stryker-parent');24strykerParent.timer.mark('test');25var strykerParent = require('stryker-parent');26strykerParent.timer.mark('test');27var strykerParent = require('stryker-parent
Using AI Code Generation
1var timer = require('stryker-parent').timer;2timer.start();3var a = 1;4var b = 2;5var c = a + b;6timer.finish();7var timer = require('stryker-parent').timer;8timer.start();9var a = 1;10var b = 2;11var c = a + b;12timer.finish();13var timer = require('stryker-parent').timer;14timer.start();15var a = 1;16var b = 2;17var c = a + b;18timer.finish();19var timer = require('stryker-parent').timer;20timer.start();21var a = 1;22var b = 2;23var c = a + b;24timer.finish();25var timer = require('stryker-parent').timer;26timer.start();27var a = 1;28var b = 2;29var c = a + b;30timer.finish();31var timer = require('stryker-parent').timer;32timer.start();33var a = 1;34var b = 2;35var c = a + b;36timer.finish();37var timer = require('stryker-parent').timer;38timer.start();39var a = 1;40var b = 2;41var c = a + b;42timer.finish();43var timer = require('stryker-parent').timer;44timer.start();45var a = 1;46var b = 2;47var c = a + b;48timer.finish();49var timer = require('stryker-parent').timer;50timer.start();51var a = 1;52var b = 2;53var c = a + b;54timer.finish();55var timer = require('stryker-parent').timer;
Using AI Code Generation
1const { timer } = require('stryker-parent');2timer.startTimer();3const { timer } = require('stryker-parent');4timer.startTimer();5Your name to display (optional):6Your name to display (optional):
Using AI Code Generation
1const { Timer } = require('stryker-parent');2const timer = new Timer();3timer.start();4setTimeout(() => {5 timer.stop();6 console.log(timer.elapsedTime);7}, 1000);8const { Timer } = require('stryker');9const timer = new Timer();10timer.start();11setTimeout(() => {12 timer.stop();13 console.log(timer.elapsedTime);14}, 1000);
Using AI Code Generation
1var timer = require('stryker-parent').timer;2timer.start();3timer.stop();4timer.log();5module.exports = {6 timer: require('./timer')7};8var startTime;9var stopTime;10var logTime = function () {11 console.log('Time taken: ' + (stopTime - startTime) + 'ms');12};13module.exports = {14 start: function () {15 startTime = new Date().getTime();16 },17 stop: function () {18 stopTime = new Date().getTime();19 },20};21var startTime;22var stopTime;23module.exports = function () {24 var logTime = function () {25 console.log('Time taken: ' + (stopTime - startTime) + 'ms');26 };27 return {28 start: function () {29 startTime = new Date().getTime();30 },31 stop: function () {32 stopTime = new Date().getTime();33 },34 };35};36var timer = require('stryker-parent').timer();37timer.start();38timer.stop();39timer.log();40var startTime;41var stopTime;42var logTime = function () {43 console.log('
Using AI Code Generation
1var timer = require('stryker-parent').timer;2var stryker = require('stryker');3timer.start('stryker');4stryker.runMutationTest({5});6timer.stop('stryker');7var timer = require('stryker-parent').timer;8var stryker = require('stryker');9timer.start('stryker');10stryker.runMutationTest({11});12timer.stop('stryker');13var timer = require('stryker-parent').timer;14var stryker = require('stryker');15timer.start('stryker');16stryker.runMutationTest({17});18timer.stop('stryker');19var timer = require('stryker-parent').timer;20var stryker = require('stryker');21timer.start('stryker');22stryker.runMutationTest({23});24timer.stop('stryker');25var timer = require('stryker-parent').timer;26var stryker = require('stryker');27timer.start('stryker');28stryker.runMutationTest({29});30timer.stop('stryker');31var timer = require('stryker-parent').timer;32var stryker = require('stryker');33timer.start('stryker');34stryker.runMutationTest({35});36timer.stop('stryker');37var timer = require('stryker-parent').timer;38var stryker = require('stryker');39timer.start('stry
Using AI Code Generation
1timer.setTimer(1000);2timer.startTimer();3timer.stopTimer();4timer.resetTimer();5timer.getTimer();6timer.isTimerRunning();7timer.getTimerStartTime();8timer.getTimerStopTime();9timer.getTimerTimeElapsed();10timer.setTimer(1000);11timer.startTimer();12timer.stopTimer();13timer.resetTimer();14timer.getTimer();15timer.isTimerRunning();16timer.getTimerStartTime();17timer.getTimerStopTime();18timer.getTimerTimeElapsed();19timer.setTimer(1000);20timer.startTimer();21timer.stopTimer();22timer.resetTimer();23timer.getTimer();24timer.isTimerRunning();25timer.getTimerStartTime();26timer.getTimerStopTime();27timer.getTimerTimeElapsed();28timer.setTimer(1000);29timer.startTimer();30timer.stopTimer();31timer.resetTimer();32timer.getTimer();33timer.isTimerRunning();34timer.getTimerStartTime();35timer.getTimerStopTime();36timer.getTimerTimeElapsed();37timer.setTimer(1000);38timer.startTimer();39timer.stopTimer();40timer.resetTimer();41timer.getTimer();42timer.isTimerRunning();43timer.getTimerStartTime();44timer.getTimerStopTime();45timer.getTimerTimeElapsed();46timer.setTimer(1000);47timer.startTimer();48timer.stopTimer();49timer.resetTimer();50timer.getTimer();51timer.isTimerRunning();52timer.getTimerStartTime();53timer.getTimerStopTime();54timer.getTimerTimeElapsed();55timer.setTimer(1000);56timer.startTimer();57timer.stopTimer();58timer.resetTimer();59timer.getTimer();60timer.isTimerRunning();61timer.getTimerStartTime();62timer.getTimerStopTime();63timer.getTimerTimeElapsed();64timer.setTimer(1000);65timer.startTimer();66timer.stopTimer();67timer.resetTimer();68timer.getTimer();69timer.isTimerRunning();70timer.getTimerStartTime();71timer.getTimerStopTime();72timer.getTimerTimeElapsed();73timer.setTimer(1000);74timer.startTimer();75timer.stopTimer();76timer.resetTimer();
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!!