EventEmiter pausing and restarting - dart

I have the following code
.html
<input
type = "text"
#raceCtrl = "ngForm"
[ngFormControl] = "raceForm.controls['raceCtrl']"
[(ngModel)] = "race.race"
(input) = "inputHandler()"
(mousemove) = "inputHandler()"
class = "mdl-textfield__input"
id = "race">
<input
type = "text"
#ethnicGroupCtrl = "ngForm"
[ngFormControl] = "raceForm.controls['ethnicGroupCtrl']"
[(ngModel)] = "race.ethnicGroup"
(input) = "inputHandler()"
(mousemove) = "inputHandler()"
class = "mdl-textfield__input"
id = "ethnicGroup">
.dart
RaceComponent( FormBuilder fb, ModelService modelSrvc ) {
raceForm = fb.group( {
'raceCtrl': ['', CustomValidators.requiredNounValidator( 2 )],
'ethnicGroupCtrl': ['', CustomValidators.optionalNounValidator( 2 )]
} );
_raceCtrl = raceForm.controls['raceCtrl'];
race = modelSrvc.getRace( );
inputHandler( );
}
void inputHandler( ) {
if ( raceForm.valid &&
!isEmpty( _raceCtrl.value ) ) {
isFormValid = true;
}
else {
isFormValid = false;
}
race.isValid = isFormValid;
}
onSubmit( ) {
isSubmitted = true;
if ( isFormValid ) {
raceEmitter.emit( {'topic': topic, 'race': race} );
}
else {
raceEmitter.emit( {'topic': topic, 'race': new Race( )} );
}
raceMap = new JsonObject.fromJsonString( encode( race ) );
The form submits as expected. But from then onwards the stream remains open and even when ethinicGroup has errors the error is propagated by the stream to storage. Is it possible to pause and unpause the stream depending on the validity of the form to prevent the erroneous data from being propagated.

Related

how to extract Elements in NSMutable Dictionary Array

my server sends me an response in hierarchy way i do no how to grab the value from that
here my sample response :
{
id = "-1";
result = (
{
keyname = "Warranty Expiry Date";
value = "06-14-2017";
}
);
},
{
id = "-1";
result = (
{
keyname = Owner;
value = "";
}
);
},
{
id = "-1";
result = (
{
keyname = Model;
value = "";
}
);
},
{
id = "-1";
result = (
{
keyname = "Price $";
value = 1000;
}
);
},
{
id = "-1";
result = (
{
keyname = Vendor;
value = "";
}
);
},
{
id = "-1";
result = (
{
keyname = "Purchase Date";
value = "";
}
);
}
)
here is sample Java code how they extracted the values
Hashtable htAttrs = (Hashtable) editedAttrHash.get(assItmId);
if (htAttrs != null) {
Set<String> keys = htAttrs.keySet();
for (String deAttr : keys) {
xmlSerializer.startTag("", "attribute");
xmlSerializer.attribute("", "keyname", deAttr);
xmlSerializer.attribute("", "value",
htAttrs.get(deAttr).toString());
xmlSerializer.endTag("", "attribute");
}
}
i need to do no how to from this structure past one day i am blocked here anyone can fix my problem
How to extract values from nsmutablearray?If it is really nsmutablearray object, then extract the values is simple.
For example, to get id of first element:
NSString firstId = response[0][#"id"]
But it seems, like for now, it is just a json object. So, you should serialize it to nsarray object first.

Sencha Touch 2.3.1 list scroll freezing

I'm using Sencha Touch 2.3.1 and using a list defined like this :
{
xtype: 'list',
id: 'index_list',
infinite: true,
flex: 1,
scrollToTopOnRefresh: false,
disableSelection: true,
store: 'store_index'
}
List's store has got more than 300 records, that's why I put the flag "infinite" to true.
Problem is when I scroll very fastly up and down through the list, app freezes and I can't do anything else with UI.
Also tested, put infinite flag to false doesn't fix it.
Cannot reproduce if data are less than ~300 records.
Platforms : iOS 6, 7 (iPhone), not iPad.
Have you got any idea ?
Use this override works for me
Ext.define('InfiniteListScroll.override.TouchGesture', {
override: 'Ext.event.publisher.TouchGesture',
lastEventType: null,
changedTouchesId: null,
lastEventObject: null,
onEvent: function(e) {
console.log('InfiniteListScroll.override.TouchGesture - onEvent');
var type = e.type,
lastEventType = this.lastEventType,
touchList = [e];
if ( type == 'touchstart' ) {
if( this.changedTouchesId == null ) {
this.changedTouchesId = e.changedTouches[0].identifier;
this.lastEventObject = e;
}
else {
console.log('changedTouchesId NOT null, touchEnd event wasnt fired for corresponding touchStart event.');
this.onTouchEnd( this.lastEventObject );
}
}
if (this.eventProcessors[type]) {
this.eventProcessors[type].call(this, e);
return;
}
if ('button' in e && e.button > 0) {
return;
}
else {
// Temporary fix for a recent Chrome bugs where events don't seem to bubble up to document
// when the element is being animated with webkit-transition (2 mousedowns without any mouseup)
if (type === 'mousedown' && lastEventType && lastEventType !== 'mouseup') {
var fixedEvent = document.createEvent("MouseEvent");
fixedEvent.initMouseEvent('mouseup', e.bubbles, e.cancelable,
document.defaultView, e.detail, e.screenX, e.screenY, e.clientX,
e.clientY, e.ctrlKey, e.altKey, e.shiftKey, e.metaKey, e.metaKey,
e.button, e.relatedTarget);
this.onEvent(fixedEvent);
}
if (type !== 'mousemove') {
this.lastEventType = type;
}
e.identifier = 1;
e.touches = (type !== 'mouseup') ? touchList : [];
e.targetTouches = (type !== 'mouseup') ? touchList : [];
e.changedTouches = touchList;
this.eventProcessors[this.mouseToTouchMap[type]].call(this, e);
}
},
onTouchEnd: function(e) {
console.log('InfiniteListScroll.override.TouchGesture - onTouchEnd');
if (!this.isStarted) {
return;
}
if (this.lastMoveEvent) {
this.onAnimationFrame();
}
var touchesMap = this.touchesMap,
currentIdentifiers = this.currentIdentifiers,
changedTouches = e.changedTouches,
ln = changedTouches.length,
identifier, i, touch;
this.changedTouchesId = null;
this.updateTouches(changedTouches);
changedTouches = e.changedTouches;
for (i = 0; i < ln; i++) {
Ext.Array.remove(currentIdentifiers, changedTouches[i].identifier);
}
e = this.factoryEvent(e);
for (i = 0; i < ln; i++) {
identifier = changedTouches[i].identifier;
touch = touchesMap[identifier];
delete touchesMap[identifier];
this.publish('touchend', touch.targets, e, {touch: touch});
}
this.invokeRecognizers('onTouchEnd', e);
// Only one touch currently active, and we're ending that one. So currentTouches should be 0 and clear the touchMap.
// This resolves an issue in iOS where it can sometimes not report a touchend/touchcancel
if (e.touches.length === 1 && currentIdentifiers.length) {
currentIdentifiers.length = 0;
this.touchesMap = {};
}
if (currentIdentifiers.length === 0) {
this.isStarted = false;
this.invokeRecognizers('onEnd', e);
if (this.animationQueued) {
this.animationQueued = false;
Ext.AnimationQueue.stop('onAnimationFrame', this);
}
}
}
});

Facebook Graph API - Status updates

I am currently using the Graph API to retrieve the News Feed for a user. However, some Posts of type "update" do not return any info on the original post e.g. in the result extract posted below, the story is "Joubert Nel commented on a link", but there is no info included as to what the link is, or the picture that goes with it. How can I obtain this info please?
actions = (
{
link = "https://www.facebook.com/637106301/posts/520940825396";
name = Comment;
}
);
comments = {
data = (
{
"can_remove" = 0;
"created_time" = "2014-03-15T13:06:43+0000";
from = {
id = 100000194244146;
name = "Laurie Edwards";
};
id = "520940825396_133907";
"like_count" = 2;
message = "Or you could just come home for a while!";
"user_likes" = 0;
},
);
paging = {
cursors = {
after = "MTI=";
before = "MQ==";
};
};
};
"created_time" = "2014-03-15T14:41:56+0000";
from = {
id = 637106301;
name = "Joubert Nel";
};
id = "637106301_520940825396";
likes = {
data = (
{
id = 214500098;
name = "Samuel Freilich";
},
{
);
paging = {
cursors = {
after = "OTUwMTE2OA==";
before = MjE0NTAwMDk4;
};
};
};
privacy = {
value = "";
};
story = "Joubert Nel commented on a link.";
"story_tags" = {
0 = (
{
id = 637106301;
length = 11;
name = "Joubert Nel";
offset = 0;
type = user;
}
);
};
type = status;
"updated_time" = "2014-03-15T14:41:56+0000";
is the link posted by Joubert? or using app you have permission. sounds like you don't have permission to post(link) but u have permission to Joubert activities

1151: A conflict exists with definition i in namespace internal

im new in action scripts and flash, i need some help with this code i couldnt find whats wrong with it, it gives this error:1151: A conflict exists with definition i in namespace internal.(var i:Number = 0;)
stop();
menu_item_group.menu_item._visible = false;
var spacing:Number = 5;
var total:Number = menu_label.length;
var distance_y:Number = menu_item_group.menu_item._height + spacing;
var i:Number = 0;
for( ; i < total; i++ )
{
menu_item_group.menu_item.duplicateMovieClip("menu_item"+i, i);
menu_item_group["menu_item"+i]._x = menu_item._x;
menu_item_group["menu_item"+i]._y = i * distance_y;
menu_item_group["menu_item"+i].over = true;
menu_item_group["menu_item"+i].item_text.text = menu_label[i];
menu_item_group["menu_item"+i].item_url = menu_url[i];
menu_item_group["menu_item"+i].onRollOver = function()
{
this.over = false;
}
menu_item_group["menu_item"+i].onRollOut = menu_item_group["menu_item"+i].onDragOut = function()
{
this.over = true;
}
menu_item_group["menu_item"+i].onRelease = function()
{
getURL(this.item_url);
}
menu_item_group["menu_item"+i].onEnterFrame = function()
{
if( this.over == true ) this.prevFrame();
else this.nextFrame();
}
}
thanks for your help!
Check your code. The variable i has been declared in the code already.

Bookmarklet to invoke onChange from actionlist in Safari on iPad

My work uses a proprietary system to store medical records. The site is coded in javascript, and we are unable to change the coding of the site. We would like to use iPads to access the site, the site is accessed through a browser which is serving HTML.
There is a drop-down list that has an onChange value, which when an item is selected from the drop-down list onChange="doAction(this)" is invoked. This works fine in a desktop browser, however the iPad doesn't support the onChange. I know that an alternative is to use onBlue, however we do not have access to change the HTML.
What I was hoping we could do was to add a bookmarklet that once clicked, in principle does what the onChange event did.
The current actionlist HTML is:
<select class="actionList" onChange="doAction(this)" style="width:100%"><option class="actionHeading" selected value="nothing">Select action ..</option><option class="action" value="moreInfo"> More Info (shortcut key ' i ')</option><option class="actionHeading" disabled>Add Electronic Form ..</option><option class="action" value="xform-progressnotes-amendment-discharge"> Amendment Discharge Summary</option><option class="action" value="xform-progressnotes-clinical-review"> Clinical Review</option><option class="action" value="xform-dischargesummary"> Discharge Summary</option><option class="action" value="xform-progressnotes-family-work"> Family Work</option><option class="action" value="xform-progressnotes-medical-review"> Medical Review</option><option class="action" value="xform-medicationsummary"> Medication Summary Form</option><option class="action" value="xform-operationrecord"> Operation Sheet</option><option class="action" value="xform-progressnotes-inpatient"> Progress Notes</option><option class="action" value="xform-progressnotes-weekly-summary"> Weekly Summary</option></select></td>
The only option I would like to have in the bookmarklet is to 'select' the medical review option, i.e
<option class="action" value="xform-progressnotes-medical-review"> Medical Review</option>
the javascript for onChange="doAction(this)" is:
function doAction(selectObj)
{
var xformPrefix = 'xform-';
var chartPrefix = 'chart-';
var action = selectObj.value;
selectObj.selectedIndex = 0;
if (action == 'moreInfo')
{
moreInfo();
}
else if (action == 'referForAttn')
{
referForAttn();
}
else if(action.startsWith(chartPrefix)) {
var chartName = action.substring(chartPrefix.length);
var url;
var processedURL;
var checkExistUrl = '/udr/json/?action=chartsdescription';
checkExistUrl += '&patientId=630402';
checkExistUrl += '&chartName=' + chartName;
$.ajax({
async:false,
dataType:"json",
url:checkExistUrl,
success:function(data){
if(data.description != "")
{
var answer = confirm(data.description);
}
if(answer || data.description == "")
{
}
}
});
}
else if (action.startsWith(xformPrefix))
{
var xformName = action.substring(xformPrefix.length);
var url;
var windowWidth;
var windowHeight;
var processedURL;
if (xformName == 'progressnotes-amendment-discharge')
{
url = '/oip-forms-viewer/forms/templates?udrSessionId=BF0C3C8399163439782C67D2757477DC&formName=progressnotes-amendment-discharge&patientId=630402&episodeId=458698&transactionId=&xformAction=new&sectionId=Admission';
processedURL = '%2Foip-forms-viewer%2Fforms%2Ftemplates%3FudrSessionId%3DBF0C3C8399163439782C67D2757477DC%26formName%3Dprogressnotes-amendment-discharge%26patientId%3D630402%26episodeId%3D458698%26transactionId%3D%26xformAction%3Dnew%26sectionId%3DAdmission'
windowWidth = 800;
windowHeight = 500;
}
if (xformName == 'progressnotes-clinical-review')
{
url = '/oip-forms-viewer/forms/templates?udrSessionId=BF0C3C8399163439782C67D2757477DC&formName=progressnotes-clinical-review&patientId=630402&episodeId=458698&transactionId=&xformAction=new&sectionId=Admission';
processedURL = '%2Foip-forms-viewer%2Fforms%2Ftemplates%3FudrSessionId%3DBF0C3C8399163439782C67D2757477DC%26formName%3Dprogressnotes-clinical-review%26patientId%3D630402%26episodeId%3D458698%26transactionId%3D%26xformAction%3Dnew%26sectionId%3DAdmission'
windowWidth = 800;
windowHeight = 500;
}
if (xformName == 'dischargesummary')
{
url = '/oip-forms-viewer/forms/templates?udrSessionId=BF0C3C8399163439782C67D2757477DC&formName=dischargesummary&patientId=630402&episodeId=458698&transactionId=&xformAction=new&sectionId=Admission';
processedURL = '%2Foip-forms-viewer%2Fforms%2Ftemplates%3FudrSessionId%3DBF0C3C8399163439782C67D2757477DC%26formName%3Ddischargesummary%26patientId%3D630402%26episodeId%3D458698%26transactionId%3D%26xformAction%3Dnew%26sectionId%3DAdmission'
windowWidth = 800;
windowHeight = 550;
}
if (xformName == 'progressnotes-family-work')
{
url = '/oip-forms-viewer/forms/templates?udrSessionId=BF0C3C8399163439782C67D2757477DC&formName=progressnotes-family-work&patientId=630402&episodeId=458698&transactionId=&xformAction=new&sectionId=Admission';
processedURL = '%2Foip-forms-viewer%2Fforms%2Ftemplates%3FudrSessionId%3DBF0C3C8399163439782C67D2757477DC%26formName%3Dprogressnotes-family-work%26patientId%3D630402%26episodeId%3D458698%26transactionId%3D%26xformAction%3Dnew%26sectionId%3DAdmission'
windowWidth = 800;
windowHeight = 500;
}
if (xformName == 'progressnotes-medical-review')
{
url = '/oip-forms-viewer/forms/templates?udrSessionId=BF0C3C8399163439782C67D2757477DC&formName=progressnotes-medical-review&patientId=630402&episodeId=458698&transactionId=&xformAction=new&sectionId=Admission';
processedURL = '%2Foip-forms-viewer%2Fforms%2Ftemplates%3FudrSessionId%3DBF0C3C8399163439782C67D2757477DC%26formName%3Dprogressnotes-medical-review%26patientId%3D630402%26episodeId%3D458698%26transactionId%3D%26xformAction%3Dnew%26sectionId%3DAdmission'
windowWidth = 800;
windowHeight = 500;
}
if (xformName == 'medicationsummary')
{
url = '/oip-forms-viewer/forms/templates?udrSessionId=BF0C3C8399163439782C67D2757477DC&formName=medicationsummary&patientId=630402&episodeId=458698&transactionId=&xformAction=new&sectionId=Admission';
processedURL = '%2Foip-forms-viewer%2Fforms%2Ftemplates%3FudrSessionId%3DBF0C3C8399163439782C67D2757477DC%26formName%3Dmedicationsummary%26patientId%3D630402%26episodeId%3D458698%26transactionId%3D%26xformAction%3Dnew%26sectionId%3DAdmission'
windowWidth = 800;
windowHeight = 760;
}
if (xformName == 'operationrecord')
{
url = '/oip-forms-viewer/forms/templates?udrSessionId=BF0C3C8399163439782C67D2757477DC&formName=operationrecord&patientId=630402&episodeId=458698&transactionId=&xformAction=new&sectionId=Admission';
processedURL = '%2Foip-forms-viewer%2Fforms%2Ftemplates%3FudrSessionId%3DBF0C3C8399163439782C67D2757477DC%26formName%3Doperationrecord%26patientId%3D630402%26episodeId%3D458698%26transactionId%3D%26xformAction%3Dnew%26sectionId%3DAdmission'
windowWidth = 800;
windowHeight = 760;
}
if (xformName == 'progressnotes-inpatient')
{
url = '/oip-forms-viewer/forms/templates?udrSessionId=BF0C3C8399163439782C67D2757477DC&formName=progressnotes-inpatient&patientId=630402&episodeId=458698&transactionId=&xformAction=new&sectionId=Admission';
processedURL = '%2Foip-forms-viewer%2Fforms%2Ftemplates%3FudrSessionId%3DBF0C3C8399163439782C67D2757477DC%26formName%3Dprogressnotes-inpatient%26patientId%3D630402%26episodeId%3D458698%26transactionId%3D%26xformAction%3Dnew%26sectionId%3DAdmission'
windowWidth = 800;
windowHeight = 500;
}
if (xformName == 'progressnotes-weekly-summary')
{
url = '/oip-forms-viewer/forms/templates?udrSessionId=BF0C3C8399163439782C67D2757477DC&formName=progressnotes-weekly-summary&patientId=630402&episodeId=458698&transactionId=&xformAction=new&sectionId=Admission';
processedURL = '%2Foip-forms-viewer%2Fforms%2Ftemplates%3FudrSessionId%3DBF0C3C8399163439782C67D2757477DC%26formName%3Dprogressnotes-weekly-summary%26patientId%3D630402%26episodeId%3D458698%26transactionId%3D%26xformAction%3Dnew%26sectionId%3DAdmission'
windowWidth = 800;
windowHeight = 500;
}
var newForm;
var confirmMsg = "There is another e-form opened. \n";
confirmMsg += "Press \"Cancel\" to finish editing the open e-form\n";
confirmMsg += "Press \"OK\" to discard it and open a new one.";
try {
var location = findFrame(top, 'main').win.document.location;
newForm = confirm(confirmMsg);
}
catch(e) {
newForm = true;
}
if(newForm) {
try {
findFrame(top, 'main').win.close();
}
catch(e) {}
findFrame(top, 'main').win = openCentredWindow(url, 'xformWindow', windowWidth, windowHeight);
try {
// setting the window title change on window load
$(findFrame(top, 'main').win).load(changeEformWindowTitle);
}
catch(e) {
// nothing to report
}
try {
// trying to change the window title early if the on load hasn't worked
setTimeout('changeEformWindowTitle()', 2000);
}
catch(e) {
// nothing to report
}
try {
// doing it a second time in case the first attempt was too early.
setTimeout('changeEformWindowTitle()', 8000);
}
catch(e) {
// nothing to report
}
try {
// doing it a third time 40 seconds later in case it there was a pre-fill.
setTimeout('changeEformWindowTitle()', 40000);
}
catch(e) {
// nothing to report
}
}
else {
findFrame(top, 'main').win.focus();
}
}
}
Any help you could provide would be very much appreciated!
Thanks.
Your best bet is to place a proxy server between the ipad and the actual product.
This proxy can then modify the html generated by the proprietary system.
You can look into nginx as a newbie friendly solution for proxying.
Cheers,
T.
PS : I dont believe bookmarklets work on iPads. Even if they did, it would be a terrible UI.

Resources