github.com/cs3org/reva/v2@v2.27.7/pkg/siteacc/account/contact/template.go (about)

     1  // Copyright 2018-2020 CERN
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  //
    15  // In applying this license, CERN does not waive the privileges and immunities
    16  // granted to it by virtue of its status as an Intergovernmental Organization
    17  // or submit itself to any jurisdiction.
    18  
    19  package contact
    20  
    21  const tplJavaScript = `
    22  function verifyForm(formData) {
    23  	if (formData.getTrimmed("subject") == "") {
    24  		setState(STATE_ERROR, "Please enter a subject.", "form", "subject", true);
    25  		return false;
    26  	}
    27  
    28  	if (formData.getTrimmed("message") == "") {
    29  		setState(STATE_ERROR, "Please enter a message.", "form", "message", true);	
    30  		return false;
    31  	}
    32  
    33  	return true;
    34  }
    35  
    36  function handleAction(action) {
    37  	const formData = new FormData(document.querySelector("form"));
    38  	if (!verifyForm(formData)) {
    39  		return;
    40  	}
    41  
    42  	setState(STATE_STATUS, "Sending message... this should only take a moment.", "form", null, false);
    43  
    44  	var xhr = new XMLHttpRequest();
    45      xhr.open("POST", "{{getServerAddress}}/" + action);
    46      xhr.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');
    47  
    48  	xhr.onload = function() {
    49  		if (this.status == 200) {
    50  			setState(STATE_SUCCESS, "Your message was successfully sent! A copy of the message has been sent to your email address.");
    51  		} else {
    52  			var resp = JSON.parse(this.responseText);
    53  			setState(STATE_ERROR, "An error occurred while trying to send your message:<br><em>" + resp.error + "</em>", "form", null, true);
    54  		}
    55  	}
    56  
    57  	var postData = {
    58  		"subject": formData.getTrimmed("subject"),
    59  		"message": formData.getTrimmed("message")
    60      };
    61  
    62      xhr.send(JSON.stringify(postData));
    63  }
    64  `
    65  
    66  const tplStyleSheet = `
    67  html * {
    68  	font-family: arial !important;
    69  }
    70  
    71  .mandatory {
    72  	color: red;
    73  	font-weight: bold;
    74  }
    75  `
    76  
    77  const tplBody = `
    78  <div>
    79  	<p>Contact the ScienceMesh administration using the form below.</p>
    80  	<p style="margin-bottom: 0em;">Please include as much information as possible in your request, especially:</p>
    81  	<ul style="margin-top: 0em;">
    82  		<li>The site your request refers to (if not obvious from your account information)</li>
    83  		<li>Your role within the ScienceMesh site (e.g., administrator, operational team member, etc.)</li>
    84  		<li>Any specific reasons for your request</li>
    85  		<li>Anything else that might help to process your request</li>
    86  	</ul>
    87  </div>
    88  <div>&nbsp;</div>
    89  <div>
    90  	<form id="form" method="POST" class="box container-inline" style="width: 100%;" onSubmit="handleAction('contact'); return false;">
    91  		<div style="grid-row: 1;"><label for="subject">Subject: <span class="mandatory">*</span></label></div>
    92  		<div style="grid-row: 2; grid-column: 1 / span 2;"><input type="text" id="subject" name="subject" {{if .Params.Subject}}value="{{.Params.Subject}}" readonly{{end}}/></div>
    93  
    94  		<div style="grid-row: 3;"><label for="message">Message: <span class="mandatory">*</span></label></div>
    95  		<div style="grid-row: 4; grid-column: 1 / span 2;">
    96  			<textarea rows="10" id="message" name="message" style="box-sizing: border-box; width: 100%;" {{if .Params.Info}}placeholder="{{.Params.Info}}"{{end}}>{{if .Params.Message}}{{.Params.Message}}{{end}}</textarea>   
    97  		</div>
    98  
    99  		<div style="grid-row: 5; align-self: center;">
   100  			Fields marked with <span class="mandatory">*</span> are mandatory.
   101  		</div>
   102  		<div style="grid-row: 5; grid-column: 2; text-align: right;">
   103  			<button type="reset">Reset</button>
   104  			<button type="submit" style="font-weight: bold;">Send</button>
   105  		</div>
   106  	</form>
   107  </div>
   108  <div>
   109  	<p>Go <a href="{{getServerAddress}}/account/?path=manage">back</a> to the main account page.</p>
   110  </div>
   111  `