Best JavaScript code snippet using wpt
selection.py
Source:selection.py
...36 { 'desc': 'sel.modify (generic)',37 'tests': [38 { 'id': 'SM:m.f.c_TEXT-1_SC-1',39 'desc': 'move caret 1 character forward',40 'function': 'sel.modify("move", "forward", "character");',41 'pad': 'foo b^ar baz',42 'expected': 'foo ba^r baz' },43 { 'id': 'SM:m.b.c_TEXT-1_SC-1',44 'desc': 'move caret 1 character backward',45 'function': 'sel.modify("move", "backward", "character");',46 'pad': 'foo b^ar baz',47 'expected': 'foo ^bar baz' },48 { 'id': 'SM:m.f.c_TEXT-1_SI-1',49 'desc': 'move caret forward (sollapse selection)',50 'function': 'sel.modify("move", "forward", "character");',51 'pad': 'foo [bar] baz',52 'expected': 'foo bar^ baz' },53 { 'id': 'SM:m.b.c_TEXT-1_SI-1',54 'desc': 'move caret backward (collapse selection)',55 'function': 'sel.modify("move", "backward", "character");',56 'pad': 'foo [bar] baz',57 'expected': 'foo ^bar baz' },58 { 'id': 'SM:m.f.w_TEXT-1_SC-1',59 'desc': 'move caret 1 word forward',60 'function': 'sel.modify("move", "forward", "word");',61 'pad': 'foo b^ar baz',62 'expected': 'foo bar^ baz' },63 { 'id': 'SM:m.f.w_TEXT-1_SC-2',64 'desc': 'move caret 1 word forward',65 'function': 'sel.modify("move", "forward", "word");',66 'pad': 'foo^ bar baz',67 'expected': 'foo bar^ baz' },68 { 'id': 'SM:m.f.w_TEXT-1_SI-1',69 'desc': 'move caret 1 word forward from non-collapsed selection',70 'function': 'sel.modify("move", "forward", "word");',71 'pad': 'foo [bar] baz',72 'expected': 'foo bar baz^' },73 { 'id': 'SM:m.b.w_TEXT-1_SC-1',74 'desc': 'move caret 1 word backward',75 'function': 'sel.modify("move", "backward", "word");',76 'pad': 'foo b^ar baz',77 'expected': 'foo ^bar baz' },78 { 'id': 'SM:m.b.w_TEXT-1_SC-3',79 'desc': 'move caret 1 word backward',80 'function': 'sel.modify("move", "backward", "word");',81 'pad': 'foo bar ^baz',82 'expected': 'foo ^bar baz' },83 { 'id': 'SM:m.b.w_TEXT-1_SI-1',84 'desc': 'move caret 1 word backward from non-collapsed selection',85 'function': 'sel.modify("move", "backward", "word");',86 'pad': 'foo [bar] baz',87 'expected': '^foo bar baz' }88 ]89 },90 { 'desc': 'sel.modify: move forward over combining diacritics, etc.',91 'tests': [92 { 'id': 'SM:m.f.c_CHAR-2_SC-1',93 'desc': 'move 1 character forward over combined o with diaeresis',94 'function': 'sel.modify("move", "forward", "character");',95 'pad': 'fo^öbarbaz',96 'expected': 'foö^barbaz' },97 { 'id': 'SM:m.f.c_CHAR-3_SC-1',98 'desc': 'move 1 character forward over character with combining diaeresis above',99 'function': 'sel.modify("move", "forward", "character");',100 'pad': 'fo^öbarbaz',101 'expected': 'foö^barbaz' },102 { 'id': 'SM:m.f.c_CHAR-4_SC-1',103 'desc': 'move 1 character forward over character with combining diaeresis below',104 'function': 'sel.modify("move", "forward", "character");',105 'pad': 'fo^o̤barbaz',106 'expected': 'foo̤^barbaz' },107 { 'id': 'SM:m.f.c_CHAR-5_SC-1',108 'desc': 'move 1 character forward over character with combining diaeresis above and below',109 'function': 'sel.modify("move", "forward", "character");',110 'pad': 'fo^ö̤barbaz',111 'expected': 'foö̤^barbaz' },112 { 'id': 'SM:m.f.c_CHAR-5_SI-1',113 'desc': 'move 1 character forward over character with combining diaeresis above and below, selection on diaeresis above',114 'function': 'sel.modify("move", "forward", "character");',115 'pad': 'foo[̈]̤barbaz',116 'expected': 'foö̤^barbaz' },117 { 'id': 'SM:m.f.c_CHAR-5_SI-2',118 'desc': 'move 1 character forward over character with combining diaeresis above and below, selection on diaeresis below',119 'function': 'sel.modify("move", "forward", "character");',120 'pad': 'foö[̤]barbaz',121 'expected': 'foö̤^barbaz' },122 { 'id': 'SM:m.f.c_CHAR-5_SL',123 'desc': 'move 1 character forward over character with combining diaeresis above and below, selection oblique on diaeresis and preceding text',124 'function': 'sel.modify("move", "forward", "character");',125 'pad': 'fo[ö]̤barbaz',126 'expected': 'foö̤^barbaz' },127 { 'id': 'SM:m.f.c_CHAR-5_SR',128 'desc': 'move 1 character forward over character with combining diaeresis above and below, selection oblique on diaeresis and following text',129 'function': 'sel.modify("move", "forward", "character");',130 'pad': 'foö[̤bar]baz',131 'expected': 'foö̤bar^baz' },132 { 'id': 'SM:m.f.c_CHAR-6_SC-1',133 'desc': 'move 1 character forward over character with enclosing square',134 'function': 'sel.modify("move", "forward", "character");',135 'pad': 'fo^o⃞barbaz',136 'expected': 'foo⃞^barbaz' },137 { 'id': 'SM:m.f.c_CHAR-7_SC-1',138 'desc': 'move 1 character forward over character with combining long solidus overlay',139 'function': 'sel.modify("move", "forward", "character");',140 'pad': 'fo^o̸barbaz',141 'expected': 'foo̸^barbaz' }142 ]143 },144 { 'desc': 'sel.modify: move backward over combining diacritics, etc.',145 'tests': [146 { 'id': 'SM:m.b.c_CHAR-2_SC-1',147 'desc': 'move 1 character backward over combined o with diaeresis',148 'function': 'sel.modify("move", "backward", "character");',149 'pad': 'foö^barbaz',150 'expected': 'fo^öbarbaz' },151 { 'id': 'SM:m.b.c_CHAR-3_SC-1',152 'desc': 'move 1 character backward over character with combining diaeresis above',153 'function': 'sel.modify("move", "backward", "character");',154 'pad': 'foö^barbaz',155 'expected': 'fo^öbarbaz' },156 { 'id': 'SM:m.b.c_CHAR-4_SC-1',157 'desc': 'move 1 character backward over character with combining diaeresis below',158 'function': 'sel.modify("move", "backward", "character");',159 'pad': 'foo̤^barbaz',160 'expected': 'fo^o̤barbaz' },161 { 'id': 'SM:m.b.c_CHAR-5_SC-1',162 'desc': 'move 1 character backward over character with combining diaeresis above and below',163 'function': 'sel.modify("move", "backward", "character");',164 'pad': 'foö̤^barbaz',165 'expected': 'fo^ö̤barbaz' },166 { 'id': 'SM:m.b.c_CHAR-5_SI-1',167 'desc': 'move 1 character backward over character with combining diaeresis above and below, selection on diaeresis above',168 'function': 'sel.modify("move", "backward", "character");',169 'pad': 'foo[̈]̤barbaz',170 'expected': 'fo^ö̤barbaz' },171 { 'id': 'SM:m.b.c_CHAR-5_SI-2',172 'desc': 'move 1 character backward over character with combining diaeresis above and below, selection on diaeresis below',173 'function': 'sel.modify("move", "backward", "character");',174 'pad': 'foö[̤]barbaz',175 'expected': 'fo^ö̤barbaz' },176 { 'id': 'SM:m.b.c_CHAR-5_SL',177 'desc': 'move 1 character backward over character with combining diaeresis above and below, selection oblique on diaeresis and preceding text',178 'function': 'sel.modify("move", "backward", "character");',179 'pad': 'fo[ö]̤barbaz',180 'expected': 'fo^ö̤barbaz' },181 { 'id': 'SM:m.b.c_CHAR-5_SR',182 'desc': 'move 1 character backward over character with combining diaeresis above and below, selection oblique on diaeresis and following text',183 'function': 'sel.modify("move", "backward", "character");',184 'pad': 'foö[̤bar]baz',185 'expected': 'fo^ö̤barbaz' },186 { 'id': 'SM:m.b.c_CHAR-6_SC-1',187 'desc': 'move 1 character backward over character with enclosing square',188 'function': 'sel.modify("move", "backward", "character");',189 'pad': 'foo⃞^barbaz',190 'expected': 'fo^o⃞barbaz' },191 { 'id': 'SM:m.b.c_CHAR-7_SC-1',192 'desc': 'move 1 character backward over character with combining long solidus overlay',193 'function': 'sel.modify("move", "backward", "character");',194 'pad': 'foo̸^barbaz',195 'expected': 'fo^o̸barbaz' }196 ]197 },198 { 'desc': 'sel.modify: move forward/backward/left/right in RTL text',199 'tests': [200 { 'id': 'SM:m.f.c_Pdir:rtl-1_SC-1',201 'desc': 'move caret forward 1 character in right-to-left text',202 'function': 'sel.modify("move", "forward", "character");',203 'pad': '<p dir="rtl">foo b^ar baz</p>',204 'expected': '<p dir="rtl">foo ba^r baz</p>' },205 206 { 'id': 'SM:m.b.c_Pdir:rtl-1_SC-1',207 'desc': 'move caret backward 1 character in right-to-left text',208 'function': 'sel.modify("move", "backward", "character");',209 'pad': '<p dir="rtl">foo ba^r baz</p>',210 'expected': '<p dir="rtl">foo b^ar baz</p>' },211 212 { 'id': 'SM:m.r.c_Pdir:rtl-1_SC-1',213 'desc': 'move caret 1 character to the right in LTR text within RTL context',214 'function': 'sel.modify("move", "right", "character");',215 'pad': '<p dir="rtl">foo b^ar baz</p>',216 'expected': '<p dir="rtl">foo ba^r baz</p>' },217 218 { 'id': 'SM:m.l.c_Pdir:rtl-1_SC-1',219 'desc': 'move caret 1 character to the left in LTR text within RTL context',220 'function': 'sel.modify("move", "left", "character");',221 'pad': '<p dir="rtl">foo ba^r baz</p>',222 'expected': '<p dir="rtl">foo b^ar baz</p>' },223 { 'id': 'SM:m.f.c_TEXT:ar-1_SC-1',224 'desc': 'move caret forward 1 character in Arabic text',225 'function': 'sel.modify("move", "forward", "character");',226 'pad': 'مرح^با العالم',227 'expected': 'مرحب^ا العالم' },228 229 { 'id': 'SM:m.b.c_TEXT:ar-1_SC-1',230 'desc': 'move caret backward 1 character in Arabic text',231 'function': 'sel.modify("move", "backward", "character");',232 'pad': 'مرح^با العالم',233 'expected': 'مر^حبا العالم' },234 235 { 'id': 'SM:m.f.c_TEXT:he-1_SC-1',236 'desc': 'move caret forward 1 character in Hebrew text',237 'function': 'sel.modify("move", "forward", "character");',238 'pad': 'של^ום עולם',239 'expected': 'שלו^ם עולם' },240 241 { 'id': 'SM:m.b.c_TEXT:he-1_SC-1',242 'desc': 'move caret backward 1 character in Hebrew text',243 'function': 'sel.modify("move", "backward", "character");',244 'pad': 'של^ום עולם',245 'expected': 'ש^לום עולם' },246 { 'id': 'SM:m.f.c_BDOdir:rtl-1_SC-1',247 'desc': 'move caret forward 1 character inside <bdo>',248 'function': 'sel.modify("move", "forward", "character");',249 'pad': 'foo <bdo dir="rtl">b^ar</bdo> baz',250 'expected': 'foo <bdo dir="rtl">ba^r</bdo> baz' },251 252 { 'id': 'SM:m.b.c_BDOdir:rtl-1_SC-1',253 'desc': 'move caret backward 1 character inside <bdo>',254 'function': 'sel.modify("move", "backward", "character");',255 'pad': 'foo <bdo dir="rtl">ba^r</bdo> baz',256 'expected': 'foo <bdo dir="rtl">b^ar</bdo> baz' },257 258 { 'id': 'SM:m.r.c_BDOdir:rtl-1_SC-1',259 'desc': 'move caret 1 character to the right inside <bdo>',260 'function': 'sel.modify("move", "right", "character");',261 'pad': 'foo <bdo dir="rtl">ba^r</bdo> baz',262 'expected': 'foo <bdo dir="rtl">b^ar</bdo> baz' },263 264 { 'id': 'SM:m.l.c_BDOdir:rtl-1_SC-1',265 'desc': 'move caret 1 character to the left inside <bdo>',266 'function': 'sel.modify("move", "left", "character");',267 'pad': 'foo <bdo dir="rtl">b^ar</bdo> baz',268 'expected': 'foo <bdo dir="rtl">ba^r</bdo> baz' },269 270 { 'id': 'SM:m.f.c_TEXTrle-1_SC-rtl-1',271 'desc': 'move caret forward in RTL text within RLE-PDF marks',272 'function': 'sel.modify("move", "forward", "character");',273 'pad': 'I said, "(RLE)‫car يعني سي^ارة‬(PDF)".',274 'expected': 'I said, "(RLE)‫car يعني سيا^رة‬(PDF)".' },275 276 { 'id': 'SM:m.b.c_TEXTrle-1_SC-rtl-1',277 'desc': 'move caret backward in RTL text within RLE-PDF marks',278 'function': 'sel.modify("move", "backward", "character");',279 'pad': 'I said, "(RLE)‫car يعني سي^ارة‬(PDF)".',280 'expected': 'I said, "(RLE)‫car يعني س^يارة‬(PDF)".' },281 282 { 'id': 'SM:m.r.c_TEXTrle-1_SC-rtl-1',283 'desc': 'move caret 1 character to the right in RTL text within RLE-PDF marks',284 'function': 'sel.modify("move", "right", "character");',285 'pad': 'I said, "(RLE)‫car يعني سي^ارة‬(PDF)".',286 'expected': 'I said, "(RLE)‫car يعني س^يارة‬(PDF)".' },287 288 { 'id': 'SM:m.l.c_TEXTrle-1_SC-rtl-1',289 'desc': 'move caret 1 character to the left in RTL text within RLE-PDF marks',290 'function': 'sel.modify("move", "left", "character");',291 'pad': 'I said, "(RLE)‫car يعني سي^ارة‬(PDF)".',292 'expected': 'I said, "(RLE)‫car يعني سيا^رة‬(PDF)".' },293 294 { 'id': 'SM:m.f.c_TEXTrle-1_SC-ltr-1',295 'desc': 'move caret forward in LTR text within RLE-PDF marks',296 'function': 'sel.modify("move", "forward", "character");',297 'pad': 'I said, "(RLE)‫c^ar يعني سيارة‬(PDF)".',298 'expected': 'I said, "(RLE)‫ca^r يعني سيارة‬(PDF)".' },299 { 'id': 'SM:m.b.c_TEXTrle-1_SC-ltr-1',300 'desc': 'move caret backward in LTR text within RLE-PDF marks',301 'function': 'sel.modify("move", "backward", "character");',302 'pad': 'I said, "(RLE)‫ca^r يعني سيارة‬(PDF)".',303 'expected': 'I said, "(RLE)‫c^ar يعني سيارة‬(PDF)".' },304 { 'id': 'SM:m.r.c_TEXTrle-1_SC-ltr-1',305 'desc': 'move caret 1 character to the right in LTR text within RLE-PDF marks',306 'function': 'sel.modify("move", "right", "character");',307 'pad': 'I said, "(RLE)‫c^ar يعني سيارة‬(PDF)".',308 'expected': 'I said, "(RLE)‫ca^r يعني سيارة‬(PDF)".' },309 { 'id': 'SM:m.l.c_TEXTrle-1_SC-ltr-1',310 'desc': 'move caret 1 character to the left in LTR text within RLE-PDF marks',311 'function': 'sel.modify("move", "left", "character");',312 'pad': 'I said, "(RLE)‫ca^r يعني سيارة‬(PDF)".',313 'expected': 'I said, "(RLE)‫c^ar يعني سيارة‬(PDF)".' },314 { 'id': 'SM:m.f.c_TEXTrlo-1_SC-rtl-1',315 'desc': 'move caret forward in RTL text within RLO-PDF marks',316 'function': 'sel.modify("move", "forward", "character");',317 'pad': 'I said, "(RLO)‮car يعني سي^ارة‬(PDF)".',318 'expected': 'I said, "(RLO)‮car يعني سيا^رة‬(PDF)".' }, 319 { 'id': 'SM:m.b.c_TEXTrlo-1_SC-rtl-1',320 'desc': 'move caret backward in RTL text within RLO-PDF marks',321 'function': 'sel.modify("move", "backward", "character");',322 'pad': 'I said, "(RLO)‮car يعني سي^ارة‬(PDF)".',323 'expected': 'I said, "(RLO)‮car يعني س^يارة‬(PDF)".' },324 325 { 'id': 'SM:m.r.c_TEXTrlo-1_SC-rtl-1',326 'desc': 'move caret 1 character to the right in RTL text within RLO-PDF marks',327 'function': 'sel.modify("move", "right", "character");',328 'pad': 'I said, "(RLO)‮car يعني سي^ارة‬(PDF)".',329 'expected': 'I said, "(RLO)‮car يعني س^يارة‬(PDF)".' }, 330 { 'id': 'SM:m.l.c_TEXTrlo-1_SC-rtl-1',331 'desc': 'move caret 1 character to the left in RTL text within RLO-PDF marks',332 'function': 'sel.modify("move", "left", "character");',333 'pad': 'I said, "(RLO)‮car يعني سي^ارة‬(PDF)".',334 'expected': 'I said, "(RLO)‮car يعني سيا^رة‬(PDF)".' },335 336 { 'id': 'SM:m.f.c_TEXTrlo-1_SC-ltr-1',337 'desc': 'move caret forward in Latin text within RLO-PDF marks',338 'function': 'sel.modify("move", "forward", "character");',339 'pad': 'I said, "(RLO)‮c^ar يعني سيارة‬(PDF)".',340 'expected': 'I said, "(RLO)‮ca^r يعني سيارة‬(PDF)".' },341 342 { 'id': 'SM:m.b.c_TEXTrlo-1_SC-ltr-1',343 'desc': 'move caret backward in Latin text within RLO-PDF marks',344 'function': 'sel.modify("move", "backward", "character");',345 'pad': 'I said, "(RLO)‮ca^r يعني سيارة‬(PDF)".',346 'expected': 'I said, "(RLO)‮c^ar يعني سيارة‬(PDF)".' },347 348 { 'id': 'SM:m.r.c_TEXTrlo-1_SC-ltr-1',349 'desc': 'move caret 1 character to the right in Latin text within RLO-PDF marks',350 'function': 'sel.modify("move", "right", "character");',351 'pad': 'I said, "(RLO)‮ca^r يعني سيارة‬(PDF)".',352 'expected': 'I said, "(RLO)‮c^ar يعني سيارة‬(PDF)".' }, 353 { 'id': 'SM:m.l.c_TEXTrlo-1_SC-ltr-1',354 'desc': 'move caret 1 character to the left in Latin text within RLO-PDF marks',355 'function': 'sel.modify("move", "left", "character");',356 'pad': 'I said, "(RLO)‮c^ar يعني سيارة‬(PDF)".',357 'expected': 'I said, "(RLO)‮ca^r يعني سيارة‬(PDF)".' },358 359 { 'id': 'SM:m.f.c_TEXTrlm-1_SC-1',360 'desc': 'move caret forward in RTL text within neutral characters followed by RLM',361 'function': 'sel.modify("move", "forward", "character");',362 'pad': 'I said, "يعني سيارة!^?!‏(RLM)".',363 'expected': 'I said, "يعني سيارة!?^!‏(RLM)".' },364 365 { 'id': 'SM:m.b.c_TEXTrlm-1_SC-1',366 'desc': 'move caret backward in RTL text within neutral characters followed by RLM',367 'function': 'sel.modify("move", "backward", "character");',368 'pad': 'I said, "يعني سيارة!?^!‏(RLM)".',369 'expected': 'I said, "يعني سيارة!^?!‏(RLM)".' },370 371 { 'id': 'SM:m.r.c_TEXTrlm-1_SC-1',372 'desc': 'move caret 1 character to the right in RTL text within neutral characters followed by RLM',373 'function': 'sel.modify("move", "right", "character");',374 'pad': 'I said, "يعني سيارة!?^!‏(RLM)".',375 'expected': 'I said, "يعني سيارة!^?!‏(RLM)".' },376 377 { 'id': 'SM:m.l.c_TEXTrlm-1_SC-1',378 'desc': 'move caret 1 character to the left in RTL text within neutral characters followed by RLM',379 'function': 'sel.modify("move", "left", "character");',380 'pad': 'I said, "يعني سيارة!^?!‏(RLM)".',381 'expected': 'I said, "يعني سيارة!?^!‏(RLM)".' }382 ]383 },384 { 'desc': 'sel.modify: move forward/backward over words in Japanese text',385 'tests': [386 { 'id': 'SM:m.f.w_TEXT-jp_SC-1',387 'desc': 'move caret forward 1 word in Japanese text (adjective)',388 'function': 'sel.modify("move", "forward", "word");',389 'pad': '^面白い例文をテストしましょう。',390 'expected': '面白い^例文をテストしましょう。' },391 392 { 'id': 'SM:m.f.w_TEXT-jp_SC-2',393 'desc': 'move caret forward 1 word in Japanese text (in the middle of a word)',394 'function': 'sel.modify("move", "forward", "word");',395 'pad': '面^白い例文をテストしましょう。',396 'expected': '面白い^例文をテストしましょう。' },397 398 { 'id': 'SM:m.f.w_TEXT-jp_SC-3',399 'desc': 'move caret forward 1 word in Japanese text (noun)',400 'function': 'sel.modify("move", "forward", "word");',401 'pad': '面白い^例文をテストしましょう。',402 'expected': [ '面白い例文^をテストしましょう。',403 '面白い例文を^テストしましょう。' ] },404 405 { 'id': 'SM:m.f.w_TEXT-jp_SC-4',406 'desc': 'move caret forward 1 word in Japanese text (Katakana)',407 'function': 'sel.modify("move", "forward", "word");',408 'pad': '面白い例文を^テストしましょう。',409 'expected': '面白い例文をテスト^しましょう。' },410 411 { 'id': 'SM:m.f.w_TEXT-jp_SC-5',412 'desc': 'move caret forward 1 word in Japanese text (verb)',413 'function': 'sel.modify("move", "forward", "word");',414 'pad': '面白い例文をテスト^しましょう。',415 'expected': '面白い例文をテストしましょう^。' }416 ]417 },418 { 'desc': 'sel.modify: extend selection forward',419 'tests': [420 { 'id': 'SM:e.f.c_TEXT-1_SC-1',421 'desc': 'extend selection 1 character forward',422 'function': 'sel.modify("extend", "forward", "character");',423 'pad': 'foo ^bar baz',424 'expected': 'foo [b]ar baz' },425 { 'id': 'SM:e.f.c_TEXT-1_SI-1',426 'desc': 'extend selection 1 character forward',427 'function': 'sel.modify("extend", "forward", "character");',428 'pad': 'foo [b]ar baz',429 'expected': 'foo [ba]r baz' },430 { 'id': 'SM:e.f.w_TEXT-1_SC-1',431 'desc': 'extend selection 1 word forward',432 'function': 'sel.modify("extend", "forward", "word");',433 'pad': 'foo ^bar baz',434 'expected': 'foo [bar] baz' },435 { 'id': 'SM:e.f.w_TEXT-1_SI-1',436 'desc': 'extend selection 1 word forward',437 'function': 'sel.modify("extend", "forward", "word");',438 'pad': 'foo [b]ar baz',439 'expected': 'foo [bar] baz' },440 { 'id': 'SM:e.f.w_TEXT-1_SI-2',441 'desc': 'extend selection 1 word forward',442 'function': 'sel.modify("extend", "forward", "word");',443 'pad': 'foo [bar] baz',444 'expected': 'foo [bar baz]' }445 ]446 },447 { 'desc': 'sel.modify: extend selection backward, shrinking it',448 'tests': [449 { 'id': 'SM:e.b.c_TEXT-1_SI-2',450 'desc': 'extend selection 1 character backward',451 'function': 'sel.modify("extend", "backward", "character");',452 'pad': 'foo [bar] baz',453 'expected': 'foo [ba]r baz' },454 { 'id': 'SM:e.b.c_TEXT-1_SI-1',455 'desc': 'extend selection 1 character backward',456 'function': 'sel.modify("extend", "backward", "character");',457 'pad': 'foo [b]ar baz',458 'expected': 'foo ^bar baz' },459 { 'id': 'SM:e.b.w_TEXT-1_SI-3',460 'desc': 'extend selection 1 word backward',461 'function': 'sel.modify("extend", "backward", "word");',462 'pad': 'foo [bar baz]',463 'expected': 'foo [bar] baz' },464 { 'id': 'SM:e.b.w_TEXT-1_SI-2',465 'desc': 'extend selection 1 word backward',466 'function': 'sel.modify("extend", "backward", "word");',467 'pad': 'foo [bar] baz',468 'expected': 'foo ^bar baz' },469 { 'id': 'SM:e.b.w_TEXT-1_SI-4',470 'desc': 'extend selection 1 word backward',471 'function': 'sel.modify("extend", "backward", "word");',472 'pad': 'foo b[ar baz]',473 'expected': 'foo b[ar] baz' },474 { 'id': 'SM:e.b.w_TEXT-1_SI-5',475 'desc': 'extend selection 1 word backward',476 'function': 'sel.modify("extend", "backward", "word");',477 'pad': 'foo b[ar] baz',478 'expected': 'foo b^ar baz' }479 ]480 },481 { 'desc': 'sel.modify: extend selection backward, creating or extending a reverse selections',482 'tests': [483 { 'id': 'SM:e.b.c_TEXT-1_SC-1',484 'desc': 'extend selection 1 character backward',485 'function': 'sel.modify("extend", "backward", "character");',486 'pad': 'foo b^ar baz',487 'expected': 'foo ]b[ar baz' },488 { 'id': 'SM:e.b.c_TEXT-1_SIR-1',489 'desc': 'extend selection 1 character backward',490 'function': 'sel.modify("extend", "backward", "character");',491 'pad': 'foo b]a[r baz',492 'expected': 'foo ]ba[r baz' },493 { 'id': 'SM:e.b.w_TEXT-1_SIR-1',494 'desc': 'extend selection 1 word backward',495 'function': 'sel.modify("extend", "backward", "word");',496 'pad': 'foo b]a[r baz',497 'expected': 'foo ]ba[r baz' },498 { 'id': 'SM:e.b.w_TEXT-1_SIR-2',499 'desc': 'extend selection 1 word backward',500 'function': 'sel.modify("extend", "backward", "word");',501 'pad': 'foo ]ba[r baz',502 'expected': ']foo ba[r baz' }503 ]504 },505 { 'desc': 'sel.modify: extend selection forward, shrinking a reverse selections',506 'tests': [507 { 'id': 'SM:e.f.c_TEXT-1_SIR-1',508 'desc': 'extend selection 1 character forward',509 'function': 'sel.modify("extend", "forward", "character");',510 'pad': 'foo b]a[r baz',511 'expected': 'foo ba^r baz' },512 { 'id': 'SM:e.f.c_TEXT-1_SIR-2',513 'desc': 'extend selection 1 character forward',514 'function': 'sel.modify("extend", "forward", "character");',515 'pad': 'foo ]ba[r baz',516 'expected': 'foo b]a[r baz' },517 { 'id': 'SM:e.f.w_TEXT-1_SIR-1',518 'desc': 'extend selection 1 word forward',519 'function': 'sel.modify("extend", "forward", "word");',520 'pad': 'foo ]ba[r baz',521 'expected': 'foo ba^r baz' },522 { 'id': 'SM:e.f.w_TEXT-1_SIR-3',523 'desc': 'extend selection 1 word forward',524 'function': 'sel.modify("extend", "forward", "word");',525 'pad': ']foo ba[r baz',526 'expected': 'foo ]ba[r baz' }527 ]528 },529 { 'desc': 'sel.modify: extend selection forward to line boundary',530 'tests': [531 { 'id': 'SM:e.f.lb_BR.BR-1_SC-1',532 'desc': 'extend selection forward to line boundary',533 'function': 'sel.modify("extend", "forward", "lineboundary");',534 'pad': 'fo^o<br>bar<br>baz',535 'expected': 'fo[o]<br>bar<br>baz' },536 { 'id': 'SM:e.f.lb_BR.BR-1_SI-1',537 'desc': 'extend selection forward to next line boundary',538 'function': 'sel.modify("extend", "forward", "lineboundary");',539 'pad': 'fo[o]<br>bar<br>baz',540 'expected': 'fo[o<br>bar]<br>baz' },541 { 'id': 'SM:e.f.lb_BR.BR-1_SM-1',542 'desc': 'extend selection forward to line boundary',543 'function': 'sel.modify("extend", "forward", "lineboundary");',544 'pad': 'fo[o<br>b]ar<br>baz',545 'expected': 'fo[o<br>bar]<br>baz' },546 { 'id': 'SM:e.f.lb_P.P.P-1_SC-1',547 'desc': 'extend selection forward to line boundary',548 'function': 'sel.modify("extend", "forward", "lineboundary");',549 'pad': '<p>fo^o</p><p>bar</p><p>baz</p>',550 'expected': '<p>fo[o]</p><p>bar</p><p>baz</p>' },551 { 'id': 'SM:e.f.lb_P.P.P-1_SI-1',552 'desc': 'extend selection forward to next line boundary',553 'function': 'sel.modify("extend", "forward", "lineboundary");',554 'pad': '<p>fo[o]</p><p>bar</p><p>baz</p>',555 'expected': '<p>fo[o</p><p>bar]</p><p>baz</p>' },556 { 'id': 'SM:e.f.lb_P.P.P-1_SM-1',557 'desc': 'extend selection forward to line boundary',558 'function': 'sel.modify("extend", "forward", "lineboundary");',559 'pad': '<p>fo[o</p><p>b]ar</p><p>baz</p>',560 'expected': '<p>fo[o</p><p>bar]</p><p>baz</p>' },561 { 'id': 'SM:e.f.lb_P.P.P-1_SMR-1',562 'desc': 'extend selection forward to line boundary',563 'function': 'sel.modify("extend", "forward", "lineboundary");',564 'pad': '<p>foo</p><p>b]a[r</p><p>baz</p>',565 'expected': '<p>foo</p><p>ba[r]</p><p>baz</p>' }566 ]567 },568 { 'desc': 'sel.modify: extend selection backward to line boundary',569 'tests': [570 { 'id': 'SM:e.b.lb_BR.BR-1_SC-2',571 'desc': 'extend selection backward to line boundary',572 'function': 'sel.modify("extend", "backward", "lineboundary");',573 'pad': 'foo<br>bar<br>b^az',574 'expected': 'foo<br>bar<br>]b[az' },575 { 'id': 'SM:e.b.lb_BR.BR-1_SIR-2',576 'desc': 'extend selection backward to previous line boundary',577 'function': 'sel.modify("extend", "backward", "lineboundary");',578 'pad': 'foo<br>bar<br>]b[az',579 'expected': 'foo<br>]bar<br>b[az' },580 { 'id': 'SM:e.b.lb_BR.BR-1_SMR-2',581 'desc': 'extend selection backward to line boundary',582 'function': 'sel.modify("extend", "backward", "lineboundary");',583 'pad': 'foo<br>ba]r<br>b[az',584 'expected': 'foo<br>]bar<br>b[az' },585 { 'id': 'SM:e.b.lb_P.P.P-1_SC-2',586 'desc': 'extend selection backward to line boundary',587 'function': 'sel.modify("extend", "backward", "lineboundary");',588 'pad': '<p>foo</p><p>bar</p><p>b^az</p>',589 'expected': '<p>foo</p><p>bar</p><p>]b[az</p>' },590 { 'id': 'SM:e.b.lb_P.P.P-1_SIR-2',591 'desc': 'extend selection backward to previous line boundary',592 'function': 'sel.modify("extend", "backward", "lineboundary");',593 'pad': '<p>foo</p><p>bar</p><p>]b[az</p>',594 'expected': '<p>foo</p><p>]bar</p><p>b[az</p>' },595 { 'id': 'SM:e.b.lb_P.P.P-1_SMR-2',596 'desc': 'extend selection backward to line boundary',597 'function': 'sel.modify("extend", "backward", "lineboundary");',598 'pad': '<p>foo</p><p>ba]r</p><p>b[az</p>',599 'expected': '<p>foo</p><p>]bar</p><p>b[az</p>' },600 { 'id': 'SM:e.b.lb_P.P.P-1_SM-2',601 'desc': 'extend selection backward to line boundary',602 'function': 'sel.modify("extend", "backward", "lineboundary");',603 'pad': '<p>foo</p><p>b[a]r</p><p>baz</p>',604 'expected': '<p>foo</p><p>]b[ar</p><p>baz</p>' }605 ]606 },607 { 'desc': 'sel.modify: extend selection forward to next line (NOTE: use identical text in every line!)',608 'tests': [609 { 'id': 'SM:e.f.l_BR.BR-2_SC-1',610 'desc': 'extend selection forward to next line',611 'function': 'sel.modify("extend", "forward", "line");',612 'pad': 'fo^o<br>foo<br>foo',613 'expected': 'fo[o<br>fo]o<br>foo' },614 { 'id': 'SM:e.f.l_BR.BR-2_SI-1',615 'desc': 'extend selection forward to next line',616 'function': 'sel.modify("extend", "forward", "line");',617 'pad': 'fo[o]<br>foo<br>foo',618 'expected': 'fo[o<br>foo]<br>foo' },619 { 'id': 'SM:e.f.l_BR.BR-2_SM-1',620 'desc': 'extend selection forward to next line',621 'function': 'sel.modify("extend", "forward", "line");',622 'pad': 'fo[o<br>f]oo<br>foo',623 'expected': 'fo[o<br>foo<br>f]oo' },624 { 'id': 'SM:e.f.l_P.P-1_SC-1',625 'desc': 'extend selection forward to next line over paragraph boundaries',626 'function': 'sel.modify("extend", "forward", "line");',627 'pad': '<p>foo^bar</p><p>foobar</p>',628 'expected': '<p>foo[bar</p><p>foo]bar</p>' },629 { 'id': 'SM:e.f.l_P.P-1_SMR-1',630 'desc': 'extend selection forward to next line over paragraph boundaries',631 'function': 'sel.modify("extend", "forward", "line");',632 'pad': '<p>fo]obar</p><p>foob[ar</p>',633 'expected': '<p>foobar</p><p>fo]ob[ar</p>' }634 ]635 },636 { 'desc': 'sel.modify: extend selection backward to previous line (NOTE: use identical text in every line!)',637 'tests': [638 { 'id': 'SM:e.b.l_BR.BR-2_SC-2',639 'desc': 'extend selection backward to previous line',640 'function': 'sel.modify("extend", "backward", "line");',641 'pad': 'foo<br>foo<br>f^oo',642 'expected': 'foo<br>f]oo<br>f[oo' },643 { 'id': 'SM:e.b.l_BR.BR-2_SIR-2',644 'desc': 'extend selection backward to previous line',645 'function': 'sel.modify("extend", "backward", "line");',646 'pad': 'foo<br>foo<br>]f[oo',647 'expected': 'foo<br>]foo<br>f[oo' },648 { 'id': 'SM:e.b.l_BR.BR-2_SMR-2',649 'desc': 'extend selection backward to previous line',650 'function': 'sel.modify("extend", "backward", "line");',651 'pad': 'foo<br>fo]o<br>f[oo',652 'expected': 'fo]o<br>foo<br>f[oo' },653 { 'id': 'SM:e.b.l_P.P-1_SC-2',654 'desc': 'extend selection backward to next line over paragraph boundaries',655 'function': 'sel.modify("extend", "backward", "line");',656 'pad': '<p>foobar</p><p>foo^bar</p>',657 'expected': '<p>foo]bar</p><p>foo[bar</p>' },658 { 'id': 'SM:e.b.l_P.P-1_SM-1',659 'desc': 'extend selection backward to next line over paragraph boundaries',660 'function': 'sel.modify("extend", "backward", "line");',661 'pad': '<p>fo[obar</p><p>foob]ar</p>',662 'expected': '<p>fo[ob]ar</p><p>foobar</p>' }663 ]664 },665 { 'desc': 'sel.selectAllChildren(<element>)',666 'function': 'sel.selectAllChildren(doc.getElementById("div"));',667 'tests': [668 { 'id': 'SAC:div_DIV-1_SC-1',669 'desc': 'selectAllChildren(<div>)',670 'pad': 'foo<div id="div">bar <span>ba^z</span></div>qoz',671 'expected': [ 'foo<div id="div">[bar <span>baz</span>}</div>qoz',672 'foo<div id="div">{bar <span>baz</span>}</div>qoz' ] },673 ]674 }...
test_personal_infomation.js
Source:test_personal_infomation.js
1$(document).ready(function(){2 /***3 * ç¨äºç¨æ·ä¸ªäººä¸å¿ï¼é¼ æ 移å°å°åè½ä¸èæ¯åè²ï¼é¼ æ 移å¼æ¢å¤ä»¥åï¼4 * @author nele nele0716@163.com 2013-11-35 */6 var modify_user_info_node=$("#modify_user_info");7 var search_user_grade_node=$("#search_user_grade");8 modify_user_info_node.mouseover(function(){9 modify_user_info_node.css("background-color","#66CC99"); 10 });11 12 modify_user_info_node.mouseout(function(){ 13 modify_user_info_node.css("background-color","#99CCFF"); 14 });15 16 search_user_grade_node.mouseover(function(){17 search_user_grade_node.css("background-color","#66CC99"); 18 });19 20 search_user_grade_node.mouseout(function() {21 search_user_grade_node.css("background-color","#99CCFF"); 22 });23 24 25 /***26 * å è½½æ¾ç¤ºå¦æ ¡ï¼ä¸ä¸ï¼ç级ç页é¢å°å½å页é¢27 * @author nele nele0716@163.com 2013-11-328 */29 modify_user_info_node.click(function(){30 $("#main").load("show_or_modify_personal_info.jsp");31 });32 33 /***34 * æ¾ç¤ºç¨æ·å¦æ ¡ï¼ä¸ä¸ï¼ç级ï¼ç¨äºä¿®æ¹35 * @author nele nele0716@163.com 2013-11-3 36 */37 /*$("#test_modify_user_info_modify_class_btn").click(function(){38 var show_xy_major__class_node=$("#show_class_div");39 show_xy_major__class_node.load("show_xy_major_class_toModify.jsp");40 });*/41 var bj;//å½åä¸ä¸ç级ç»æ42 var bjId;//å½åç级id43 $("#test_modify_user_info_modify_class_btn").click(function(){44 $("#show_class_div").hide();45 $("#show_xy_major_class").show("slow",function(){46 var xyIdString=$("#xy").find("option:first").val();47 var majorIdString=$("#major").find("option:first").val();48 var bjIdString=$("#bj").find("option:first").val();49 var xyId=parseInt(xyIdString, 10);50 var majorId=parseInt(majorIdString,10);51 bjId=parseInt(bjIdString,10);52 $.ajax({53 type: "POST",54 url: "getAllXyAndMajorAndClass",55 data:{56 "xyId":xyId,57 "majorId":majorId,58 },59 // æåè¿åmap60 success: function(data){61 var options="";62 var majoroptions="";63 var bjoptions="";64 //å
ååºå¦é¢ åmajorçlist å¨eval解æ65 // var xueYuan=eval("("+data["xueYuan"]+")");\66 var xueYuanDemo=data["xueYuan"];67 var majorDemo=data["major"];68 var bjDamo=data["bj"];69 var major=eval("("+majorDemo+")");70 var xueYuan=eval("("+xueYuanDemo+")");71 bj=eval("("+bjDamo+")");72 73 for(var i=0;i<xueYuan.length;i++){74 if(xyId==xueYuan[i].xyId){75 options+="<option value="+xueYuan[i].xyId+" selected='selected'>"+xueYuan[i].xyName+"</option>";76 }77 else{78 options+="<option value="+xueYuan[i].xyId+">"+xueYuan[i].xyName+"</option>";79 }80 }81 82 83 for(var j=0;j<major.length;j++){84 if(majorId==major[j].majorId){85 majoroptions+="<option value="+major[j].majorId+" selected='selected'>"+major[j].majorName+"</option>";86 }87 else{88 majoroptions+="<option value="+major[j].majorId+">"+major[j].majorName+"</option>";89 }90 }91 92 for(var k=0;k<bj.length;k++){93 if(bjId==bj[k].classId){94 bjoptions+="<option value="+bj[k].classId+" selected='selected'>"+bj[k].classGrade+"</option>";95 }96 else{97 bjoptions+="<option value="+bj[k].classId+">"+bj[k].classGrade+"</option>";98 }99 }100 $("#xy").html(options);101 $("#major").html(majoroptions);102 $("#bj").html(bjoptions);103 }, 104 error:function(data){105 alert(data);106 },107 }); 108 }); 109 });110 111 /***112 * å¦æ ¡æ¹åï¼ä¸ä¸èå¨113 * @author nele nele0716@163.com 2013-11-5114 */115 $("#xy").change(function(){116 var xyIdModifyString=$("#xy").val();117 var xyIdModify=parseInt(xyIdModifyString, 10);118 $.ajax({119 type:"post",120 url:"getMajor",121 dataType:"json",122 cache:false,123 data:{124 "xyId":xyIdModify,125 },126 success:function(data){127 var dataObj=eval("("+data+")");//讲å符å转æ¢æjsonæ ¼å¼128// alert(dataObj.length);//å¯ä»¥å»jsonå¼å¾é¿åº¦129 var options="";130 options+="<option value='0'>==请éæ©ç±»å==</option>"; 131 for(var i=0;i<dataObj.length;i++){132 options+="<option value="+dataObj[i].majorId+">"+dataObj[i].majorName+"</option>";//æ¼åoption133 }134 135 $("#major").html(options);//讲optionså å
¥<select>ä¸136 $("#bj").html("<option>==请éæ©ç级==</option>")137 },138 error:function(data){139 alert(data);140 }141 });142 143 });144 145 /***146 * ä¸ä¸æ¹åæ¶ï¼è·å¾å¯¹åºçç级ï¼æ¾ç¤ºå¨ç级çä¸æå表ä¸147 * @author nele nele0716@163.com 2013-11-4148 */149 $("#major").change(function(){150 var majorIdModifyString=$("#major").val();151 var majorIdModify=parseInt(majorIdModifyString, 10);152 $.ajax({153 type:"post",154 url:"getClass",155 dataType:"json",156 cache:false,157 data:{158 "majorId":majorIdModify,159 },160 success:function(data){161 var result=eval("("+data+")");162 var options="";163 options+="<option value='0'>==请éæ©ç±»å==</option>";164 for(var i=0;i<result.length;i++){165 options+="<option value="+result[i].classId+">"+result[i].classGrade+"</options>";166 }167 $("#bj").html(options);168 },169 error:function(data){170 alert(data);171 }172 }); 173 174 });175 176 /***177 * éæ©æ°ç级æ¶ãè·å¾æ°ç级çid178 * @author nele nele0716@163.com 2013-11-5179 */180 var bjIdModify;//éæ©çæ°ç级çid181 $("#bj").change(function(){182 var bjIdModifyString=$("#bj").val();183 bjIdModify=parseInt(bjIdModifyString, 10); 184 });185 186 /***187 * æ交修æ¹çå¦é¢ï¼ä¸ä¸ï¼ç级ï¼188 * @author nele nele0716@163.com 2013-11-4189 */190 $("#modify_ok").click(function(){191 var bjIdModifyString=$("#bj").val();192 var bjIdModifySubmit=parseInt(bjIdModifyString, 10);193 var s_num=$("#sno").val();194 var pk_sno_string=$("#pk_sno").val();195 var pk_sno=parseInt(pk_sno_string, 10);196 $("#show_xy_major_class").hide("fast");197 $("#show_class_div").show("slow");198 if(bjIdModify!=bjId){199 for(var k=0;k<bj.length;k++){200 if(bj[k].classId==bjIdModify)201 $("#bjName").text(bj[k].classGrade);202 }203 $.ajax({204 type:"post",205 url:"modifyClassId",206 dataType:"json",207 cache:false, 208 data:{209 "classId":bjIdModifySubmit,210 "sno":pk_sno,211 },212 success:function(data){213 alert(data);214 },215 error:function(data){216 alert("ä¿®æ¹ç级åºéï¼");217 }218 });219 }220 221 });222 223 /**224 * ä¿®æ¹ç级idåæ¶æä½225 * @author nele nele0716@163.com 2013-11-5226 */227 $("#bi_modify_cancal_btn").click(function(){228 $("#show_xy_major_class").hide("fast");229 $("#show_class_div").show("slow");230 });231 232 /***233 * ç¹å»ä¿®æ¹å¯ç ï¼æ¾ç¤ºä¿®æ¹div234 * @author nele nele0716@163.com 2013-11-5235 */236 $("#click_to_modify_pwd").click(function(){237 $("#click_modify_pwd_div").hide();238 $("#show_modify_pwd_box").show("slow");239 });240 241 242 /***243 * 对è¾å
¥åå§å¯ç è¿è¡éªè¯244 * @author nele nele0716@163.com 2013-11-6245 */246 $("#pre_pwd").blur(function(){247 var sno=$("#sno").val();248 var pre_pwd_node=$("#pre_pwd");249 var waring_node= $("#right_show_error_warning");250 var new_pwd_node=$("#new_pwd");251 var new_pwd_again_node=$("#new_pwd_again");252 var pre_pwd=pre_pwd_node.val();253 if(pre_pwd==""){254 waring_node.html("åå§å¯ç ä¸è½ä¸ºç©ºï¼");255 return;256 }257 $.ajax({258 type:"post",259 url:"verifyToPrePwd",260 dataType:"json",261 cache:false, 262 data:{263 "prePwd":pre_pwd,264 "s_num":sno,265 },266 success:function(data){267 if(data=="åå§å¯ç ä¸æ£ç¡®"){268 if(new_pwd_node.attr("disabled")!="disabled")269 new_pwd_node.attr("disabled","disabled");270 if(new_pwd_again_node.attr("disabled")!="disabled")271 new_pwd_again_node.attr("disabled","disabled");272 waring_node.html("åå§å¯ç ä¸æ£ç¡®,请éæ°è¾å
¥");273 return;274 }275 else{276 if(new_pwd_node.attr("disabled")=="disabled")277 new_pwd_node.attr("disabled",false);278 if(new_pwd_again_node.attr("disabled")=="disabled")279 new_pwd_again_node.attr("disabled",false);280 waring_node.html("åå§å¯ç æ£ç¡®");281 }282 283 },284 error:function(data){285 alert("éªè¯åå§å¯ç åºç°é误ï¼");286 return;287 }288 });289 });290 291 /***292 * ç¹å»ååè¾æ°å¯ç ï¼å¹¶æ交修æ¹å¯ç 293 * @author nele nele0716@163.com 2013-11-5294 */295 $("#pwd_modify_ok").click(function(){296 var sno=$("#sno").val();297 var pk_sno_string=$("#pk_sno").val();298 var pk_sno=parseInt(pk_sno_string, 10);299 var pre_pwd_node=$("#pre_pwd");300 var new_pwd_node=$("#new_pwd");301 var new_pwd_again_node=$("#new_pwd_again");302 var waring_node= $("#right_show_error_warning");303 var new_pwd=new_pwd_node.val();304 var new_pwd_again=new_pwd_again_node.val();305 pre_pwd_node.val("");306 new_pwd_node.val("");307 new_pwd_again_node.val("");308 309 if(new_pwd==""){310 waring_node.html("æ°å¯ç ä¸è½ä¸ºç©º!");311 return;312 }313 if(new_pwd_again==""){314 waring_node.html("æ°å¯ç éå¤ä¸è½ä¸ºç©º!");315 return;316 }317 if(new_pwd!=new_pwd_again){318 waring_node.html("两次è¾å
¥çæ°å¯ç ä¸ä¸è´");319 return;320 }321 $.ajax({322 type:"post",323 url:"studentModifyPwd",324 dataType:"json",325 cache:false, 326 data:{327 "pwd":new_pwd,328 "sno":pk_sno,329 },330 success:function(data){331 alert(data);332 $("#show_modify_pwd_box").hide();333 $("#click_modify_pwd_div").show(); 334 },335 error:function(data){336 alert("æ´æ¹å¯ç 失败å¦");337 }338 339 });340 341 });342 /***343 *å¯ç ä¿®æ¹divåæ¶344 * @author nele nele0716@163.com 2013-11-6345 */346 $("#pwd_modify_cancel").click(function(){347 $("#show_modify_pwd_box").hide();348 $("#click_modify_pwd_div").show();349 });350 351 352 /**353 * ç¹å»ä¿®æ¹é®ç®±354 * @author nele nele0716@163.com 2013-11-6355 */356 $("#email_submit_modify_btn").click(function(){357 var new_email_node=$("#email_modify_text");358 var new_email=new_email_node.val();359 var pk_sno_string=$("#pk_sno").val();360 var pk_sno=parseInt(pk_sno_string, 10);361 var emailReg=/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;362 if(!emailReg.test(new_email)){363 $("#email_warning").text("é®ç®±æ ¼å¼ä¸æ£ç¡®ï¼");364 return;365 }366 else{367 $("#email_warning").text("");368 }369 $.ajax({370 type:"post",371 url:"modifyEmail",372 dataType:"json",373 cache:false, 374 data:{375 "new_email":new_email,376 "sno":pk_sno,377 },378 success:function(data){379 alert(data); 380 },381 error:function(data){382 alert("ä¿®æ¹é®ç®±é误ï¼");383 }384 385 });386 });...
headerinfoconf.js
Source:headerinfoconf.js
1var global_pageintegration_header={2 email_old : null,3 phoneNum_old : null,4 descInfo_old : null,5 modifyUserInfo:function(){6 var canSendRequest = true;7// var modifyUserInfoUserNameTF = new Gv.form.TextField({8// id : 'modifyUserInfoUserNameTF-id',9// fieldLabel : 'ç¨æ·å',10// allowBlank : true,11// disabled : true,12// value : "aaa"13// });14 //alert(global_pageintegration_header.LonginUserEmail);15 var modifyUserInfoEmailEF = new Gv.form.EmailField({16 id : 'modifyUserInfoEmailEF-id',17 fieldLabel : '<i class="gv-field-required-star">*</i>é®ç®±å°å',18 allowBlank : false,19 //value : global_pageintegration_header.LonginUserEmail,20 blankText : 'é®ç®±å°åä¸è½ä¸ºç©º',21 emptyText : "请è¾å
¥é®ç®±å°å"22 });23 var modifyUserInfoPhoneNumTF = new Gv.form.TextField({24 id : 'modifyUserInfoPhoneNumTF-id',25 fieldLabel : 'ææºå·',26 //value : global_pageintegration_header.LonginUserPhoneNum,27 allowBlank : true,28 emptyText : "请è¾å
¥ææºå·"29 });30 var modifyUserInfoDescInfoTA = new Gv.form.TextArea({31 id : 'modifyUserInfoDescInfoTA-id',32 height : 50,33 fieldLabel : 'æè¿°ä¿¡æ¯',34 allowBlank : true,35 //value : global_pageintegration_header.LonginUserDescInfo,36 emptyText : "请è¾å
¥æè¿°ä¿¡æ¯",37 maxLength : 12838 });39 var modifyUserInfoForm = new Gv.form.FormPanel({40 id : 'modifyUserInfoForm-id',41 layout : 'form',// ååå½¢å¼form,ååå½¢å¼column42 items : [ modifyUserInfoEmailEF,modifyUserInfoPhoneNumTF,modifyUserInfoDescInfoTA ]43 });44 var modifyUserInfoWin = new Gv.Window(45 {46 id : 'modifyUserInfoWin-id',47 title : 'ä¿®æ¹ä¸ªäººä¿¡æ¯',48 width : 415,49 height : 140,50 bodyStyle : 'padding:10px;',51 items : [ modifyUserInfoForm ],52 listeners:{53 afterLayout : function() {54 //ç´§è´è¾å
¥å¯ç 55 $("#modifyUserInfoEmailEF-id").bind('keyup',function(){56 this.value = this.value.replace(/\s/g,'');57 });58 $("#modifyUserInfoPhoneNumTF-id").bind('keyup',function(){59 this.value = this.value.replace(/\s/g,'');60 });61 }62 },63 tbar : [64 {65 text : '确认',66 handler : function() {67 if(!canSendRequest){68 return;69 }70 var emailVal = modifyUserInfoEmailEF.value().trim();71 var phoneNumVal = modifyUserInfoPhoneNumTF.value().trim();72 var userDescVal = modifyUserInfoDescInfoTA.value().trim();73 Gv.log("emailVal : " + emailVal);74 Gv.log("phoneNumVal : " + phoneNumVal);75 Gv.log("userDescVal : " + userDescVal);76 if(global_pageintegration_header.email_old == emailVal && global_pageintegration_header.phoneNum_old == phoneNumVal && global_pageintegration_header.descInfo_old == userDescVal){77 Gv.msg.info({html:'å项å¼é½æªæ¹å,ä¸éè¦ä¿®æ¹!',zIndex : 11000});78 return;79 }80 var checkNoError = true;81 if(!modifyUserInfoEmailEF.validate()){82 checkNoError = false;83 }84// if(emailVal == null || emailVal == ""){85// modifyUserInfoEmailEF.setTipsContent('Emailä¸è½ä¸ºç©º');86// modifyUserInfoEmailEF.addError();87// checkNoError = false;88// }else{89// var eamilPtn = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,4}$/;90// if (emailVal != "" && emailVal != null91// && !eamilPtn.exec(emailVal)) {92// modifyUserInfoEmailEF.setTipsContent('ä¸æ¯åæ³çEmailï¼è¯·éæ°è¾å
¥');93// modifyUserInfoEmailEF.addError();94// checkNoError = false;95// }96// }97 var phoneNumPtn = /^1[3|5|8][0-9]\d{8}$/;98 if (phoneNumVal != "" && phoneNumVal != null99 && !phoneNumPtn.exec(phoneNumVal)) {100 modifyUserInfoPhoneNumTF.setTipsContent('ä¸æ¯å®æ´ç11ä½ææºå·æè
æ£ç¡®çææºå·ï¼è¯·éæ°è¾å
¥');101 modifyUserInfoPhoneNumTF.addError();102 checkNoError = false;103 }104 if(userDescVal.length > 128){105 modifyUserInfoDescInfoTA.setTipsContent('æè¿°ä¿¡æ¯ä¸è½è¶
è¿128个å符ï¼è¯·éæ°è¾å
¥');106 modifyUserInfoDescInfoTA.addError();107 checkNoError = false;108 }109 if(!checkNoError){110 return;111 }112// var tabId = Gv.frameTabPanel.getCurrentTabId();113// Gv.maskMsg(true, 'tab-content-' + tabId, 'å è½½ä¸ï¼è¯·ç¨å...');114 Gv.ajax({115 url : '/pageframe/main/modifyUserInfo.action',116 data : {117 email : emailVal,118 phoneNum : phoneNumVal,119 descInfo : userDescVal,120 test : null121 },122 type : 'post',123 async : true,124 dataType : 'json',125 beforeSend:function(){126 canSendRequest = false;127 },128 successFun : function(retVal) {129 canSendRequest = true;130 //Gv.maskMsg(false, 'tab-content-' + tabId, 'å è½½ä¸ï¼è¯·ç¨å...');131 if(retVal.result){132 modifyUserInfoWin.close();133 Gv.msgNote("æä½æåï¼");134 }else{135 Gv.msg.error({html:retVal.msg,136 zIndex : 11000});137 }138 }139 });140 }141 }, {142 text : 'åæ¶',143 handler : function() {144 modifyUserInfoWin.close();145 }146 } ]147 });148 Gv.ajax({149 url : '/pageframe/main/queryLoginUser.action',150 data : {151 },152 type : 'post',153 async : true,154 dataType : 'json',155 beforeSend:function(){156 canSendRequest = false;157 },158 successFun : function(retVal) {159 canSendRequest = true;160 Gv.log(retVal);161 if(retVal.result){162 modifyUserInfoEmailEF.value(retVal.email);163 modifyUserInfoPhoneNumTF.value(retVal.phoneNum);164 modifyUserInfoDescInfoTA.value(retVal.descInfo);165 global_pageintegration_header.email_old = retVal.email;166 global_pageintegration_header.phoneNum_old = retVal.phoneNum;167 global_pageintegration_header.descInfo_old = retVal.descInfo;168 }else{169 Gv.msg.error({html:retVal.msg,170 zIndex : 11000});171 }172 }173 });174 },175 modifyPwd:function(){176 var canSendRequest = true;177 var modifyPwdNewPwd = new Gv.form.Password({178 id : 'modifyPwdNewPwd-id',179 fieldLabel : '<i class="gv-field-required-star">*</i>æ°å¯ç ',180 allowBlank : false,181 blankText : 'æ°å¯ç ä¸è½ä¸ºç©º',182 emptyText : "请è¾å
¥æ°å¯ç "183 });184 var modifyPwdVerifyNewPwd = new Gv.form.Password({185 id : 'modifyPwdVerifyNewPwd-id',186 fieldLabel : '<i class="gv-field-required-star">*</i>确认æ°å¯ç ',187 allowBlank : false,188 blankText : '确认æ°å¯ç ä¸è½ä¸ºç©º',189 emptyText : "请è¾å
¥æ°å¯ç "190 });191 var modifyPwdForm = new Gv.form.FormPanel({192 id : 'modifyPwdForm-id',193 layout : 'form',// ååå½¢å¼form,ååå½¢å¼column194 items : [ modifyPwdNewPwd,modifyPwdVerifyNewPwd ]195 });196 var modifyPwdWin = new Gv.Window(197 {198 id : 'modifyPwd-id',199 title : 'ä¿®æ¹ä¸ªäººå¯ç ',200 width : 415,201 height : 90,202 bodyStyle : 'padding:10px;',203 items : [ modifyPwdForm ],204 listeners:{205 afterLayout : function() {206 //ç¦æ¢è¾å
¥ç©ºæ ¼207 $("#modifyPwdNewPwd-id").bind('keydown',function(e){208 e=window.event||e;209 if(e.keyCode==32){210 e.keyCode = 0;211 return false;212 }213 });214 $("#modifyPwdVerifyNewPwd-id").bind('keydown',function(e){215 e=window.event||e;216 if(e.keyCode==32){217 e.keyCode = 0;218 return false;219 }220 });221 }222 },223 tbar : [224 {225 text : '确认',226 handler : function(id,text) {227 if(!canSendRequest){228 return;229 }230 var newPwd = modifyPwdNewPwd.value().trim();231 var newPwd2 = modifyPwdVerifyNewPwd.value().trim();232 Gv.log("newPwd : " + newPwd);233 var checkNoError = true;234 if(newPwd == null || newPwd == ""){235 modifyPwdNewPwd.setTipsContent('æ°å¯ç ä¸è½ä¸ºç©º');236 modifyPwdNewPwd.addError();237 checkNoError = false;238 }else if(newPwd.length < 6 || newPwd.length > 16){239 modifyPwdNewPwd.setTipsContent('å¯ç ç±6-16ä½å符ç»æ');240 modifyPwdNewPwd.addError();241 checkNoError = false;242 }243 if(newPwd2 == null || newPwd2 == ""){244 modifyPwdVerifyNewPwd.setTipsContent('确认æ°å¯ç ä¸è½ä¸ºç©º');245 modifyPwdVerifyNewPwd.addError();246 checkNoError = false;247 }else if (newPwd2 != newPwd) {248 modifyPwdVerifyNewPwd.setTipsContent('确认æ°å¯ç ä¸æ°å¯ç ä¸ä¸è´');249 modifyPwdVerifyNewPwd.addError();250 checkNoError = false;251 }252 if(!checkNoError){253 return;254 }255// var tabId = Gv.frameTabPanel.getCurrentTabId();256// Gv.maskMsg(true, 'tab-content-' + tabId, 'å è½½ä¸ï¼è¯·ç¨å...');257 Gv.get(id).html(Gv.LoadingHtml);258 Gv.ajax({259 url : '/pageframe/main/modifyPwd.action',260 data : {261 newPwd : newPwd262 },263 type : 'post',264 async : true,265 dataType : 'json',266 beforeSend:function(){267 canSendRequest = false;268 },269 successFun : function(retVal) {270 Gv.get(id).html("ç¡®å®");271 canSendRequest = true;272 //Gv.maskMsg(false, 'tab-content-' + tabId, 'å è½½ä¸ï¼è¯·ç¨å...');273 modifyPwdWin.close();274 if(retVal.result){275 Gv.msgNote("æä½æåï¼");276 }else{277 Gv.msg.error({html:retVal.msg,278 zIndex : 11000});279 }280 }281 });282 }283 }, {284 text : 'åæ¶',285 handler : function() {286 modifyPwdWin.close();287 }288 } ]289 });290 },291 infoConf:function(){292 }...
abilities.js
Source:abilities.js
1'use strict';2exports.BattleAbilities = {3 "defeatist": {4 inherit: true,5 onModifyAtk: function (atk, pokemon) {6 if (pokemon.hp <= pokemon.maxhp / 4) {7 return this.chainModify(0.5);8 }9 },10 onModifySpA: function (atk, pokemon) {11 if (pokemon.hp <= pokemon.maxhp / 4) {12 return this.chainModify(0.5);13 }14 },15 desc: "Halves Attack damage when the user's health is below 1/4",16 shortDesc: "Halves Attack damage when the user's health is below 1/4",17 },18 "gluttony": {19 inherit: true,20 onEatItem: function (item, pokemon) {21 if (!pokemon.volatiles['gluttony']) pokemon.addVolatile('gluttony');22 },23 effect: {24 duration: 2,25 onStart: function (target) {26 this.add('-start', target, 'ability: Gluttony');27 },28 onModifySpe: function (spe, pokemon) {29 return this.chainModify(0.66);30 },31 onModifyAtk: function (atk, pokemon) {32 return this.chainModify(0.66);33 },34 onModifyAtkPriority: 6,35 onSourceModifyAtk: function (atk, attacker, defender, move) {36 if (move.type === 'Ice' || move.type === 'Fire') {37 this.debug('Gluttony weaken');38 return this.chainModify(0.5);39 }40 },41 onModifySpAPriority: 5,42 onSourceModifySpA: function (atk, attacker, defender, move) {43 if (move.type === 'Ice' || move.type === 'Fire') {44 this.debug('Gluttony weaken');45 return this.chainModify(0.5);46 }47 },48 onEnd: function (target) {49 this.add('-end', target, 'ability: Gluttony');50 },51 },52 desc: "Doubles berries effects upon being eaten.",53 shortDesc: "Doubles berries effects upon being eaten. Lowers users speed and atk by 1 stage for 2 turns, adds thick fat effect",54 },55 "immunity": {56 inherit: true,57 desc: "This Pokemon cannot be poisoned, burned or paralyzed. Gaining this Ability while poisoned, burned or paralyzed cures it.",58 shortDesc: "This Pokemon cannot be poisoned, burned or paralyzed. Gaining this Ability while poisoned, burned or paralyzed cures it.",59 onUpdate: function (pokemon) {60 if (pokemon.status === 'psn' || pokemon.status === 'tox' || pokemon.status === 'par' || pokemon.status === 'brn') {61 this.add('-activate', pokemon, 'ability: Immunity');62 pokemon.cureStatus();63 }64 },65 onSetStatus: function (status, target, source, effect) {66 if (status.id !== 'psn' && status.id !== 'tox' || status.id !== 'brn' || status.id !== 'par') return;67 if (!effect || !effect.status) return false;68 this.add('-immune', target, '[msg]', '[from] ability: Immunity');69 return false;70 },71 },72 "turboblaze": {73 inherit: true,74 onModifyAtkPriority: 5,75 onModifyAtk: function (atk, attacker, defender, move) {76 if (move.type === 'Fire') {77 this.debug('TurboBlaze boost');78 return this.chainModify(1.5);79 }80 },81 onModifySpAPriority: 5,82 onModifySpA: function (atk, attacker, defender, move) {83 if (move.type === 'Fire') {84 this.debug('TurboBlaze boost');85 return this.chainModify(1.5);86 }87 },88 desc: "Boosts Fire type attacks by 1.5x.",89 shortDesc: "Boosts Fire type attacks by 1.5x.",90 },91 "teravolt": {92 inherit: true,93 onModifyAtkPriority: 5,94 onModifyAtk: function (atk, attacker, defender, move) {95 if (move.type === 'Electric') {96 this.debug('Teravolt boost');97 return this.chainModify(1.5);98 }99 },100 onModifySpAPriority: 5,101 onModifySpA: function (atk, attacker, defender, move) {102 if (move.type === 'Electric') {103 this.debug('Teravolt boost');104 return this.chainModify(1.5);105 }106 },107 desc: "Boosts Electric type attacks by 1.5x.",108 shortDesc: "Boosts Electric type attacks by 1.5x.",109 },110 "moldbreaker": {111 inherit: true,112 onHit: function (target, source, move) {113 if (move && move.effectType === 'Move') {114 this.chainModify(1.33);115 }116 },117 onModifyMove: function (move, pokemon) {118 if (move.basePower < 120 && pokemon.types.indexOf(move.type) > -1) this.chainModify(1.25);119 },120 desc: "Ignores abilities, increases the power of all STAB moves at or under 120 BP by 50%. In return, damage taken is increased by 33%.",121 shortDesc: "Ignores Abilities, Boosts STAB Moves under 120 BP by 50%, but takes 33% more damage.",122 },123 "unburden": {124 inherit: true,125 onAfterUseItem: function (item, pokemon) {126 if (pokemon !== this.effectData.target) return;127 pokemon.addVolatile('unburden');128 },129 onTakeItem: function (item, pokemon) {130 pokemon.addVolatile('unburden');131 },132 onEnd: function (pokemon) {133 pokemon.removeVolatile('unburden');134 },135 effect: {136 onModifySpe: function (spe, pokemon) {137 if (!pokemon.item) {138 return this.chainModify(1.5);139 }140 },141 },142 desc: "1.5x Speed when the user loses their item.",143 shortDesc: "1.5x Speed when the user loses their item.",144 },145 "intimidate": {146 inherit: true,147 onStart: function (pokemon) {148 let foeactive = pokemon.side.foe.active;149 let activated = false;150 for (let i = 0; i < foeactive.length; i++) {151 if (!foeactive[i] || !this.isAdjacent(foeactive[i], pokemon)) continue;152 if (!activated) {153 this.add('-ability', pokemon, 'Intimidate', 'boost');154 activated = true;155 }156 if (foeactive[i].volatiles['substitute'] || foeactive[i].ability === 'intimidate') {157 this.add('-immune', foeactive[i], '[msg]');158 } else {159 this.boost({atk: -1}, foeactive[i], pokemon);160 }161 if (Math.floor(Math.random() * 99) < 20) {162 this.boost({spe: -1}, foeactive[i], pokemon);163 }164 }165 },166 desc: "Intimidate cannot affect other Intimidate users. In return, Intimidate also has a 20% chance to lower the enemies' Speed by one stage.",167 shortDesc: "Intimidaters are immune to Intimidate, Intimidaters has 20% chance to lower foe's Speed by 1 stage.",168 },169 "stickyhold": {170 inherit: true,171 onAfterDamage: function (target, source, effect, damage) {172 if (effect && effect.flags['contact']) {173 this.add('-ability', target, 'Sticky Hold');174 this.boost({175 spe: -1,176 }, source, target, null, true);177 }178 },179 desc: "User's item cannot be knocked off, and lowers Speed by one stage upon being hit by a contact move.",180 shortDesc: "User's item cannot be knocked off, and lowers Speed by one stage upon being hit by a contact move.",181 },182 "gooey": {183 inherit: true,184 onAfterDamage: function (damage, target, source, effect) {185 if (effect && effect.flags['contact']) {186 this.add('-ability', target, 'Gooey');187 this.boost({spe: -2}, source, target, null, true);188 }189 },190 desc: "If the user is hit by a contact move, the attacker's speed drops two stages.",191 shortDesc: "If the user is hit by a contact move, the attacker's speed drops two stages.",192 },193 "multitype": {194 inherit: true,195 desc: "If this Pokemon is an Arceus or Dunsparce, its type changes to match its held Plate or Z-Crystal.",196 shortDesc: "If this Pokemon is an Arceus or Dunsparce, its type changes to match its held Plate or Z-Crystal.",197 },...
urls.py
Source:urls.py
1from django.urls import path2from .views import base_views, scripture_views, meditation_views, question_views, \3 answer_views, comment_views, vote_views, weeklybible_views, research_views, \4 goldmembership_views, customer_views, activity_views5app_name = 'neworld'6urlpatterns = [7 # base_views.py8 path('', base_views.index, name='index'),9 # goldmembership_views.py10 path('goldmembership_guide/', goldmembership_views.goldmembership_guide, name='goldmembership_guide'),11 # scripture_views.py12 path('scripture/',13 scripture_views.scripture, name='scripture'),14 path('scripture/<int:scripture_id>/',15 scripture_views.daily_scripture, name='daily_scripture'),16 # meditation_views.py17 path('meditation/create/<int:scripture_id>/',18 meditation_views.meditation_create, name='meditation_create'),19 path('meditation/modify/<int:meditation_id>/',20 meditation_views.meditation_modify, name='meditation_modify'),21 path('meditation/delete/<int:meditation_id>/',22 meditation_views.meditation_delete, name='meditation_delete'),23 # question_views.py24 path('question/', question_views.question, name='question'),25 path('question/<int:question_id>/',26 question_views.detail, name='detail'),27 path('question/create/',28 question_views.question_create, name='question_create'),29 path('question/modify/<int:question_id>/',30 question_views.question_modify, name='question_modify'),31 path('question/delete/<int:question_id>/',32 question_views.question_delete, name='question_delete'),33 # answer_views.py34 path('answer/create/<int:question_id>/',35 answer_views.answer_create, name='answer_create'),36 path('answer/modify/<int:answer_id>/',37 answer_views.answer_modify, name='answer_modify'),38 path('answer/delete/<int:answer_id>/',39 answer_views.answer_delete, name='answer_delete'),40 # comment_views.py41 path('comment/create/question/<int:question_id>/',42 comment_views.comment_create_question, name='comment_create_question'),43 path('comment/modify/question/<int:comment_id>/',44 comment_views.comment_modify_question, name='comment_modify_question'),45 path('comment/delete/question/<int:comment_id>/',46 comment_views.comment_delete_question, name='comment_delete_question'),47 path('comment/create/customer/<int:customer_id>/',48 comment_views.comment_create_customer, name='comment_create_customer'),49 path('comment/modify/customer/<int:comment_id>/',50 comment_views.comment_modify_customer, name='comment_modify_customer'),51 path('comment/delete/customer/<int:comment_id>/',52 comment_views.comment_delete_customer, name='comment_delete_customer'),53 path('comment/create/activity/<int:activity_id>/',54 comment_views.comment_create_activity, name='comment_create_activity'),55 path('comment/modify/activity/<int:comment_id>/',56 comment_views.comment_modify_activity, name='comment_modify_activity'),57 path('comment/delete/activity/<int:comment_id>/',58 comment_views.comment_delete_activity, name='comment_delete_activity'),59 path('comment/create/answer/<int:answer_id>/',60 comment_views.comment_create_answer, name='comment_create_answer'),61 path('comment/modify/answer/<int:comment_id>/',62 comment_views.comment_modify_answer, name='comment_modify_answer'),63 path('comment/delete/answer/<int:comment_id>/',64 comment_views.comment_delete_answer, name='comment_delete_answer'),65 path('comment/create/meditation/<int:meditation_id>/',66 comment_views.comment_create_meditation, name='comment_create_meditation'),67 path('comment/modify/meditation/<int:comment_id>/',68 comment_views.comment_modify_meditation, name='comment_modify_meditation'),69 path('comment/delete/meditation/<int:comment_id>/',70 comment_views.comment_delete_meditation, name='comment_delete_meditation'),71 path('comment/create/research/<int:research_id>/',72 comment_views.comment_create_research, name='comment_create_research'),73 path('comment/modify/research/<int:comment_id>/',74 comment_views.comment_modify_research, name='comment_modify_research'),75 path('comment/delete/research/<int:comment_id>/',76 comment_views.comment_delete_research, name='comment_delete_research'),77 # vote_views.py78 path('vote/question/<int:question_id>/', vote_views.vote_question, name='vote_question'),79 path('vote/answer/<int:answer_id>/', vote_views.vote_answer, name='vote_answer'),80 path('vote/scripture/<int:scripture_id>/', vote_views.vote_scripture, name='vote_scripture'),81 path('vote/meditation/<int:meditation_id>/', vote_views.vote_meditation, name='vote_meditation'),82 path('vote/weeklybible/<int:weeklybible_id>/', vote_views.vote_weeklybible, name='vote_weeklybible'),83 path('vote/research/<int:research_id>/', vote_views.vote_research, name='vote_research'),84 path('vote/customer/<int:customer_id>/', vote_views.vote_customer, name='vote_customer'),85 path('vote/activity/<int:activity_id>/', vote_views.vote_activity, name='vote_activity'),86 # weeklybible_views.py87 path('weeklybible/', weeklybible_views.weeklybible, name='weeklybible'),88 path('weeklybible/<int:weeklybible_id>/',89 weeklybible_views.weeklybible_detail, name='weeklybible_detail'),90 # research_views.py91 path('research/create/<int:weeklybible_id>/',92 research_views.research_create, name='research_create'),93 path('research/modify/<int:research_id>/',94 research_views.research_modify, name='research_modify'),95 path('research/delete/<int:research_id>/',96 research_views.research_delete, name='research_delete'),97 # customer_views.py98 path('customer/', customer_views.customer, name='customer'),99 path('customer/<int:customer_id>/',100 customer_views.customer_detail, name='customer_detail'),101 path('customer/create/',102 customer_views.customer_create, name='customer_create'),103 path('customer/modify/<int:customer_id>/',104 customer_views.customer_modify, name='customer_modify'),105 path('customer/delete/<int:customer_id>/',106 customer_views.customer_delete, name='customer_delete'),107 # activity_views.py108 path('activity/create/<int:customer_id>/',109 activity_views.activity_create, name='activity_create'),110 path('activity/modify/<int:activity_id>/',111 activity_views.activity_modify, name='activity_modify'),112 path('activity/delete/<int:activity_id>/',113 activity_views.activity_delete, name='activity_delete'),...
validations.ts
Source:validations.ts
1import { NextApiRequest } from 'next';2import jwtDecode from 'jwt-decode';3import * as Yup from 'yup';4import { User } from '@pages/api/models/user';5import { ResponseYup } from '@@types/response';6import { returnEnv } from '@utils/returnEnv';7import jwt from 'jsonwebtoken';8import { EnvEnum } from '@enums/enum.environments';9import { errorEnum } from '@enums/enum.errors';10export class Validations {11 decriptToken(token: string) {12 try {13 const user = jwtDecode(token);14 if (!user) throw new Error(errorEnum.TOKEN_EXPIRED);15 return user as User;16 } catch (error) {17 throw new Error(errorEnum.INVALID_TOKEN);18 }19 }20 tokenValidator = (req: NextApiRequest) => {21 try {22 const token = req.headers.authorization as string;23 jwt.verify(token, returnEnv(EnvEnum.SECRET_TOKEN));24 const { _id } = jwtDecode(token) as User;25 req.query = { ...req.query, idToken: String(_id) };26 } catch (error) {27 throw new Error(errorEnum.INVALID_TOKEN);28 }29 };30 codeParamsValidator = async (req: NextApiRequest) => {31 const { _idCollection, code = '' } = req.query;32 let modify_idCollection = _idCollection;33 for (let index = 0; index < 24; index++) {34 if (!modify_idCollection || modify_idCollection?.length < 24) {35 modify_idCollection += '0';36 } else if (modify_idCollection?.length > 24) {37 modify_idCollection = '000000000000000000000000';38 }39 }40 req.query = {41 ...req.query,42 _id: modify_idCollection,43 code: `RD-${String(code)44 .replaceAll('R', '')45 .replaceAll('D', '')46 .replaceAll('-', '')}`,47 };48 };49 codeFindParamsValidator = async (req: NextApiRequest) => {50 const { code = '' } = req.query;51 req.query = {52 ...req.query,53 code: `RD-${String(code)54 .replaceAll('R', '')55 .replaceAll('D', '')56 .replaceAll('-', '')}`,57 };58 };59 collectionIdParamsValidator = async (req: NextApiRequest) => {60 const { _idCollection, code = '' } = req.query;61 let modify_idCollection = _idCollection;62 for (let index = 0; index < 24; index++) {63 if (!modify_idCollection || modify_idCollection?.length < 24) {64 modify_idCollection += '0';65 } else if (modify_idCollection?.length > 24) {66 modify_idCollection = '000000000000000000000000';67 }68 }69 req.query = { ...req.query, _idCollection: modify_idCollection, code };70 };71 idParamsValidator = async (req: NextApiRequest) => {72 const { _id } = req.query;73 let modify_id = _id;74 for (let index = 0; index < 24; index++) {75 if (!modify_id || modify_id?.length < 24) {76 modify_id += '0';77 } else if (modify_id?.length > 24) {78 modify_id = '000000000000000000000000';79 }80 }81 req.query = { ...req.query, _id: modify_id };82 };83 idsParamsValidator = async (req: NextApiRequest) => {84 const { _idCollection, _idElement } = req.query;85 let modify_idCollection = _idCollection;86 let modify_idElement = _idElement;87 for (let index = 0; index < 24; index++) {88 if (!modify_idCollection || modify_idCollection?.length < 24) {89 modify_idCollection += '0';90 } else if (modify_idCollection?.length > 24) {91 modify_idCollection = '000000000000000000000000';92 }93 }94 for (let index = 0; index < 24; index++) {95 if (!modify_idElement || modify_idElement?.length < 24) {96 modify_idElement += '0';97 } else if (modify_idElement?.length > 24) {98 modify_idElement = '000000000000000000000000';99 }100 }101 req.query = {102 ...req.query,103 _idCollection: modify_idCollection,104 _idElement: modify_idElement,105 };106 };107 idParamsValidatorAndType = async (req: NextApiRequest) => {108 const { _idCollection, active } = req.query;109 let modify_idCollection = _idCollection;110 for (let index = 0; index < 24; index++) {111 if (!modify_idCollection || modify_idCollection?.length < 24) {112 modify_idCollection += '0';113 } else if (modify_idCollection?.length > 24) {114 modify_idCollection = '000000000000000000000000';115 }116 }117 req.query = {118 ...req.query,119 _idCollection: modify_idCollection,120 active,121 };122 };123 emailParamValidator = async (req: NextApiRequest) => {124 try {125 const userSchema = Yup.object().shape({126 email: Yup.string()127 .email(errorEnum.VALID_EMAIL_REQUIRED)128 .max(60, errorEnum.EMAIL_MAX_LENGTH)129 .required(errorEnum.EMAIL_CANNOT_EMPTY),130 });131 await userSchema.validate(req.query);132 } catch (err) {133 const { message } = err as ResponseYup;134 throw new Error(message);135 }136 };...
recurrent.ts
Source:recurrent.ts
...36 const modifyParams = {37 path: `/1/RecurrentPayment/${params.paymentId}/Customer`,38 data: params.customer39 };40 return this.modify(modifyParams);41 };42 public modifyEndDate(params: RecurrentModifyEndDateModel): Promise<IHttpResponse> {43 const modifyParams = {44 path: `/1/RecurrentPayment/${params.paymentId}/EndDate`,45 data: params.endDate46 };47 return this.modify(modifyParams);48 };49 public modifyInterval(params: RecurrentModifyIntervalModel): Promise<IHttpResponse> {50 const modifyParams = {51 path: `/1/RecurrentPayment/${params.paymentId}/Interval`,52 data: params.interval53 };54 return this.modify(modifyParams);55 };56 public modifyRecurrencyDay(params: RecurrentModifyDayModel): Promise<IHttpResponse> {57 const modifyParams = {58 path: `/1/RecurrentPayment/${params.paymentId}/RecurrencyDay`,59 data: params.recurrencyDay60 };61 return this.modify(modifyParams);62 };63 public modifyAmount(params: RecurrentModifyAmountModel): Promise<IHttpResponse> {64 const modifyParams = {65 path: `/1/RecurrentPayment/${params.paymentId}/Amount`,66 data: (params.amount * 100).toString()67 };68 return this.modify(modifyParams);69 };70 public modifyNextPaymentDate(params: RecurrentModifyNextPaymentDateModel): Promise<IHttpResponse> {71 const modifyParams = {72 path: `/1/RecurrentPayment/${params.paymentId}/NextPaymentDate`,73 data: params.nextPaymentDate74 };75 return this.modify(modifyParams);76 };77 public modifyPayment(params: RecurrentModifyPaymentModel): Promise<IHttpResponse> {78 const modifyParams = {79 path: `/1/RecurrentPayment/${params.paymentId}/Payment`,80 data: params.payment81 };82 return this.modify(modifyParams);83 };84 public deactivate(params: RecurrentModifyModel): Promise<IHttpResponse> {85 const modifyParams = {86 path: `/1/RecurrentPayment/${params.paymentId}/Deactivate`,87 data: ''88 };89 return this.modify(modifyParams);90 };91 public reactivate(params: RecurrentModifyModel): Promise<IHttpResponse> {92 const modifyParams = {93 path: `/1/RecurrentPayment/${params.paymentId}/Reactivate`,94 data: ''95 };96 return this.modify(modifyParams);97 };98 private modify(params: {path: string, data: string | CustomerModel | PaymentRecurrentModifyModel | number}): Promise<IHttpResponse> {99 return new Promise<IHttpResponse>((resolve, reject) => {100 const util = new Utils(this.cieloTransactionParams);101 const options: IHttpRequestOptions = util.getHttpRequestOptions({102 method: HttpRequestMethodEnum.PUT,103 path: params.path,104 hostname: this.cieloTransactionParams.hostnameTransacao,105 });106 util.httpRequest(options, params.data)107 .then((response) => {108 return resolve(109 camelcaseKeys(response, {110 deep: true,111 }) as IHttpResponse112 );...
Using AI Code Generation
1var wpt = require('webpagetest');2var client = wpt('www.webpagetest.org');3var options = {4};5client.runTest(url, options, function(err, data) {6 if (err) return console.error(err);7 var testId = data.data.testId;8 console.log('Test ID: %s', testId);9 client.getTestResults(testId, function(err, data) {10 if (err) return console.error(err);11 console.log(data);12 });13});14client.modifyTest(testId, {location: 'Dulles:Chrome'}, function(err, data) {15 if (err) return console.error(err);16 console.log(data);17});18{ statusCode: 400,19 data: 'The test is already running and cannot be modified' }20{ statusCode: 400,21 data: 'The test is already running and cannot be modified' }22{ statusCode: 400,23 data: 'The test is already running and cannot be modified' }24{ statusCode: 400,25 data: 'The test is already running and cannot be modified' }
Using AI Code Generation
1const wptools = require('wptools');2const page = wptools.page('Albert Einstein');3page.get((err, data) => {4 if (err) {5 console.log(err);6 }7 console.log(data);8});9page.modify('Albert Einstein', 'Albert Einstein',
Using AI Code Generation
1var wpt = require("wpt");2var wpt = new WebPageTest("www.webpagetest.org");3var options = {4};5wpt.runTest(options, function(err, data) {6 if (err) return console.error(err);7 wpt.getTestResults(data.data.testId, function(err, data) {8 if (err) return console.error(err);9 console.log(data.data);10 });11});
Using AI Code Generation
1var wpt = require('webpagetest');2var test = wpt('www.webpagetest.org');3 if (err) return console.error(err);4 test.modifyTest(data.data.testId, {location: 'Dulles:Chrome'}, function(err, data) {5 if (err) return console.error(err);6 console.log(data);7 });8});9var wpt = require('webpagetest');10var test = wpt('www.webpagetest.org');11test.getLocations(function(err, data) {12 if (err) return console.error(err);13 console.log(data);14});15var wpt = require('webpagetest');16var test = wpt('www.webpagetest.org');17test.getLocations(function(err, data) {18 if (err) return console.error(err);19 console.log(data);20});21var wpt = require('webpagetest');22var test = wpt('www.webpagetest.org');23test.getTesters('Dulles:Chrome', function(err, data) {24 if (err) return console.error(err);25 console.log(data);26});27var wpt = require('webpagetest');28var test = wpt('www.webpagetest.org');29test.getTestStatus('141030_2H_5c5f0e7d1a1a8a7e4e0d4a0d9d2c2d1e', function(err, data) {
Using AI Code Generation
1var wptool = require('wptool');2wptool.modify('test.txt','Hello World','Hello World!');3### `wptool.remove()`4var wptool = require('wptool');5wptool.remove('test.txt');6### `wptool.copy()`7var wptool = require('wptool');8wptool.copy('test.txt','test2.txt');9### `wptool.move()`10var wptool = require('wptool');11wptool.move('test.txt','test2.txt');12### `wptool.rename()`13var wptool = require('wptool');14wptool.rename('test.txt','test2.txt');15### `wptool.append()`16var wptool = require('wptool');17wptool.append('test.txt','Hello World!');
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!!