dynamic view of the syncfusion schedule angular component - html

In the parameterization of the Schedule to Angular component I would like to know if it is possible to somehow define the start time and end time for a day.
I would like to define for each day what is the start time and the end time.
As this example I realized that the start time and end time is for every day, I would like to set the start time and end time for each day.
const resourceObject = {
text: p.nome, id: p.id,
color: '#848484', workDays: daysNumber,
startHour: '13:00', endHour: '18:00'
};

We have prepared the below sample to have different work hours per day using DataBinding event.
https://stackblitz.com/edit/angular-fxqnrc-njutc8?file=app.component.ts
Please refer below UG.
https://ej2.syncfusion.com/angular/documentation/api/schedule/#setworkhours
if (this.flag) {
if (
this.scheduleObj.currentView !== "Month" &&
this.scheduleObj.currentView !== "Agenda"
) {
var currentViewDates = this.scheduleObj.getCurrentViewDates();
for (var i = 0; i < currentViewDates.length; i++) {
switch ((currentViewDates[i] as any).getDay()) {
case 0:
this.scheduleObj.setWorkHours(
[currentViewDates[i]],
"06:00",
"14:00"
);
break;
case 1:
this.scheduleObj.setWorkHours(
[currentViewDates[i]],
"08:00",
"14:00"
);
break;
case 2:
this.scheduleObj.setWorkHours(
[currentViewDates[i]],
"07:00",
"20:00"
);
break;
case 3:
debugger;
this.scheduleObj.setWorkHours(
[currentViewDates[i]],
"09:00",
"13:00"
);
break;
case 4:
debugger
this.scheduleObj.setWorkHours(
[currentViewDates[i]],
"06:00",
"14:00"
);
break;
case 5:
debugger
this.scheduleObj.setWorkHours(
[currentViewDates[i]],
"08:00",
"15:00"
);
break;
case 6:
this.scheduleObj.setWorkHours(
[currentViewDates[i]],
"07:00",
"19:00"
);
}
}
}
this.flag = false;
}

Related

System.Text.Json parse document that exists internal to a string

I receive string content that starts with a JSON value (could be simple or complex) and has some additional content afterward. I'd like to be able to parse the JSON document.
I don't have control over the string, so I can't put any kind of delimiter after the JSON content that would enable me to isolate it.
Examples:
"true and some more" - yields <true>
"false this is different" - yields <false>
"5.6/7" - yields <5.6>
"\"a string\""; then this" - yields <"a string">
"[null, true]; and some more" - yields <[null, true]>
"{\"key\": \"value\"}, then the end" - yields <{"key": "value"}>
The issue is the trailing content. The parser expects the input to end and throws an exception:
')' is invalid after a single JSON value. Expected end of data.
There isn't an option in JsonDocumentOptions to allow trailing content.
As a bonus, if you can give a solution that uses ReadOnlySpan<char>, that'd be aweseme.
The suggested answer of the custom reader wasn't working for me because the problem existed in the base reader: it just doesn't like certain trailing characters.
Since I still wanted to rely on JsonDocument.Parse() to extract the element for me, I really just needed to find where the element stopped break that bit off as a separate piece and submit that to the parse method. Here's what I came up with:
public static bool TryParseJsonElement(this ReadOnlySpan<char> span, ref int i, out JsonElement element)
{
try
{
int end = i;
char endChar;
switch (span[i])
{
case 'f':
end += 5;
break;
case 't':
case 'n':
end += 4;
break;
case '.': case '-': case '0':
case '1': case '2': case '3':
case '4': case '5': case '6':
case '7': case '8': case '9':
end = i;
var allowDash = false;
while (end < span.Length && (span[end].In('0'..'9') ||
span[end].In('e', '.', '-')))
{
if (!allowDash && span[end] == '-') break;
allowDash = span[end] == 'e';
end++;
}
break;
case '\'':
case '"':
end = i + 1;
endChar = span[i];
while (end < span.Length && span[end] != endChar)
{
if (span[end] == '\\')
{
end++;
if (end >= span.Length) break;
}
end++;
}
end++;
break;
case '{':
case '[':
end = i + 1;
endChar = span[i] == '{' ? '}' : ']';
var inString = false;
while (end < span.Length)
{
var escaped = false;
if (span[end] == '\\')
{
escaped = true;
end++;
if (end >= span.Length) break;
}
if (!escaped && span[end] == '"')
{
inString = !inString;
}
else if (!inString && span[end] == endChar) break;
end++;
}
end++;
break;
default:
element = default;
return false;
}
var block = span[i..end];
if (block[0] == '\'' && block[^1] == '\'')
block = $"\"{block[1..^1].ToString()}\"".AsSpan();
element = JsonDocument.Parse(block.ToString()).RootElement;
i = end;
return true;
}
catch
{
element = default;
return false;
}
}
It doesn't care so much about what's in the middle except (for strings, objects, and arrays) to know whether it's in the middle of a string (where it would be valid for the end character to be found) and checking for \-delimited characters. It works well enough for my purposes.
It takes a ReadOnlySpan<char> and an integer by reference. i needs to be the start of the expected JSON value, and it will be advanced to the next character after, if a valid value is found. It also follows the standard Try* pattern of returning a bool with an output parameter for the value.

When pressed button in react, console log shows the result but page does not

I am new to react and web. I have an issue when calling the function console shows it but i can not show it in my page.
usePriest = (evt, id) => {
const num = 3;
const { rear,bottom2,bottom3,bottom,player1, player2, player3, player4, mycards } = this.state;
var whichPlayer;
switch(num){
case 1:
whichPlayer = player1[0];
rear[1]=whichPlayer;
rear[0]=card6;
break;
case 2:
whichPlayer = player2[0];
bottom[1]=whichPlayer;
bottom[0]=card6;
break;
case 3:
whichPlayer = player3[0];
bottom2[1]=whichPlayer;
bottom2[0]=card6;
break;
case 4:
whichPlayer = player4[0];
bottom3[1]=whichPlayer;
bottom3[0]=card6;
break;
}
// bottom[1]=whichPlayer;
// bottom[0]=card6;
// console.log(bottom);
}
and i call my function in here
else if (mycards[0]==="/static/media/priest.ae71698d.jpg") {
return ( <div>
<button className="button_card1_use" onClick={(evt) => this.usePriest(evt, 1)}>Use</button>
<button className="button_card1_discard">Discard</button>
<div className="about1"><p>Priest</p>
Player is allowed to see another player's hand. </div></div>
)
}
What should i return in function or do something in order to be able to show it on the page.
You just need to call a setState at the end of the function in order tot reflect the changes -:
usePriest = (evt, id) => {
const num = 3;
// your old code
this.setState({ rear,bottom2,bottom3,bottom,player1, player2, player3, player4, mycards })
}
Actually in JS things get copied by reference, so effectively we are mutating the state directly. This is a better solution for the same -:
usePriest = (evt, id) => {
const num = 3;
const { rear,bottom2,bottom3,bottom,player1, player2, player3, player4, mycards } = this.state;
var whichPlayer;
switch(num){
case 1:
this.setState({whichPlayer: player1[0], rear: [...rear, 0: card6, 1: whichPlayer]});
break;
case 2:
this.setState({whichPlayer: player2[0], bottom: [...bottom, 0: card6, 1: whichPlayer]});
break;
case 3:
this.setState({whichPlayer: player3[0], bottom2: [...bottom2, 0: card6, 1: whichPlayer]});
break;
case 4:
this.setState({whichPlayer: player4[0], bottom3: [...bottom3, 0: card6, 1: whichPlayer]});
break;
}
}

Building a autocomplete search input with a combobox

I'm trying to create a combobox that will fill with posible auto complete results, I firstly have all the words in an array that compares to the user input, its then put into a switch statement that adds the words to the combobox. I however can't get it right to remove the results from the combobox when the input changes.
var dictionary:Vector.<String> = new Vector.<String>();
dictionary.push("University Chapel");
dictionary.push("IT Building");
dictionary.push("Student Centre");
dictionary.push("EMS Building");
dictionary.push("EMB Building");
dictionary.push("Monastry Hall");
dictionary.push("Conference Centre");
dictionary.push("Client Service Centre");
var objects:Vector.<MovieClip> = new Vector.<MovieClip>();
stage.focus = inputBox;
inputBox.addEventListener(Event.CHANGE, onCompletions);
function onCompletions(event:Event):void{
for(var i:int = 0; i < dictionary.length; ++i){
if(dictionary[i].indexOf(inputBox.text) >= 0){
switch(dictionary[i]) {
case 'IT Building':
cbox.addItemAt({label:"IT Building", data:"screenData" + newRow},0);
break;
case 'University Chapel':
cbox.addItemAt({label:"University Chapel", data:"screenData" + newRow},0);
break;
case 'Student Centre':
cbox.addItemAt({label:"Student Centre", data:"screenData" + newRow},0);
break;
case 'EMS Building':
cbox.addItemAt({label:"EMS Building", data:"screenData" + newRow},0);
break;
case 'EMB Building':
cbox.addItemAt({label:"EMB Building", data:"screenData" + newRow},0);
break;
case 'Monastry Hall':
cbox.addItemAt({label:"Monastry Hall", data:"screenData" + newRow},0);
break;
case 'Conference Centre':
cbox.addItemAt({label:"Conference Centre", data:"screenData" + newRow},0);
break;
case 'Client Service Centre':
cbox.addItemAt({label:"Client Service Centre", data:"screenData" + newRow},0);
break;
}
}
else {
//cbox.removeAll(); //Where I attempted to remove all the results
}
}
}
So I'm trying to remove the results from the combobox and have them re evaluated and then inserted again. Just as a side question is there a way to expand comboboxs through actionscript ?
Thanks in advance
If anyone is interested, I got it to work, so this will basically create a autocomplete search input box.
var dictionary:Vector.<String> = new Vector.<String>();
dictionary.push("University Chapel");
dictionary.push("IT Building");
dictionary.push("Student Centre");
dictionary.push("EMS Building");
dictionary.push("EMB Building");
dictionary.push("Monastry Hall");
dictionary.push("Conference Centre");
dictionary.push("Client Service Centre");
stage.focus = inputBox;
inputBox.addEventListener(Event.CHANGE, onCompletions);
cbox.open();
function onCompletions(event:Event):void{
cbox.removeAll();
cbox.close();
for(var i:int = 0; i < dictionary.length; ++i){
if(dictionary[i].indexOf(inputBox.text) >= 0 && inputBox.text != ''){
switch(dictionary[i]) {
case 'IT Building':
cbox.addItemAt({label:"IT Building", data:"screenData"},0);
cbox.open();
break;
case 'University Chapel':
cbox.addItemAt({label:"University Chapel", data:"screenData"},0);
cbox.open();
break;
case 'Student Centre':
cbox.addItemAt({label:"Student Centre", data:"screenData"},0);
cbox.open();
break;
case 'EMS Building':
cbox.addItemAt({label:"EMS Building", data:"screenData"},0);
cbox.open();
break;
case 'EMB Building':
cbox.addItemAt({label:"EMB Building", data:"screenData"},0);
cbox.open();
break;
case 'Monastry Hall':
cbox.addItemAt({label:"Monastry Hall", data:"screenData"},0);
cbox.open();
break;
case 'Conference Centre':
cbox.addItemAt({label:"Conference Centre", data:"screenData"},0);
cbox.open();
break;
case 'Client Service Centre':
cbox.addItemAt({label:"Client Service Centre", data:"screenData"},0);
cbox.open();
break;
}
}
}
}

why is this switch case not working?

why is this switch case not working... even if i pick the button monday it shows me default message..
switch (finalsave.weekday) {
case finalsave.weekday == 1:
trace ("monday");
break;
case finalsave.weekday== 2:
trace ("tuesday");
break;
case finalsave.weekday == 3:
trace ("wednesday");
break;
case finalsave.weekday == 4:
trace ("thursday");
break;
case finalsave.weekday == 5:
trace ("friday");
break;
default:
trace ("nothingness");
}
switch (finalsave.weekday) {
case 1:
trace ("monday");
break;
case 2:
trace ("tuesday");
break;
case 3:
trace ("wednesday");
break;
... etc.
}
Or if you want to ditch that godawful switch-case altogether:
var weekdays: Array = [
"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"
]
var index : int = finalsave.weekday -1;
trace( weekdays[ index ] );
After case, you should mention the possible value of your variable,
Below is the syntax of switch case for action script, c/c++ , java and javascript:
Switch case using strings.
view sourceprint?
switch("hello world")
{
case "hello":
trace("The man says hello");
break;
case "hello cat":
trace("The man says hello cat");
break;
case "hello world":
trace("The man says hello world");
break;
default:
trace("None of the above were met");
}
In this example the text "The man says hello world" is traced out.
Switch Case using integers, what fun.
switch(1)
{
case 1:
trace("The Number 1");
break;
case 2:
case 3:
trace("The Number 2 or 3");
break;
default:
trace("None of the numbers above");
}
from http://www.how-to-code.com/as3-actionscript3/as3-conditionals/as3-switch-case.html

Adobe AIR 3.2 Glitch

I just finished a successful build of my program last night. Then, I get up this morning, and after an update fro Adobe AIR 3.1 to AIR 3.2, I find THIS bug!
The same build under 3.1 works perfectly. However, as soon as 3.2 is installed, the following code after stopDrag fails silently. Mind you, it only fails in the packed and installed AIR application. It works perfectly when I test it inside of Adobe Flash Professional CS5.5
WHAT is going on? Here's the code I'm dealing with. Again, this works without error for Adobe AIR 3.1, but fails for 3.2. I cannot get to any other MouseEvent.MOUSE_UP events in my program at this point, due to my structure.
I omitted the irrelevant parts of the code. All the same, there is a lot, due to the fact that I don't know where the error occurs exactly. Instead of everything that is supposed to happen happening, stopDrag is the last line of code that fires in this block.
tile5.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler5);
function mouseUpHandler5(evt:MouseEvent):void
{
Mouse.cursor = "paw";
var obj = evt.target;
var target = obj.dropTarget;
obj.stopDrag();
if (target != null && target.parent == hsSlot1)
{
brdgcheck(5, 1);
}
}
function brdgcheck(tile:int, slot:int)
{
var ck_brdg_l:String = "osr.Langue.brdg_l" + String(slot);
var ck_brdg_t:String = "osr.Langue.brdg_t" + String(tile);
var ck_slotfilled:String = "Slot" + String(slot) + "Filled";
var ck_tile:String = "tile" + String(tile);
var ck_slot:String = "hsSlot" + String(slot);
var ck_txtTile:String;
switch(tile)
{
case 1:
ck_brdg_t = osr.Langue.brdg_t1;
ck_txtTile = tile1.txtTile1.text;
break;
case 2:
ck_brdg_t = osr.Langue.brdg_t2;
ck_txtTile = tile2.txtTile2.text;
break;
case 3:
ck_brdg_t = osr.Langue.brdg_t3;
ck_txtTile = tile3.txtTile3.text;
break;
case 4:
ck_brdg_t = osr.Langue.brdg_t4;
ck_txtTile = tile4.txtTile4.text;
break;
case 5:
ck_brdg_t = osr.Langue.brdg_t5;
ck_txtTile = tile5.txtTile5.text;
break;
}
switch(slot)
{
case 1:
ck_brdg_l = osr.Langue.brdg_l1;
break;
case 2:
ck_brdg_l = osr.Langue.brdg_l2;
break;
case 3:
ck_brdg_l = osr.Langue.brdg_l3;
break;
case 4:
ck_brdg_l = osr.Langue.brdg_l4;
break;
case 5:
ck_brdg_l = osr.Langue.brdg_l5;
break;
}
if (ck_brdg_l == ck_brdg_t)
{
osr.Sonus.PlaySound("concretehit");
this[ck_slotfilled].visible = true;
switch(slot)
{
case 1:
Slot1Filled.txtSlot1.text = ck_txtTile;
break;
case 2:
Slot2Filled.txtSlot2.text = ck_txtTile;
break;
case 3:
Slot3Filled.txtSlot3.text = ck_txtTile;
break;
case 4:
Slot4Filled.txtSlot4.text = ck_txtTile;
break;
case 5:
Slot5Filled.txtSlot5.text = ck_txtTile;
break;
}
this[ck_tile].visible = false;
this[ck_slot].visible = false;
if (hsSlot1.visible == false && hsSlot2.visible == false && hsSlot3.visible == false && hsSlot4.visible == false && hsSlot5.visible == false)
{
osr.Gradua.Score(true);
osr.Gradua.Evaluate("brdg");
btnReset.visible = false;
hsChar.visible = false;
if (osr.Gradua.Fetch("brdg", "arr_act_stcnt") < 4)
{
bga.gotoAndPlay("FINKEY");
win_key();
}
else
{
bga.gotoAndPlay("FINNON");
}
}
else
{
osr.Gradua.Score(true);
}
}
else
{
osr.Gradua.Score(false);
osr.Sonus.PlaySound("glassbreak");
switch(tile)
{
case 1:
tile1.x = 92.85;
tile1.y = 65.85;
break;
case 2:
tile2.x = 208.80;
tile2.y = 162.85;
break;
case 3:
tile3.x = 324.80;
tile3.y = 65.85;
break;
case 4:
tile4.x = 437.80;
tile4.y = 162.85;
break;
case 5:
tile5.x = 549.80;
tile5.y = 65.85;
break;
}
}
}
EDIT: I found a good workaround, to use "if (hsSlot1.hitTestPoint(mouseX,mouseY) && hsSlot1.visible == true)"
However, a solution to this problem would still be appreciated!