Search The ForumSearch   RegisterRegister  LoginLogin

AfterLogic WebMail Pro

 AfterLogic Forum : AfterLogic WebMail Pro
Subject Topic: Adding javascript, Auto Domain Insertion Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
ajhalls
Newbie
Newbie


Joined: 20 August 2015
Online Status: Offline
Posts: 4
Posted: 20 August 2015 at 3:30pm | IP Logged Quote ajhalls

I was able to get it installed alongside ISPConfig and finally have Postfix configured correctly (not fun). I was getting around to setting up a few accounts to play with and have a couple questions.

In the main Admin Panel, there is a spot to create user accounts, but I don't understand what that is for. Once the account is created, there is no way to edit it / reset password. It also isn't needed to have an account setup there if the domain is configured, it just checks the mail server for that domain and authenticates there, which is all administered from the ISPConfig section. I am certainly not against having a Users tab, I just don't see what it does in this situation.

I was using the script from http://url.websanova.com/ which helps to isolate the TLD so I can have mail.domain1.com, mail.domain2.com, mail.domain13.com and all would point to the same /var/www/webmail directory, and the javascript would append the right domain to the username.

When editing the templates, I attempted to add some javascript to detect the domain which was being logged into. I added it to the bottom of the Index.html and it works for a console.log, but I can't use it to populate the data for the email address. I was hoping to put a div just to the right of the username field with a "@domain.com" which would be automatically appended to the username. Unfortunately if I put that on the Index.html page, that part of the page doesn't exist yet and so isn't populated, so I tried putting it in the WrapLoginView.html file but it wouldn't let me put in a <script> tag, it replaced it with this code I think:
$sTemplateHtml = preg_replace('/<script([^>]*)>/', '<script$1>', $sTemplateHtml);

I am not sure why we are doing that, is there a "right" way to add some javascript that will load at the end, after all else is loaded? I see it already supports configurations for multiple domains, am I rebuilding something already built in to have it auto append the domain?

I did notice this: http://www.afterlogic.com/wiki/Configuring_web_domain_names_%28WebMail_Pro%29, which can let me set the theme, but not sure how to remove the need to put in the domain from the user, which is kind of redundant in my opinion when we are already typed it in to get to the page :)
Back to Top View ajhalls's Profile Search for other posts by ajhalls
 
Igor
AfterLogic Support
AfterLogic Support


Joined: 24 June 2008
Location: United States
Online Status: Offline
Posts: 6087
Posted: 21 August 2015 at 4:13am | IP Logged Quote Igor

Due to the nature of how WebMail is built, there's no straightforward way to add JavaScript onto the pages. In the near future, however, we're going to publish a tutorial on how to add HTML and JavaScript code - for example, banner network code snippet or stats counter.

Adding users through AdminPanel wouldn't usually be required; as long as user account exists on mail server, they should be able to log into that account from login page. We keep the option of adding users via AdminPanel for systems that use non-IMAP backend for authentication, and for those who are willing to restrict users allowed to log in to a certain list, and Adding users effectively works as creating that list.

--
Regards,
Igor, AfterLogic Support

Back to Top View Igor's Profile Search for other posts by Igor
 
ajhalls
Newbie
Newbie


Joined: 20 August 2015
Online Status: Offline
Posts: 4
Posted: 21 August 2015 at 2:15pm | IP Logged Quote ajhalls

I put this in on the bottom of the Index.html
<script type="text/javascript">
<!--
$(function(){
     window.setInterval(function() {
               $("#Domain").text("@" + window.url('domain'));
                    var domain = window.url('domain');
                    if($("#email2").val())
                         {
                              if($("#email2").val( ).indexOf('@') === -1)
                              {
                               $("#email").val($("#email2").val() + "@" + domain);
                              }
                         else
                              {
                              $("#email").val($("# email2").val());
                              }   & nbsp; 
                         }
              
            }, 100);
});
//-->
</script>

and added this to the bottom of /templates/views/Login/LoginViewModel.html

<div class="row email" data-bind="visible: emailVisible, css: {'focused': emailFocus(), 'filled': email().length > 0, shake: shake()}">
               <label for="email" class="title placeholder"></label>
               <span class="value">
                    <input id="email2" tabindex="1" class="input check_autocomplete_input" name="email2"
                         type="email" spellcheck="false" data-bind="hasfocus: emailFocus" placeholder="Username"/>
               <div id="Domain" style="position:absolute;left:270px;font-size:25px;top:130px;"></div></span>
          </div>
          <input id="email" tabindex="1" class="input check_autocomplete_input" name="email" data-i18n="LOGIN/LABEL_EMAIL"
                         type="hidden" spellcheck="false" data-bind="value: email, hasfocus: emailFocus, valueUpdate: 'afterkeydown', initDom: emailDom, i18n: 'placeholder'" />

It would be great if I didn't have to use the setInterval, but it works. Basically I just made the email field hidden, created an email2 field which is what users type in, then every 0.1 seconds I update the email value with the one in email2 so it can be passed through to the Ajax call. It puts the @domain.com to the right of the email to hint that it is just the username, but it isn't mobile friendly right now FYI.
Back to Top View ajhalls's Profile Search for other posts by ajhalls
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump

Powered by Web Wiz Forums version 7.9
Copyright ©2001-2004 Web Wiz Guide