Formatting ng-init text inside input tag - AngularJS - angularjs

I am having ng-init defined in my input tag. I would like to have this input in the specified format with line breaks.
I tried using <pre> tags and white-space:pre-line property too. But this seems not to get sorted.
<div style="font-family: Poppins !important;-webkit-font-smoothing: antialiased;top:35%; position:absolute; width: 100%; background:transparent !important; margin-bottom:0rem !important">
<input class="form-control"
id="volunteerCallTextId" type="text" placeholder="Volunteer Call Text"
ng-model="volunteerCallText"
ng-init="volunteerCallText ='Hello, may I speak to (Insured). Hi (Mr., Mrs. Etc), my name is _________.
I am with xxx Insurance and am calling you about the recent fire/flood/weather event in_____.
We are calling to check and see if your family is safe and let you know that xxx is here for you.
I want to let you know that we have emergency claims locations set up at: (use locations below).
Or you can call our Claims center at 888....Please be aware that.....'"
style="width: 75em; height:25em; white-space:pre-line" />
</div>
Format expected:
Hello, may I speak to (Insured). Hi (Mr., Mrs. Etc), my name is
_________.
I am with xxx Insurance and am calling you about the recent fire/flood/weather event in_____. We are calling to check and
see if your family is safe and let you know that xxx is here for you.
I want to let you know that we have emergency claims locations set up
at: (use locations below). Or you can call our Claims center at
888....Please be aware that.....
Can someone suggest what could be done?

I am not sure it can be done in input box or not but it works like this in textarea please try and let me know if t helps you
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<body>
<div ng-app="" >
<div style="font-family: Poppins !important;-webkit-font-smoothing: antialiased;top:35%; position:absolute; width: 100%; background:transparent !important; margin-bottom:0rem !important">
<textarea class="form-control"
id="volunteerCallTextId" style="width:75em; height:25em; white-space: pre-wrap;" type="text" placeholder="Volunteer Call Text"
ng-model="volunteerCallText"
ng-init="volunteerCallText ='Hello, may I speak to (Insured). Hi (Mr., Mrs. Etc), my name is _________ \n\
I am with xxx Insurance and am calling you about the recent fire/flood/weather event in_____.\n\
We are calling to check and see if your family is safe and let you know that xxx is here for you.I want to let you know that we have emergency claims locations set up at: (use locations below).Or you can call our Claims center at 888....Please be aware that.....'"
></textarea>
</div>
</div>
</body>
</html>

Related

Need explanation with Icecast URL authentication

Foreword: I am stuck due to poor coding skills and a lack of understanding of the details of the URL authentication. I am not a coder but an amateur who usually get by with a little help from Google.
Challenge 1:
I am trying to set Icecast up in such a way that the audio stream can only be heard when you log in to my website. The method is called URL authentication by Icecast. Here is the link to the official documentation:
https://icecast.org/docs/icecast-2.4.0/auth.html
My problem: I understand that I have to integrate certain queries in the icecast.xml that are then answered by the player on my website. Unfortunately, I don't know where to integrate these codes. In a file in the webroot? In the header of the player page?
Challenge 2:
Another thing is that the player is working, but when I hit the pause button and restart the player 10 minutes later the song picks up there I paused the player even though the radio stream is already 2 titles ahead. So the cover art does not match the audio.
I guess that also has something to do with certain tweaks in the icecast.xml. Again ... I don't know how to add these tweaks and how to address them on my website (same issue as with the authentication).
Due to royalty issues, my website is behind a firewall for the time being.
Can anyone shed some light on my questions?
I included the code of my icecast.xml and of the iFrame that contains the player.
Best wishes,
Paul
This is the iFrame that contains the Drupal website and the HTML5 player:
<html>
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="-1" />
<meta name=viewport content="width=device-width, initial-scale=1">
<style type="text/css">
html, body {
background: #333333;
height: 100%;
margin: 0px;
padding: 0px;
border: 0px;
}
iframe {
width: 100%;
height: 92%;
margin: 0px;
padding: 0px;
border: none;
display: block;
}
</style>
<body>
<?php
print('<iframe id="drupal_site" src="http://test.zoootradio.com" height="92%" width="100%" frameborder="0"></iframe>');
header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP 1.1.
header("Pragma: no-cache"); // HTTP 1.0.
header("Expires: 0"); // Proxies.
print('<audio id="player" controls>');
print('<source src="http://192.168.2.50:8000/zr.mp3" type="audio/mpeg">');
print('</audio>');
?>
</body>
</html>
This is my icecast.xml file:
<icecast>
<location>Earth</location>
<admin>icemaster#localhost</admin>
<limits>
<clients>15</clients>
<sources>1</sources>
<queue-size>524288</queue-size>
<client-timeout>30</client-timeout>
<header-timeout>15</header-timeout>
<source-timeout>10</source-timeout>
<burst-on-connect>1</burst-on-connect>
<burst-size>65535</burst-size>
</limits>
<authentication>
<!-- Sources log in with username 'source' -->
<source-password>XXXXXXX</source-password>
<!-- Relays log in with username 'relay' -->
<relay-password>XXXXXXX</relay-password>
<!-- Admin logs in with the username given below -->
<admin-user>XXXXXXX</admin-user>
<admin-password>XXXXXXX</admin-password>
</authentication>
<hostname>192.168.2.50</hostname>
<!-- You may have multiple <listener> elements -->
<listen-socket>
<port>8000</port>
<!-- <bind-address>127.0.0.1</bind-address> -->
<!-- <shoutcast-mount>/stream</shoutcast-mount> -->
</listen-socket>
<http-headers>
<header name="Access-Control-Allow-Origin" value="*" />
</http-headers>
<mount type="normal">
<mount-name>/zr.mp3</mount-name>
<authentication type="url">
<option name="stream_auth" value="http://test.zoootradio.com/player"/>
</authentication>
</mount>
<fileserve>1</fileserve>
<paths>
<!-- basedir is only used if chroot is enabled -->
<basedir>/usr/share/icecast2</basedir>
<!-- Note that if <chroot> is turned on below, these paths must both
be relative to the new root, not the original root -->
<logdir>/var/log/icecast2</logdir>
<webroot>/usr/share/icecast2/web</webroot>
<adminroot>/usr/share/icecast2/admin</adminroot>
<!-- <pidfile>/usr/share/icecast2/icecast.pid</pidfile> -->
<alias source="/" destination="/status.xsl"/>
<!-- The certificate file needs to contain both public and private part.
Both should be PEM encoded.
<ssl-certificate>/usr/share/icecast2/icecast.pem</ssl-certificate>
-->
</paths>
<logging>
<accesslog>access.log</accesslog>
<errorlog>error.log</errorlog>
<!-- <playlistlog>playlist.log</playlistlog> -->
<loglevel>3</loglevel> <!-- 4 Debug, 3 Info, 2 Warn, 1 Error -->
<logsize>10000</logsize> <!-- Max size of a logfile -->
<!-- If logarchive is enabled (1), then when logsize is reached
the logfile will be moved to [error|access|playlist].log.DATESTAMP,
otherwise it will be moved to [error|access|playlist].log.old.
Default is non-archive mode (i.e. overwrite)
-->
<!-- <logarchive>1</logarchive> -->
</logging>
<security>
<chroot>0</chroot>
<!--
<changeowner>
<user>nobody</user>
<group>nogroup</group>
</changeowner>
-->
</security>
1 - "URL auth"
Your icecast.xml does not contain any definition, so you don't have URL-auth configured.
What are you really trying to achieve?
2 - pause
Streams can't be paused, don't try to do it, it will break things. If you stop a stream, make sure that you do it in a way that makes the browser actually drop the connection.
Also you should always use a 'cache buster' or other way to ensure that the browser does not try to use cached stream content. (See my other answers on related topics here)

Unable to get value from paper-input

<question-chrome question="{{question}}">
<paper-input label="{{question.Description}}" id="answer" name="answer" type="number">
{{question.Description}}
</paper-input>
</question-chrome>
Where question-chrome.html has the followign code:
<template>
<div class="questioncontainer {{question.Type }}" style="padding-top:10px;">
<div class="questiontext">
<span class="questiontitle">{{question.Title}}</span>
</div>
<div class="questionanswers">
<content select=".questionanswers"></content>
</div>
</div>
</template>
I am using the above paper input, when I am trying to get the values from this, I cannot find the value anywhere. the question element/object, I can get and see every other item's value of the question object. How would I get the value of what is put into the input field? in this case, the value was 3323.
this:
The code to retrieve it I have tried all of these:
this.$.answer.value;
And the results through developer tools in chrome result in:
Object
AdditionalProperties:null
Answers:Array[0]
Code:720061
Description:"Monetary marks ...."
ExtensionData:null
HasAnswers:false
HasChildren:false
Id:"9999dcc3-d3eb-40cf-8414-05ae385e11cf"
IsDefault:true
IsDeleted:false
.....so on and so forth
I went through all of these and did not find it. It is a numeric type of field, so not sure if that has anything to do with it.

Including style sheets in a PDF in cakePHP

I am using dompdf to generate PDFs for some of the views and that is working just fine. The problem is that I cannot include the css files anywhere, and only css included in the <style> tags inside the view itself is taken into consideration.
Here is the controller action:
public function view_pdf($id=null){
ini_set('memory_limit','512M');
$event = $this->Event->findById($id);
$evt_data=new \DateTime($event['Event']['date']);
$this->set('event', $event);
$this->layout='event';
}
Here is the layout:
require_once(APP . 'Vendor' . DS . 'dompdf' . DS . 'dompdf_config.inc.php');
spl_autoload_register('DOMPDF_autoload');
$dompdf = new DOMPDF();
$dompdf->set_paper = 'A4';
$dompdf->load_html(utf8_decode($content_for_layout), Configure::read('App.encoding'));
$dompdf->render();
echo $dompdf->stream('Event.pdf');
And here is the view itself (shortened version):
<style>
div.content-event{
background: gray;
color: black;
padding: 20px;
}
</style>
<div class="content-event" style="margin-bottom: 80px">
<div class="heading">
<div class="row">
<div class="col-md-12">
<h3><?php echo $event['Event']['name']; ?></h3>
</div>
</div>
</div>
I have tried to include the css files in the usual way, like: echo $this->Html->css('event');, in both the view and the layout, but this is just not taking any action.
Any help or guidance is much appreciated.
You can include CSS file like following:-
<link rel="stylesheet" type="text/css" href="<?php echo APP.'webroot'.DS.'css'.DS.'event.css'; ?>" media="all" />
Put your css file into webroot/css folder.
Archana's answer appears to be valid, but I wanted to provide a bit more context. When you load a document using $dompdf->load_html() dompdf has no information about the source of the file. When you provide links to external resources dompdf sets the currently executing file on the local file system as the base path.
Essentially URLs will be parsed in the following manner:
relative URLs (e.g. css/styles.css) will be evaluated relative to the currently executing file
absolute URLs (e.g. /css/styles.css) will be evaluated relative to the file system root
URLs with a domain (e.g. http://example.com/css/styles.css) will be evaluated as written
When you make the following call to HTMLHelper::css:
$this->Html->css('styles')
CakePHP will produce a style reference similar to the following:
<link rel="stylesheet" type="text/css" href="/css/styles.css" />
Based on the parsing rules I outlined above that reference will be read from the filesystem root. And unless you have a root folder called "css" with your stylesheet in it that reference will be invalid. The reason Archana's answer works is that you're providing a path from the root of the file system to the file (e.g. /inet/www/cakesite/app/webroot/css/styles.css).
It's a bit easier to get a handle on external resource references if you specify a domain. In that manner dompdf will access the resource via your web server as would any web browser. This type of reference does require a bit more attention to your dompdf and server configuration.
You might find the following questions helpful on how to construct a URL:
Q: How to get the base Url in cakephp?
Q: base_url in CakePHP

An image to be displayed inline in a JavaMail created message shows up twice in Apple Mail – but not Outlook?

An image to be displayed inline in a JavaMail created message shows up twice in Apple Mail – but not Outlook?
EmailMaster sends a test email message that includes:
1) an image sent with the email to be displayed inline in the title when the message is opened
2) a link to an image that has to be downloaded from a remote URL after the message is displayed.
The goal is for the message to be fully rendered when it is opened (owl). Not require the reader download it before seeing full message.
The code below works perfectly when the message is opened in a client like Outlook.
-- the Owl image displayed in line when its opened, and
-- the underline must be downloaded.
When AppleMail opens the message the Owl is displayed twice. The screen show:
-- the owl as a standalone image,
-- then the message with the owl correctly displayed in the Title.
I can’t post a screen shot, but I put a screen shot of the AppleMail screen at
http://america-3.org/images/shot.jpg
Can anyone point me to the cause of the problem? Or a solution?
HTML code added as one MimeBodyPart.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="cid:fonts" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.text-blue-12 {font-family: Verdana, Arial, Helvetica, sans-serif;
text-decoration: none; font-weight: normal;
font-size:12pt; color: #0F0F0F}
body { margin: 0; padding: 0; background-color: #1A4576; width: 480px;}
tr {width:100%; background-color: white;}
-->
</style>
</head>
<body>
<table width='480px' cellspacing='0' cellpadding='6' class='text-blue-12' align="center">
<tr><td style='text-align: center;'>
Hello! <img src='cid:owl'>
</td></tr>
<tr><td style='text-align: center;'>
<img align="center" alt="Shadow" class="kmImage"
src="https://d3k81ch9hvuctc.cloudfront.net/assets/email/bottom_shadow_444.png"
width="600" style="border: 0; height: auto; line-height: 100%;
outline:none; text-decoration: none; max-width: 100%; padding-bottom: 0;
display: inline; vertical-align: bottom" />
</td></tr>
<tr><td>
This is test # 1005. The Table should be a 480px wide and centered.
If not there is a problem.
</td></tr>
<tr><td>
Yours truly,
GLB
</td></tr>
</table>
</body>
</html>
Extract of Java Class I use to test JavaMail code
public class EmailMaster {
/* JavaMail attempts to use IPv6 to connect. Windows IPv4.
* The error message will be "Network Unreachable: Connect.
* To fix it, I ran this code from the command window
* setx _JAVA_OPTIONS -Djava.net.preferIPv4Stack=true
* I tried to set _JAVA_OPTIONS as an environment variable but that didn't
* work.
*/
/* the constructor instantiates EmailMaster.
* It parses a ".properties" text file that provides the everything
* needed to define a message:
* -- send from, reply to, subject etc. Strings
* -- local paths to one or more files:
* .. a text file containing the to addresses.
* .. the HTML file that holds the message body,
* .. one of more images to be displayed inline
* in the HTML message body. I used one.
* .. one or more files to be attached to the msg. I used one.
*/
/* then it calls sendEmail() to read through the list of addresses
* and sends an individual email to each address*/
sendEmail () {
/*this section of code is done once. */
Session session = Session.getInstance(this.sessionParameters);
SMTPTransport tr = new SMTPTransport(session, new URLName (host));
tr.connect(...); // this is successful
/* the method loops through this section for every to address provided*/
Message msg = new MimeMessage(session);
msg.setReplyTo(this.replyToAddress);// read from properties file
msg.setSentDate(new java.util.Date());// read from properties file
msg.setSubject(this.subject);// read from properties file
msg.setFrom(this.fromAddress);// read from properties file
msg.setRecipient(RecipientType.TO, singleToAddress);// read from properties file
MimeMultipart mmp = new MimeMultipart();
/* add a MimeBodyPart for each image be displayed inline the HTML text */
for (MimeBodyPart part : this.imagesBodyParts.values()) {
mmp.addBodyPart(part);
/* add a MimeBodyPart for each HTML page in the message. */
for (MimeBodyPart part : this.attachmentBodyParts.values()) {
mmp.addBodyPart(part);
}
mmp.addBodyPart(this.msgPart);
msg.setContent(mmp);
msg.saveChanges();
tr.sendMessage(msg, msg.getAllRecipients());
}
}
There's a limit to how much control you have over how mail readers display messages. In the end, you may not be able to accomplish what you're trying to do with all mail readers. That said, there's some issues with the code you posted...
You've got a double nested "for" loop that first adds an image body part, then adds a bunch of attachment (html?) body parts, then sends the message, then adds more of both to the same message, then sends the message again, and so on. Surely this isn't what you intended.
If you want the message to include a single html part and some image parts that are referenced by the html part, you need to create a multipart/related message, and the image parts need Content-ID headers. This JavaMail FAQ entry will point you in the right direction.
Finally, you should never be calling the constructor for SMTPTransport directly. Instead, you should use the Session.getTransport method.

Composite C1 4.0 Beta and MVC Player outputting 2nd html and body tags

I have setup and installed the Composite C1 4.0 beta, along with the latest MVC Player build (from 12/7/2012 nightly), but whenever I call the MVCPlayer function, it outputs additional tags on the page. For example, I am calling a MVCPlayer function for breadcrums. This is the output:
..... before breadcrum content .....
<a name="site-nav" class="screen-reader"></a>
<html xmlns="http://www.w3.org/1999/xhtml">
<head />
<body>
<html>
<head />
<body>
<!-- START BREADCRUM SECTION -->
<ul id="breadcrumbs">
<li>Homep</li>
<li>Events</li>
</ul>
<!-- END BREADCRUM SECTION -->
</body>
</html>
</body>
</html>
<div class="clear"></div>
</div>
..... rest of page .....
As you can see, it is in the middle of the page. The MVCPlayer is returning an XDocument in the render function. So, how do I get rid of the extra tags before the START & END BREADCRUM SECTION comments? The page renders fine, but this is impacting the ability for me to use a page filter to add additional content to the output, such as switching out image tag src's so I can use a jquery script to perform lazy loading images (see http://www.appelsiini.net/projects/lazyload).
Any thoughts?
Thanks!
Chad
The output of the actual breadcrums page is simply <ul><li>...</li></ul>, and there are no errors in the log files. The MVC Player actually adds the additional code:
<html xmlns="http://www.w3.org/1999/xhtml">
<head />
<body>
</body>
</html>
In the Player.cs file, here is the code:
var sbHtml = new StringBuilder();
sbHtml
.Append(#"<html xmlns=""http://www.w3.org/1999/xhtml"">
<head/>
<body>")
.Append(responseWriter.ToString())
.Append(#"
</body>
</html>");
try
{
return XDocument.Parse(sbHtml.ToString());
}
I was able to modify the /Renderers/Page.aspx.cs and changed this line to "strip" out the extra tags:
Original:
xhtml = _renderingContext.FormatXhtml(xhtml);
Updated:
xhtml = _renderingContext.FormatXhtml(xhtml.Replace(#"<html xmlns=""http://www.w3.org/1999/xhtml"">", "").Replace("<html>", "").Replace("<head />", "").Replace("<head></head>", "").Replace("<body>", "").Replace("</body>", "").Replace("</html>", ""));
I'm sure there is a better solution than this? :)
Chad
It could be that somewhere else on the the page you have markup which makes the whole result document and invalid XHTML, and therefore the system cannot process it correctly.
Try to
a) Check the log files to see if there any related warnings
b) validate the output xhtml http://www.xmlvalidation.com/

Resources