unzu127

ミリシタカツドウ

Jun 17th, 2018
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.40 KB | None | 0 0
  1. https://docs.google.com/spreadsheets/d/1CpwNLrurUVVLX2dmMgZHU-uQC7WQfyfWqLlaiooRaN8/edit#gid=0
  2. http://sokudon.s17.xrea.com/gg.html ←自分用
  3.  
  4.  
  5. https://docs.google.com/spreadsheets/d/1htAsRAyEl5zwwNlb5PhrVIqSrT1h3U5zmHR-UUSoP-Y/edit?usp=sharing ← お試しよう
  6. http://sokudon.s17.xrea.com/gtes.html ← お試しよう
  7.  
  8. スクショがゴッゴル先生de txtjson変換器、すこあがひろいずらい [67]桁限定にするるか
  9. http://sokudon.s17.xrea.com/mirisita_katudou_calc.html
  10.  
  11. //sample json
  12. {"出勤日数":"126日","覚醒回数":"165回","マスターレッスン回数":"154回","カード枚数":"340枚","ファン数":"223,042人","メインコミュ達成数":"60本","メモリアルコミュ達成数":"155本","エピソードコミュ達成数":"161本","ライブ成功回数":"1,317回","ライブフルコンボ回数":"313回","フラスタを貰った数":"347回","フラスタを贈った数":"557回","お仕事回数":"1,463回","入手衣装数":"113着","プロデューサーゲージMAX回数":"89回","time":"2018/06/12 18:02"}
  13.  
  14.  
  15. JSON_TESTER をじこ記録用に変更
  16. https://docs.google.com/spreadsheets/d/1u9uRPvj5_DRz5z8mR7mV4DOm4X0PgF12zMf_ZStmKC0/edit#gid=0
  17.  
  18.  
  19. 実行からsetupを2回,apikを発行 実行設定と共有設定で編集権限をこまかくいじれる?
  20. //共有が必要
  21.  
  22. // 1. Enter sheet name where data is to be written below
  23.  
  24. // 2. Run > setup
  25. //
  26. // 3. Publish > Deploy as web app
  27. // - enter Project Version name and click 'Save New Version'
  28. // - set security level and enable service (most likely execute as 'me' and access 'anyone, even anonymously)
  29. //
  30. // 4. Copy the 'Current web app URL' and post this in your form/script action
  31. //
  32. // 5. Insert column names on your destination sheet matching the parameter names of the data you are passing in (exactly matching case)
  33.  
  34. var SCRIPT_PROP = PropertiesService.getScriptProperties(); // new property service
  35.  
  36. // If you don't want to expose either GET or POST methods you can comment out the appropriate function
  37. function doPost(e) {
  38. // shortly after my original solution Google announced the LockService[1]
  39. // this prevents concurrent access overwritting data
  40. // [1] http://googleappsdeveloper.blogspot.co.uk/2011/10/concurrency-and-google-apps-script.html
  41. // we want a public lock, one that locks for all invocations
  42. var lock = LockService.getPublicLock();
  43. lock.waitLock(30000); // wait 30 seconds before conceding defeat.
  44.  
  45.  
  46. var boda=2; //列番号 B=2
  47. var headrow=1;//3行目 行番号 1
  48.  
  49.  
  50. try {
  51. // next set where we write the data - you could write to multiple/alternate destinations
  52. var doc = SpreadsheetApp.openById(SCRIPT_PROP.getProperty("key"));
  53.  
  54. //JSONでーたを受け取り
  55. var JSON_DATA= JSON.parse(e.parameter["BD_JSON"]);
  56. var log="(*^_^*)でーた入力にご協力ありがとうございます(*^_^*)~\r\nごっごるしーと受け皿でのろぐをお伝えします~\r\n\r\n";
  57. log= log+"送信したJSONでーた:\r\n" + JSON.stringify(JSON_DATA)+"\r\n\r\n";
  58.  
  59.  
  60.  
  61. log= log+"対象しーと名: 時刻,すこあ,すてーたす,行番号(0以下は更新なし)\r\n";
  62.  
  63. //しーと+時刻べつに仕分けする
  64. var sheet = doc.getSheetByName("時速よび");
  65. if (sheet.getRange(1,1).getValue()=="time"){
  66.  
  67. var headers = sheet.getRange(1, 1, 1, sheet.getLastColumn()).getValues()[0];
  68. var row = [];
  69. var timer=1;
  70.  
  71. //おなじ日付のでーたがある場合更新停止
  72. if(sheet.getRange(2,1).getValue()!=timer){
  73.  
  74. //降順になるよう2行目にでーたをついか
  75. if(sheet.getRange(2,1).getValue()!=""){
  76. sheet.insertRowBefore(2);
  77. }
  78.  
  79. // loop through the header columns
  80. for (i in headers){
  81. if (headers[i] == "time"){ // special case if you include a 'Timestamp' column
  82. row.push(JSON_DATA['date']);
  83. }
  84. else{ // else use header name to get data
  85. row.push(JSON_DATA[headers[i]]);
  86. }
  87. }
  88.  
  89.  
  90. sheet.getRange(2, 1, 1, row.length).setValues([row]);//2行目に貼り付ける
  91.  
  92. log= log + "時速よび" + ":" +timer + "," + row[0] + status(3) + "新規、3行目追加\r\n";
  93. }
  94. else{
  95. log= log + "時速よび" + "えらー重複 : すでに同じ日付のでーたがあります"
  96. }
  97. }
  98. else{
  99. log= log + "時速よび" + ":へっどが所定の場所(" +headrow +","+ boda+")にありません、しーとを確認してください\r\n";
  100. }
  101.  
  102.  
  103.  
  104. return ContentService
  105. .createTextOutput(log)
  106. .setMimeType(ContentService.MimeType.JSON)
  107.  
  108.  
  109. } catch(e){
  110. // 何か例外発生時のろぐ
  111. return ContentService
  112. .createTextOutput(log + JSON.stringify({"結果":"エラー", "エラー": e}))
  113. .setMimeType(ContentService.MimeType.JSON);
  114. } finally { //release lock
  115. lock.releaseLock();
  116. }
  117. }
  118.  
  119. function status(d){
  120. var st;
  121. if(d>0){
  122. st=",成功,"
  123. }
  124. else if(d==0){
  125. st=",同じすこあが存在,"
  126. }
  127. else if(d==-1){
  128. st=",検索対象なし,"
  129. }
  130. else if(d==-2){
  131. st=",送信すこあが前回より小さい,"
  132. }
  133.  
  134. return st;
  135. }
  136.  
  137. function setup() {
  138. var doc = SpreadsheetApp.getActiveSpreadsheet();
  139. SCRIPT_PROP.setProperty("key", doc.getId());
  140. }
Advertisement
Add Comment
Please, Sign In to add comment