Debugging: just WTF?

This commit is contained in:
Falkvinge
2016-11-23 18:03:42 +01:00
parent 7b05d1a30e
commit f22cb6cc62
3 changed files with 20 additions and 23 deletions
+13 -7
View File
@@ -6,6 +6,8 @@
$(document).ready(function () {
alertify.log("Initialize <%=this.Cookie%>");
$('#<%=this.ClientID%>_sliderContainer').toggles(
{
on: <%= this.InitialValue.ToString().ToLower() %>,
@@ -16,12 +18,11 @@
off: SwarmopsJS.unescape('<%= this.Localized_SwitchLabelOff_Upper %>')
}
})
.on('toggle', function(e, active)
{
.on('toggle', function(e, active) {
alertify.log("Toggle: <%=this.Cookie%> " + active);
if (active != _initVal_<%=this.SliderCheckbox.ClientID%>) {
var jsonData = {};
jsonData.newValue = active;
jsonData.cookie = '<%=this.Cookie%>';
alertify.log("Change detect");
// The AJAX call expects the following function prototype:
//
@@ -34,6 +35,10 @@
if ("" != "<%=this.AjaxCallbackUrl%>") { // if there's a direct callback AJAX url
var jsonData = {};
jsonData.newValue = active;
jsonData.cookie = '<%=this.Cookie%>';
SwarmopsJS.ajaxCall(
"<%=this.AjaxCallbackUrl%>",
jsonData,
@@ -80,6 +85,7 @@
} else {
// if there's no AJAX callback URL given, the javascript handler must take care of it
// Resharper marks this code as unused because it falsely thinks the if condition above is always true
alertify.log("Calling <%=this.OnChange%>()");
_initVal_<%=this.SliderCheckbox.ClientID%> = active;
<%=this.OnChange%> (active, '<%=this.Cookie%>', '<%=this.ClientID%>'); // JavaScript callback on successful change
}
@@ -98,12 +104,12 @@
}
function <%=this.ClientID%>_setValue(newValue) {
$('#<%=this.ClientID%>_sliderContainer').toggles({ on: newValue });
$('#<%=this.ClientID%>_sliderContainer').toggles({ on: newValue }, true, true);
}
function <%=this.ClientID%>_initialize(initValue) {
_initVal_<%=this.SliderCheckbox.ClientID%> = initValue;
$('#<%=this.ClientID%>_sliderContainer').toggles({ on: initValue });
$('#<%=this.ClientID%>_sliderContainer').toggles({ on: initValue }, true, true);
<%=this.ClientID%>_enable();
}
+7 -7
View File
@@ -250,7 +250,7 @@
<h2><span class="spanModalEditingPersonName">PERSONNAME</span>: <asp:Label runat="server" ID="MasterLabelEditPersonHeaderSecurity" Text="#Your Security#"/></h2>
<div class="entryFields">
<Swarmops5:AjaxTextBox ID="MasterEditPersonCurrentPassword" runat="server" Mode="Password" OnKeyDown="masterPersonEditorOnSecurityPasswordKeyDown" OnChanging="masterPersonEditorOnSecurityPasswordChanging" Cookie="CurrentPassword" AjaxCallbackUrl="" />&#8203;<br/>
<div class="divMasterPersonEditSecurityRolldown" style="display:none"><Swarmops5:AjaxToggleSlider ID="MasterEditPerson2FA" runat="server" OnChange="masterPersonEditor2FAToggle" Cookie="2FA" AjaxCallbackUrl="" />&#8203;<br/>
<div class="divMasterPersonEditSecurityRolldown" style="display:none">&#8203;<br/>
<Swarmops5:AjaxTextBox ID="MasterEditPersonNewPassword1" runat="server" Mode="Password" OnChanging="masterPersonEditorOnSecurityNewPasswordChanging" Cookie="Password1" AjaxCallbackUrl="" />&#8203;<br/>
<Swarmops5:AjaxTextBox ID="MasterEditPersonNewPassword2" runat="server" Mode="Password" OnChanging="masterPersonEditorOnSecurityNewPasswordChanging" Cookie="Password2" AjaxCallbackUrl="" />
</div>
@@ -266,7 +266,7 @@
<h2><span class="spanModalEditingPersonName">PERSONNAME</span>: <asp:Label ID="MasterLabelEditPersonHeaderSecurityProvisioning" runat="server" /></h2>
<div class="entryFields">
<input type="button" id="masterPersonEditButtonResetPassword" onclick="masterPersonEditorConfirmResetPassword(); return false;" value="#SendResetMail#" />&#8203;<br/>
<Swarmops5:AjaxToggleSlider ID="MasterEditPerson2FAProvisioning" runat="server" Label="2FALabel" Cookie="2FA" AjaxCallbackUrl="" OnChange="masterPersonEditor2FAProvisionToggle"/>
<Swarmops5:AjaxToggleSlider ID="MasterEditPerson2FAProvisioning" runat="server" Label="BitID enable" Cookie="2FAProvision" AjaxCallbackUrl="" OnChange="masterPersonEditor2FAProvisionToggle"/>
</div>
<div class="entryLabels">
@@ -485,7 +485,7 @@
<%= this.MasterEditPersonPhone.ClientID %>_initialize(data.Phone);
<%= this.MasterEditPersonTwitterId.ClientID %>_initialize(data.TwitterId);
<%= this.MasterEditPerson2FA.ClientID%>_initialize(data.TwoFactorActive);
<%= this.MasterEditPerson2FAProvisioning.ClientID %>_initialize(data.TwoFactorActive);
_master_PersonEditLoading = false;
@@ -508,12 +508,12 @@
// (the AjaxToggleSlider auto-callback is disabled for this reason)
alert("Field Change: " + fieldName + " changed to '" + newValue + "'");
alertify.log("Field Change: " + fieldName + " changed to '" + newValue + "'");
}
function masterPersonEditor2FAToggle(newValue, fieldName, controlName) {
alert("2FA Field Change: " + fieldName + " changed to '" + newValue + "'");
alertify.log("2FA Field Change: " + fieldName + " changed to '" + newValue + "'");
if (newValue) // this is a boolean, so "== true" is implicit
{
<%= this.ModalMasterEnableBitId.ClientID %>_open();
@@ -523,11 +523,11 @@
function masterPersonEditor2FAProvisionToggle(newValue, fieldName, controlName) {
alert("2FA Provisioning Field Change: " + fieldName + " changed to '" + newValue + "'");
alertify.log("2FA Provisioning Field Change: " + fieldName + " changed to '" + newValue + "'");
if (newValue) { // it's a boolean, so "if true" meaning if the slider is "on"
// 2FA can't be provisioned true, only installed by the user
<%= this.MasterEditPerson2FAProvisioning.ClientID %>_initialize(false);
setTimeout(function() { <%= this.MasterEditPerson2FAProvisioning.ClientID %>_initialize(false); }, 500);
alertify.alert(SwarmopsJS.unescape('<%=this.Localized_MasterPersonEdit_CannotProvision2FA%>'));
} else {
alertify.confirm(SwarmopsJS.unescape('<%=this.Localized_MasterPersonEdit_ConfirmRemove2FAProvision%>'),
-9
View File
@@ -381,15 +381,6 @@ namespace Swarmops.Frontend {
/// </remarks>
protected global::Swarmops.Frontend.Controls.Base.AjaxTextBox MasterEditPersonCurrentPassword;
/// <summary>
/// MasterEditPerson2FA control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::Swarmops.Frontend.Controls.Base.AjaxToggleSlider MasterEditPerson2FA;
/// <summary>
/// MasterEditPersonNewPassword1 control.
/// </summary>