stingray - trafficscript without change the URL - javascript

I have the following code :-
$hostheader = http.getHostHeader();
$path = http.getPath();
$languages = [‘cs’, ‘cs-cs’, ‘pt’, ‘pt-pt’, ‘fi’, ‘fi-fi’, ‘sl’, ‘sl-sl’, ‘el’, ‘el-gr’, ‘sr’, ‘sr-sr’, ‘ro’, ‘ro-ro’, ‘hu’, ‘hu-hu’, ‘es’, ‘sv’, ‘de’, ‘de-de’, ‘cn’, ‘zh’, ‘zh-cn’, ‘ru’, ‘ru-ru’, ‘fr’, ‘fr-fr’, ‘pl’, ‘pl-pl’, ‘at’, ‘ja’, ‘ja-jp’, ‘zh-hk’, ‘de-at’];
if ($hostheader == “website” ) {
foreach($lang in $languages) {
if (string.endsWithI($path, $lang) ) {
http.setResponseHeader(“Host”, “host”);
http.setHeader(“Host”, “host” . $lang);
if(!ssl.isSSL()) {
pool.use(“cms-splash-https-Pool”);
}
else {
pool.use(“cms-splash-http-Pool”);
}
}
}
}
if( http.getHostHeader() == "host" ) {
http.changeSite( "newwebsite" );
}
I want to redirect without change the URL so no one will notice anything , is this possible ?

Related

Gatsby - Trying to render image with URL - Cannot read property '0' of undefined

This is my code:
const Image = () => {
const data = useStaticQuery(graphql`
query {
facebook {
posts {
data {
full_picture
}
}
}
}
`)
// console.log(data.facebook.posts.data)
const images = data.facebook.posts.data;
const sources = images.filter(function(img) {
if (img.full_picture == null) {
return false;
}
return true
}).map(function (img) {
return (
<Img src={img.full_picture} />
)
})
return (
<div>
{sources}
</div>
)
}
The error I'm receiving is
"TypeError: Cannot read property '0' of undefined"
If I remove the HTML from the return (Img) then it will display all the URLs on the page, but as soon as I add the Img tag it doesn't run.
It is possible that the images are not loaded when you try to display it in Img you could do :
<Img src={img?img.full_picture:''} />
This should help.

C# if statement within Javascript, Razor/MVC

I have the following variable that work very well on the code bellow, but I would like to add an if/else statement and I'm having some issue with the formatting. Any feedback would be greatly appreciated.
Before:
var originalSales = {
"RenewalDate": validateDefaultDateValue('#(Model.Program.RenewalDate.HasValue ?
Model.Program.RenewalDate.Value.AddYears(1).ToString("g") : "" )'),}
What I'm trying to Accomplish:
var originalSales = {
"RenewalDate": validateDefaultDateValue(#if((Model.Program.IsNonServiceYear) &&
(Model.ProgramCode.HasAutoRenewDate == true))
{('#(Model.Program.RenewalDate.HasValue ? Model.Program.RenewalDate.Value.AddYears(1).ToString("g") : "" )'),}
else
{('#(Model.Program.RenewalDate.HasValue ? Model.Program.RenewalDate.Value.ToString("g") : "" )'),}),
You can use this pattern:
#{
if ( Model.Program.IsNonServiceYear && Model.ProgramCode.HasAutoRenewDate )
{
originalSales =x;
}
else
{
originalSales =y;
}
}

Jquery collection plugin for symfony not working

Since I've put together all of my Javascript and jQuery file, the Jquery plugin collection for Symfony didn't work. I don't know why but when I click on the add button, nothing happen ...
Here is my jQuery code :
var indexAdd = 0
var collectionToAdd ='';
jQuery('.my-selector').collection({
allow_up: false,
allow_add: true,
allow_down: false,
after_remove: function(collection, element) {
indexAdd--;
var count = 0;
jQuery(collection).children().each(function(){
if(jQuery(this).is('div')){
count++;
}
})
if(count > 1){
jQuery(element).find("a.collection-add.collection-action").eq(indexAdd-1).parent().show();
}
if(count == 0){
jQuery(collection).find('a.collection-action.collection-rescue-add').css('display','unset');
}
},
after_add: function(collection, element) {
jQuery(element).css('margin-top','50px');
indexAdd++;
collectionToAdd = '';
collectionToAdd = collection;
jQuery('#modalCollection .modal-body .col-6').empty()
var nomCollection = jQuery(jQuery(collection).parent()).parent().find('label').eq(0).text()
if(jQuery('#modalCollection .modal-body .col-6 h1').length == 0){
jQuery('#modalCollection .modal-body .col-6').append('<h1>'+nomCollection+'</h1>')
}
jQuery('#modalCollection .modal-body .col-6').append('<div class="detach"></div>')
jQuery('#modalCollection').modal('show');
jQuery(jQuery(element).detach()).appendTo('#modalCollection .modal-body .detach')
jQuery(element).parent().children("div").each(function(){
jQuery(this).children("label").css('display','none')
})
jQuery(element).find('label').each(function(event){
if(jQuery(this).text().indexOf('label') > 0){
jQuery(this).hide();
}
})
newCollection = jQuery(element).parent().find("div:last").parent()
jQuery(newCollection).find("div").wrap('<td></td>')
jQuery(newCollection).find("div").each(function(){
jQuery(this).find("td").wrapAll(('<tr></tr>'))
if(jQuery(this).find("label")){
label = jQuery(this).find("label").attr("for")
if(typeof label !== 'undefined'){
label = (label.substring(0, String(label).indexOf('-'))).substring(label.lastIndexOf("_")+1)
jQuery(this).find("label").html(label)
}
}
})
jQuery(element).find('td').each(function(){
jQuery(this).find('div').attr("class","md-form")
jQuery(this).find('div').each(function(){
if(jQuery(this).find('input').attr('type') == 'file'){
jQuery(this).find('label').hide();
}
})
})
}
})
Here is the form view : formView
That's how I create my CollectionType :
$builder->add($key, CollectionType::class, array(
'entry_type' => DynamicFormType::class,
'entry_options' => array('data' => $arrayOfFieldType),
'allow_add' => true,
'allow_delete' => true,
'prototype' => true,
'attr' => array(
'class' => 'my-selector',
),));
When i clicked on the add button (in blue) nothing happen.
If someone have an idea, will be great to know.
Thanks in advance.
Problem solved. I just add to add a my-selector class that was deleted i dont know how but everything is working now.

Unable to get property 'new_textholder' of undefined or null reference

I'm using code I found online to convert a standard option set field to a checkbox in MS CRM 2015 online. It keeps giving me the above error.
Here is the code:
function MultiPickList3(param1, param2, param3,param4,param5)
{
try
{
var fn = arguments.callee.toString().match(/function\s+([^\s\(]+)/);
if (param1==null || param2==null)
{
alert("Error: Parameter missing. \n Format: <optionset fieldname> , <option value text field> , [<option header>], [<select color>] , [<deselect color>] , \n ["+"Function="+fn[1]+"]" );
return true;
}
var tparamtype=Xrm.Page.data.entity.attributes.get(param1).getAttributeType();
if (tparamtype!="optionset")
{ alert (param1+"(first parameter) should be of type optionset \n"+"[function="+fn[1]+"]");
return true;
}
var tparamtype=Xrm.Page.data.entity.attributes.get(param2).getAttributeType();
if (tparamtype!="memo")
{ alert (param2+"(second parameter) should be of type memo (text with mutiline) \n[function="+fn[1]+"]");
return true;
}
var plOptions=param1;
var plText=param2;
var plMenuItem="View Selected List";
var SelectedList_orig = crmForm.all[plText];
var FullList=crmForm.all[plOptions];
var SelCtr=-1;
var new_selColor="orange";
var new_deSelColor="white";
if (param4!=null)
new_selColor=param4;
if (param5!=null)
new_deSelColor=param5;
var SelectedList =SelectedList_orig.value.split("\r\n");
crmForm.all[plText].style.display="none";
if(FullList!=null && SelectedList!=null)
{
initColor();
if (param3!=null && param3!="")
{
plMenuItem=param3;
}
else
{
plMenuItem=FullList.options[0].text;
changeColor("grey",0);
}
for (var ctr=0; ctr<SelectedList.length;ctr++)
{
selCtr=SelectedIndex(SelectedList[ctr]);
if (selCtr >-1)
{
changeColor(new_selColor,selCtr);
}
}
}
function SelectedIndex(selectedText)
{
var FullListText;
for (var ctr1=0; ctr1<FullList.options.length;ctr1++)
{
FullListText=FullList.options[ctr1].text;
if ( FullListText==selectedText)
{
return ctr1;
}
}
return -2;
}
crmForm.all[plOptions].attachEvent('onchange', OnChangePL);
function OnChangePL()
{
var SelCtr=-1;
var sel=crmForm.all[plOptions].SelectedText;
if (sel==plMenuItem)
return;
SelCtr=SelectedIndex(sel);
var SelColor="grey";
SelColor=crmForm.all[plOptions][SelCtr].style.backgroundColor;
if (SelColor==new_selColor)
{
changeColor(new_deSelColor,SelCtr);
saveChanges(sel,selCtr,"del");
}
else
{
changeColor(new_selColor, SelCtr);
saveChanges(sel,selCtr,"add");
}
}
function saveChanges(p_selText,p_SelCtr,p_mode)
{
switch(p_mode)
{
case "add":
SelectedList.push(p_selText);
break;
case "del":
for (var ctr2=0;ctr2<SelectedList.length;ctr2++)
{
if (SelectedList[ctr2]==p_selText)
{
SelectedList.splice(ctr2,1);
break;
}
}
break;
}
Xrm.Page.getAttribute(plText).setValue(SelectedList.join("\r\n"));
}
function initColor()
{
for (var ctr3=0; ctr3<FullList.options.length;ctr3++)
{ changeColor(new_deSelColor, ctr3); }
}
function changeColor(newColor, newCtr)
{
crmForm.all[plOptions][newCtr].style.backgroundColor=newColor;
}
}
catch (e)
{ alert (e.description);}
}
param2 takes the field "new_textholder" which is a multiline text field. It's defined on the form and I have checked to make sure I am writing it correctly.
What could be the problem?
Thank you!!
This error is likely coming from the crmForm.all[plText] line. I'm guessing your org is recent enough that support for the old 4.0 api is no longer present, which would mean that the all object is no longer available, which would give you that error (plText is set to the value of param2). You might be able to modify this code to work on your 2015 form, but I don't have a 2015 org available to me at the moment so I can't say for sure.

How to initialiaze an object and assign different variables javascript

I have created an object where i need to assign some variables(parameters) and when the object is called, the variables(parameters) change. Here is my code:
var Modal = {
init: function () {
contact1: "";
contact2: "";
aboutus1: "";
aboutus2: "";
privacy1: "";
privacy2: "";
terms1: "";
terms2: "";
$(".modaltrigger").removeAttr("target");
$(".modaltrigger").click(function () {
if ($(this).is("#contact")) {
$('#primary_url').attr('href', contact1);
$('#secondary_url').attr('href', contact2);
} else if ($(this).is("#aboutus")) {
$('#primary_url').attr('href', aboutus1);
$('#secondary_url').attr('href', aboutus2);
} else if ($(this).is("#termsconditions")) {
$('#primary_url').attr('href', terms1);
$('#secondary_url').attr('href', terms2);
} else if ($(this).is("#privacy")) {
$('#primary_url').attr('href', privacy1);
$('#secondary_url').attr('href', privacy2);
}
});
}
};
I am trying to initialize the object above, and it does not work:
Modal.init(
contact1: "http:www.test1.com";
contact2: "http:www.test2.com";
aboutus1: "http:www.test3.com";
aboutus2: "http:www.test4.com";
privacy1: "http:www.test5.com";
privacy2: "http:www.test6.com";
terms1: "http:www.test7.com";
terms2: "http:www.test8.com"
);
it is Done like this way,
i Guess this is what you want to do.
var Modal = {
init: function (args) {
//then access your values like this
contact1= args.contact1;
contact2 = args.contact2;
..........
.........
.........
}
}
And to initiate this method you have write as
Modal.init({
contact1:"contact str",
contact2:"contact str",
.....
.....
lastitem : "last str"
});

Categories