Laravel 5.8 parsing HTML text from database to modal - bootstrap-modal

I'm trying to show HTML text which is an event program stored in database from TinyMCE textarea in a bootstrap modal.
I need to parse it before, for that I found that Laravel 5.* uses:{!! !!} to parse but with $event->program it always shows the last one stored.
here is my js code
$('#eventDetails').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget)
var id = button.data('id')
var name = button.data('name')
var description = button.data('description')
var program = button.data('program')
var date = button.data('date')
var modal = $(this)
modal.find('.modal-body #id').text(id);
modal.find('.modal-body #name').text(name);
modal.find('.modal-body #description').text(description);
modal.find('.modal-body #program').text(program);
modal.find('.modal-body #date').text(date);
});
so what shoud I do please !!?

Related

search and replace on google slide refuse to work

I'm trying to replace placeholder Text with text from form or var on Google Slides using Google Script
everything looks like it working but when I open the new google slides the placeholder are not changed. Thanks.
function project(){
var projectname = '666'
var category = '12345'
var subtitle = '12345'
var excerpt = '12345'
//PP-Slides template file, and you get it by ID
var file = DriveApp.getFileById('fileID');
//We can make a copy of the template, name it, and optionally tell it what folder to live in
//file.makeCopy will return a Google Drive file object
var folder = DriveApp.getFolderById('folderid')
var copy = file.makeCopy(projectname + '-' + "Project", folder).getId();
var Slides = SlidesApp.openById(copy).getSlides();
Slides.forEach(slide => requests = [{
replaceAllText: {
containsText: {
text: '{{subtitle}}',
matchCase: true
},
replaceText: projectname
}
}]);
Logger.log(copy);
Logger.log(Slides);
console.log(projectname);
}

share_open_graph is not taking dynamic OG tags link or image

The code snippet below certainly works when manually specifying OG tags in the head. But when dynamically creating the tags via the share_open_graph method in the JS SDK, the dynamic image or link is not taken by the share dialog.
Is share_open_graph is deprecated or how to achieve this?
var FBDesc = "Test description";
var FBTitle = "Test Title";
var FBLink = "http://facebook.com";
var FBPic = "http://lorempixel.com/1200/630/sports/1/";
FB.ui({
method: "share_open_graph",
action_type: "og.shares",
display: "popup",
action_properties: JSON.stringify({
object: {
"og:url": FBLink,
"og:title": FBTitle,
"og:description": FBDesc,
"og:image": FBPic
}
})
});

powerbi global object not found in typescript

I am trying to use this power bi below code where powerbi object not found error is getting in my typescript code:
// Read embed application token from textbox
var txtAccessToken = $('#txtAccessToken').val();
// Read embed URL from textbox
var txtEmbedUrl = $('#txtReportEmbed').val();
// Read report Id from textbox
var txtEmbedReportId = $('#txtEmbedReportId').val();
// Read embed type from radio
var tokenType = $('input:radio[name=tokenType]:checked').val();
// Get models. models contains enums that can be used.
var models = window['powerbi-client'].models;
// We give All permissions to demonstrate switching between View and Edit mode and saving report.
var permissions = models.Permissions.All;
// Embed configuration used to describe the what and how to embed.
// This object is used when calling powerbi.embed.
// This also includes settings and options such as filters.
// You can find more information at https://github.com/Microsoft/PowerBI-JavaScript/wiki/Embed-Configuration-Details.
var config= {
type: 'report',
tokenType: tokenType == '0' ? models.TokenType.Aad : models.TokenType.Embed,
accessToken: txtAccessToken,
embedUrl: txtEmbedUrl,
id: txtEmbedReportId,
permissions: permissions,
settings: {
filterPaneEnabled: true,
navContentPaneEnabled: true
}
};
// Get a reference to the embedded report HTML element
var embedContainer = $('#embedContainer')[0];
// Embed the report and display it within the div container.
var report = powerbi.embed(embedContainer, config);
// Report.off removes a given event handler if it exists.
report.off("loaded");
// Report.on will add an event handler which prints to Log window.
report.on("loaded", function() {
Log.logText("Loaded");
});
report.on("error", function(event) {
Log.log(event.detail);
report.off("error");
});
report.off("saved");
report.on("saved", function(event) {
Log.log(event.detail);
if(event.detail.saveAs) {
Log.logText('In order to interact with the new report, create a new token and load the new report');
}
});
in the above code the powerbi object shows not found in my typescript code: powerbi.embed(embedContainer, config);
I tried to use window['powerbi'] or window.powerbi but doesn't work. What should be the solution then?
I faced a similar issue a few weeks back (probably exactly the same). For me it seems that what works is using window.powerbi.embed() for the embed action, whereas the import import * as powerbi from "powerbi-client"; is used for all other Power BI objects.
I had the same problem, found this question through a google search. I wasn't able to figure out why it wasn't on the window, but as a work around you can initialize it yourself like this:
import * as pbi from "powerbi-client";
const powerbi = new pbi.service.Service(
pbi.factories.hpmFactory,
pbi.factories.wpmpFactory,
pbi.factories.routerFactory
);
const container = document.getElementById("report-container");
powerbi.embed(container, embedConfiguration);

Color rows when "group by" sharepoint 2013

I need some help. I'm trying to set color when group by in a sharepoint list.
I'm using the following code
SP.SOD.executeFunc("clienttemplates.js", "SPClientTemplates", function() {
SPClientTemplates.TemplateManager.RegisterTemplateOverrides({
OnPostRender: function(ctx) {
var statusColors = {
'Liberada' : '#FFF1AD',
'Cancelada' : '#FFD800',
'Créditos' : '#01DF3A'
};
var rows = ctx.ListData.Row;
for (var i=0;i<rows.length;i++)
{
var status = rows[i]["Status"];
var rowId = GenerateIIDForListItem(ctx, rows[i]);
var row = document.getElementById(rowId);
row.style.backgroundColor = statusColors[status];
}
}
});
});
Can someone give a hint?
As I can see in my local Sharepoint 2013 environment, when I create a view with a group by, Sharepoint add a CSS class named « ms-gb » on the table cell that contains the group name.
Knowing this, a solution would be to edit the page of the view.
Then you can add to the page a Script Editor Webpart.
Inside this Script Editor Webpart you can add some JavaScript code to add the background-color.
Something like this for example :
<script>
$(document).ready(function(){
var statusNames = ['Liberada', 'Cancelada', 'Créditos'];
var statusColors = {
'Liberada' : '#FFF1AD',
'Cancelada' : '#FFD800',
'Créditos' : '#01DF3A'
};
$('td.ms-gb').each(function(){
for (var x=0;x<statusNames.length;x++) {
if ($(this).text().indexOf(statusNames[x]) > -1) {
$(this).css('background-color',statusColors[statusNames[x]]);
}
}
});
});
</script>
If you try this script and you don't already have a reference to JQuery in your masterpage or page layout, you will need to add one inside the script editor webpart.
You can download a local copy of JQuery or use one hosted like :
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
Hope this help.

Convert plain text email to clickable link - REGEX/jQuery

I am trying to convert plain text email addresses into clickable mailto links inside of a table.
I have the following function that is converting found links into mailto links, but it only seems to work for the first found link. Any subsequent links (2nd, 3rd occurrence etc.) remain as plain text links. I can't seem to figure out what I might be doing wrong. Any help would be much appreciated!
The code:
HTML
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<div class='filter-email-box'>
<div>This is a sample text which contains john#gmail.com </div>
<div>This text contains two emails adam#example.com and paul#example.com </div>
</div>
Javascript
$(".filter-email-box div").filter(function(){
var html = $(this).html();
var emailPattern = /[a-zA-Z0-9._-]+#[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}/;
var matched_str = $(this).html().match(emailPattern);
if(matched_str){
$(this).html(html.replace(emailPattern,"<a href='mailto:"+matched_str+"'>"+matched_str+"</a>"));
return $(this)
}
})
Heres the fiddle I've setup:
http://jsfiddle.net/z6LF5/
When there's more than one email address, JQuery method match returns an array (when the global search flag g is set), so we're looping over that array (called matched_str in this case) and replacing the matching emails.
$(".filter-email-box div").filter(function () {
var html = $(this).html();
var emailPattern = /[a-zA-Z0-9._-]+#[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}/g;
var matched_str = $(this).html().match(emailPattern);
if ( matched_str ) {
var text = $(this).html();
$.each(matched_str, function (index, value) {
text = text.replace(value,"<a href='mailto:"+value+"'>"+value+"</a>");
});
$(this).html(text);
return $(this)
}
})
JSFiddle
Use the g (global) modifier which ( finds all matches rather than stopping after the first match ).
You could implement the following:
$('.filter-email-box div').ready(function() {
$('.filter-email-box div').each(function() {
var html = $(this).html();
var regex = /([a-z0-9._-]+#[a-z0-9.-]+\.[a-z]{2,4})/ig
var text = html.replace(regex, "<a href='mailto:$1'>$1</a>");
$(this).html(text);
});
});
Fiddle
if anyone is interested I translated the jquery code to vanilla JS code
var elem = document.querySelector('.filter-email-box');
var html = elem.innerHTML;
if (html) {
var regex = /([a-z0-9._-]+#[a-z0-9.-]+\.[a-z]{2,4})/ig;
elem.innerHTML = html.replace(regex, '$1');
}
Demo link: https://jsfiddle.net/q0x4tjr3/