즐거운 물놀이 뽀로로 소방관 배낭 물총 장난감



0}); if(retryItem.length > 0) { var param = {status: 'ERROR_SOME', ocrRes:ocrRes, isRetry: true}; updateGoodsCodeItems(targetGoodsCode, param); return false; } updateGoodsCodeItems(targetGoodsCode, {status: 'SUCCESS', ocrRes:ocrRes, isSuccess: true, isRetry: false}); return false; } } function ocrTranslationApi (goodsCode, detailVersionType, callback) { var ajaxOption = { type: 'POST', dataType: 'json', url: '/Item/GetTextGoodsCode', data: {goodsCode, detailVersion: Number(detailVersionType)}, async: true, } ajaxSync(ajaxOption).then(function(res) { return callback(res) }) } function ocrTranslationRetryApi (goodsCode, detailVersionType, callback) { var ocrResItem = goodsCodeItems.get(targetGoodsCode); if(ocrResItem && ocrResItem.ocrRes) { var urls = ocrResItem.ocrRes.filter(function(item) {return item.retryCount > 0}).map(function(item) {return item.u}); var ajaxOption = { type: 'POST', dataType: 'json', traditional: true, url: '/Item/GetRetryTextGoodsCode', data: {goodsCode, detailVersion: Number(detailVersionType), urls}, async: true, } ajaxSync(ajaxOption).then(function(res) { return callback(res) }) } } function ocrResponseData(ocrRes) { var successItems = ocrRes.filter(function(item) {return item.result === true}).map(function(item) { var text = item.t === "" ? ocrStatusText['DIFFICULT_COGNITION'] : item.t; return Object.assign({}, item, {t: text}, {retryCount: 0}); }); var failItems = ocrRes .filter(function(item) {return item.result === false}) .map(function(item) { var errMsgCheck = ocrCheckErrMsg(item); var retryCount = errMsgCheck ? errMsgCheck.retryCount : 0; var text = retryCount === 0 ? ocrStatusText['DIFFICULT_COGNITION'] : item.t; return Object.assign({}, item, {t: text}, {retryCount: retryCount}); }); return [].concat(successItems, failItems); } function ocrRetryResponseData(ocrRes) { var ocrResItem = goodsCodeItems.get(targetGoodsCode); if(ocrResItem && ocrResItem.ocrRes) { return ocrResItem.ocrRes.map(function(item) { var retryItem = ocrRes.find(function(urlItem) {return urlItem.u === item.u}); if (retryItem) { var errMsgCheck = ocrCheckErrMsg(item); var retryCount = retryItem.result ? 0 : (errMsgCheck ? errMsgCheck.retryCount : 0); var text = retryCount === 0 ? ocrStatusText['DIFFICULT_COGNITION'] : item.t; return Object.assign({}, retryItem, {t: text}, {retryCount: retryCount}); } else { return item; } }); }else{ return []; } } function ocrCheckErrMsg(item) { return errMsg.find(function(errItem) {return item.errMsg.includes(errItem.msg)}); } function ocrTranslationApiCallback(ocrRes) { var ocrResponse = ocrResponseData(ocrRes); ocrApiResState(ocrResponse); announceForAccessibility(); translationAltText(targetElement); } function ocrTranslationRetryApiCallback(ocrRes) { var ocrRetryResponse = ocrRetryResponseData(ocrRes); ocrApiResState(ocrRetryResponse); announceForAccessibility(); translationAltText(targetElement); } function checkGoodsCodeItem(goodsCode) { var hasItem = goodsCodeItems.has(goodsCode); if(!hasItem){ goodsCodeItems.set(goodsCode, { status: 'INIT', ocrRes: [], isRetry: false, ongoing: false, isSuccess: false }); } return goodsCodeItems.get(targetGoodsCode); } function updateGoodsCodeItems(goodsCode, updateOption) { goodsCodeItems.set( goodsCode, Object.assign(goodsCodeItems.get(goodsCode), updateOption) ); } function initOcr(targetElement) { goodsCodeItems.clear(); setTimeout(function () { $ocrAnnounceTag.empty().text(ocrStatusText['INIT']) }, 200); } function onTranslationSubmit(goodsCode, detailVersionType) { targetGoodsCode = goodsCode; var getItemInfo = checkGoodsCodeItem(goodsCode); if (getItemInfo.ongoing) { updateGoodsCodeItems(targetGoodsCode, {status: 'ONGOING'}); return announceForAccessibility(); } if (getItemInfo.isSuccess) { updateGoodsCodeItems(targetGoodsCode, {status: 'ALREADY'}); return announceForAccessibility(); } if(!getItemInfo.isRetry){ ocrTranslationApi(goodsCode, detailVersionType, function(ocrRes) { return ocrTranslationApiCallback(ocrRes)}); }else{ ocrTranslationRetryApi(goodsCode, detailVersionType, function(ocrRes) { return ocrTranslationRetryApiCallback(ocrRes)}); } } return {onTranslationSubmit: onTranslationSubmit} })(window.Ocr = window.Ocr || {}, jQuery);