@capillarytech/creatives-library 0.1.28 → 0.1.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/FormBuilder/_formBuilder.scss +19 -0
- package/components/FormBuilder/index.js +30 -12
- package/components/NewSidebar/_newsidebar.scss +115 -0
- package/components/NewSidebar/index.js +234 -0
- package/components/NewSidebar/messages.js +21 -0
- package/components/NewSidebar/tests/index.test.js +10 -0
- package/components/NewTopBar/_newtopbar.scss +84 -0
- package/components/NewTopBar/assets/images/capillary_logo.png +0 -0
- package/components/NewTopBar/assets/images/capillary_logo_2.png +0 -0
- package/components/NewTopBar/index.js +195 -0
- package/components/NewTopBar/messages.js +29 -0
- package/components/NewTopBar/tests/index.test.js +10 -0
- package/components/PreviewSideBar/index.js +2 -1
- package/components/TemplatePreview/_templatePreview.scss +120 -39
- package/components/TemplatePreview/index.js +36 -6
- package/components/TemplatePreview/messages.js +11 -3
- package/containers/Cap/constants.js +1 -0
- package/containers/Cap/index.js +37 -4
- package/containers/Cap/reducer.js +5 -0
- package/containers/Cap/selectors.js +1 -0
- package/containers/Line/Create/_lineCreate.scss +6 -0
- package/containers/Line/Create/index.js +20 -15
- package/containers/Line/Create/sagas.js +1 -2
- package/containers/Sms/Create/index.js +3 -2
- package/containers/Sms/Edit/index.js +3 -3
- package/containers/Templates/index.js +55 -42
- package/containers/WeChat/index.js +1 -0
- package/package.json +3 -1
- package/utils/smsCharCountV2.js +143 -0
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
margin-bottom: 16px;
|
|
3
3
|
}
|
|
4
4
|
.image-container{
|
|
5
|
+
display: flex;
|
|
6
|
+
height: 150px;
|
|
7
|
+
width: 320px;
|
|
5
8
|
border: solid 1px #C2C2C2;
|
|
6
9
|
border-radius: 5px;
|
|
7
10
|
.image-placeholder{
|
|
@@ -10,6 +13,9 @@
|
|
|
10
13
|
img {
|
|
11
14
|
object-fit: cover;
|
|
12
15
|
max-width: 100%;
|
|
16
|
+
max-height: 100%;
|
|
17
|
+
height: auto !important;
|
|
18
|
+
width: auto !important;
|
|
13
19
|
}
|
|
14
20
|
}
|
|
15
21
|
//.ant-tabs-bar{
|
|
@@ -140,6 +140,7 @@ export class Line extends Component {
|
|
|
140
140
|
layout: 'LINE',
|
|
141
141
|
type: 'TAG',
|
|
142
142
|
context: 'outbound',
|
|
143
|
+
embedded: this.props.location.query.type === 'embedded' ? this.props.location.query.type : 'full',
|
|
143
144
|
};
|
|
144
145
|
if (tags === undefined && modeType !== 'image') {
|
|
145
146
|
this.props.globalActions.fetchSchemaForEntity(getTagsQuery);
|
|
@@ -203,6 +204,7 @@ export class Line extends Component {
|
|
|
203
204
|
const formData = _.cloneDeep(this.state.formData);
|
|
204
205
|
// TODO: if multiple image upload supports, change below accordingly.
|
|
205
206
|
formData[this.state.currentTab - 1].image = nextProps.Line.uploadedAssetData.metaInfo.secure_file_path;
|
|
207
|
+
formData[this.state.currentTab - 1].imagePreview = nextProps.Line.uploadedAssetData.metaInfo.secure_file_path_preview;
|
|
206
208
|
console.log("before 2", formData[this.state.currentTab - 1].image);
|
|
207
209
|
this.setState({formData});
|
|
208
210
|
console.log("ooo", this.state.formData);
|
|
@@ -292,21 +294,20 @@ export class Line extends Component {
|
|
|
292
294
|
if (editTemplateId && editTemplateId !== undefined) {
|
|
293
295
|
obj._id = editTemplateId;
|
|
294
296
|
msgData.originalContentUrl = formData['0'].image;
|
|
295
|
-
msgData.previewImageUrl = formData['0'].
|
|
297
|
+
msgData.previewImageUrl = formData['0'].imagePreview;
|
|
296
298
|
}
|
|
297
299
|
} else {
|
|
298
|
-
//
|
|
299
|
-
|
|
300
|
-
img.
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
//
|
|
305
|
-
|
|
306
|
-
prevImgSet.src = formData['0'].image;
|
|
300
|
+
// const img = new Image();
|
|
301
|
+
// img.src = formData['0'].image;
|
|
302
|
+
// img.onload = () => {
|
|
303
|
+
// console.log(`Image aspect ratio details line@@@${img.width} and ${img.height}`);
|
|
304
|
+
// };
|
|
305
|
+
// // Preview Image set to 240px max
|
|
306
|
+
// const prevImgSet = new Image(240, 240);
|
|
307
|
+
// prevImgSet.src = formData['0'].image;
|
|
307
308
|
|
|
308
309
|
msgData.originalContentUrl = formData['0'].image;
|
|
309
|
-
msgData.previewImageUrl = formData['0'].
|
|
310
|
+
msgData.previewImageUrl = formData['0'].imagePreview;
|
|
310
311
|
}
|
|
311
312
|
}
|
|
312
313
|
obj.versions.base.content.messages.push(msgData);
|
|
@@ -326,7 +327,9 @@ export class Line extends Component {
|
|
|
326
327
|
obj['0']['message-editor'] = versions.base.content.messages[0].text;
|
|
327
328
|
} else if (modeType === 'image') {
|
|
328
329
|
obj.base.image = versions.base.content.messages[0].originalContentUrl;
|
|
329
|
-
obj['0'].image = versions.base.content.messages[0].
|
|
330
|
+
obj['0'].image = versions.base.content.messages[0].originalContentUrl;
|
|
331
|
+
obj['0'].imagePreview = versions.base.content.messages[0].previewImageUrl;
|
|
332
|
+
obj.base.imagePreview = versions.base.content.messages[0].previewImageUrl;
|
|
330
333
|
}
|
|
331
334
|
|
|
332
335
|
console.log("getEditTransformedData", obj);
|
|
@@ -564,7 +567,7 @@ export class Line extends Component {
|
|
|
564
567
|
obj.base.image = content;
|
|
565
568
|
obj['0'].image = content;
|
|
566
569
|
}
|
|
567
|
-
this.setState({formData: obj, loading: false});
|
|
570
|
+
this.setState({formData: obj, loading: false, injectedTags: data.tags});
|
|
568
571
|
};
|
|
569
572
|
|
|
570
573
|
startLoading = (ifEdit) => {
|
|
@@ -708,12 +711,14 @@ export class Line extends Component {
|
|
|
708
711
|
this.props.globalActions.fetchSchemaForEntity(query);
|
|
709
712
|
};
|
|
710
713
|
|
|
711
|
-
uploadImage = (
|
|
712
|
-
console.log("image data line@@@",
|
|
714
|
+
uploadImage = (pearmData) => {
|
|
715
|
+
console.log("image data line@@@", pearmData);
|
|
716
|
+
const data = pearmData;
|
|
713
717
|
if (data.file.size > 1000000) {
|
|
714
718
|
const message = getMessageObject('error', this.props.intl.formatMessage(messages['File size cannot be more than 1mb']), true);
|
|
715
719
|
this.props.globalActions.addMessageToQueue(message);
|
|
716
720
|
} else {
|
|
721
|
+
data.fileParams.isGeneratePreview = true;
|
|
717
722
|
const name = data.file.name.split('.');
|
|
718
723
|
const blob = data.file.slice(0, -1, 'image');
|
|
719
724
|
const newFile = new File([blob], `${name[0]}${Date.now()}.${name[1]}`, {type: 'image'});
|
|
@@ -35,7 +35,7 @@ function* watchCreateTemplate() {
|
|
|
35
35
|
yield cancel(watcher);
|
|
36
36
|
}
|
|
37
37
|
function* watchUploadAsset() {
|
|
38
|
-
console.log("inside watchUploadAsset")
|
|
38
|
+
console.log("inside watchUploadAsset");
|
|
39
39
|
const watcher = yield takeLatest(types.UPLOAD_ASSET_REQUEST, uploadAsset);
|
|
40
40
|
yield take(LOCATION_CHANGE);
|
|
41
41
|
yield cancel(watcher);
|
|
@@ -104,5 +104,4 @@ export default [
|
|
|
104
104
|
watchEditTemplate,
|
|
105
105
|
watchGetTemplateDetails,
|
|
106
106
|
watchLineTemplatesList,
|
|
107
|
-
watchUploadAsset,
|
|
108
107
|
];
|
|
@@ -19,6 +19,7 @@ import FormBuilder from '../../../components/FormBuilder';
|
|
|
19
19
|
import * as actions from './actions';
|
|
20
20
|
import messages from './messages';
|
|
21
21
|
import * as charCount from '../../../utils/smsCharCount';
|
|
22
|
+
import {updateCharCount, checkUnicode} from '../../../utils/smsCharCountV2';
|
|
22
23
|
import * as globalActions from '../../../containers/Cap/actions';
|
|
23
24
|
import {getMessageObject} from '../../../utils/messageUtils';
|
|
24
25
|
|
|
@@ -378,7 +379,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
378
379
|
|
|
379
380
|
injectEvents(schema) {
|
|
380
381
|
console.log('now injecting events');
|
|
381
|
-
|
|
382
|
+
let temp = schema;
|
|
382
383
|
temp.standalone.sections = this.injectSections(temp.standalone.sections);
|
|
383
384
|
_.forEach(temp.containers, (container) => {
|
|
384
385
|
let tempContainer = container;
|
|
@@ -761,7 +762,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
761
762
|
startTemplateCreation(data) {
|
|
762
763
|
if (data.edit) {
|
|
763
764
|
console.log('startTemplateCreation');
|
|
764
|
-
const ifUnicode =
|
|
765
|
+
const ifUnicode = checkUnicode(data.content ? data.content : '');
|
|
765
766
|
console.log('smsDetails', ifUnicode, data.content);
|
|
766
767
|
const content = data.content;
|
|
767
768
|
const id = _.uniqueId();
|
|
@@ -17,7 +17,7 @@ import { makeSelectMetaEntities } from '../../Cap/selectors';
|
|
|
17
17
|
import { UserIsAuthenticated } from '../../../utils/authWrapper';
|
|
18
18
|
import FormBuilder from '../../../components/FormBuilder';
|
|
19
19
|
import * as actions from './actions';
|
|
20
|
-
import
|
|
20
|
+
import {checkUnicode, updateCharCount} from '../../../utils/smsCharCountV2';
|
|
21
21
|
import '../Create/_smsCreate.scss';
|
|
22
22
|
import messages from './messages';
|
|
23
23
|
import * as globalActions from '../../../containers/Cap/actions';
|
|
@@ -286,7 +286,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
286
286
|
}
|
|
287
287
|
const result = {};
|
|
288
288
|
result.base = baseData;
|
|
289
|
-
const msgObj =
|
|
289
|
+
const msgObj = updateCharCount(baseData['sms-editor']);
|
|
290
290
|
result.base.msg_count = msgObj.msgCount;
|
|
291
291
|
console.log("Message Count", msgObj.msgCount);
|
|
292
292
|
const response = {
|
|
@@ -386,7 +386,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
386
386
|
startTemplateCreation(data) {
|
|
387
387
|
console.log('startTemplateCreation');
|
|
388
388
|
if (data.edit) {
|
|
389
|
-
const ifUnicode =
|
|
389
|
+
const ifUnicode = checkUnicode(data.content);
|
|
390
390
|
console.log('smsDetails', ifUnicode, data.content);
|
|
391
391
|
const content = data.content;
|
|
392
392
|
const tempData = {
|
|
@@ -23,7 +23,7 @@ import { makeSelectEdit } from '../Sms/Edit/selectors';
|
|
|
23
23
|
import { makeSelectLine } from '../Line/Create/selectors';
|
|
24
24
|
import { UserIsAuthenticated } from '../../utils/authWrapper';
|
|
25
25
|
import messages from './messages';
|
|
26
|
-
import
|
|
26
|
+
import {checkUnicode} from '../../utils/smsCharCountV2';
|
|
27
27
|
import * as actions from './actions';
|
|
28
28
|
import * as smsActions from '../Sms/Create/actions';
|
|
29
29
|
import * as mobilepushActions from '../MobilePush/Create/actions';
|
|
@@ -657,7 +657,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
657
657
|
startTemplateCreation(data) {
|
|
658
658
|
console.log('startTemplateCreation');
|
|
659
659
|
if (data.edit) {
|
|
660
|
-
const ifUnicode =
|
|
660
|
+
const ifUnicode = checkUnicode(data.content);
|
|
661
661
|
console.log('smsDetails', ifUnicode, data.content);
|
|
662
662
|
const content = data.content;
|
|
663
663
|
const tempData = {
|
|
@@ -1146,22 +1146,24 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1146
1146
|
this.setState({ device });
|
|
1147
1147
|
};
|
|
1148
1148
|
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1149
|
+
//Gets called only when creatives gets used as node library
|
|
1150
|
+
isEnabledInLibraryModule = (property) => {
|
|
1151
|
+
if (this.props.location.query.type === "embedded" && this.props.location.query.module === "library") {
|
|
1152
|
+
switch (property) {
|
|
1153
|
+
case "showAccountSelection":
|
|
1154
|
+
return (this.props.route && (this.props.route.name.toLowerCase() === "wechat" || this.props.route.name.toLowerCase() === "mobilepush"));
|
|
1155
|
+
case "setLocale":
|
|
1156
|
+
return true;
|
|
1157
|
+
case "callCreateFromProps":
|
|
1158
|
+
return true;
|
|
1159
|
+
case "callSelectFromProps":
|
|
1160
|
+
return true;
|
|
1161
|
+
default:
|
|
1162
|
+
return false;
|
|
1163
|
+
}
|
|
1164
|
+
} else {
|
|
1165
|
+
return false;
|
|
1166
|
+
}
|
|
1165
1167
|
}
|
|
1166
1168
|
|
|
1167
1169
|
renderDeleteConfirmationModal = () => {
|
|
@@ -1182,29 +1184,29 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1182
1184
|
</Modal>);
|
|
1183
1185
|
return modal;
|
|
1184
1186
|
};
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
}
|
|
1187
|
+
|
|
1188
|
+
renderEmailPreviewModal() {
|
|
1189
|
+
const slideboxContent = (
|
|
1190
|
+
<div style={{height: "75vh", width: '55vw'}}>
|
|
1191
|
+
<iframe />
|
|
1192
|
+
</div>
|
|
1193
|
+
);
|
|
1194
|
+
|
|
1195
|
+
return (
|
|
1196
|
+
<SlideBox
|
|
1197
|
+
header={this.state.previewTemplate.name}
|
|
1198
|
+
content={slideboxContent}
|
|
1199
|
+
show={this.state.showEmailPreviewModal}
|
|
1200
|
+
handleClose={this.toggleImagePreview}
|
|
1201
|
+
width={60}
|
|
1202
|
+
/>
|
|
1203
|
+
);
|
|
1203
1204
|
}
|
|
1204
1205
|
|
|
1205
1206
|
render() {
|
|
1206
1207
|
console.log('templates props', this.props);
|
|
1207
1208
|
let pageHeaderText = '';
|
|
1209
|
+
const moduleName = this.props.location.query.module;
|
|
1208
1210
|
if (this.props.location.query.type !== 'embedded') {
|
|
1209
1211
|
if (this.state.channel.toUpperCase() === 'WECHAT') {
|
|
1210
1212
|
pageHeaderText = this.props.intl.formatMessage(messages.wechatHeader);
|
|
@@ -1313,6 +1315,15 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1313
1315
|
</Select>}
|
|
1314
1316
|
</div>
|
|
1315
1317
|
);
|
|
1318
|
+
const pageHeaderDvs = (
|
|
1319
|
+
<div>
|
|
1320
|
+
{(this.props.location.query.type === 'embedded' && moduleName === 'dvs') ? `${templateText}` : pageHeaderText}
|
|
1321
|
+
{((this.state.channel.toUpperCase() === 'WECHAT') && (this.props.location.query.type === 'embedded') && !_.isEmpty(this.props.Templates.weCrmAccounts)) &&
|
|
1322
|
+
<Select className="selectAccount" onSelect={this.onAccountSelect} value={this.props.Templates.selectedWeChatAccount ? this.props.Templates.selectedWeChatAccount.name : undefined} placeholder={this.props.intl.formatMessage(messages.selectAccount)}>
|
|
1323
|
+
{accountOptions}
|
|
1324
|
+
</Select>}
|
|
1325
|
+
</div>
|
|
1326
|
+
);
|
|
1316
1327
|
let actionButton = '';
|
|
1317
1328
|
if (this.props.location.query.type !== 'embedded') {
|
|
1318
1329
|
if (this.state.channel.toUpperCase() === 'WECHAT') {
|
|
@@ -1445,15 +1456,17 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1445
1456
|
<input type="file" id="filename" style={{ display: 'none'}} accept=".zip, .html, .htm" onChange={(event) => this.handleFileUpload(event, {files: event.target.files})} />
|
|
1446
1457
|
<Row>
|
|
1447
1458
|
<Col>
|
|
1448
|
-
|
|
1449
|
-
<
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1459
|
+
{this.props.location.query.type !== "embedded" &&
|
|
1460
|
+
<Breadcrumb>
|
|
1461
|
+
<BreadcrumbItem>{this.props.intl.formatMessage(messages.campaigns)}</BreadcrumbItem>
|
|
1462
|
+
<BreadcrumbItem>{this.props.intl.formatMessage(messages.creatives)}</BreadcrumbItem>
|
|
1463
|
+
<BreadcrumbItem>{ this.state.channel }</BreadcrumbItem>
|
|
1464
|
+
</Breadcrumb>
|
|
1465
|
+
}
|
|
1453
1466
|
</Col>
|
|
1454
1467
|
</Row>
|
|
1455
1468
|
<Row className="template-header-container">
|
|
1456
|
-
<div className="template-header">{pageHeader}</div>
|
|
1469
|
+
<div className="template-header">{(this.props.location.query.type === 'embedded' && moduleName === 'dvs') ? pageHeaderDvs : pageHeader}</div>
|
|
1457
1470
|
{actionButton}
|
|
1458
1471
|
</Row>
|
|
1459
1472
|
<Row>
|
|
@@ -704,6 +704,7 @@ export class WeChat extends React.Component { // eslint-disable-line react/prefe
|
|
|
704
704
|
content: this.state.editTemplateData.versions.base.content,
|
|
705
705
|
isInternalUrl: this.state.formData['is-internal-url'],
|
|
706
706
|
creative_template_id: this.state.editTemplateData._id,
|
|
707
|
+
touser: "{{wechat_open_id}}",
|
|
707
708
|
};
|
|
708
709
|
_.forEach(this.state.selectedTemplateTags, (templateTag) => {
|
|
709
710
|
const tagName = templateTag.substr(0, templateTag.indexOf('.'));
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capillarytech/creatives-library",
|
|
3
3
|
"author": "meharaj",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.30",
|
|
5
5
|
"description": "Capillary creatives ui",
|
|
6
6
|
"main": "./index.js",
|
|
7
7
|
"module": "./index.es.js",
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"express": "4.14.0",
|
|
26
26
|
"fixed-data-table": "^0.6.4",
|
|
27
27
|
"fontfaceobserver": "2.0.7",
|
|
28
|
+
"fs": "0.0.1-security",
|
|
28
29
|
"fs-extra": "^5.0.0",
|
|
29
30
|
"immutable": "3.8.1",
|
|
30
31
|
"intl": "1.2.5",
|
|
@@ -57,6 +58,7 @@
|
|
|
57
58
|
"reselect": "2.5.4",
|
|
58
59
|
"sanitize.css": "4.1.0",
|
|
59
60
|
"semantic-ui-react": "0.68.3",
|
|
61
|
+
"source-map-loader": "^0.2.4",
|
|
60
62
|
"styled-components": "1.1.2",
|
|
61
63
|
"warning": "3.0.0",
|
|
62
64
|
"whatwg-fetch": "2.0.1"
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
function getURLParameter(name) {
|
|
3
|
+
return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search) || [, ""])[1].replace(/\+/g, '%20')) || null
|
|
4
|
+
}
|
|
5
|
+
var charset7bit = ['@', '£', '$', '¥', 'è', 'é', 'ù', 'ì', 'ò', 'Ç', "\n", 'Ø', 'ø', "\r", 'Å', 'å', 'Δ', '_', 'Φ', 'Γ', 'Λ', 'Ω', 'Π', 'Ψ', 'Σ', 'Θ', 'Ξ', 'Æ', 'æ', 'ß', 'É', ' ', '!', '"', '#', '¤', '%', '&', "'", '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', '¡', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'Ä', 'Ö', 'Ñ', 'Ü', '§', '¿', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'ä', 'ö', 'ñ', 'ü', 'à'];
|
|
6
|
+
var charset7bitext = ["\f", '^', '{', '}', '\\', '[', '~', ']', '|', '€'];
|
|
7
|
+
var udh_template = '<span className="udh"><span className="udh-total-length" title="UDH length">0x05</span><span className="udh-multipart-header" title="UDH header - Multipart SMS">0x00</span><span className="udh-multipart-length" title="Multipart SMS - UDH length">0x03</span><span className="udh-multipart-id" title="Multipart SMS - Unique ID">0x0a</span><span className="udh-total" title="Multipart SMS - Total number of parts"></span><span className="udh-part" title="Multipart SMS - Part order"></span></span>';
|
|
8
|
+
|
|
9
|
+
function charToSpan(chr, coding, isUnicodeEnabled) {
|
|
10
|
+
var ret;
|
|
11
|
+
var clss = '';
|
|
12
|
+
if (coding == '7bit') {
|
|
13
|
+
clss = 'c7b';
|
|
14
|
+
if (charset7bitext.indexOf(chr) >= 0) {
|
|
15
|
+
//ret = <div className="c7eb">ESC</div>;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
let isUnicode = false;
|
|
19
|
+
if (coding == '16bit') {
|
|
20
|
+
clss = 'c16b';
|
|
21
|
+
if (charset7bit.indexOf(chr) == -1 && charset7bitext.indexOf(chr) == -1 && !isUnicodeEnabled) {
|
|
22
|
+
isUnicode = true;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return <span className={isUnicode ? 'unicode-disabled' : ''}>{isUnicode ? ` \u2588 ` : chr}</span>
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function getUHDHtml(parts, part) {
|
|
29
|
+
if (parts < 15) {
|
|
30
|
+
udh.find('.udh-total').html('0x0' + parts.toString(16));
|
|
31
|
+
} else {
|
|
32
|
+
udh.find('.udh-total').html('0x' + parts.toString(16));
|
|
33
|
+
}
|
|
34
|
+
if (part < 15) {
|
|
35
|
+
udh.find('.udh-part').html('0x0' + part.toString(16));
|
|
36
|
+
} else {
|
|
37
|
+
udh.find('.udh-part').html('0x' + part.toString(16));
|
|
38
|
+
}
|
|
39
|
+
return udh;
|
|
40
|
+
}
|
|
41
|
+
export function checkUnicode(content) {
|
|
42
|
+
var chars_arr = content.split("");
|
|
43
|
+
for (let i = 0; i < chars_arr.length; i++) {
|
|
44
|
+
let chr = chars_arr[i];
|
|
45
|
+
if (charset7bit.indexOf(chr) == -1 && charset7bitext.indexOf(chr) == -1) {
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
export function updateCharCount(content, isUnicodeEnabled) {
|
|
52
|
+
console.log(content);
|
|
53
|
+
var chars_arr = content.split("");
|
|
54
|
+
console.log(chars_arr);
|
|
55
|
+
var coding = '7bit';
|
|
56
|
+
var parts = 1;
|
|
57
|
+
var part = 1;
|
|
58
|
+
var chars_used = 0;
|
|
59
|
+
var chars_sms = 160;
|
|
60
|
+
var sms_parts_container = [];
|
|
61
|
+
var partc = [];
|
|
62
|
+
for (let i = 0; i < chars_arr.length; i++) {
|
|
63
|
+
if (charset7bit.indexOf(chars_arr[i]) >= 0) {
|
|
64
|
+
chars_used = chars_used + 1;
|
|
65
|
+
console.log('X1:', chars_used);
|
|
66
|
+
} else if (charset7bitext.indexOf(chars_arr[i]) >= 0) {
|
|
67
|
+
chars_used = chars_used + 2;
|
|
68
|
+
console.log('X2:', chars_used);
|
|
69
|
+
} else {
|
|
70
|
+
coding = '16bit';
|
|
71
|
+
chars_used = chars_arr.length;
|
|
72
|
+
console.log('X3:', chars_used);
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (coding == '7bit') {
|
|
77
|
+
if (chars_used > 160) {
|
|
78
|
+
var parts = Math.ceil(chars_used / 153);
|
|
79
|
+
var part_chars_used = 7;
|
|
80
|
+
chars_sms = 153;
|
|
81
|
+
// partc.push(getUHDHtml(parts, part));
|
|
82
|
+
for (let i = 0; i < chars_arr.length; i++) {
|
|
83
|
+
if (part_chars_used + 1 > 160) {
|
|
84
|
+
part = part + 1;
|
|
85
|
+
part_chars_used = 7;
|
|
86
|
+
sms_parts_container.push(partc);
|
|
87
|
+
}
|
|
88
|
+
if (charset7bitext.indexOf(chars_arr[i]) >= 0 && part_chars_used + 2 > 160) {
|
|
89
|
+
part = part + 1;
|
|
90
|
+
part_chars_used = 7;
|
|
91
|
+
sms_parts_container.push(partc);
|
|
92
|
+
}
|
|
93
|
+
partc = [...partc, charToSpan(chars_arr[i], coding, isUnicodeEnabled)];
|
|
94
|
+
if (charset7bitext.indexOf(chars_arr[i]) == -1) {
|
|
95
|
+
part_chars_used = part_chars_used + 1;
|
|
96
|
+
} else {
|
|
97
|
+
part_chars_used = part_chars_used + 2;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
} else {
|
|
101
|
+
chars_sms = 160;
|
|
102
|
+
for (let i = 0; i < chars_arr.length; i++) {
|
|
103
|
+
partc = [...partc, charToSpan(chars_arr[i], coding, isUnicodeEnabled)];
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
} else {
|
|
107
|
+
if (chars_used > 70) {
|
|
108
|
+
|
|
109
|
+
parts = Math.ceil(chars_used / 67);
|
|
110
|
+
var part_chars_used = 3;
|
|
111
|
+
chars_sms = 67;
|
|
112
|
+
//partc.push(getUHDHtml(parts, part));
|
|
113
|
+
for (let i = 0; i < chars_arr.length; i++) {
|
|
114
|
+
if (part_chars_used + 1 > 70) {
|
|
115
|
+
part = part + 1;
|
|
116
|
+
// partc.push(getUHDHtml(parts, part));
|
|
117
|
+
part_chars_used = 3;
|
|
118
|
+
}
|
|
119
|
+
partc = [...partc, charToSpan(chars_arr[i], coding, isUnicodeEnabled)];
|
|
120
|
+
part_chars_used = part_chars_used + 1;
|
|
121
|
+
}
|
|
122
|
+
} else {
|
|
123
|
+
chars_sms = 70;
|
|
124
|
+
for (let i = 0; i < chars_arr.length; i++) {
|
|
125
|
+
partc = [...partc, charToSpan(chars_arr[i], coding, isUnicodeEnabled)];
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
console.log('Type:', (coding == '7bit' ? '7bit' : 'Unicode'));
|
|
131
|
+
console.log('Parts:', parts);
|
|
132
|
+
console.log('SMS Chars:', chars_sms);
|
|
133
|
+
console.log('SMS Char total:', chars_used);
|
|
134
|
+
|
|
135
|
+
return {
|
|
136
|
+
unicode: (coding === '7bit' ? false : true),
|
|
137
|
+
parts,
|
|
138
|
+
chars_sms,
|
|
139
|
+
chars_used,
|
|
140
|
+
char_list: partc,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|