Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- https://docs.google.com/spreadsheets/d/1CpwNLrurUVVLX2dmMgZHU-uQC7WQfyfWqLlaiooRaN8/edit#gid=0
- http://sokudon.s17.xrea.com/gg.html ←自分用
- https://docs.google.com/spreadsheets/d/1htAsRAyEl5zwwNlb5PhrVIqSrT1h3U5zmHR-UUSoP-Y/edit?usp=sharing ← お試しよう
- http://sokudon.s17.xrea.com/gtes.html ← お試しよう
- スクショがゴッゴル先生de txtjson変換器、すこあがひろいずらい [67]桁限定にするるか
- http://sokudon.s17.xrea.com/mirisita_katudou_calc.html
- //sample json
- {"出勤日数":"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"}
- JSON_TESTER をじこ記録用に変更
- https://docs.google.com/spreadsheets/d/1u9uRPvj5_DRz5z8mR7mV4DOm4X0PgF12zMf_ZStmKC0/edit#gid=0
- 実行からsetupを2回,apikを発行 実行設定と共有設定で編集権限をこまかくいじれる?
- //共有が必要
- // 1. Enter sheet name where data is to be written below
- // 2. Run > setup
- //
- // 3. Publish > Deploy as web app
- // - enter Project Version name and click 'Save New Version'
- // - set security level and enable service (most likely execute as 'me' and access 'anyone, even anonymously)
- //
- // 4. Copy the 'Current web app URL' and post this in your form/script action
- //
- // 5. Insert column names on your destination sheet matching the parameter names of the data you are passing in (exactly matching case)
- var SCRIPT_PROP = PropertiesService.getScriptProperties(); // new property service
- // If you don't want to expose either GET or POST methods you can comment out the appropriate function
- function doPost(e) {
- // shortly after my original solution Google announced the LockService[1]
- // this prevents concurrent access overwritting data
- // [1] http://googleappsdeveloper.blogspot.co.uk/2011/10/concurrency-and-google-apps-script.html
- // we want a public lock, one that locks for all invocations
- var lock = LockService.getPublicLock();
- lock.waitLock(30000); // wait 30 seconds before conceding defeat.
- var boda=2; //列番号 B=2
- var headrow=1;//3行目 行番号 1
- try {
- // next set where we write the data - you could write to multiple/alternate destinations
- var doc = SpreadsheetApp.openById(SCRIPT_PROP.getProperty("key"));
- //JSONでーたを受け取り
- var JSON_DATA= JSON.parse(e.parameter["BD_JSON"]);
- var log="(*^_^*)でーた入力にご協力ありがとうございます(*^_^*)~\r\nごっごるしーと受け皿でのろぐをお伝えします~\r\n\r\n";
- log= log+"送信したJSONでーた:\r\n" + JSON.stringify(JSON_DATA)+"\r\n\r\n";
- log= log+"対象しーと名: 時刻,すこあ,すてーたす,行番号(0以下は更新なし)\r\n";
- //しーと+時刻べつに仕分けする
- var sheet = doc.getSheetByName("時速よび");
- if (sheet.getRange(1,1).getValue()=="time"){
- var headers = sheet.getRange(1, 1, 1, sheet.getLastColumn()).getValues()[0];
- var row = [];
- var timer=1;
- //おなじ日付のでーたがある場合更新停止
- if(sheet.getRange(2,1).getValue()!=timer){
- //降順になるよう2行目にでーたをついか
- if(sheet.getRange(2,1).getValue()!=""){
- sheet.insertRowBefore(2);
- }
- // loop through the header columns
- for (i in headers){
- if (headers[i] == "time"){ // special case if you include a 'Timestamp' column
- row.push(JSON_DATA['date']);
- }
- else{ // else use header name to get data
- row.push(JSON_DATA[headers[i]]);
- }
- }
- sheet.getRange(2, 1, 1, row.length).setValues([row]);//2行目に貼り付ける
- log= log + "時速よび" + ":" +timer + "," + row[0] + status(3) + "新規、3行目追加\r\n";
- }
- else{
- log= log + "時速よび" + "えらー重複 : すでに同じ日付のでーたがあります"
- }
- }
- else{
- log= log + "時速よび" + ":へっどが所定の場所(" +headrow +","+ boda+")にありません、しーとを確認してください\r\n";
- }
- return ContentService
- .createTextOutput(log)
- .setMimeType(ContentService.MimeType.JSON)
- } catch(e){
- // 何か例外発生時のろぐ
- return ContentService
- .createTextOutput(log + JSON.stringify({"結果":"エラー", "エラー": e}))
- .setMimeType(ContentService.MimeType.JSON);
- } finally { //release lock
- lock.releaseLock();
- }
- }
- function status(d){
- var st;
- if(d>0){
- st=",成功,"
- }
- else if(d==0){
- st=",同じすこあが存在,"
- }
- else if(d==-1){
- st=",検索対象なし,"
- }
- else if(d==-2){
- st=",送信すこあが前回より小さい,"
- }
- return st;
- }
- function setup() {
- var doc = SpreadsheetApp.getActiveSpreadsheet();
- SCRIPT_PROP.setProperty("key", doc.getId());
- }
Advertisement
Add Comment
Please, Sign In to add comment