From 9f6c14ced042e43b4833cbe13fcc30d99c48f69f Mon Sep 17 00:00:00 2001 From: cutls Date: Thu, 12 Dec 2019 00:06:40 +0900 Subject: [PATCH] WIP: to null-safety app --- app/js/platform/first.js | 23 ++++++++++++++++++----- app/js/post/img.js | 2 +- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/app/js/platform/first.js b/app/js/platform/first.js index 3e566845..d309c3d4 100644 --- a/app/js/platform/first.js +++ b/app/js/platform/first.js @@ -211,8 +211,23 @@ function escapeCsv(str) { } return result } +function evalAttr(json, attr, lenCk) { + if (json[attr]) { + if (lenCk) { + if (json[attr][0]) { + return true + } else { + return false + } + } else { + return true + } + } else { + return false + } +} function statusModel(now) { - if(!now){ + if (!now) { var now = new Date().toString() } return { @@ -248,12 +263,10 @@ function statusModel(now) { locked: false, bot: false, created_at: now, - note: - '', + note: '', url: '', avatar: '', - avatar_static: - '', + avatar_static: '', header: '', header_static: '', followers_count: 0, diff --git a/app/js/post/img.js b/app/js/post/img.js index ff13ae48..9001bcf3 100644 --- a/app/js/post/img.js +++ b/app/js/post/img.js @@ -151,7 +151,7 @@ function media(b64, type, no) { mediav = mediav.replace(regExp, json['id']) $('#media').val(mediav) } - if (img == 'url') { + if (img == 'url' && json['text_url']) { $('#textarea').val($('#textarea').val() + ' ' + json['text_url']) } todc()