@@ -2,7 +2,9 @@ var app = new Vue({
22 el : '#app' ,
33 data : {
44 tel : localStorage . getItem ( 'tel' ) === null ? '' : localStorage . getItem ( 'tel' ) ,
5- message : localStorage . getItem ( 'message' ) === null ? 'Здравствуйте, ' : localStorage . getItem ( 'message' )
5+ messages : localStorage . getItem ( 'messages' ) === null ? [ 'Здравствуйте, ' , 'Здравствуйте, ' , 'Здравствуйте, ' , 'Здравствуйте, ' , 'Здравствуйте, ' ] :
6+ JSON . parse ( localStorage . getItem ( 'messages' ) ) ,
7+ active_tab : localStorage . getItem ( 'active_tab' ) === null ? '0' : localStorage . getItem ( 'active_tab' )
68 } ,
79 computed : {
810 tel_numeric : function ( ) {
@@ -13,35 +15,47 @@ var app = new Vue({
1315
1416 return numbers
1517 } ,
18+ active_message : {
19+ get : function ( ) {
20+ return this . messages [ this . active_tab ]
21+ } ,
22+ set : function ( newValue ) {
23+ Vue . set ( this . messages , this . active_tab , newValue )
24+ }
25+ } ,
1626 message_encoded : function ( ) {
17- return encodeURI ( this . message ) . replace ( / % 5 B / g, '[' ) . replace ( / % 5 D / g, ']' )
27+ return encodeURI ( this . messages [ this . active_tab ] ) . replace ( / % 5 B / g, '[' ) . replace ( / % 5 D / g, ']' )
1828 } ,
1929 whatsapp_link : function ( ) {
2030 return 'https://api.whatsapp.com/send?phone=' + this . tel_numeric + '&text=' + this . message_encoded
2131 } ,
2232 country : function ( ) {
2333 var data = new libphonenumber . parse ( '+' + this . tel_numeric )
24-
34+
2535 if ( data . country == undefined )
2636 return ''
2737
28- return data . country + ' - ' + getCountryName ( data . country )
38+ return '<span class="badge badge-secondary">' + data . country + '</span> - <span class="badge badge-light"> ' + getCountryName ( data . country ) + '</span>'
2939 }
3040 } ,
3141 methods : {
3242 saveTel : function ( ) {
3343 localStorage . setItem ( 'tel' , this . tel )
3444 } ,
35- saveMessage : function ( ) {
36- localStorage . setItem ( 'message ' , this . message )
45+ saveMessages : function ( ) {
46+ localStorage . setItem ( 'messages ' , JSON . stringify ( this . messages ) )
3747 } ,
3848 clearTel : function ( ) {
3949 this . tel = ''
4050 this . saveTel ( )
4151 } ,
42- clearMessage : function ( ) {
43- this . message = ''
44- this . saveMessage ( )
52+ clearActiveMessage : function ( ) {
53+ this . active_message = ''
54+ this . saveMessages ( )
55+ } ,
56+ setActiveTab : function ( n ) {
57+ this . active_tab = n
58+ localStorage . setItem ( 'active_tab' , n )
4559 }
4660 }
4761} )
0 commit comments