wisest owl (wisest_owl) wrote in changelog,
wisest owl
wisest_owl
changelog

[ljcom] r9484: LJSUP-6482

Committer: gprochaev
[LJSUP-6482] SMS Notification RU

U   trunk/bin/upgrading/update-db-local.pl
U   trunk/htdocs/js/editprofile.js
Modified: trunk/bin/upgrading/update-db-local.pl
===================================================================
--- trunk/bin/upgrading/update-db-local.pl	2010-09-10 07:11:31 UTC (rev 9483)
+++ trunk/bin/upgrading/update-db-local.pl	2010-09-10 07:46:49 UTC (rev 9484)
@@ -1530,7 +1530,7 @@
 register_tablecreate("smsru_phones", <<'EOC');
 create table `smsru_phones` (
     userid      INT(10) UNSIGNED,
-    phone       INT(10),
+    phone       varchar(12),
     status      varchar(50),
 
     UNIQUE INDEX(userid)
@@ -1992,6 +1992,10 @@
                  "ALTER TABLE shop_userheads ADD uh_desc VARCHAR(20) DEFAULT '' AFTER uh_author");
     }
 
+    unless (column_type("smsru_phones", "phone") =~ /char/i) {
+        do_alter("smsru_phones",
+            "ALTER TABLE smsru_phones MODIFY phone VARCHAR(12)");
+    }
 
 });
 

Modified: trunk/htdocs/js/editprofile.js
===================================================================
--- trunk/htdocs/js/editprofile.js	2010-09-10 07:11:31 UTC (rev 9483)
+++ trunk/htdocs/js/editprofile.js	2010-09-10 07:46:49 UTC (rev 9484)
@@ -82,12 +82,13 @@
 					}
 					else
 					{
-						if(initial)
-						{
-							that.checkVerification();
+						that.setState('correctNum', 'success', 'correctnum');
+						if(initial) {
+							var initState = smsNotifyInitialState || "";
+							if(initState.length > 0) {
+								that.checkVerification(initState);
+							}
 						}
-						else
-							that.setState('correctNum', 'success', 'correctnum');
 					}
 					initial = false;
 				}
@@ -139,12 +140,19 @@
 			});
 		},
 
-		checkVerification: function()
+		checkVerification: function(override)
 		{
+			override = override || "";
+
+			if(override.length > 0) {
+				this.processVerificationResult(override);
+				return;
+			}
+
 			var that = this;
-			clearInterval(this.verifyTimer);
+			clearTimeout(this.verifyTimer);
 			this.stopVerification = false;
-			this.verifyTimer = setInterval(function()
+			this.verifyTimer = setTimeout(function()
 			{
 				$.get(that.endpoint, function(data)
 				{
@@ -152,19 +160,28 @@
 						return;
 
 					var result = $.trim(data.replace('status:',''));
-					switch(result)
-					{
-						case 'rate_limit_exceded': that.setState('totallimitexceeded', 'error', 'rateexceed'); break;
-						case 'verification_sms_sended': that.setState('smssent', 'success', 'smssent'); break;
-						case 'wrong_rcpt_number': that.setState('notasubscriber', 'error'); break;
-						case 'verified': that.setState('verified', 'success', 'verified'); break;
-						case 'verification_outdated': that.setState('linkexpired', 'error'); break;
-						case 'added': that.setState('requestsent', 'success', 'reqsent'); break;
-					}
+					that.processVerificationResult(result);
 				});
 			}, 1500);
 		},
 
+		processVerificationResult: function(result)
+		{
+			switch(result)
+			{
+				case 'rate_limit_exceded': this.setState('totallimitexceeded', 'error', 'rateexceed'); break;
+				case 'verification_sms_sended': this.setState('smssent', 'success', 'smssent'); break;
+				case 'wrong_rcpt_number': this.setState('notasubscriber', 'error'); break;
+				case 'verified': this.setState('verified', 'success', 'verified'); break;
+				case 'verification_outdated': this.setState('linkexpired', 'error'); break;
+				case 'verification_asked': this.setState('requestsent', 'success', 'reqsent');
+											this.checkVerification();
+											break;
+				case 'not_verified': this.setState('requestsent', 'success', 'reqsent');
+
+			}
+		},
+
 		getState: function()
 		{
 			return this.state;
@@ -197,7 +214,7 @@
 			{
 				hideSendButton = hideSendButton || false;
 				that.ui.resendBtn.parent('.b-manage-smsn-btn').css('display', (hideSendButton) ? 'none' : '');
-				clearInterval(that.verifyTimer);
+				clearTimeout(that.verifyTimer);
 				that.stopVerification = true;
 				that.ui.phVerification.css('display', 'none');
 				that.ui.verCode.val('');
@@ -225,8 +242,9 @@
 									resetUI();
 									break;
 					case 'reqsent':	bt.val( dict['resendsmsbut']);
+									bt.attr('disabled', false);
 									this.ui.resendBtn.parent('.b-manage-smsn-btn').css('display','');
-									this.ui.phVerification.removeAttr('style')
+									this.ui.phVerification.removeAttr('style');
 									break;
 					case 'rateexceed': bt.attr('disabled', true);
 									resetUI();

Tags: js, ljcom, pl, wisest-owl
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments