Best JavaScript code snippet using webdriverio-monorepo
main.gs
Source:main.gs
1function Main() {2 // ã¹ãã¬ããã·ã¼ããåå¾3 const getSS = SpreadsheetApp.openById('11Y5gKhXQnXspVgih58s3_DDT5orEz-WAZ4sCwSXpAOs'); // ã¹ãã¬ããã·ã¼ãæ
å ±ï¼èªåºãï¼4 const setSS = SpreadsheetApp.openById('1zzq1OQxTZJOFo2eFaTGkNLyipGWDjl9i-LijcgIU3Hw'); // ã¹ãã¬ããã·ã¼ãæ
å ±ï¼æ¸è¾¼ã¿ï¼5 const form = getSS.getSheetByName('ãã©ã¼ã ã®åç 1'); // ã¹ãã¬ããã·ã¼ãï¼ãã©ã¼ã åçï¼æ
å ±6 let keyForm = setSS.getSheetByName('ãã¼ã¯ã¼ããã©ã¼ã '); // ã¹ãã¬ããã·ã¼ãï¼ãã¼ã¯ã¼ããã©ã¼ã ï¼æ
å ±7 // ã·ã¼ãã®æçµè¡ã»æçµåãåå¾8 const formLastRow = form.getLastRow(); // æçµè¡ç®ãåå¾ï¼ãã©ã¼ã åç1ï¼9 const formLastCol = form.getLastColumn(); // æçµåç®ãåå¾ï¼ãã©ã¼ã åç1ï¼10 // ã¢ãããã¼ãããå
ãã¡ã¤ã«ã®ä¿åå
ãã©ã«ãID11 const upfolder = '0BxQbdvn-LT2ufmlKRk5SY3k2VFg0MzQxak1uYVZpNXdDYURKVkk2RHgtSUk1WDI3UExMWlk';12 // ã¹ãã¬ããã·ã¼ã(ãã©ã¼ã åç1)ã®æçµè¡ã®åçå
¨ã¦ãåå¾13 const getAnswers = form.getRange(formLastRow, 1, 1, formLastCol).getValues().flat();14 // ãã©ã¼ã åçãåå¥ã«åå¾15 const __A = getAnswers[0]; 16 const _A = new Date(__A);17 const A = Utilities.formatDate(_A, 'JST', 'yyyy/M/d'); // ã¿ã¤ã ã¹ã¿ã³ã18 const B = getAnswers[1]; // ãã¡ã¤ã«é¸æ >>> ã¡ã¼ã«ã¢ãã¬ã¹ 19 const C = getAnswers[2].replace(/ã/g,""); // ä½æè
ï¼ãã«ãã¼ã ï¼ >>> ç»é²è
(ãã«ãã¼ã )20 const D = getAnswers[3]; // ç»é²è
ï¼ãã«ãã¼ã ï¼ >>> ä½æè
(ãã«ãã¼ã )21 const E = getAnswers[4]; // ã客æ§å >>> ãã¡ã¤ã«å
容22 const F = getAnswers[5]; // é¢é£ä»ãããããã¼ã¯ã¼ã >>> è±ç¥èã»ããæ
å ±(ã¢ãããã¼ããã¡ã¤ã«ã®æç¡)23 const G = getAnswers[6]; // ãã¡ã¤ã«å
容 >>> è±ç¥èã»ããæ
å ±(ã¿ã¤ãã«)24 const H = getAnswers[7]; // ãã¡ã¤ã«å
容ï¼ãã®ä»ï¼ >>> è±ç¥èã»ããæ
å ±(å
容)25 const I = getAnswers[8]; // è±ç¥èã»ããæ
å ±ã®ã¿ã¤ãã« >>> æ©æ¢°ã®ç¨®é¡26 const J = getAnswers[9]; // è±ç¥èã»ããæ
å ± >>> ã³ã«ã²ã¼ã¿ã®ç¨®é¡27 const K = getAnswers[10]; // æ©æ¢°ã®ç¨®é¡ >>> ãã«ãã¼ã«ã¹ã¿ã³ãã®æ©ç¨®28 const L = getAnswers[11]; // ã³ã«ã²ã¼ã¿ã®ç¨®é¡ >>> ãã¼ã¯ã¼ã(é¨ä½)29 const M = getAnswers[12]; // ãã«ãã¼ã«ã¹ã¿ã³ãã®æ©ç¨® >>> ãã¼ã¯ã¼ã(åä½)30 const N = getAnswers[13]; // ã¹ãã©ã¤ãµã®æ©ç¨® >>> ãã¼ã¯ã¼ã(çç¶ã»ç¶æ
)31 const O = getAnswers[14]; // ã·ã³ã°ã«ãã§ã¼ãµã®æ©ç¨® >>> ãã¼ã¯ã¼ã(é¨å)32 const P = getAnswers[15]; // ãã¬ã¼ãã¹ã¿ã³ãã®æ©ç¨® >>> ã¹ãã©ã¤ãµã®æ©ç¨®33 const Q = getAnswers[16]; // ãã¬ãã¼ã¿ã®æ©ç¨® >>> ã·ã³ã°ã«ãã§ã¼ãµã®æ©ç¨®34 const R = getAnswers[17]; // ã°ã«ã¼ãã·ã³ã®æ©ç¨® >>> ãã¼ã¯ã¼ã(é¨ä½)35 const S = getAnswers[18]; // ããã«ãã§ã¼ãµã®æ©ç¨® >>> ãã¼ã¯ã¼ã(åä½)36 const T = getAnswers[19]; // ã¹ãªãã¿ã¹ã³ã¢ã©ã®æ©ç¨® >>> ãã¼ã¯ã¼ã(çç¶ã»ç¶æ
)37 const U = getAnswers[20]; // ã«ãã¿ã¼ã®æ©ç¨® >>> ãã¼ã¯ã¼ã(é¨å)38 const V = getAnswers[21]; // ã¹ã¿ãã«ã¼ã®æ©ç¨® >>> ãã¬ã¼ãã¹ã¿ã³ãã®æ©ç¨®39 const W = getAnswers[22]; // 管çè£
ç½®ã®æ©ç¨®ï¼ã³ã«ã²ã¼ã¿ï¼ >>> ãã¼ã¯ã¼ã(é¨ä½)40 const X = getAnswers[23]; // 製å½æ©ã®ç¨®é¡ >>> ãã¼ã¯ã¼ã(åä½)41 const Y = getAnswers[24]; // ã¢ã¤ãã¹ã»ãã¡ã«ã³ã³ã®æ©ç¨® >>> ãã¼ã¯ã¼ã(çç¶ã»ç¶æ
)42 const Z = getAnswers[25]; // ãã¬ãã½ã®æ©ç¨® >>> ãã¼ã¯ã¼ã(é¨å)43 const AA = getAnswers[26]; // ããªã¹ãã®æ©ç¨® >>> ãã¬ãã¼ã¿ã®æ©ç¨®44 const AB = getAnswers[27]; // ãã©ã«ãã¼ã°ã«ã¢ã®æ©ç¨® >>> ãã¼ã¯ã¼ã(é¨ä½)45 const AC = getAnswers[28]; // ã¹ã¿ãã«ã¼ã®æ©ç¨®ï¼è£½å½æ©ï¼ >>> ãã¼ã¯ã¼ã(åä½)46 const AD = getAnswers[29]; // 管çè£
ç½®ï¼è£½å½æ©ï¼ >>> ãã¼ã¯ã¼ã(çç¶ã»ç¶æ
)47 const AE = getAnswers[30]; // ã«ã¦ã³ã¿ã¼ã¨ã¸ã§ã¯ã¿ã®æ©ç¨® >>> ãã¼ã¯ã¼ã(é¨å)48 const AF = getAnswers[31]; // ä»ç¤¾è£½ã»åå£²æ© >>> ã°ã«ã¼ãã·ã³ã®æ©ç¨®49 const AG = getAnswers[32]; // ãã®ä»ï¼è£½å½æ©ï¼ >>> ãã¼ã¯ã¼ã(é¨ä½)50 const AH = getAnswers[33]; // æ©å¨ã»é¨åã®ç¨®é¡ >>> ãã¼ã¯ã¼ã(åä½)51 const AI = getAnswers[34]; // æ©å¨ã»é¨ååï¼æ©æ¢°ï¼ >>> ãã¼ã¯ã¼ã(çç¶ã»ç¶æ
)52 const AJ = getAnswers[35]; // æ©å¨ã»é¨ååï¼é»æ°ï¼ >>> ãã¼ã¯ã¼ã(é¨å)53 const AK = getAnswers[36]; // 社å
æ¥åããã¥ã¢ã« >>> ããã«ãã§ã¼ãµã®æ©ç¨®54 const AL = getAnswers[37]; // ã¡ã¼ã«ã¢ãã¬ã¹ >>> ãã¼ã¯ã¼ã(é¨ä½)55 const AM = getAnswers[38]; // ååãã»è¦æ >>> ãã¼ã¯ã¼ã(åä½)56 const AN = getAnswers[39]; // é¢é£ä»ãããããã¼ã¯ã¼ã >>> ãã¼ã¯ã¼ã(çç¶ã»ç¶æ
)57 const AO = getAnswers[40]; // ãã¡ã¤ã«é¸æ >>> ãã¼ã¯ã¼ã(é¨å)58 const AP = getAnswers[41]; // é¢é£ä»ãããããã¼ã¯ã¼ã >>> ã¹ãªãã¿ã¹ã³ã¢ã©ã®æ©ç¨®59 const AQ = getAnswers[42]; // é¢é£ä»ãããããã¼ã¯ã¼ã >>> ãã¼ã¯ã¼ã(é¨ä½)60 const AR = getAnswers[43]; // é¢é£ä»ãããããã¼ã¯ã¼ã >>> ãã¼ã¯ã¼ã(åä½)61 const AS = getAnswers[44]; // é¢é£ä»ãããããã¼ã¯ã¼ã >>> ãã¼ã¯ã¼ã(çç¶ã»ç¶æ
)62 const AT = getAnswers[45]; // é¢é£ä»ãããããã¼ã¯ã¼ã >>> ãã¼ã¯ã¼ã(é¨å)63 const AU = getAnswers[46]; // é¢é£ä»ãããããã¼ã¯ã¼ã >>> ã«ãã¿ã¼ã®æ©ç¨®64 const AV = getAnswers[47]; // é¢é£ä»ãããããã¼ã¯ã¼ã >>> ãã¼ã¯ã¼ã(é¨ä½)65 const AW = getAnswers[48]; // é¢é£ä»ãããããã¼ã¯ã¼ã >>> ãã¼ã¯ã¼ã(åä½)66 const AX = getAnswers[49]; // é¢é£ä»ãããããã¼ã¯ã¼ã >>> ãã¼ã¯ã¼ã(çç¶ã»ç¶æ
)67 const AY = getAnswers[50]; // é¢é£ä»ãããããã¼ã¯ã¼ã >>> ãã¼ã¯ã¼ã(é¨å)68 const AZ = getAnswers[51]; // é¢é£ä»ãããããã¼ã¯ã¼ã >>> ã¹ã¿ãã«ã¼ã®æ©ç¨®69 const BA = getAnswers[52]; // é¢é£ä»ãããããã¼ã¯ã¼ã >>> ãã¼ã¯ã¼ã(é¨ä½)70 const BB = getAnswers[53]; // é¢é£ä»ãããããã¼ã¯ã¼ã >>> ãã¼ã¯ã¼ã(åä½)71 const BC = getAnswers[54]; // é¢é£ä»ãããããã¼ã¯ã¼ã >>> ãã¼ã¯ã¼ã(çç¶ã»ç¶æ
)72 const BD = getAnswers[55]; // é¢é£ä»ãããããã¼ã¯ã¼ã >>> ãã¼ã¯ã¼ã(é¨å)73 const BE = getAnswers[56]; // é¢é£ä»ãããããã¼ã¯ã¼ã >>> 管çè£
ç½®ã®æ©ç¨®74 const BF = getAnswers[57]; // é¢é£ä»ãããããã¼ã¯ã¼ã >>> ãã¼ã¯ã¼ã(é¨ä½)75 const BG = getAnswers[58]; // é¢é£ä»ãããããã¼ã¯ã¼ã >>> ãã¼ã¯ã¼ã(åä½)76 const BH = getAnswers[59]; // é¢é£ä»ãããããã¼ã¯ã¼ã >>> ãã¼ã¯ã¼ã(çç¶ã»ç¶æ
)77 const BI = getAnswers[60]; // é¢é£ä»ãããããã¼ã¯ã¼ã >>> ãã¼ã¯ã¼ã(é¨å)78 const BJ = getAnswers[61]; // é¢é£ä»ãããããã¼ã¯ã¼ã >>> ãã¡ã¤ã«é¸æ79 const BK = getAnswers[62]; // é¢é£ä»ãããããã¼ã¯ã¼ã >>> ã客æ§å80 const BL = getAnswers[63]; // é¢é£ä»ãããããã¼ã¯ã¼ã >>> ä½ãæ¹åãã¦ã»ããç¹ã»è¿½å è¦æçããã°è¨å
¥ãã¦ä¸ããã81 const BM = getAnswers[64]; // é¢é£ä»ãããããã¼ã¯ã¼ã >>> ãã¼ã¯ã¼ã(é¨ä½) ã¹ãã©ã¤ãµ82 const BN = getAnswers[65]; // é¢é£ä»ãããããã¼ã¯ã¼ã >>> ãã¼ã¯ã¼ã(åä½) ã¹ãã©ã¤ãµ83 const BO = getAnswers[66]; // é¢é£ä»ãããããã¼ã¯ã¼ã >>> ãã¼ã¯ã¼ã(çç¶ã»ç¶æ
) ã¹ãã©ã¤ãµ84 const BP = getAnswers[67]; // é¢é£ä»ãããããã¼ã¯ã¼ã >>> ãã¼ã¯ã¼ã(é¨å) ã¹ãã©ã¤ãµ85 // googleãã©ã¼ã ããã®åå¾ãã¼ã¿(googleãã©ã¼ã ã«è¿½å ããã追å å¿
è¦)86 // G, H ã¯ãé
åã®æå¾ã«è¨å
¥ãããæ
å ±ã¿ã¤ãã«ã»å
容ã®çºãæå¾ã«æ¸è¾¼ã87 const getDatas = [ A, B, C, D, E, F, I, J, K, L, M, N,88 O, P, Q, R, S, T, U, V, W, X, Y, Z,89 AA, AB, AC, AD, AE, AF, AG, AH, AI, AJ, AK, AL,90 AM, AN, AO, AP, AQ, AR, AS, AT, AU, AV, AW, AX,91 AY, AZ, BA, BB, BC, BD, BE, BF, BG, BH, BI, BJ,92 BK, BL, BM, BL, BO, BP, G, H ];93 // ãã©ã¼ã åçã®è¨å®(é¢æ°å
ã§ãã©ã¼ã åçã使ç¨ããå ´åã¯ãããã«è¿½å ããå¤æ°ã使ç¨ãã¦ï¼)94 const timeStamp = A; // ã¿ã¤ã ã¹ã¿ã³ã95 const mailAddress = B; // ã¡ã¼ã«ã¢ãã¬ã¹96 const registPerson = C; // ç»é²è
97 const fileContents = E; // ãã¡ã¤ã«å
容98 const notUploadFile = F; // è±ç¥èã»ããæ
å ±ã®ã¢ãããã¼ããã¡ã¤ã«æç¡99 const littleInfoTitle = G; // è±ç¥èã»ããæ
å ±ã®ã¿ã¤ãã«100 const littleInfoConts = H; // è±ç¥èã»ããæ
å ±ã®å
容101 const uploadFileUrl = BJ; // ã¢ãããã¼ãããå
ãã¡ã¤ã«ã®URL102 const requests = BL; // æ¹åç¹ã»è¦æ103 // ãã¼ã¯ã¼ããã©ã¼ã ã«è¨è¼ä¸è¦ãªãã¼ã¿104 const getNotDatas = [ mailAddress, notUploadFile, uploadFileUrl, requests ];105 // ãã¼ã¯ã¼ããã©ã¼ã ã«è¨è¼ãã説ææ106 const AAA = "ç»é²æ¥æ";107 const CCC = "ç»é²è
";108 const DDD = "ä½æè
";109 const KEY = "ãã¼ã¯ã¼ã";110 const dataTitle = [ AAA, DDD, CCC, KEY ]; // 説ææãé
åã«æ ¼ç´111 // ã¢ãããã¼ããã¡ã¤ã«å
容ã¨ä¿åå
ãã©ã«ãID112 const a = { contents:"å説ã»ããã¥ã¢ã«ï¼ISOWAãªãªã¸ãã«ï¼", id:"1a3JnMp6ZfToZ4lthL4bGDdZOkT1IIpTR" };113 const b = { contents:"æ©å¨ã»é¨åããã¥ã¢ã«ï¼ã¡ã¼ã«ã¼ï¼", id:"1OxoFmxgU-hS07Klcqa7S7I12rpt1tlJa" };114 const c = { contents:"æé æ¸", id:"1c7TqF0wHPrFCdfIpx7xfWdTE6-MTbvRW" };115 const d = { contents:"調æ´è¦é æ¸", id:"1kJRlkkqtn3EFAlpdYJzCgRWLEtWBrcib" };116 const e = { contents:"ãã©ãã«ã·ã¥ã¼ãã£ã³ã°ã»å®æ°è¡¨ã»ãã©ã¡ã¼ã¿", id:"1KkrkvTAx0oEtyaTZTYYYVzq35I055lz5" };117 const f = { contents:"ä»æ§æ¸", id:"1far2FpiadbUZ_XHQD9BzwKlJVySGEKx9" };118 const g = { contents:"å ±åæ¸", id:"1oXXtqrc96Ze4mykkfvI6K9bkzTvflNpE" };119 const h = { contents:"è¦è§£æ¸", id:"16sky4P09sT2KdW1ngcPdeH5f0AjAaA-u" };120 const i = { contents:"ç¹æ¤ã»æ¤æ»è¡¨", id:"1cL_4s38of31LA_xJKxLyplD_lu_5nIWl" };121 const j = { contents:"è¨è¨å¤æ´", id:"1DLPbnYjJQmkib4AmmfKdV2YNk9eHU42N" };122 const k = { contents:"ã¢ã¤ã¬ãï¼ä¿®çã»çµç«ï¼", id:"1-cSlKa2xEy1raZqf5ySf4lLOWQ4A8hm-" };123 const l = { contents:"è±ç¥èã»ããæ
å ±", id:"1W34glQWjt-spp7Hl5IN0TzczUnW8dyXF" };124 const m = { contents:"社å
è³æï¼æ¥åããã¥ã¢ã«ï¼", id:"1tQsfk5n3MME2zJopDE2QShXN8v5jtYsK" };125 const n = { contents:"社å
è³æï¼ãã©ã¼ã ï¼", id:"1GQTozvYrRCdq7c24J8Nk3K8YpJ1HHi8h" };126 const o = { contents:"ãã®ä»", id:"1RxdO0E4rNmEM1Yg9zwQrBh4PufuIDvRn" };127 const p = { contents:"ç»å", id:"1y5_S_pZxmPAFyY9P59uL9ggtNTJq5bud" };128 const q = { contents:"åç»", id:"1NMIkUvyFwJUqHLQaIu4jWbb5AX5HeqIs" };129 const r = { contents:"", id:"" };130 const s = { contents:"", id:"" };131 const t = { contents:"", id:"" };132 const u = { contents:"", id:"" };133 const v = { contents:"", id:"" };134 const w = { contents:"", id:"" };135 const x = { contents:"", id:"" };136 const y = { contents:"", id:"" };137 const z = { contents:"", id:"" };138 // ãã¡ã¤ã«å
容ã¨ä¿åå
ãã©ã«ãIDãæ ¼ç´ããé
å139 const contentsIds = [ a, b, c, d, e, f, g, h, i, j, k,l, m, n, o, p, q,140 r, s, t, u, v, w, x, y, z ];141 // ã¢ãããã¼ããã¡ã¤ã«æç¡ å¤å®142 const uploadFileExists = uploadFileUrl !== "";143 // ããããå¦çãå®è¡144 class Obj {145 constructor() {};146 // ========== [ ã¡ã½ãã ] ã¢ãããã¼ããã¡ã¤ã«ã»ãã¼ã¯ã¼ããã¡ã¤ã«åãå¤æ´ ========== //147 GetFileData() {148 console.log("ãGetFileData å®è¡!ã");149 // å¤æ°ã®å®ç¾©ã»åæå150 let id; // ã¢ãããã¼ãID151 let uploadFile; // ã¢ãããã¼ããã¡ã¤ã«152 let upLoadName; // ã¢ãããã¼ãããããã¡ã¤ã«åãåå¾(ååæ)153 let upLoadNames = []; // é
å ã¢ãããã¼ãããããã¡ã¤ã«å154 let upLoadUrls = []; // é
å ã¢ãããã¼ãããããã¡ã¤ã«URL155 console.log("uploadFileExists(ã¢ãããã¼ããã¡ã¤ã«ã®åå¨å¤å®):" + uploadFileExists); // ãã°ç¢ºèªç¨156 // ã¢ãããã¼ããã¡ã¤ã«ãåå¨ããå ´åã«å®è¡157 if ( uploadFileExists ) {158 const multiple = uploadFileUrl.indexOf(", ") !== -1; // ã¢ãããã¼ããã¡ã¤ã«ãè¤æ°ãããå¤å®159 // ã¢ãããã¼ããã¡ã¤ã«ã®URLãé
åã§åå¾160 if ( multiple ) {161 console.log("ã¢ãããã¼ããã¡ã¤ã«ã¯è¤æ°ã§ãï¼"); // ãã°ç¢ºèªç¨ 162 upLoadUrls = uploadFileUrl.split(', '); // è¤æ°ãã¡ã¤ã«ã®å ´å163 } else {164 console.log("ã¢ãããã¼ããã¡ã¤ã«ã¯ï¼ã¤ã§ãï¼"); // ãã°ç¢ºèªç¨165 upLoadUrls = [ uploadFileUrl ]; // 1ãã¡ã¤ã«ã®ã¿ã®å ´å166 }167 // ã¢ãããã¼ããã¡ã¤ã«åãåå¾ãé
åã«è¿½å 168 upLoadUrls.forEach( el => {169 id = el.split('=')[1] // åå¾ããã¢ãããã¼ããã¡ã¤ã«ã®urlããIDé¨åã®ã¿æ½åº170 uploadFile = DriveApp.getFileById(id); // IDãããã¡ã¤ã«ãåå¾171 upLoadName = uploadFile.getName(); // ã¢ãããã¼ãããããã¡ã¤ã«åãåå¾(ååæ)172 upLoadNames.push(upLoadName); // ã¢ãããã¼ãããããã¡ã¤ã«å(ååæ)ãé
åã«è¿½å 173 })174 }175 console.log("upLoadNames(ã¢ãããã¼ããã¡ã¤ã«å):" + upLoadNames); // ãã°ç¢ºèªç¨176 // ãªãã¸ã§ã¯ãã«è¿½å 177 this.upLoadUrls = upLoadUrls; // ã¢ãããã¼ããã¡ã¤ã«URL(çãã¼ã¿)178 this.upLoadNames = upLoadNames; // ã¢ãããã¼ããã¡ã¤ã«å(çãã¼ã¿)179 }; // GetFileData()_END180 // ========== [ ã¡ã½ãã ] æå®ãã©ã«ãã«ã¢ãããã¼ããã¡ã¤ã«ã®ã³ãã¼ã追å ========== //181 FileMove() {182 console.log("ãFileMove å®è¡!ã");183 184 // å¤æ°ã®å®ç¾©ã»åæå185 let copyId; // ã³ãã¼ãã¡ã¤ã«ã®ID186 let fileName; // ã³ãã¼å
ã®ãã¡ã¤ã«å187 let fileName0, fileName1; // ã³ãã¼å
ã®ãã¡ã¤ã«å(åå²)188 let fileUrl; // ã³ãã¼ãã¡ã¤ã«URL189 let fileRename; // ååãä»ããããåã®å
ã
ã®ãã¡ã¤ã«å190 let keywordName; // ãã¼ã¯ã¼ããã¡ã¤ã«ã®ãã¡ã¤ã«å191 let fileNames = []; // é
å [ã³ãã¼å
ã®ãã¡ã¤ã«å]192 let fileUrls = []; // é
å [ã³ãã¼ãã¡ã¤ã«URL]193 let fileRenames = []; // ååãä»ããããåã®å
ã
ã®ãã¡ã¤ã«åã®é
å194 let keywordNames = []; // é
å [ãã¼ã¯ã¼ããã¡ã¤ã«ã®ãã¡ã¤ã«å]195 196 let folder = DriveApp.getFolderById(upfolder); // ã³ãã¼å
ãã¡ã¤ã«ã®ãã©ã«ã197 let files = folder.getFiles(); // ã³ãã¼å
ãã¡ã¤ã«;198 199 // ç»é²å
ãã©ã«ãåã¨åçãã©ã¼ã ã®å
容ãä¸è´ãããã©ã«ãIDã[copyId]ã«æ ¼ç´ããã200 contentsIds.forEach( el => {201 if ( fileContents === el.contents ) copyId = el.id;202 })203 // ã¢ãããã¼ããã¡ã¤ã«ç»é²ãããæå®ãã©ã«ãå
ã«ãã¡ã¤ã«ãåå¨ããªãå ´å204 for ( let i = 0; i < 50; i++ ) {205 if ( uploadFileExists && !files.hasNext() ) {206 console.log("ãã©ã«ãå
ã«ãã¡ã¤ã«ãåå¨ãã¾ããã§ããï¼");207 SleepTimer(upfolder);208 }209 };210 // ã¢ãããã¼ãé¢é£ã®ãã¡ã¤ã«ãåå¨ããå ´åãã³ãã¼ãã¦æå®ãã©ã«ãã«ä¿å(URLãåå¾)211 while(files.hasNext()) {212 console.log();213 let file = files.next(); // ãã¡ã¤ã«ãåå¾214 fileName = file.getName(); // ãã¡ã¤ã«åãåå¾215 fileName0 = fileName.split(' - ')[0]; // ã¢ãããã¼ããã¡ã¤ã«å(ååç¡ ã» æ¡å¼µåç¡)216 fileName1 = fileName.split(' - ')[1]; // ã¢ãããã¼ããã¡ã¤ã«ã®ç»é²è
å以éã®æååãæ½åº217 // ç»é²è
åãåé¤ãããã¡ã¤ã«åãåå¾218 if ( fileName.indexOf(".") !== -1 ) {219 const extension = fileName1.split('.')[1]; // æ¡å¼µåãæ½åº220 fileRename = `${fileName0}.${extension}`; // ãã¡ã¤ã«ã«æ¡å¼µåãããå ´å221 } else {222 fileRename = fileName0; // ãã¡ã¤ã«ã«æ¡å¼µåããªãå ´å223 }224 keywordName = `${fileName0}_ãã¼ã¯ã¼ã.pdf`; // ãã¼ã¯ã¼ããã¡ã¤ã«å225 const fileNum = this.upLoadNames.indexOf(fileName); // ãã¡ã¤ã«åã¨ä¸è´ããé
åçªå·226 const nameJudge = ( fileNum !== -1 ); // ãã¡ã¤ã«åã®æç¡å¤å®227 // ãã°ç¢ºèªç¨228 console.log("fileName(ãã¡ã¤ã«å ååæã»æ¡å¼µåå«):" + fileName);229 console.log("fileName0(ãã¡ã¤ã«å ååç¡ã»æ¡å¼µåç¡):" + fileName0);230 console.log("fileName1(ãã¡ã¤ã«å ååã®ã¿ã»æ¡å¼µåå«):" + fileName1);231 console.log("fileRename(ç»é²è
åãåé¤ãããã¡ã¤ã«å):" + fileRename);232 console.log("keywordName(ãã¼ã¯ã¼ããã¡ã¤ã«å):" + keywordName);233 console.log("fileNum(ã¢ãããã¼ããã¡ã¤ã«ã®æ ¼ç´ãããé
åã¨åå¾ãããã¡ã¤ã«åãä¸è´ããé
åçªå·):" + fileNum);234 console.log("upLoadNames(ã¢ãããã¼ããã¡ã¤ã«å):" + this.upLoadNames);235 console.log("nameJudge(ãã¡ã¤ã«åä¸è´å¤å®):" + nameJudge);236 237 // ãã¡ã¤ã«åãä¸è´ãããå®è¡238 if ( nameJudge ) {239 console.log("ãã¡ã¤ã«åãä¸è´ãã¾ããï¼");240 const copyFolder = DriveApp.getFolderById(copyId); // ã³ãã¼ãã¡ã¤ã«ã®ä¿åå
ãã©ã«ãID241 const originalFile = DriveApp.getFilesByName(fileName).next(); // ã³ãã¼å
ã®ãªãã¸ã§ã¯ããåå¾242 const newFile = originalFile.makeCopy(fileRename, copyFolder); // æå®ãããã©ã«ãã«ãã¡ã¤ã«ãã³ãã¼243 fileUrl = newFile.getUrl(); // ãã¡ã¤ã«ã®URLãåå¾244 // é
åã«è¿½å 245 fileNames.push(fileName); // ãã¡ã¤ã«å(å
ãã¼ã¿)ãé
åã«è¿½å 246 fileRenames.push(fileRename); // ãã¡ã¤ã«å(ã³ãã¼ãã¼ã¿)ãé
åã«è¿½å 247 fileUrls.push(fileUrl); // ãã¡ã¤ã«URL(ã³ãã¼ãã¼ã¿)ãé
åã«è¿½å 248 keywordNames.push(keywordName); // ãã¼ã¯ã¼ããã¡ã¤ã«åãé
åã«è¿½å 249 } else {250 console.log("ãã¡ã¤ã«åãä¸è´ãã¾ããã§ããï¼");251 }252 }253 // ãã°ç¢ºèªç¨254 console.log("fileNames(å
ãã¡ã¤ã«åã®é
å):" + fileNames);255 console.log("fileRenames(ã³ãã¼ãã¡ã¤ã«åã®é
å):" + fileRenames);256 console.log("fileUrls(ã³ãã¼ãã¡ã¤ã«URLã®é
å):" + fileUrls);257 console.log("keywordNames(ãã¼ã¯ã¼ããã¡ã¤ã«åã®é
å):" + keywordNames);258 // ãªãã¸ã§ã¯ãã«è¿½å ã259 this.fileNames = fileNames; // ãã¡ã¤ã«å(å
ãã¼ã¿)260 this.fileRenames = fileRenames; // ãã¡ã¤ã«å(ã³ãã¼ãã¼ã¿)261 this.fileUrls = fileUrls; // ãã¡ã¤ã«URL(ã³ãã¼ãã¼ã¿)262 this.keywordNames = keywordNames; // ãã¼ã¯ã¼ããã¡ã¤ã«å263 }; // FileMove()_END264 // ========== [ ã¡ã½ãã ] ãã©ã¼ã åçããã¼ã¯ã¼ããã¡ã¤ã«(ã¹ãã¬ããã·ã¼ã)ã«æ¸è¾¼ ========== //265 266 WhiteForm() {267 console.log("ãWhiteForm å®è¡!ã");268 269 // å¤æ°ã®å®ç¾©ã»åæå270 const datas = getDatas; // ãã©ã¼ã ã®åå¾ãã¼ã¿é
ågetDatasãæ ¼ç´271 const setSubDatas = dataTitle; // ãã¼ã¯ã¼ããã¡ã¤ã«ã«è¨è¼ãããã¼ã¿ã®ã¿ã¤ãã«ï¼Aåï¼272 const notDatas = getNotDatas; // ãã¼ã¯ã¼ããã¡ã¤ã«ã«è¨è¼ä¸è¦ãªãã¼ã¿273 let setDatas = []; // ãã¼ã¯ã¼ããã¡ã¤ã«ã«æ¸ãè¾¼ããã¼ã¿ï¼Båï¼274 // [getDatas] 㨠[notDatas] å
ã®ãã¼ã¿ãæ¯è¼ããéè¤ãã¦ããªããã¼ã¿ã [setDatas] ã«è¿½å 275 datas.concat(notDatas).forEach( data => {276 if ( datas.includes(data) && !notDatas.includes(data)) setDatas.push(data);277 });278 // ãã°ç¢ºèªç¨279 console.log("datas(åå¾ãã¼ã¿)ï¼" + datas);280 console.log("setSubDatas(æ¸è¾¼è£å©ãã¼ã¿)ï¼" + setSubDatas);281 console.log("setDatas(æ¸è¾¼ãã¼ã¿)ï¼" + setDatas);282 // ãã¼ã¯ã¼ã説ææãæ¸è¾¼ (ã¹ãã¬ããã·ã¼ãã®Aå)283 let num = 1; // æ¸è¾¼ã¿è¡(åæè¨å®)284 // é
å[setSubDatas]ã«å
¥ã£ã¦ãã説ææãæ¸è¾¼285 setSubDatas.forEach( setSubData => {286 keyForm.getRange(`A${num}`).setValue(setSubData); // setSubDataãæ¸è¾¼ã 287 num++; // æ¹è¡288 });289 // ãã¼ã¯ã¼ããæ¸è¾¼ (ã¹ãã¬ããã·ã¼ãã®Bå) 290 num = 1; // æ¸è¾¼ã¿è¡(åæè¨å®)291 // é
å[setDatas]ã«å
¥ã£ã¦ãããã¼ã¯ã¼ããæ¸è¾¼292 setDatas.forEach( setData => {293 if ( setData != "" ) {294 if ( setData === littleInfoTitle ) num += 2; // setDataã è±ç¥èã¿ã¤ãã«ã ã£ãå ´åã¯æ¹è¡295 if ( setData === littleInfoConts ) num++; // setDataã è±ç¥èã»ããæ
å ±å
容ã ã£ãå ´åã¯æ¹è¡296 }297 keyForm.getRange(`B${num}`).setValue(setData); // setDataãæ¸è¾¼ã298 if ( setData !== "" ) num++; // setDataã®ä¸èº«ã空ã§ãªãå ´åã¯æ¹è¡299 });300 // ãã¡ã¤ã«åã»URLãæ¸è¾¼301 if ( uploadFileUrl !== "" ) {302 let i = 0;303 this.fileUrls.forEach( fileUrl => {304 keyForm.getRange(`B${num}`).setValue(this.fileRenames[i]);305 num++; 306 keyForm.getRange(`B${num}`).setValue(fileUrl);307 num++;308 i++;309 })310 console.log("ã¢ãããã¼ããã¡ã¤ã«åã¨URLãæ¸è¾¼ã¿ã¾ããï¼");311 } else {312 console.log("ã¢ãããã¼ããã¡ã¤ã«ãè¦ã¤ããã¾ããã§ããï¼");313 }314 // åãåããã»è¦æã®é
ç®ã«åçããã£ãããåãåããã»è¦æã®ã¹ãã¬ããã·ã¼ãã«å
容ãæ¸è¾¼315 if ( requests !== "" ) {316 console.log("åãåããã»è¦æããï¼");317 // ã¹ãã¬ããã·ã¼ãæ
å ±318 const ssForm = SpreadsheetApp.openById('1gctMJ1s7HJ51XQojAJDITSD9cab9hSB8f4CHBlYo94g'); // ã¹ãã¬ããã·ã¼ãæ
å ±ï¼æ¸è¾¼ã¿å
ï¼319 const reqForm = ssForm.getSheetByName('åãåããã»è¦æ'); // ã¹ãã¬ããã·ã¼ãï¼åãåããã»è¦æï¼æ
å ±320 const lastRow = reqForm.getLastRow(); // ã¹ãã¬ããã·ã¼ãã®æçµè¡ç®ãåå¾ããã321 322 // ã¹ãã¬ããã·ã¼ãã«è¨å
¥323 const reqA = reqForm.getRange(lastRow+1, 1).setValue(timeStamp); // ã¿ã¤ã ã¹ã¿ã³ã324 const reqB = reqForm.getRange(lastRow+1, 2).setValue(mailAddress); // ã¡ã¼ã«ã¢ãã¬ã¹325 const reqC = reqForm.getRange(lastRow+1, 3).setValue(requests); // åãåããã»è¦æ 326 // ãªãã¸ã§ã¯ãã«è¿½å 327 this.timeStamp = timeStamp; // æ¥æ328 this.mailAddress = mailAddress; // ã¡ã¼ã«ã¢ãã¬ã¹329 this.requests = requests; // åãåããå
容330 } else {331 console.log("åãåããã»è¦æãªãï¼");332 }333 }; // WhiteForm()_END334 // ========== [ ã¡ã½ãã ] ãã¼ã¯ã¼ããã©ã¼ã (ã¹ãã¬ããã·ã¼ã)ãPDFå¤æãã¦æå®ãã©ã«ãã«è¿½å ========== //335 336 PdfCreate() {337 console.log("ãPdfCreate å®è¡!ã");338 339 // ãã¼ã¯ã¼ããã©ã¼ã (ã¹ãã¬ããã·ã¼ã)ãpdfå¤æ340 SpreadsheetApp.flush();341 const sheetId = keyForm.getSheetId(); // ã¹ãã¬ããã·ã¼ãã®IDãåå¾342 const url = 'https://docs.google.com/spreadsheets/d/1zzq1OQxTZJOFo2eFaTGkNLyipGWDjl9i-LijcgIU3Hw/export?exportFormat=pdf&gid=SID'.replace('SID', sheetId);343 const token = ScriptApp.getOAuthToken();344 const response = UrlFetchApp.fetch(url, {345 headers:{346 'Authorization': 'Bearer '+token347 }348 });349 350 // å¤æ°ã®åæåã»å®ç¾©351 let fileName; // ãã¼ã¯ã¼ããã¡ã¤ã«ã®ãã¡ã¤ã«å352 let folderId; // ã¢ãããã¼ããã¡ã¤ã«ã®ä¿åå
ãã©ã«ãã®ID353 let folderIdKey = '14YTMjpzTq77UDN-bPT_zAGELWJudJuli'; // ãã¼ã¯ã¼ããã¡ã¤ã«ã®ä¿åå
ãã©ã«ãID354 let keywordUrls = []; // ãã¼ã¯ã¼ããã¡ã¤ã«URLã®é
å355 356 /* ãã¡ã¤ã«å
容ãè±ç¥èã»ããæ
å ±(ã¢ãããã¼ããã¡ã¤ã«ãªã)ã®å ´å //357 // åçãã©ã¼ã ãããã¡ã¤ã«ã®ã¿ã¤ãã«ãä½æã»å
容ãæ¸è¾¼ã //358 // è±ç¥èã»ããæ
å ±ã®ãã©ã«ãã«ä¿å */359 if ( notUploadFile === 'ãªã' ) {360 fileName = [`${littleInfoTitle}.pdf`]; // ãã¡ã¤ã«åãæå®361 // ãã°ç¢ºèªç¨362 console.log("è±ç¥èã»ããæ
å ±ã®ã¢ãããã¼ããã¡ã¤ã«ã¯ããã¾ããï¼");363 console.log(`ãã¡ã¤ã«åã¯ã${littleInfoTitle}.pdf`);364 365 // ä¿åå
ãã©ã«ãã¨åçãã©ã¼ã ã®ä¸è´ãããã©ã«ãIDã [folderId] ã«æ ¼ç´366 contentsIds.forEach( el => {367 if ( fileContents === el.contents ) {368 folderId = el.id;369 console.log(`ãã¡ã¤ã«ã®ä¿åå
ã®ãã©ã«ãåã¯ã${el.contents}ã§ãï¼`);370 }371 });372 373 // ãã¼ã¯ã¼ããã¡ã¤ã«ãæå®ãã©ã«ãã«ä½æ374 } else {375 folderId = folderIdKey; // æå®ãã©ã«ãã®IDãåå¾376 fileName = this.keywordNames;377 }378 // ãã¼ã¯ã¼ããã¡ã¤ã«ãä½æ379 fileName.forEach( el => {380 const blob = response.getBlob().setName(el); // pdfã®åå381 const folder = DriveApp.getFolderById(folderId); // pdfã®ä¿åå
ãã©ã«ããæå®382 const requestForm = folder.createFile(blob); // ãã©ã«ãå
ã«pdfãä½æ383 const keywordUrl = requestForm.getUrl(); // ãã¼ã¯ã¼ããã¡ã¤ã«URLãåå¾384 console.log(`ãã¼ã¯ã¼ããã©ã«ãå
ã«${el}ã追å ãã¾ããï¼`); // ãã°ç¢ºèªç¨385 keywordUrls.push(keywordUrl); // é
åã«è¿½å 386 });387 console.log("keywordUrls(ãã¼ã¯ã¼ããã¡ã¤ã«URLã®é
å):" + keywordUrls); // ãã°ç¢ºèªç¨388 // ãªãã¸ã§ã¯ãã«è¿½å 389 this.keywordUrls = keywordUrls;390 }; // PdfCreate()_END391 // ========== [ ã¡ã½ãã ] ãã¼ã¯ã¼ããã¡ã¤ã«(ã¹ãã¬ããã·ã¼ã)ã®å
容ãã¯ãªã¢ ========== //392 SSRemove() {393 console.log("ãSSRemove å®è¡!ã");394 395 const keyFormLastRow = keyForm.getLastRow(); // ã¹ãã¬ããã·ã¼ãï¼ãã¼ã¯ã¼ãæ¸è¾¼å
ï¼ã®æçµè¡ç®ãåå¾396 keyForm.getRange(1, 1, keyFormLastRow, 2).clearContent(); // æå®ããã»ã«ã®ã³ã³ãã³ããåé¤397 }; // SSRemove()_END398 // ========== [ ã¡ã½ãã ] ã¢ãããã¼ãããå
ãã¡ã¤ã«ãã¢ãããã¼ããã©ã«ãå
ããåé¤ ========== //399 FileTrash() {400 console.log("ãFileTrash å®è¡!ã");401 const delFolder = DriveApp.getFolderById(upfolder) // åé¤ããããã¡ã¤ã«ã®ãã©ã«ã402 const delfiles = delFolder.getFiles(); // åé¤ããããã¡ã¤ã«403 404 // æå®ãããã©ã«ãå
ã«ã¢ãããã¼ãé¢é£ã®ãã¡ã¤ã«ãããã°åé¤405 while(delfiles.hasNext()) {406 const file = delfiles.next(); // ãã¡ã¤ã«ãåå¾407 const fileName = file.getName(); // ãã¡ã¤ã«åãåå¾408 const nameJudge = this.upLoadNames.indexOf(fileName) !== -1; // ãã¡ã¤ã«åã®æç¡å¤å®409 // ãã°ç¢ºèªç¨410 console.log("ãã©ã«ãå
ã«ãã¡ã¤ã«ã確èªã1ã¤åãåºãã¾ãï¼");411 console.log(`åãåºãããã¡ã¤ã«ã¯ã${fileName}ã§ãï¼`)412 // ãã¡ã¤ã«åãä¸è´ãããåé¤ 413 if ( nameJudge ) {414 file.setTrashed(true);415 console.log(`ãã¡ã¤ã«åãä¸è´ããããã${fileName}ãåé¤ãã¾ããï¼`); // ãã°ç¢ºèªç¨416 } else {417 console.log("ã¢ãããã¼ããã¡ã¤ã«ã¨ãã¡ã¤ã«åãä¸è´ãã¾ããã§ããï¼"); // ãã°ç¢ºèªç¨418 }419 }420 }; // FileTrash()_END421 // ========== [ ã¡ã½ãã ] ãã©ã¼ã åçè
ã«ãã¡ã¤ã«ä¿åå®äºéç¥ãéä¿¡ ========== //422 SendMail() {423 424 console.log("ãSendMail å®è¡!ã");425 426 // ã¢ãã¬ã¹ãè¦ã¤ãããªãå ´åã®éä¿¡å
427 const errAddress = 'k.kamikura@isowa.co.jp';428 429 // ååãã»è¦æã«åçããã£ãå ´åã®éä¿¡å
430 const contactAddress = 'k.kamikura@isowa.co.jp';431 432 // isowaããã®ã¢ãã¬ã¹ãè¨è¼ãããã¹ãã¬ããã·ã¼ããåå¾433 const ssId = SpreadsheetApp.openById('1r9Ok3NF0_lwNa2fzCcpttteEim_Kb79xOBLB8GsJjnA');434 const addressSS = ssId.getSheetByName('ã¡ã¼ã«ã¢ãã¬ã¹ä¸è¦§ï¼ISOWAï¼');435 const arrData = addressSS.getDataRange().getValues();436 const addressUrl = 'https://docs.google.com/spreadsheets/d/1r9Ok3NF0_lwNa2fzCcpttteEim_Kb79xOBLB8GsJjnA/edit#gid=0';437 // ã¢ãã¬ã¹ãªã¹ãã®é
åã®è¡ã¨åãå
¥æ¿438 const _ = Underscore.load(); // ã¢ã³ãã¼ã¹ã³ã¢ã使ç¨439 const arrTrans = _.zip.apply(_, arrData); // é
åã®è¡ã¨åãå
¥æ¿440 const resNum = arrTrans[1].indexOf(registPerson); // åçè
åã¨ä¸è´ããè¡çªå·(éå§No:0)441 // ãã¡ã¤ã«URL442 let setKeywordUrl, setUrls;443 if ( this.keywordUrl !== undefined ) setKeywordUrl = this.keywordUrl;444 if ( this.fileUrls !== undefined ) setUrls = this.fileUrls;445 // åãåããã»è¦æãã©ã¼ã ã®URL446 const requestsUrl = "https://forms.gle/GkYxu4ENEmq2RzvX9";447 // ã¡ã¼ã«éä¿¡ç¨448 let reply; // ã¡ã¼ã«éä¿¡å
449 let title; // ã¡ã¼ã«ã¿ã¤ãã«450 let content; // ã¡ã¼ã«æ¬æ451 // ã¢ãããã¼ããã¡ã¤ã«åã¨URLã®æè¨452 let setNameUrl = SetNamesUrls(this.fileRenames) 453 // ç»é²è
(C)ã«ã¢ãããã¼ãå®äºéç¥ã¡ã¼ã«ãéä¿¡454 if ( resNum !== -1 ) {455 console.log("ç»é²è
ã«ã¢ãããã¼ãå®äºéç¥ãéä¿¡ï¼");456 reply = arrTrans[2][resNum];457 title = 'ãiãµã¼ãããã¡ã¤ã«ã®ã¢ãããã¼ãå®äºéç¥';458 content = '\459 ${registPerson}ãã\n\460 \n\461 ãã¤ããä»äºãç²ãæ§ã§ãã\n\462 iãµã¼ãã«è²´éãªè³æã®ç»é²ããããã¨ããããã¾ãã\n\463 ãã¼ã¯ã¼ããã¡ã¤ã«ï¼\n\464 ${setKeywordUrl}\n\n\465 ã¢ãããã¼ããã¡ã¤ã«ï¼\n\466 ${setNameUrl}\n\467 \n\468 ãããæ§ã§ISOWAãããå®å¿ãã¦æ¥åãè¡ãäºãã§ãã¾ãã\n\469 \n\470 æ¹åã»ä¸æç¹çããã¾ãããããæ°è»½ã«åãåãããã©ã¼ã \n\471 ãããé£çµ¡ä¸ããã\n\472 ${requestsUrl}'473 .replace('${registPerson}', registPerson)474 .replace('${setKeywordUrl}', setKeywordUrl)475 .replace('${setNameUrl}', setNameUrl)476 .replace('${requestsUrl}', requestsUrl);477 // ã¡ã¼ã«ãéä¿¡478 MailContents( reply, title, content );479 // ç»é²è
ã®ã¢ãã¬ã¹ãä¸æãªå ´åãerrAddressã«ã¡ã¼ã«éä¿¡480 } else {481 console.log("ç»é²è
ãè¦ã¤ããã¾ããã§ãããå ±åã¡ã¼ã«ãéä¿¡ï¼");482 reply = errAddress;483 title = 'ãiãµã¼ããã¢ãããã¼ããã¡ã¤ã«ç»é²è
ã®ã¢ãã¬ã¹ãè¦ã¤ããã¾ããã§ããã';484 content = '\485 iãµã¼ãéå¶ãã¼ã ã®ã¿ãªãã¾\n\486 \n\487 ãã¤ããä»äºãç²ãæ§ã§ãã\n\488 iãµã¼ãã«ãã¡ã¤ã«ãã¢ãããã¼ããã${registPerson}ããã®\n\489 ã¢ãã¬ã¹ãè¦ã¤ããã¾ããã§ããã\n\490 ãã¼ã¯ã¼ããã¡ã¤ã«ï¼\n\491 ${setKeywordUrl}\n\n\492 ã¢ãããã¼ããã¡ã¤ã«ï¼\n\493 ${setNameUrl}\n\494 ã¢ãã¬ã¹ãªã¹ãï¼${addressUrl}\n\495 \n\496 ç»é²è
åã¨ã¢ãã¬ã¹ãªã¹ã(ã¹ãã¬ããã·ã¼ã)ã\n\497 確èªãé¡ããã¾ãã'498 .replace('${registPerson}', registPerson)499 .replace('${setNameUrl}', setNameUrl)500 .replace('${setKeywordUrl}', setKeywordUrl)501 .replace('${addressUrl}', addressUrl);502 503 // ã¡ã¼ã«ãéä¿¡504 MailContents( reply, title, content );505 };506 507 508 // ååãã»è¦æã«åçããã£ãå ´åãã¡ã¼ã«ãéä¿¡509 if ( requests !== "" ) {ã510 console.log("ååãã»è¦æããã£ãã®ã§éç¥ã¡ã¼ã«ãéä¿¡ï¼");511 reply = contactAddress;512 title = 'ãiãµã¼ãããã©ã¼ã ããåãåããã»è¦æãããã¾ããã';513 content = '\514 iãµã¼ãéå¶ãã¼ã ã®ã¿ãªãã¾\n\515 \n\516 ãã¤ããä»äºãç²ãæ§ã§ãã\n\517 iãµã¼ãã«ãã¡ã¤ã«ãã¢ãããã¼ããã${registPerson}ãããã\n\518 以ä¸ã®åãåããã»è¦æãããã¾ããã\n\519 \n\520 ${requests}\n\521 ãããããé¡ããã¾ãã\n\522 '523 .replace('${requests}', requests)524 .replace('${registPerson}', registPerson)525 526 // ã¡ã¼ã«ãéä¿¡527 MailContents( reply, title, content );528 }529 530 // [é¢æ°]ã¢ãããã¼ããã¡ã¤ã«åã»URLã®æè¨531 function SetNamesUrls(fileRenames) {532 // å¤æ°ã®å®ç¾©ã»åæå533 let nameAndUrl;534 let i = 0;535 536 // ãã¡ã¤ã«åã»URLãæ¸è¾¼537 setUrls.forEach( setUrl => {538 const name = fileRenames[i]; 539 const url = setUrl;540 // ååå®è¡541 if ( i === 0) {542 nameAndUrl = `${name}\n\ ã${url}\n\543 `544 // 2åç®ä»¥é545 } else {546 nameAndUrl += ` ${name}\n\ ã${url}\n\547 `548 }549 i++; // 次ã®ãã¡ã¤ã«ãåå¾550 })551 return nameAndUrl; // setNameUrlã¸è¿å´552 }; // SetNamesUrls()_END553 // [é¢æ°]ã¡ã¼ã«éä¿¡554 function MailContents( reply, title, content ) {555 556 console.log("MailContents å®è¡!");557 558 // ã¡ã¼ã«ã®éä¿¡æ
å ±559 const to = reply; // éä¿¡å
560 const subject = title; // ã¿ã¤ãã«561 const body = content; // æ¬æ562 const options = { name: 'iãµã¼ã', // éä¿¡å
ã®åå563 bcc: 'k.kamikura@isowa.co.jp' // bcc éä¿¡å
564 }565 // éä¿¡å®è¡ 566 GmailApp.sendEmail(567 to,568 subject,569 body,570 options571 )572 573 }; // MailContents()_END574 }; // SendMail()_END575 }; // Class Obj()_END576 // === ãªãã¸ã§ã¯ããä½æ(ã¢ãããã¼ããã¡ã¤ã«ã»ãã¼ã¯ã¼ããã¡ã¤ã«ãæå®ãã©ã«ãã«ä½æ) === //577 const objArr = []; // é
åãåæå578 const obj = new Obj(); // ãªãã¸ã§ã¯ã{obj}ä½æ579 obj.GetFileData(); // ã¢ãããã¼ããã¡ã¤ã«ã»ãã¼ã¯ã¼ããã¡ã¤ã«åãå¤æ´580 obj.FileMove(); // æå®ãã©ã«ãã«ã¢ãããã¼ããã¡ã¤ã«ã®ã³ãã¼ã追å 581 obj.WhiteForm(); // ãã©ã¼ã åçããã¼ã¯ã¼ããã¡ã¤ã«(ã¹ãã¬ããã·ã¼ã)ã«æ¸è¾¼582 obj.PdfCreate(); // ãã¼ã¯ã¼ããã¡ã¤ã«(ã¹ãã¬ããã·ã¼ã)ãPDFå¤æãã¦æå®ãã©ã«ãã«è¿½å 583 obj.SSRemove(); // ãã¼ã¯ã¼ããã¡ã¤ã«(ã¹ãã¬ããã·ã¼ã)ã®å
容ãã¯ãªã¢584 obj.FileTrash(); // ã¢ãããã¼ãããå
ãã¡ã¤ã«ãã¢ãããã¼ããã©ã«ãå
ããåé¤585 obj.SendMail(); // ãã©ã¼ã åçè
ã«ãã¡ã¤ã«ä¿åã®å®äºéç¥ãéä¿¡586 objArr.push(obj); // é
å[objArr]ã«ãªãã¸ã§ã¯ãã追å 587 console.log(objArr); // ãã°ç¢ºèªç¨588}; // Main()_END589// æå®ãã©ã«ãå
ã«ãã¡ã¤ã«ãåå¨ããªãå ´åã¯ã5ç§éã¹ãªã¼ã *** 対çã½ãã_20210219 ***590function SleepTimer(upLoadFolId) {591 let now = Utilities.formatDate(new Date(), "Asia/Tokyo", "HH:mm:ss"); // ç¾å¨ã®æé592 console.log("now(ç¾å¨æé):" + now); // ç¾å¨æéã®è¡¨ç¤º593 folder = DriveApp.getFolderById(upLoadFolId); // ã³ãã¼å
ãã¡ã¤ã«ã®ãã©ã«ã594 files = folder.getFiles(); // ã³ãã¼å
ãã¡ã¤ã«595 let staySecond = 5; // é
延æéã®è¨å®(ç§)596 Utilities.sleep(staySecond * 1000); // é
延å®è¡597};598/* 599ã» ã¢ãããã¼ããã¡ã¤ã«ã®ãã¡ã¤ã«ååå¾(æ¡å¼µåç¡ã) >>> å®äº600ã» ãã¼ã¯ã¼ããã¡ã¤ã«(ã¹ãã¬ããã·ã¼ã)ã«ãã¼ã¯ã¼ããæ¸è¾¼ >>> å®äº 601ã» ã ããã¡ã¤ã«å_ãã¼ã¯ã¼ãã«renameã»pdfå¤æããæå®ãã©ã«ãã«ä¿å >>> å®äº602ã» ã¢ãããã¼ããã¡ã¤ã«ãæå®ã®ãã©ã«ãã«ç§»å >>> å®äº603ã» ã¢ãããã¼ããã¡ã¤ã«ã®URLãã¹ãã¬ããã·ã¼ãã«æ¸è¾¼ >>> å®äº604ã» ãã¼ã¯ã¼ããã¡ã¤ã«(ã¹ãã¬ããã·ã¼ã)ã®å
容ãã¯ãªã¢ >>> å®äº605ã» ã¢ãããã¼ããã¡ã¤ã«ãåé¤ >>> å®äº606ã» é
å[keyword], [getData]ã®å
å®¹ç¢ºèª >>> å®äº607ã» åå¾ããæ
å ±ãå¤æ´ããå ´åã§ãããã«ä¿®æ£ã§ããæ§ã«ããã >>> å®äº608ã» åæå®è¡æã®å¦ç対ç >>> å®äº609ã» ã¢ãããã¼ããã¡ã¤ã«åãå¤æ´(ç»é²è
åãåé¤) >>> å®äº610ã» ã¡ã¼ã«ãéä¿¡ >>> å®äº611ã» ã¨ã©ã¼ã¨ãªã£ãå ´åã«ã¨ã©ã¼å
容ãã¡ã¼ã«ã§éç¥ã >>> å®äº612ã» ç»é²è
åã«ã¹ãã¼ã¹ããã£ãå ´åã¯ãã¹ãã¼ã¹ãåé¤ãã¦æ ¼ç´ããã >>> å®äº613ã» ã¢ãããã¼ããã¡ã¤ã«ãè¤æ°ç»é²ããå ´åã«å¯¾å¿ããã >>> å®äº614ã» ã¢ãããã¼ããã¡ã¤ã«ãGOOGLEãã©ã¤ãã®ãã©ã«ãã«ä¿åãããã¾ã§615ã ã¿ã¤ã ã©ã°ããããï½ç´40ç§616 >>> ãã©ã«ãå
ã«ãã¡ã¤ã«ãç¡ãã£ãå ´åã5ç§éå¾
ã£ã¦å度ãã¡ã¤ã«617 ãã ã®åå¨ç¢ºèªãè¡ãå¦çã追å ã >>> å®äº â»1618ã» ä¸è¨ã®åå¨ç¢ºèªã®å¦çãè¡ãæ¡ä»¶ã«ã¢ãããã¼ããã¡ã¤ã«ç»é²ããã£ãå ´åã追å ã >>> å®äº619ã» å
¨ã¦ã®ã¹ã¯ãªããå®è¡å¾ã«ä½ãè¡ãä½ãè¡ãããªãã£ãã®ããããããã« >>> å®äº620ã ãã°ã«æ®ãæ§ã«ããã621ã¡ã¼ã«éç¥ã½ããã«ã¤ãã¦622ã» åãåããã»è¦æã®ãªã³ã¯ãè²¼ã£ãæ¹ã親åã >>> å®äº623â»1 5ç§éé
延ãããã«ã¼ãå¦çãæãã¦ãã¾ãæ¡ä»¶624ããâ ååã®ã¢ãããã¼ãå¦ç(ã¹ã¯ãªããã®å®è¡)ãå®äºãã¦ããªãã625ããã ãã©ã«ãå
ã«ååã®ãã¡ã¤ã«ãæ®ã£ã¦ããå ´åã626ãã Googleãã©ã¼ã ããéä¿¡ããæç¹ã§ã¢ãããã¼ããã¡ã¤ã«ã¯627ããã ãã©ã«ãã«ä¿åããã¦ãã¾ããããååã®ãã¡ã¤ã«ãæ®ããªã628ããã æ§ã«ããåé¿æ¹æ³ã¯ãªãã629ããâ¡ è¤æ°ã®ãã¡ã¤ã«ãã¢ãããã¼ãããå ´åãå
¨ã¦åæã«ä¿åããã630ããã ããã§ã¯ç¡ãã¨1ã¤ç®ã®ãã¡ã¤ã«ãä¿åãããæç¹ã§ã¢ã³ããã¼ã631ããã å¦ç(ã¹ã¯ãªããã®å®è¡)ã¯éå§ãã¦ãã¾ãã632ããã å
¨ã¦ã®ãã¡ã¤ã«ãä¿åãããæéã稼ãããã«ããã¡ã¤ã«1ã¤ã®633ããã å¦çæéã伸ã°ãã(ãã®éã«2ã¤ç®ä»¥éã®ãã¡ã¤ã«ãä¿åããã634ããã ã®ãå¾
ã¤)635ãã⢠ååã®ã¢ãããã¼ãå¦ç(ã¹ã¯ãªããã®å®è¡)ãå®äºããå¾ãä½ã636ããã ãã®è¦å ã§ãã©ã«ãå
ã«ãã¡ã¤ã«ãæ®ã£ã¦ãã¾ã£ãå ´åã637ããã ã¹ã¯ãªãã(FileTrash)ã§ä½ããã®å¯¾çãè¡ãã...
database.test.js
Source:database.test.js
...54 });55});56describe('getAnswers method', () => {57 test('Call getAnswers with correct ID', async () => {58 expect(await db.getAnswers(1, 1)).toStrictEqual([{59 id: 1,60 score: 0,61 text: 'leave the smoking area then..',62 user_id: 1,63 currentUserHasVoted: false,64 }]);65 });66 test('Call getAnswers with incorrect ID', async () => {67 expect(await db.getAnswers(-1, 1)).toStrictEqual([]);68 });69});70describe('validQuestionId method', () => {71 test('Call validQuestionId with correct ID', async () => {72 expect(await db.validQuestionId(1)).toBe(true);73 });74 test('Call validQuestionId with incorrect ID', async () => {75 expect(await db.validQuestionId(-1)).toBe(false);76 });77});78describe('insertUser method', () => {79 test('Call insertUser with already taken details', async () => {80 expect(await db.insertUser(81 'test-email@test.ac.uk',82 '5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8',83 )).toBe(-1);84 });85 test('Call insertUser with new details', async () => {86 expect(await db.insertUser(87 'Sams-email@test.ac.uk',88 '5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8',89 )).toEqual(expect.any(Number));90 });91});92describe('insertQuestion method', () => {93 test('Call insertQuestion with new details', async () => {94 expect(await db.insertQuestion(95 1,96 'Test question, please ignore',97 'Test Question - Working',98 )).toEqual(expect.any(Number));99 });100 // test('Call insertQuestion with incorrect details', async () => {101 // expect(await db.insertQuestion(102 // 'one',103 // 2,104 // 3,105 // )).mockReturnValue(new Error('error: column "one" does not exist'));106 // });107});108describe('insertAnswer method', () => {109 test('Call insertAnswer to insert new answer', async () => {110 expect(await db.insertAnswer(2,111 2,112 'Have you tried turning it off and on again?'));113 });114 test('Call getAnswers with newly inserted answer', async () => {115 expect(await db.getAnswers(2, 2)).not.toBe([]);116 });117});118describe('voteOnAnswer method', () => {119 test('Call voteOnAnswer with an upvote', async () => {120 expect(await db.voteOnAnswer(1, 1));121 });122 test('Call getAnswers to check new score', async () => {123 expect(await db.getAnswers(1, 1)).toStrictEqual([{124 id: 1,125 score: 1,126 text: 'leave the smoking area then..',127 user_id: 1,128 currentUserHasVoted: true,129 }]);130 });131 test('Call voteOnAnswer with a downvote', async () => {132 expect(await db.voteOnAnswer(1, 1));133 });134 test('Call getAnswers to check new score', async () => {135 expect(await db.getAnswers(1, 1)).toStrictEqual([{136 id: 1,137 score: 0,138 text: 'leave the smoking area then..',139 user_id: 1,140 currentUserHasVoted: false,141 }]);142 });143});144describe('searchQuestions method', () => {145 test('Call searchQuestions without a value. Show all items, newest first', async () => {146 expect(await db.searchQuestions('')).not.toBe([]);147 });148 test('Call searchQuestions with criteria in order of similarity', async () => {149 expect(await db.searchQuestions("I need air! I can''t breath!"));...
survey.js
Source:survey.js
...116 };117 this.getAnswers = function() {118 var answers = {};119 for (var i = 0; i < questions.length; i++) {120 answers[questions[i].title] = questions[i].getAnswers();121 }122 return answers;123 };124}125function Survey(title, sections) {126 this.toHTML = function() {127 var result = "<h1>" + title + "</h1>\n";128 for (var i = 0; i < sections.length; i++) {129 result += sections[i].toHTML();130 }131 result += '<input id="submit" type="button" value="SUBMIT">\n';132 return result;133 };134 this.getAnswers = function() {135 var answers = {};136 for (let i = 0; i < sections.length; i++) {137 answers[sections[i].title] = sections[i].getAnswers();138 }139 return answers;140 }; 141}142function submit() {143 console.log("Answers Submitted");144}145window.addEventListener("load", function() {146 var survey = createSurveyQuestions();147 function submit() {148 console.log("Answers Submitted");149 console.log(survey.getAnswers());150 }151 document.getElementById("survey").innerHTML = survey.toHTML();152 document.getElementById("submit").addEventListener("click", submit);...
script.js
Source:script.js
1// accordion menu2// Script waarmee de afzonderlijke vragen worden geopend door erop te klikken345{6 window.addEventListener("pageshow", faqMenu);7 const getQuestions = document.getElementsByClassName('question');8 const getAnswers = document.getElementsByClassName('answer');9 const getImages = document.getElementsByTagName('img');10 const arrowImages = [];11 const getAnswersHeight = [];1213 function faqMenu() {14 // verberg alle vragen15 for (let i = 0; i < getAnswers.length; i++) {16 getAnswersHeight.push(getAnswers[i].scrollHeight);17 getAnswers[i].style.visibility = "hidden";18 getAnswers[i].style.height = "0px";19 getAnswers[i].style.opacity = 0;20 getAnswers[i].style.padding = "0px 0px 0px 0px"21 }22 console.log(document.getElementsByClassName('box')[0]);232425 // vind alle arrow-images op de pagina26 for (let i = 0; i < getImages.length; i++) {27 if (getImages[i].alt === "arrow") {28 arrowImages.push(getImages[i]);29 console.log(arrowImages);30 }31 }32 //als mouseover vragen maak vraag rood en voeg muishandje toe en verplaats doosje33 for (let i = 0; i < getQuestions.length; i++) {34 getQuestions[i].onmouseover = function () { mouseOver() };35 function mouseOver() {36 getQuestions[i].style.color = "hsl(14, 88%, 65%)";37 getQuestions[i].style.cursor = "pointer";38 document.getElementsByClassName('box')[0].style.right = "130px";39 document.getElementsByClassName('box')[0].style.transition = "all 0.3s";40 // als vraag = open geen rode kleur of pointer41 if (getQuestions[i].style.fontWeight === "700") {42 getQuestions[i].style.color = "hsl(237, 12%, 33%)";43 getQuestions[i].style.cursor = "auto";44 }45 }46 // als muishandje naar volgende vraag gaat --> andere vragen zwart47 getQuestions[i].onmouseout = function () { mouseOut() };48 function mouseOut() {49 getQuestions[i].style.color = "hsl(237, 12%, 33%)";50 document.getElementsByClassName('box')[0].style.right = "90px";51 }52 //als ik op de vraag klik maak antwoord zichtbaar53 getQuestions[i].onmousedown = function () { mouseClick(); }54 function mouseClick() {55 //Sluit alle vragen waar al op geklikt is56 for (let i = 0; i < getQuestions.length; i++) {57 if (getAnswers[i].style.height !== "0px") {58 getAnswers[i].style.height = "0px";59 getAnswers[i].style.padding = "0px 0px 0px 0px";60 getAnswers[i].style.visibility = "hidden";61 getQuestions[i].style.fontWeight = "400";62 getAnswers[i].style.opacity = 0;63 arrowImages[i].style.transform = "rotate(0deg)";64 getQuestions[i].style.color = "hsl(237, 12%, 33%)";6566 }67 }68 //open vraag en maak deze vet en draai het pijltje69 getQuestions[i].style.color = "hsl(238, 29%, 16%)";70 getQuestions[i].style.fontWeight = "700";71 arrowImages[i].style.transform = "rotate(180deg)";72 arrowImages[i].style.transition = "all 0.3s"73 getAnswers[i].style.visibility = "visible";74 getAnswers[i].style.height = getAnswersHeight[i] + 'px';75 getAnswers[i].style.padding = "15px 30px 0px 0px";76 getAnswers[i].style.opacity = 1;77 getAnswers[i].style.transition = "opacity 1.2s, height 0.3s, padding 0.2s";78 }79 }80 }81}82// console.log(document.getElementsByClassName('box')[0].offsetLeft);83// console.log(getAnswers[i].style.visibility);84// console.log(document.getElementsByClassName('box')[0].offsetLeft);85// console.log(getAnswers[i].style.visibility);86
...
Session.js
Source:Session.js
1import React, {useState, Fragment} from 'react';2import '../../App.css';3import Single from "./QuestionType/Single";4import Text from "./QuestionType/Text";5import Multy from "./QuestionType/Multy";6import {Button} from '@material-ui/core'7import toast from "../../utils/toast";8import {Redirect} from 'react-router-dom';9export default function Session({initialData, id}) {10 const [getAnswers, setAnswers] = useState([]);11 const [getRedirect, setRedirect] = useState();12 if(getRedirect){13 return <Redirect push to={getRedirect}/>14 }15 const sendData = () =>{16 fetch(`http://${process.env.REACT_APP_SERVER_HOST}:8000/question_answers`, {17 method: 'POST',18 headers: {19 'Content-Type': 'application/json',20 'x-access-token': localStorage.getItem('auth_token')21 },22 body: JSON.stringify(getAnswers)23 })24 .then(async (res) => {25 if(res.status != 200){26 res = await res.json();27 toast.error(res.message)28 }else{29 res = await res.json();30 toast.success(res.message)31 setRedirect(`/istrazivanja`);32 }33 })34 }35 const renderQuestion = () =>{36 if(!initialData || !initialData.length){37 return <div>Test</div>38 }else{39 return initialData.map((question, index) =>{40 switch (question.type) {41 case 'SINGLE':42 return <Single43 getAnswers={getAnswers}44 setAnswers={setAnswers}45 key={"_" + index}46 index={index + 1}47 initialData={question}/>48 case 'TEXT':49 return <Text50 getAnswers={getAnswers}51 setAnswers={setAnswers}52 key={"_" + index}53 index={index + 1}54 initialData={question}/>55 case 'MULTY':56 return <Multy57 getAnswers={getAnswers}58 setAnswers={setAnswers}59 key={"_" + index}60 index={index + 1}61 initialData={question}/>62 }63 })64 }65 }66 return (67 <>68 {renderQuestion()}69 <Button70 variant="contained"71 color="primary"72 onClick={() =>{73 sendData()74 }}75 >76 Potvrdi77 </Button>78 </>79 )...
sequencetest.js
Source:sequencetest.js
...20 it('should return 4', function () {21 assert.deepEqual(sequence.getAnswer(4), 4)22 })23 })24 describe('#getAnswers()', function () {25 it('should return first 10 integer numbers', function () {26 assert.deepEqual(sequence.getAnswers(4), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])27 })28 })29 })30 describe('Square', function () {31 const sequence = new Sequence([], 'square')32 describe('#getAnswer()', function () {33 it('should return 5', function () {34 assert.deepEqual(sequence.getAnswer(4), 16)35 })36 })37 describe('#getAnswers()', function () {38 it('should return first 10 square numbers', function () {39 assert.deepEqual(sequence.getAnswers(4), [ 0, 1, 4, 9, 16, 25, 36, 49, 64, 81 ])40 })41 })42 })43 describe('Cubic', function () {44 const sequence = new Sequence([], 'cubic')45 describe('#getAnswer()', function () {46 it('should return 5', function () {47 assert.deepEqual(sequence.getAnswer(4), 64)48 })49 })50 describe('#getAnswers()', function () {51 it('should return first 10 cubic numbers', function () {52 assert.deepEqual(sequence.getAnswers(4), [ 0, 1, 8, 27, 64, 125, 216, 343, 512, 729 ])53 })54 })55 })56 describe('Prime', function () {57 const sequence = new Sequence([], 'prime')58 describe('#getAnswer()', function () {59 it('should return 11', function () {60 assert.deepEqual(sequence.getAnswer(4), 11)61 })62 })63 describe('#getAnswers()', function () {64 it('should return first 10 prime numbers', function () {65 assert.deepEqual(sequence.getAnswers(4), [ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29 ])66 })67 })68 })69 describe('Fibonacci', function () {70 const sequence = new Sequence([], 'fibonacci')71 describe('#getAnswer()', function () {72 it('should return 5', function () {73 assert.deepEqual(sequence.getAnswer(4), 5)74 })75 })76 describe('#getAnswers()', function () {77 it('should return first 10 fibonacci numbers', function () {78 assert.deepEqual(sequence.getAnswers(4), [ 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 ])79 })80 })81 })...
angular-answer-controller.js
Source:angular-answer-controller.js
...5 $scope.post = postAndUser;6 },7 answer: function(newAnswer) {8 $scope.answer = {};9 $scope.getAnswers();10 },11 newAnswerError: function(err) {12 $scope.newAnswerErrors = '';13 $scope.newAnswerErrors = err;14 },15 getAnswers: function(answersCommentsAndUsers) {16 $scope.allAnswers = answersCommentsAndUsers;17 },18 upVote: function() {19 $scope.getAnswers();20 },21 downVote: function() {22 $scope.getAnswers();23 },24 comment: function(newComment) {25 // console.log($scope.allAnswers);26 for (var i = 0; i < $scope.allAnswers.length; i++) {27 $scope.allAnswers[i].newUserComment = {};28 if (i == $scope.allAnswers.length - 1) {29 $scope.getAnswers();30 }31 };32 },33 commentError: function(err) {34 $scope.newCommentErrors = '';35 $scope.newCommentErrors = err;36 },37 logout: function() {38 $location.url('/');39 },40 };41 // Get Post/Topic:42 $scope.getPost = function() {43 answerFactory.getPost($routeParams.id, cb.getPost);44 };45 // Get Post/Topic on partial load:46 $scope.getPost();47 // Create New Answer:48 $scope.newAnswer = function(post) {49 $scope.answerData = {50 description: $scope.answer.description,51 postID: post._id,52 };53 answerFactory.newAnswer($scope.answerData, cb.answer, cb.newAnswerError);54 };55 // Get All Answers:56 $scope.getAnswers = function() {57 answerFactory.getAnswers({postID: $routeParams.id}, cb.getAnswers);58 };59 // Get All Answers on page load:60 $scope.getAnswers();61 // Up Vote:62 $scope.upVote = function(answer) {63 answerFactory.upVote({id: answer._id}, cb.upVote)64 };65 // Down Vote:66 $scope.downVote = function(answer) {67 answerFactory.downVote({id: answer._id}, cb.downVote)68 };69 // Create a Comment:70 $scope.newComment = function(answer) {71 answer.newUserComment.answerID = answer._id;72 answerFactory.newComment(answer.newUserComment, cb.comment, cb.commentError);73 };74 // Dashboard Home Button:...
getAnswers.spec.js
Source:getAnswers.spec.js
1import store from "@/store/";2describe("question/getAnswers getter", () => {3 beforeEach(() => {4 store.commit("question/SET_ANSWERS", require("./.fixtures/answers"));5 });6 it("Returns only root answers by default", () => {7 expect(store.getters["question/getAnswers"]()).toHaveLength(3);8 });9 it("Returns root answers if parent is null", () => {10 expect(store.getters["question/getAnswers"]({ parent: null })).toHaveLength(3);11 });12 it("Does not die when answers are empty", () => {13 store.commit("question/SET_ANSWERS", null);14 expect(store.getters["question/getAnswers"]()).toEqual([]);15 });16 it("Returns answer objects", () => {17 const answer = store.getters["question/getAnswers"]()[1];18 expect(answer).toMatchObject({19 slug: "0275ad47-6f33-4541-b5c6-4641dc6ea006",20 author: {21 first_name: "ÐеÑÑовиÑ",22 last_name: "",23 },24 });25 });26 it("Returns answers with given parent", () => {27 expect(store.getters["question/getAnswers"]({ parent: "21ad3f0a-1c6f-4d8c-ab9e-e8ae49f78cdc" })).toHaveLength(2);28 });29 it("Returns no answers for not matching queries", () => {30 expect(store.getters["question/getAnswers"]({ parent: "88b04599-b184-4620-a588-7447a525d2db" })).toHaveLength(0);31 });32});33describe("question/getAnswers getter sorting", () => {34 beforeEach(() => {35 store.commit("question/SET_ANSWERS", require("./.fixtures/answers"));36 });37 it("Answers are sorted by created time ASC by default", () => {38 const answers = store.getters["question/getAnswers"]();39 expect(answers[0].slug).toEqual("d957725b-e485-4d31-bb7a-1c3bee9b6327");40 });41 it("Answers are sorted by created time ASC if asked", () => {42 store.commit("question/SET_ANSWER_SORTING_ORDER", "asc");43 const answers = store.getters["question/getAnswers"]();44 expect(answers[0].slug).toEqual("d957725b-e485-4d31-bb7a-1c3bee9b6327");45 });46 it("Answers are sorted by created time DESC if asked", () => {47 store.commit("question/SET_ANSWER_SORTING_ORDER", "desc");48 const answers = store.getters["question/getAnswers"]();49 expect(answers[2].slug).toEqual("d957725b-e485-4d31-bb7a-1c3bee9b6327");50 });...
Using AI Code Generation
1var webdriverio = require('webdriverio');2var options = { desiredCapabilities: { browserName: 'chrome' } };3 .remote(options)4 .init()5 .getTitle().then(function(title) {6 console.log('Title was: ' + title);7 })8 .end();
Using AI Code Generation
1var webdriverio = require('webdriverio');2var options = { desiredCapabilities: { browserName: 'chrome' } };3var client = webdriverio.remote(options);4 .init()5 .getTitle().then(function(title) {6 console.log('Title was: ' + title);7 })8 .end();
Using AI Code Generation
1var webdriverio = require('webdriverio');2var options = { desiredCapabilities: { browserName: 'chrome' } };3var client = webdriverio.remote(options);4 .init()5 .getTitle().then(function(title) {6 console.log('Title was: ' + title);7 })8 .end();9module.exports = {
Using AI Code Generation
1describe('webdriver.io page', () => {2 it('should have the right title', () => {3 const title = browser.getTitle();4 expect(title).toBe('WebdriverIO · Next-gen browser and mobile automation test framework for Node.js');5 });6 it('should have the right title', () => {7 const title = browser.getTitle();8 expect(title).toBe('WebdriverIO · Next-gen browser and mobile automation test framework for Node.js');9 });10});11* **Nikita Kulkarni** - *Initial work* - [Nikita Kulkarni](
Using AI Code Generation
1var webdriverio = require('webdriverio');2var options = { desiredCapabilities: { browserName: 'chrome' } };3 .remote(options)4 .init()5 .getTitle().then(function(title) {6 console.log('Title was: ' + title);7 })8 .end();
Using AI Code Generation
1var webdriverio = require('webdriverio');2describe('Stackoverflow', function() {3 it('should return answers', function() {4 var options = {5 desiredCapabilities: {6 }7 };8 .remote(options)9 .init()10 .setValue('#search input[name="q"]', 'webdriverio')11 .click('#search input[type="submit"]')12 .getTitle().then(function(title) {13 console.log('Title was: ' + title);14 })15 .end();16 });17});
Using AI Code Generation
1var webdriverio = require('webdriverio');2var options = { desiredCapabilities: { browserName: 'chrome' } };3var client = webdriverio.remote(options);4.init()5.getTitle().then(function(title) {6 console.log('Title was: ' + title);7})8.getTagName('body').then(function(tagName) {9 console.log('Tag name of body: ' + tagName);10})11.getTagName('input').then(function(tagName) {12 console.log('Tag name of input: ' + tagName);13})14.end();
Wondering what could be a next-gen browser and mobile test automation framework that is also simple and concise? Yes, that’s right, it's WebdriverIO. Since the setup is very easy to follow compared to Selenium testing configuration, you can configure the features manually thereby being the center of attraction for automation testing. Therefore the testers adopt WedriverIO to fulfill their needs of browser testing.
Learn to run automation testing with WebdriverIO tutorial. Go from a beginner to a professional automation test expert with LambdaTest WebdriverIO tutorial.
Running Your First Automation Script - Learn the steps involved to execute your first Test Automation Script using WebdriverIO since the setup is very easy to follow and the features can be configured manually.
Selenium Automation With WebdriverIO - Read more about automation testing with WebdriverIO and how it supports both browsers and mobile devices.
Browser Commands For Selenium Testing - Understand more about the barriers faced while working on your Selenium Automation Scripts in WebdriverIO, the ‘browser’ object and how to use them?
Handling Alerts & Overlay In Selenium - Learn different types of alerts faced during automation, how to handle these alerts and pops and also overlay modal in WebdriverIO.
How To Use Selenium Locators? - Understand how Webdriver uses selenium locators in a most unique way since having to choose web elements very carefully for script execution is very important to get stable test results.
Deep Selectors In Selenium WebdriverIO - The most popular automation testing framework that is extensively adopted by all the testers at a global level is WebdriverIO. Learn how you can use Deep Selectors in Selenium WebdriverIO.
Handling Dropdown In Selenium - Learn more about handling dropdowns and how it's important while performing automated browser testing.
Automated Monkey Testing with Selenium & WebdriverIO - Understand how you can leverage the amazing quality of WebdriverIO along with selenium framework to automate monkey testing of your website or web applications.
JavaScript Testing with Selenium and WebdriverIO - Speed up your Javascript testing with Selenium and WebdriverIO.
Cross Browser Testing With WebdriverIO - Learn more with this step-by-step tutorial about WebdriverIO framework and how cross-browser testing is done with WebdriverIO.
Get 100 minutes of automation test minutes FREE!!