Source: site.view [edit]
Function name: sell2
Arguments:
Description: Optional Args: 0: message, 1:sessionkey, 2:type, 3:address, 4:price, 5:size, 6:lotSize, 7;beds, 8:baths, 9:features, 10:description
Page type: html
Render function:  
Module: maybeathome

Page source:

<!DOCTYPE html>
        <webl>WubCall("maybeathome.header", ["sell"]);</webl>

        <div class="login-register-wrapper">
            <div class="container">
          
       <webl>
         //print message
         if (Size(OPTIONALARGS) > 1) and (OPTIONALARGS[1] != "msg") then
            "<p class='message'>" + ToString(OPTIONALARGS[1]) + "</p>\n"
         else
            ""
         end;
       </webl>
          
                <h3 data-localize="sell.sellProperty">List Your Property</h3>
                <div class="custom-form-wrapper owner-wrapper">
                    <span id="response_mesg"></span>
                    <div class="alert alert-danger alert-message">
                        <p class="street-number-hid">Street Number is required</p>
                        <p class="route-hid">Route is required</p>
                        <p class="locality-hid">Locality is required</p>
                        <p class="administrative-area-level-1-hid">Administrative area level 1 is required</p>
                        <p class="administrative_area-level-2-hid">Administrative area level 2 is required</p>
                        <p class="country-hid">Country is required</p>
                        <p class="postal-code-hid">Postal Code is required</p>
                        <p class="lat-hid">Latitude is required</p>
                        <p class="lng-hid">Longitude is required</p>
                    </div>
                    <form id="post_form" onsubmit="return false;" class="form-horizontal" enctype="multipart/form-data">
                      
                        <webl>
                           var res = "";
                           var sessionkey = wubinfo.cookies.sessionkey ? nil;
                           if (sessionkey != nil) then
                              res = `<input type="hidden" name="sessionkey" value="` + sessionkey + `" />` + "\n";
                           else
                              res = `<input type="hidden" name="sessionkey" value="nil" />` + "\n";
                           end;
                          
                           var userInfo = WubCall("siteutil.getSessionInfo", ["maybeathome", sessionkey]);
                           if (userInfo == nil) then
                               res = res + `<input type="hidden" class="form-control" name="userId" id="userId" >` + "\n";
                               res = res + `<input type="hidden" class="form-control" name="userType" id="userType" >` + "\n"
                           else
                               res = res + `<input type="hidden" class="form-control" name="userId" id="userId" value="` + userInfo.username + `">` + "\n";
                               res = res + `<input type="hidden" class="form-control" name="userType" id="userType" value="` + (userInfo.arg0 ? "unknown") + `">` + "\n"
                           end;
                           res;
                        </webl>
                                            
                      
                        <div class="row">
                            <div class="col-sm-6">
                                <div class="form-group">
                                    <label for="type" class="col-sm-3 control-label" data-localize="sell.type">Type</label>
                                    <div class="col-sm-9">
                                        <select class="form-control" id="type" name="type" >
                                            <option data-localize="buy.existingHouse" selected>Home</option>
                                            <option data-localize="buy.existingApartment">Apartment</option>
                                            <option data-localize="buy.newHouse">New Home</option>
                                            <option data-localize="buy.newApartment">New Apartment</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="address" class="col-sm-3 control-label" data-localize="sell.address">Address</label>
                                    <div class="col-sm-9">
                                        <input type="text" class="form-control" id="address" name="address" onFocus="geolocate()" placeholder="" data-localize="sell.addressPlaceholder" required>    
                                        <span class="error-msg address"></span>
                                    </div>
                                    <label for="addressLine2" class="col-sm-3 control-label" data-localize="sell.addressLine2">Line 2</label>
                                    <div class="col-sm-9">
                                        <input type="text" class="form-control" id="addressLine2" name="addressLine2" placeholder="Apartment #" data-localize="sell.addressLine2Placeholder">    
                                        <span class="error-msg address"></span>
                                    </div>
                                </div>                              

                                 <!-- Hidden fields that break up address into constituent parts -->
                                   <input type="hidden"  id="street_number_hid" name="street_number_hid">
                                   <input type="hidden"  id="route_hid" name="route_hid" required>
                                   <input type="hidden"  id="locality_hid" name="locality_hid" required>
                                   <input type="hidden"  id="administrative_area_level_1_hid" name="administrative_area_level_1_hid">
                                   <input type="hidden"  id="administrative_area_level_2_hid" name="administrative_area_level_2_hid">
                                   <input type="hidden"  id="country_hid" name="country_hid">
                                   <input type="hidden"  id="postal_code_hid" name="postal_code_hid">
                                   <input type="hidden"  id="lat_hid" name="lat_hid">
                                   <input type="hidden"  id="lng_hid" name="lng_hid">
                              
                              
                                 <div class="form-group">
                                    <label for="photos" class="col-sm-3 control-label" data-localize="sell.photos">Photo</label>
                                    <div class="col-sm-9">
                                        <div class="dropzone">
                                            <div class="fallback">
                                                <input id="file" name="file" type="file" multiple required />
                                            </div>
                                        </div>
                                        <div class="error-msg photos-error">Photos are required</div>
                                        <span class="error-msg file"></span>

                                        <!--                                        <div class="bootstrap-file-input-wrapper">
                                                                                    <input id="input-id" webkitdirectory data-file-caption-name="name" name="image[]" class="image file-uploading" type="file" multiple="multiple"  data-preview-file-type="image" data-show-remove="false" data-show-upload="false">
                                                                                </div>-->
                                    </div>
                                </div>
                            </div>
                            <div class="col-sm-6">
                                <div class="form-group">
                                    <label for="name" class="col-sm-3 control-label" data-localize="sell.sizes">Size, Lot Size</label>
                                    <div class="col-sm-9">
                                        <div class="row">
                                            <div class="col-sm-6">
                                                <input type="text" class="form-control" id="size" name="size" placeholder="" data-localize="sell.size" required>
                                                <span class="error-msg size"></span>
                                            </div>
                                            <div class="col-sm-6">
                                                <input type="text" class="form-control" id="lotSize" name="lotSize" placeholder="" data-localize="sell.lotSize" required>
                                                <span class="error-msg lotSize"></span>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="name" class="col-sm-3 control-label" data-localize="sell.rooms">Number of Rooms</label>
                                    <div class="col-sm-9">
                                        <div class="row">
                                            <div class="col-sm-12">
                                                <input type="text" class="form-control" id="rooms" name="rooms" placeholder="" data-localize="sell.rooms" required>
                                                <span class="error-msg rooms"></span>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <input type="hidden" class="form-control" data-localize="sell.currency" name="currency" id="currency" required value="USD" >
                                    <input type="hidden" class="form-control" data-localize="sell.measurement" name="measurement" required id="measurement" 
                                        value="sqft">
                                </div>
                             
                                <div class="form-group">
                                    <label for="name" class="col-sm-3 control-label" data-localize="sell.bedsBaths">Beds, Baths</label>
                                    <div class="col-sm-9">
                                        <div class="row">
                                            <div class="col-sm-6">
                                                <input type="text" class="form-control" id="beds" name="beds" placeholder="" data-localize="sell.beds" required>                                                         <span class="error-msg beds"></span>
                                            </div>
                                            <div class="col-sm-6"> 
                                                <input type="text" class="form-control" id="baths" name="baths" placeholder="" data-localize="sell.baths" required>
                                                <span class="error-msg baths"></span>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group">
                                   <label for="price" class="col-sm-3 control-label" data-localize="sell.price">Desired Price</label>
                                   <div class="col-sm-8">
                                      <div class="row">
                                          <div class="col-sm-8">                                            
                                             <input type="text" class="form-control" id="price" name="price"  data-localize="sell.pricePlaceholder"
                                                    <webl>if Size(OPTIONALARGS) > 4 then `value="` + OPTIONALARGS[4] + `"` else "" end; </webl>
                                        		placeholder="" required>
                                             <span class="error-msg price"></span>
                                          </div>
                                          <div class="col-sm-4">
                                              <button type="button" onclick="getEstimate()" id="estimate_btn" class="btn pull-right btn-custom" 
                                                   data-localize="sell.estimate">Estimate</button>
                                          </div>
                                      </div>
                                   </div>
                                </div>                      
                                <div class="form-group">
                                    <label for="features" class="col-sm-3 control-label" data-localize="sell.features">Features</label>
                                    <div class="col-sm-9">
                                        <div class="bootstrap-tagsinput-wrapper">
                                            <input type="text" class="form-control" id="features" name="features" value="" data-role="tagsinput"/>
                                            <span class="error-msg features"></span>
                                        </div>
                                         <div class="error-msg features-error">Features are required</div>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="features" class="col-sm-3 control-label" data-localize="sell.description">Description</label>
                                    <div class="col-sm-9">
                                        <div class="bootstrap-tagsinput-wrapper">
                                           <textarea class="form-control" id="description" name="description" cols="3" rows="3" data-role="tagsinput" required></textarea>
                                          <span class="error-msg description"></span>
                                        </div>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-sm-9 col-sm-offset-3">
                                      <button type="button" data-toggle="modal" data-target="#previewModal" class="btn pull-left btn-custom btn-preview" 
                                           data-localize="sell.preview">Preview</button>
                                        <button type="submit" class="btn pull-right btn-custom submit_form" id="form_submit" data-localize="sell.submit"
                        <webl>
                           var sessionkey = wubinfo.cookies.sessionkey ? nil;
                           if Size(OPTIONALARGS) > 0 then
                              sessionkey = OPTIONALARGS[0]
                           end;
                           var userInfo = WubCall("siteutil.getSessionInfo", ["maybeathome", sessionkey]);
                           if (userInfo == nil or userInfo.arg0 == "buyer") then
                              "disabled=true"
                           else
                              ""
                           end;
                        </webl>
                                      
                                           value="listed">Submit</button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>

        <!--  Preview Modal Starts  -->
        <div class="modal fade modal-wrapper" id="previewModal" tabindex="-1" role="dialog" aria-labelledby="scheduleModalLabel">
            <div class="modal-dialog modal-lg" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <!--<span aria-hidden="true">&times;</span>-->
                            <span data-localize="results.modal.close"></span>
                        </button>
                        <h4 class="modal-title" id="myModalLabel" data-localize="results.modal.head"></h4>
                    </div>
                    <div class="modal-body">
                        <div class="well">
                            <div class="row">
                                <div class="col-sm-6">
                                    <p class="row">
                                        <strong class="col-sm-4"  data-localize="sell.type"></strong>
                                        <span class="col-sm-8" id="type"></span>
                                    </p>
                                    <p class="row">
                                        <strong class="col-sm-4" data-localize="sell.address"></strong>
                                        <span class="col-sm-8" id="address"></span>
                                    </p>
                                    <p class="row">
                                        <strong class="col-sm-4" data-localize="sell.sizes"></strong>
                                        <span class="col-sm-4" id="size"></span>
                                        <span class="col-sm-4" id="lotSize"></span>
                                    </p>
                                  	<p class="row">
                                        <strong class="col-sm-4" data-localize="sell.rooms">Rooms</strong>
                                        <span class="col-sm-4" id="rooms"></span>
                                    </p>
                                </div>
                                <div class="col-sm-6">
                                    <p class="row">
                                        <strong class="col-sm-4" data-localize="sell.bedsBaths"></strong>
                                          <span class="col-sm-4" id="beds"></span>
                                          <span class="col-sm-4" id="baths"></span>
                                      </p>
                                    <p class="row">
                                        <strong class="col-sm-4" data-localize="sell.price"></strong>
                                        <span class="col-sm-8" id="price"></span>
                                    </p>
                                    <p class="row">
                                        <strong class="col-sm-4" data-localize="sell.features"></strong>
                                        <span class="col-sm-8" id="features"></span>
                                    </p>
                                </div>
                            </div>
                            <div class="bx-slider-wrapper">
                                <ul class="bxslider clearfix"></ul>
                            </div>
                            <p class="row">
                                <strong class="col-sm-2" data-localize="sell.description"></strong>
                                <span class="col-sm-10 perfect-scroll" id="description"></span>
                            </p>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <!-- div class="row">
                            <div class="col-sm-12">
                                <button type="button" class="btn btn-schedule" data-localize="results.modal.button"></button>
                            </div>
                        </div -->
                    </div>
                </div>
            </div>
        </div>
        <!--  Preview Modal Ends  -->

       <webl>WubCall("maybeathome.footer", ["sell"]);</webl>


       <webl> WubCall("maybeathome.autocomplete", []); </webl>
        <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAO2RntyX5IUgDJmXO-i39U06wwIhKwdEE&libraries=places&callback=initAutocomplete"
           async defer></script>
	
        <!--  Perfect Scrollbar Script  -->
        <script src="assets/plugins/perfect-scrollbar/perfect-scrollbar.min.js" type="text/javascript"></script>

        <!--  Dropzone Script  -->
        <script src="assets/plugins/dropzone/dropzone.js" type="text/javascript"></script>

        <!--Bootstrap Tags Input Script  -->
        <script src="assets/plugins/bootstrap-tagsinput/bootstrap-tagsinput.js" type="text/javascript"></script>
		<!--  BX-Slider Script  -->
        <script src="assets/plugins/bxslider/jquery.bxslider.js" type="text/javascript"></script>
        <!--<script src="assets/js/custom.js" type="text/javascript"></script>-->
        <!--  Custom Script  -->
        <script type="text/javascript">
                    function validateForm(form) {
                            var type, address, size, lotSize,rooms, beds, baths, price, features, description,
                                    streetNumberHid, routeHid, localityHid, administrativeArea1Hid, administrativeArea2Hid,
                                    countryHid, postalCodeHid, latHid, lngHid;

                            type = $(".owner-wrapper #type").val();
                            address = $(".owner-wrapper #address").val();
                            size = $(".owner-wrapper #size").val();
                            lotSize = $(".owner-wrapper #lotSize").val();
                      		rooms = $(".owner-wrapper #rooms").val();
                            beds = $(".owner-wrapper #beds").val();
                            baths = $(".owner-wrapper #baths").val();
                            price = $(".owner-wrapper #price").val();
                            features = $(".owner-wrapper #features").val();
                            description = $(".owner-wrapper #description").val();

                            /*--  Hidden Fields Value  --*/
                            streetNumberHid = $(".owner-wrapper #street_number_hid").val();
                            routeHid = $(".owner-wrapper #route_hid").val();
                            localityHid = $(".owner-wrapper #locality_hid").val();
                            administrativeArea1Hid = $(".owner-wrapper #administrative_area_level_1_hid").val();
                            administrativeArea2Hid = $(".owner-wrapper #administrative_area_level_2_hid").val();
                            countryHid = $(".owner-wrapper #country_hid").val();
                            postalCodeHid = $(".owner-wrapper #postal_code_hid").val();
                            latHid = $(".owner-wrapper #lat_hid").val();
                            lngHid = $(".owner-wrapper #lng_hid").val();

                            if (address == '') {
                                return false;
                            }
                            else if (address == '') {
                                return false;
                            }
                            else if (size == '') {
                                return false;
                            }
                            else if (lotSize == '') {
                                return false;
                            }
                      		 else if (rooms == '') {
                                return false;
                            }
                            else if (beds == '') {
                                return false;
                            }
                            else if (baths == '') {
                                return false;
                            }
                            else if (price == '') {
                                return false;
                            }
                            else if (features == '') {
                                $(".features-error").show();
                                return false;
                            }
                            else if (description == '') {
                                return false;
                            } 

                            /*--  Hidden Fields  --*/
                            else if (streetNumberHid == '') {
                                $(".alert-message").show();
                                $(".street-number-hid").show();
                                return false;
                            }
                            else if (routeHid == '') {
                                $(".alert-message").show();
                                $(".route-hid").show();
                                return false;
                            }
                            else if (localityHid == '') {
                                $(".alert-message").show();
                                $(".locality-hid").show();
                                return false;
                            }
                            else if (administrativeArea1Hid == '') {
                                $(".alert-message").show();
                                $(".administrative-area-level-1-hid").show();
                                return false;
                            }
                            else if (administrativeArea2Hid == '') {
                                $(".alert-message").show();
                                $(".administrative_area-level-2-hid").show();
                                return false;
                            }
                            else if (countryHid == '') {
                                $(".alert-message").show();
                                $(".country-hid").show();
                                return false;
                            }
                            else if (postalCodeHid == '') {
                                $(".alert-message").show();
                                $(".postal-code-hid").show();
                                return false;
                            }
                            else if (latHid == '') {
                                $(".alert-message").show();
                                $(".lat-hid").show();
                                return false;
                            }
                            else if (lngHid == '') {
                                $(".alert-message").show();
                                $(".lng-hid").show();
                                return false;
                            }
                            else {
                                $(".features-error").hide();
                                $(".alert-message").hide();
                                $(".street-number-hid").hide();
                                $(".route-hid").hide();
                                $(".locality-hid").hide();
                                $(".administrative-area-level-1-hid").hide();
                                $(".administrative_area-level-2-hid").hide();
                                $(".country-hid").hide();
                                $(".postal-code-hid").hide();
                                $(".lat-hid").hide();
                                $(".lng-hid").hide();
                                return true;
                            }
                        }
	
                        /*--   Bootstrap Tags Input Initialization  --*/
                        $("#features").tagsinput();

                        var status = "";
                        $("button[type=submit]").click(function () {                         
                            if (this.id == "form_submit") {
                                status = "listed";
                            } else {
                                status = "preview"
                            }
                        });

                        $("input[type=text], textarea[name='description'], .dz-preview ").on('blur change select', function () {
                          if($(this).parents().hasClass("bootstrap-tagsinput")){
                             //$('#features').tagsinput('focus');   
                               return false;
                          }
                         // console.log($(this).parents().hasClass("bootstrap-tagsinput"));
                            if ($('.dz-preview').length == 0) {
                                $('.file').show();
                            } else {
                                $('.file').hide();
                            }
                            if ($('#' + this.id).val() != "") {
                                $('.' + this.id).hide();
                            } else if ($('#' + this.id).val() == "") {
                                $('.' + this.id).show();  
                               
                            }
                            else {
                              
                            }
                          
                        });
          
                        /*--   Dropzone Initialization  --*/
                        var currentdate = new Date(), previewImgUrl = [];
                        var datetime = currentdate.getFullYear() + "-"
                                + (currentdate.getMonth() + 1) + "-"
                                + currentdate.getDate() + " "
                                + currentdate.getHours() + ":"
                                + currentdate.getMinutes() + ":"
                                + currentdate.getSeconds();
                        Dropzone.autoDiscover = false;
                        myDropzone = $("#post_form .dropzone").dropzone({
                            url: "restAPI.php",
                            autoProcessQueue: false,
                            addRemoveLinks: true,
                            previewsContainer: ".dropzone",
                            uploadMultiple: true,
                            parallelUploads: 25,
                            maxFiles: 25,
                            sending: function (file, xhr, formData) {
                                formData.append("type", $("#type").val());
                                formData.append("address", $("#address").val());
                                formData.append("addressLine2", $("#addressLine2").val());
                                formData.append("street", $("#street_number_hid").val() + " " + $("#route_hid").val());
                                formData.append("city", $("#locality_hid").val());
                                formData.append("state", $("#administrative_area_level_1_hid").val());
                                formData.append("zip", $("#postal_code_hid").val());
                                formData.append("county", $("#administrative_area_level_2_hid").val());
                                formData.append("country", $("#country_hid").val());
                                formData.append("lat", $("#lat_hid").val());
                                formData.append("lng", $("#lng_hid").val());
                                formData.append("size", $("#size").val());
                                formData.append("lotSize", $("#lotSize").val());
                                formData.append("rooms", $("#rooms").val());
                                formData.append("beds", $("#beds").val());
                                formData.append("baths", $("#baths").val());
                                formData.append("price", $("#price").val());
                                formData.append("features", $("#features").val());
                                formData.append("description", $("#description").val());
                                formData.append("status", status);
                                formData.append("currency", typeof ($("#currency").val()) != "undefined" ? $("#currency").val() : "null");
                                formData.append("measurement", typeof ($("#measurement").val()) != "undefined" ? $("#measurement").val() : "null");
                                formData.append("userId", typeof ($("#userId").val()) != "undefined" ? $("#userId").val() : "null");
                                formData.append("userType", typeof ($("#userType").val()) != "undefined" ? $("#userType").val() : "null");
                                formData.append("createdAt", datetime);
                            },
                            init: function (file, xhr, formData) {
                               // var submitButton = document.querySelector("#form_submit");
                                var myDropzone = this;

                                myDropzone.on("addedfile", function (file) {                                                                    
                                        setTimeout(function () {
                                            if (myDropzone.getQueuedFiles().length > 0) {
                                               $(".photos-error").hide();
                                            }
                                            previewImgUrl = [];
                                            $(".dropzone .dz-preview").each(function () {
                                                previewImgUrl.push($(this).find(".dz-image img").attr("src"));
                                            });
                                           
                                            $("#previewModal .bx-slider-wrapper .bxslider li").remove();
                                            for (i = 0; i < previewImgUrl.length; i++) {
                                                $("#previewModal .bx-slider-wrapper .bxslider").append("<li><img src=" + previewImgUrl[i] + " alt='image' /></li>");
                                            }
                                        }, 200);
                                });
                                myDropzone.on("removedfile", function (file) {                                                                 
                                        setTimeout(function () {
                                             if (myDropzone.getQueuedFiles().length > 0) {
                                               $(".photos-error").hide();
                                             }
                                            previewImgUrl = [];
                                            $(".dropzone .dz-preview").each(function () {
                                                previewImgUrl.push($(this).find(".dz-image img").attr("src"));
                                            });
                                            
                                            $("#previewModal .bx-slider-wrapper .bxslider li").remove();
                                            for (i = 0; i < previewImgUrl.length; i++) {
                                                $("#previewModal .bx-slider-wrapper .bxslider").append("<li><img src=" + previewImgUrl[i] + " alt='image' /></li>");
                                            }
                                        }, 200);
                                });

                                $('#post_form').on('submit', function (e) {
                                  //e.preventDefault();
                                    if (myDropzone.getQueuedFiles().length > 0) {
                                          if (validateForm(this) === true) {
                                           myDropzone.processQueue();
                                           return false;
                                        }
                                    }else if (myDropzone.getQueuedFiles().length === 0) {
                                        validateForm(this) === false;
                                        $(".photos-error").show();
                                    }
                                   /* else {
                                         if (validateForm(this) == true) {
                                           e.preventDefault();
                                            var imageData = new FormData(this);
                                            var currentdate = new Date();
                                            var datetime = currentdate.getFullYear() + "-"
                                                    + (currentdate.getMonth() + 1) + "-"
                                                    + currentdate.getDate() + " "
                                                    + currentdate.getHours() + ":"
                                                    + currentdate.getMinutes() + ":"
                                                    + currentdate.getSeconds();

                                            imageData.append("type", $("#type").val());
                                            imageData.append("type", $("#type").val());
                                            imageData.append("address", $("#address").val());
                                            imageData.append("addressLine2", $("#addressLine2").val());
                                            imageData.append("street", $("#street_number_hid").val() + " " + $("#route_hid").val());
                                            imageData.append("city", $("#locality_hid").val());
                                            imageData.append("state", $("#administrative_area_level_1_hid").val());
                                            imageData.append("zip", $("#postal_code_hid").val());
                                            imageData.append("county", $("#administrative_area_level_2_hid").val());
                                            imageData.append("country", $("#country_hid").val());
                                            imageData.append("lat", $("#lat_hid").val());
                                            imageData.append("lng", $("#lng_hid").val());
                                            imageData.append("size", $("#size").val());
                                            imageData.append("lotSize", $("#lotSize").val());
                                            imageData.append("beds", $("#beds").val());
                                            imageData.append("baths", $("#baths").val());
                                            imageData.append("price", $("#price").val());
                                            imageData.append("features", $("#features").val());
                                            imageData.append("description", $("#description").val());
                                            imageData.append("status", status);
                                            imageData.append("currency", typeof ($("#currency").val()) != "undefined" ? $("#currency").val() : "null");
                                            imageData.append("measurement", typeof ($("#measurement").val()) != "undefined" ? $("#measurement").val() : "null");
                                            imageData.append("userId", typeof ($("#userId").val()) != "undefined" ? $("#userId").val() : "null");
                                            imageData.append("userType", typeof ($("#userType").val()) != "undefined" ? $("#userType").val() : "null");
                                            imageData.append("createdAt", datetime);

                                            $.ajax({
                                                url: "restAPI.php",
                                                type: 'POST',
                                                data: imageData,
                                                enctype: 'multipart/form-data',
                                                async: false,
                                                processData: false,
                                                contentType: false,
                                                success: function (response) {
                                                    $('#response_mesg').empty();
                                                    if (response.status == 200) {
                                                        $('#response_mesg').focus();
                                                        $('#response_mesg').html("<div class='alert alert-success fade in'>" + response.message + "\n\
                                                        <button type='button' class='close' data-dismiss='alert'>x</button></div>");
                                                    }
                                                    else {
                                                        $('#response_mesg').focus();
                                                        $('#response_mesg').html("<div class='alert alert-danger fade in'>" + response.message + "\n\
                                                        <button type='button' class='close' data-dismiss='alert'>x</button></div>");
                                                    }
                                                },
                                                error: function (XMLHttpRequest, textStatus, errorThrown) {
                                                    console.log("Req: " + XMLHttpRequest);
                                                    console.log("Status: " + textStatus);
                                                    console.log("Error: " + errorThrown);
                                                }
                                            });
                                        }
                                       });
                                    }*/
                                });
                            },
                            complete: function (file) {
                              //console.log(file.xhr.response, "formdata");
                              var response = JSON.parse(file.xhr.response)
                              console.log(response);
                               if (response.status == 200) {
                                       $('#response_mesg').focus();
                                       $('#response_mesg').html("<div data-localize='sell.added' class='alert alert-success fade in'>" + "Property added." + "\n\
                                           <button type='button' class='close' data-dismiss='alert'>x</button></div>");
                                     setTimeout(function () {
                                       
                        <webl>
                           var sessionkey = wubinfo.cookies.sessionkey ? nil;
                           if Size(OPTIONALARGS) > 0 then
                              sessionkey = OPTIONALARGS[0]
                           end;
                           var userInfo = WubCall("siteutil.getSessionInfo", ["maybeathome", sessionkey]);
                           if (userInfo != nil and userInfo.arg0 == "agent") then
                              "location.reload();"
                           else
                              "window.location.href = 'http://www.maybeathome.com';"
                           end;
                        </webl>                                                                              
                                    }, 3000);
                                   }
                                else {
                                    $('#response_mesg').focus();
                                     $('#response_mesg').html("<div class='alert alert-danger fade in'>" + response.message + "\n\
                                      <button type='button' class='close' data-dismiss='alert'>x</button></div>");
                              }
                            }
                        });
          
          				/*--  End Dropzone Functionality   --*/
          
                        /*--  Perfect Scroll Initialization  --*/
                        function initModalPerfectScroll() {
                            $(".modal-wrapper .perfect-scroll").perfectScrollbar({
                                wheelSpeed: 20,
                                wheelPropagation: false,
                                suppressScrollX: true,
                                minScrollbarLength: 25,
                                scrollYMarginOffset: 20,
                                scrollXMarginOffset: 20
                            });
                        }
                        initModalPerfectScroll();
          
                        <webl>
                           var sessionkey = wubinfo.cookies.sessionkey ? nil;
                           if Size(OPTIONALARGS) > 0 then
                              sessionkey = OPTIONALARGS[0]
                           end;
                           var userInfo = WubCall("siteutil.getSessionInfo", ["maybeathome", sessionkey]);
                           if (userInfo == nil or userInfo.arg0 == "buyer") then
                              `
                           $('#response_mesg').focus();
                           $('#response_mesg').html("<div class='alert alert-danger fade in'>" + 
                              "You must login as a seller or an agent before you can list a property." + "\n\
                             <button type='button' class='close' data-dismiss='alert'>x</button></div>");`
                           else
                              ""
                           end;
                        </webl>
                        
          
                        /*--  BX Slider Initialization  --*/
                        var previewSlider = $("#previewModal .bxslider").bxSlider({
                            minSlides: 1,
                            maxSlides: 2,
                            slideWidth: 485,
                            slideMargin: 0,
                            pager: false
                        });
                        $(document).on("click", ".btn-preview", function () {
                            var type, address, addressLine2, size, lotSize,rooms, beds, baths, price, features, description,
                                    modalTitle = '', previewFormData = [];

                            type = $(".owner-wrapper #type").val();
                            address = $(".owner-wrapper #address").val();
                            addressLine2 = $(".owner-wrapper #addressLine2").val();
                            size = $(".owner-wrapper #size").val();
                            lotSize = $(".owner-wrapper #lotSize").val();
                            rooms = $(".owner-wrapper #rooms").val();
                            beds = $(".owner-wrapper #beds").val();
                            baths = $(".owner-wrapper #baths").val();
                            price = $(".owner-wrapper #price").val();
                            features = $(".owner-wrapper #features").val();
                            description = $(".owner-wrapper #description").val();
                            
                            var adr = address + " " + addressLine2;
                            adr = adr.trim();
                          
                            modalTitle = price + " -- " + adr;

                            /*--  Store Message Requested Stay Code  --*/
                            previewFormData = [type, address, addressLine2, size, lotSize,rooms, previewImgUrl, beds, baths, price, features, description, modalTitle];
                            localStorage.setItem("previewFormData", JSON.stringify(previewFormData));

                            $('#previewModal').on('shown.bs.modal', function () {
                                $("#previewModal #type").text(type);
                                $("#previewModal #address").text(adr);
                                $("#previewModal #size").text(size);
                                $("#previewModal #lotSize").text(lotSize);
                                $("#previewModal #rooms").text(rooms);
                                $("#previewModal #beds").text(beds);
                                $("#previewModal #baths").text(baths);
                                $("#previewModal #price").text(price);
                                $("#previewModal #features").text(features);
                                $("#previewModal #description").text(description);

                                $(".modal-title").text(modalTitle);
                                setTimeout(function () {
                                    previewSlider.reloadSlider();
                                }, 200);
                                $(".modal-wrapper .perfect-scroll").perfectScrollbar("destroy");
                                initModalPerfectScroll();
                            });
                        });
        </script>

   </body>

</html>