Jump to content

altagur

Members
  • Posts

    127
  • Joined

  • Last visited

  • Days Won

    6

Everything posted by altagur

  1. Because unigui developers dont wont insert custom http request hhandling i publich how i done it around the unigui sources: In file unit ExtHTTPServer; i insert uses after implementation implementation uses {$IFDEF GUR} UniGUIApplication,dtHtmlMain, Dialogs, ServerModule{, uMain, ServerModule, DB}, {$ENDIF} {$IFDEF MSWINDOWS}Windows, Messages,{$ENDIF} StrUtils, (* deleted IdGlobalProtocols, *) (* added *) uIdGlobalProtocols, (* added *) ExtPascal; and in function insert a call to datamodule function procedure TIdExtSession.HandleRequest(ARequest: TIdHTTPRequestInfo; AResponse: TIdHTTPResponseInfo); (* added *) {$WARNINGS OFF} (* added *) function CheckIfFileIsModified(FileName: string): Boolean; const FCompareDateFmt = 'yyyymmddhhnnss'; var FFileDateTime: TDateTime; begin Result := True; if (ARequest.RawHeaders.Values['if-Modified-Since'] <> '') then begin FFileDateTime := FileDateToDateTime(FileAge(FileName)); Result := not SameText(FormatDateTime(FCompareDateFmt, FFileDateTime), FormatDateTime(FCompareDateFmt, StrInternetToDateTime(ARequest.RawHeaders.Values['if-Modified-Since']))); end; end; function TryToServeFile: boolean; var FileName: string; FileDateTime: TDateTime; begin FileName := ExtractFilePath(ParamStr(0)); FileName := StringReplace(FileName, ExtractFileDrive(FileName), '', []); if (Length(ARequest.Document) > 1) and (ARequest.Document[1]in ['/', '\']) then FileName := FileName + Copy(ARequest.Document, 2, MaxInt) else FileName := FileName + ARequest.Document; FileName := ExpandFilename(FileName); if FileExists(FileName) then begin Result := True; if CheckIfFileIsModified(FileName) then begin AResponse.ContentStream := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite); AResponse.FreeContentStream := True; AResponse.ContentLength := AResponse.ContentStream.Size; FileDateTime := FileDateToDateTime(FileAge(FileName)); AResponse.LastModified := FileDateTime; AResponse.ContentType := FileType2MimeType(FileName); end else AResponse.ResponseNo := 304; //Not Modified, use cache version end else begin (* added *) AResponse.ResponseNo := 404; //Not found (* added *) Result := false; end; end; function TryToServeDiskFile(FileName: String): boolean; var FileDateTime: TDateTime; begin if FileExists(FileName) then begin Result := True; if CheckIfFileIsModified(FileName) then begin AResponse.ContentStream := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite); AResponse.FreeContentStream := True; AResponse.ContentLength := AResponse.ContentStream.Size; FileDateTime := FileDateToDateTime(FileAge(FileName)); AResponse.LastModified := FileDateTime; AResponse.ContentType := FileType2MimeType(FileName); end else AResponse.ResponseNo := 304; //Not Modified, use cache version end else begin (* added *) AResponse.ResponseNo := 404; //Not found (* added *) Result := false; end; end; (* added *) {$WARNINGS ON} (* added *) type MethodCall = procedure of object; var PageMethod : TMethod; MethodCode : pointer; {$IFDEF GUR} var AID: variant; ACmd: Integer; AFileName: String; AUID: variant; (* md: TMainData; S : TStream; F: TSTringStream; FName, DOcName, AExt, ANam, ASendName: string; *) {$ENDIF} begin (* deleted *) //CurrentFCGIThread := Self; (* deleted *) (* added *) SetCurrentFCGIThread(Self); (* added *) FCurrentRequest := ARequest; FCurrentResponse := AResponse; // FCurrentResponse.CacheControl:='no-cache'; (* deleted *) { if ARequest.Cookies.GetCookieIndex(0, 'FCGIThread') = -1 then with AResponse.Cookies.Add do begin CookieName := 'FCGIThread'; Value := SessionID; ARequest.Cookies.AddSrcCookie(CookieText); end; AResponse.ContentType := 'text/html'; // this changes charset in D2011 see #0000531 } (* deleted *) if Length(ARequest.Params.Values['cmd'])>0 then begin Response := ''; end; Response := ''; FParams.DelimitedText := FCurrentRequest.UnParsedParams; if BeforeHandleRequest then if PathInfo = '' then begin {$IFDEF GUR} if Length(ARequest.Params.Values['$$$'])>0 then begin ACmd := StrToInt(ARequest.Params.Values['$$$']); case ACmd of 0: // file begin AID := StrToFloat(ARequest.Params.Values['id']); AUID := StrToFloat(ARequest.Params.Values['uid']); if TMainData(TUNIGUISession(Self).UniMainModule).PutToTmpFileByUser(AID, AFileName, AUID) then //; if FileExists(FILE_ROOT + ARequestInfo.Document) then begin TryToServeDiskFile(AFileName); //AResponse.ServeFile(AContext, AFileName); end; end; end; end //; else {$ENDIF} begin Home; end; end else begin if Length(ARequest.Params.Values['$$$'])>0 then ShowMessage('PathInfo <> '''); MethodCode := MethodAddress(PathInfo); if MethodCode <> nil then begin PageMethod.Code := MethodCode; PageMethod.Data := Self; try (* {$IFDEF GUR} if Length(ARequest.Params.Values['cmd'])>0 then begin ACmd := StrToInt(ARequest.Params.Values['cmd']); case ACmd of 0: // file begin AID := StrToFloat(ARequest.Params.Values['id']); if TMainData(TUNIGUISession(Self).UniMainModule).PutToTmpFile(AID, AFileName) then //; if FileExists(FILE_ROOT + ARequestInfo.Document) then begin TryToServeDiskFile(AFileName); //AResponse.ServeFile(AContext, AFileName); end; end; end; end //; else {$ENDIF} *) MethodCall(PageMethod); // Call published method except on E : Exception do OnError(E, E.Message, PathInfo, FCurrentRequest.UnParsedParams); end; end else begin if not TryToServeFile then OnNotFoundError; end; end; AfterHandleRequest; if not Assigned(AResponse.ContentStream) and (Response <> '') and (AResponse.ResponseNo <> 304) then FCurrentResponse.ContentText := Response; end; in DataModule add function to handle function TMainData.PutToTmpFileByUser(AID: variant; var AFileName: String; AUID: variant): Boolean; var S : TStream; F: TSTringStream; FName, DOcName, AExt, ANam, ASendName: string; baseAct: Boolean; begin Result := False; baseAct := AltaData.Connected; if not baseAct then begin AltaData.SpecificOptions.Clear; //if Length(_Local)>0 then Database.Properties.Add('codepage='+_Local); AltaData.SpecificOptions.Values['SQL Server.OLEDBProvider'] := ProvToStrEx(StrToInt(UniServerModule.AdminProtocol)); AltaData.Server := UniServerModule.AdminHostName; //; AltaData.Database := UniServerModule.AdminBaseName; AltaData.UserName := UniServerModule.AdminUserName; AltaData.PASSWORD := UniServerModule.AdminPassword; AltaData.LoginPrompt := False; AltaData.Connected := True; end; with qrGetUsrDoc do begin Params[0].Value := AID; Params[1].Value := AUID; Active := True; try if Active and (not EOF) then begin DocName := FieldByName('DocName').AsString; AFileName := FieldByName('FileName').AsString; AExt := ExtractFileExt(AFileName); ANam := ExtractFileName(AFileName); if Length(DocName)>0 then begin if DocName<>ANam then ASendName := DocName+AExt else ASendName := DocName; end else begin ASendName := ANam; end; (* S := CreateBlobStream(TBlobField(FieldByName('Body')), bmRead); if S<>nil then try S.Position := 0; UniSession.SendStream(S, ASendName); finally S.Free; end; *) AFileName := GetTmpFileInDir(UniServerModule.TempFolderPath, AExt, DocName); //FName := UniServerModule.TempFolderPath + DocName + AExt; // + FormatDateTime('hhnnss', Time) TBlobField(FieldByName('Body')).SaveToFile(AFileName); Result := True; end; finally Active := False; end; end; if not baseAct then begin AltaData.Connected := False; end; end; But remember http server create new sessin with new datamodule where wil be new database compontent and need set bin server module global login and password I havnt unigui sources and because i can not prcreate code to call function in current DataModule in javascrip you can now create requests with parameters and handle it for eamle in drag from grid to desctop in google chrome <script> function dragStart(evt) { var curgrid = GetGrid(evt.target); if (curgrid==null) return true; evt.dataTransfer.setData("gridid", curgrid.getAttribute('id')); var egrid=Ext.getCmp(curgrid.id); var sm = egrid.getSelectionModel().getSelection()[0]; // var fName = sm.get("2").toString(); var fID = sm.get("4").toString(); files = "application/octet-stream:"+fName+":"+ document.location+"?$$$=0&id="+fID+"&uid="+MainForm.uid.text; event.dataTransfer.setData("DownloadURL",files); return true; } ldropbox.addEventListener("dragstart", dragStart, false); </script> Exaple how drag from grid to descto i can send if needed BR Nick Gurov
  2. Thank you for experimental, fact double refresh is work!
  3. Please include event in TUniMainModule for custom htnml request handling on with done like TUniguiSession = class(TIdExtSession) function BeforeHandleRequest : boolean; override; end; function TUniguiSession.BeforeHandleRequest : boolean; override; begin if Assigned (MainDataModule.FOnBeforeHanle) then Result := MainDataModule.FOnBeforeHanle(CurrentRequest ,CurrentResponse) else Result := inherited; ) This threaded method will be very useful for custom file download in dragdrop and another
  4. for handling requests like localhost:8077?cmd=1&id=12375 define project define GUR if main database module named MainData from file dtHtmlMain In module ExtHTTPServer; in uses after implementation insert uses implementation uses {$IFDEF GUR} UniGUIApplication,dtHtmlMain, {$ENDIF} and change TIdExtSession.HandleRequest( procedure TIdExtSession.HandleRequest(ARequest: TIdHTTPRequestInfo; AResponse: TIdHTTPResponseInfo); (* added *) {$WARNINGS OFF} (* added *) function CheckIfFileIsModified(FileName: string): Boolean; const FCompareDateFmt = 'yyyymmddhhnnss'; var FFileDateTime: TDateTime; begin Result := True; if (ARequest.RawHeaders.Values['if-Modified-Since'] <> '') then begin FFileDateTime := FileDateToDateTime(FileAge(FileName)); Result := not SameText(FormatDateTime(FCompareDateFmt, FFileDateTime), FormatDateTime(FCompareDateFmt, StrInternetToDateTime(ARequest.RawHeaders.Values['if-Modified-Since']))); end; end; function TryToServeFile: boolean; var FileName: string; FileDateTime: TDateTime; begin FileName := ExtractFilePath(ParamStr(0)); FileName := StringReplace(FileName, ExtractFileDrive(FileName), '', []); if (Length(ARequest.Document) > 1) and (ARequest.Document[1]in ['/', '\']) then FileName := FileName + Copy(ARequest.Document, 2, MaxInt) else FileName := FileName + ARequest.Document; FileName := ExpandFilename(FileName); if FileExists(FileName) then begin Result := True; if CheckIfFileIsModified(FileName) then begin AResponse.ContentStream := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite); AResponse.FreeContentStream := True; AResponse.ContentLength := AResponse.ContentStream.Size; FileDateTime := FileDateToDateTime(FileAge(FileName)); AResponse.LastModified := FileDateTime; AResponse.ContentType := FileType2MimeType(FileName); end else AResponse.ResponseNo := 304; //Not Modified, use cache version end else begin (* added *) AResponse.ResponseNo := 404; //Not found (* added *) Result := false; end; end; function TryToServeDiskFile(FileName: String): boolean; var FileDateTime: TDateTime; begin if FileExists(FileName) then begin Result := True; if CheckIfFileIsModified(FileName) then begin AResponse.ContentStream := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite); AResponse.FreeContentStream := True; AResponse.ContentLength := AResponse.ContentStream.Size; FileDateTime := FileDateToDateTime(FileAge(FileName)); AResponse.LastModified := FileDateTime; AResponse.ContentType := FileType2MimeType(FileName); end else AResponse.ResponseNo := 304; //Not Modified, use cache version end else begin (* added *) AResponse.ResponseNo := 404; //Not found (* added *) Result := false; end; end; (* added *) {$WARNINGS ON} (* added *) type MethodCall = procedure of object; var PageMethod : TMethod; MethodCode : pointer; {$IFDEF GUR} var AID: variant; ACmd: Integer; AFileName: String; {$ENDIF} begin (* deleted *) //CurrentFCGIThread := Self; (* deleted *) (* added *) SetCurrentFCGIThread(Self); (* added *) FCurrentRequest := ARequest; FCurrentResponse := AResponse; // FCurrentResponse.CacheControl:='no-cache'; (* deleted *) { if ARequest.Cookies.GetCookieIndex(0, 'FCGIThread') = -1 then with AResponse.Cookies.Add do begin CookieName := 'FCGIThread'; Value := SessionID; ARequest.Cookies.AddSrcCookie(CookieText); end; AResponse.ContentType := 'text/html'; // this changes charset in D2011 see #0000531 } (* deleted *) if Length(ARequest.Params.Values['cmd'])>0 then begin Response := ''; end; Response := ''; FParams.DelimitedText := FCurrentRequest.UnParsedParams; if BeforeHandleRequest then if PathInfo = '' then begin {$IFDEF GUR} if Length(ARequest.Params.Values['cmd'])>0 then begin ACmd := StrToInt(ARequest.Params.Values['cmd']); case ACmd of 0: // file begin AID := StrToFloat(ARequest.Params.Values['id']); if TMainData(TUNIGUISession(Self).UniMainModule).PutToTmpFile(AID, AFileName) then //; if FileExists(FILE_ROOT + ARequestInfo.Document) then begin TryToServeDiskFile(AFileName); //AResponse.ServeFile(AContext, AFileName); end; end; end; end //; else {$ENDIF} Home; end else begin MethodCode := MethodAddress(PathInfo); if MethodCode <> nil then begin PageMethod.Code := MethodCode; PageMethod.Data := Self; try {$IFDEF GUR} if Length(ARequest.Params.Values['cmd'])>0 then begin ACmd := StrToInt(ARequest.Params.Values['cmd']); case ACmd of 0: // file begin AID := StrToFloat(ARequest.Params.Values['id']); if TMainData(TUNIGUISession(Self).UniMainModule).PutToTmpFile(AID, AFileName) then //; if FileExists(FILE_ROOT + ARequestInfo.Document) then begin TryToServeDiskFile(AFileName); //AResponse.ServeFile(AContext, AFileName); end; end; end; end //; else {$ENDIF} MethodCall(PageMethod); // Call published method except on E : Exception do OnError(E, E.Message, PathInfo, FCurrentRequest.UnParsedParams); end; end else begin if not TryToServeFile then OnNotFoundError; end; end; AfterHandleRequest; if not Assigned(AResponse.ContentStream) and (Response <> '') and (AResponse.ResponseNo <> 304) then FCurrentResponse.ContentText := Response; end; In tunihtmlframe you can define startdrag function <script type="text/javascript"> function dragStart(evt) { fID = MyForm.MyLabel.text; files = "application/octet-stream:"+fName+":"+document.location+"?cmd=0&id="+fID; event.dataTransfer.setData("DownloadURL",files); return true; } and register procedure var box = document.getElementById(MYForm.MyGrid.id); box.addEventListener("dragstart", dragStart, false); </script> Its way to dragdrop files from tunidbgrid in browser to desctop Work only in googlechrome. Possible unigui developers included event in MainModule on with done like function TUniguiSession.BeforeHandleRequest : boolean; override; begin if Assigned (MainDataModule.FOnBeforeHanle) then Result := MainDataModule.FOnBeforeHanle(CurrentRequest ,CurrentResponse) else inherited; ) end;
  5. I need to post files to client. I am not find such event in unigui. I am catch event in procedure TIdCustomHTTPServer.DoCommandGet where TMethod(FOnCommandGet).Data is TUniExtServer How to get current TUniExtSession from TUniExtServer and while such requests localhost:8077/tmp/myfile.jpg?cmd=1&id=2 not translated by TUniExtServer to procedure TIdExtSession.HandleRequest()? Please help me. I need drop file from brauser to desctop in google chrome i altready write javascript and now need catch file request to generate file dinamically from database. For this i need MainDataModule from UniSession in TIdCustomHTTPServer.DoCommandGet or translation localhost:8077/tmp/myfile.jpg?cmd=1&id=2 to TIdExtSession.HandleRequest or event in unigui for user manual params and request handling Please help
  6. Is exist legal recomended method of unigui for returning files dinamically created on file request?? such as localhost:8077/files/myfile.jpg or i need only to rewrite sources if indy DoComandGet? Where in unigui write code like: procedure TForm1.IdHTTPServer1CommandGet(AThread: TIdPeerThread; ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo); begin ... File prepare; IdHTTPServer1.ServeFile(AThread,AResponseInfo,'path to file'); ... end;
  7. Excuse me for misplace. I find description how do this ( http://www.unigui.com/component/wordpress/2011/07/29/client-side-scripting-with-unigui/?Itemid=17) Please delete my question. Logically need control chain but a component chain is pleasant.
  8. I create form with panel with label. Label on panel panel on form. I think in javascript need call like var txt = MyForm.MyPanel.MyLabel.text; alert(txt) ; But in fierbug i see MyLabel is a child of MyForm and call must be var txt = MyForm.MyLabel.text; alert(txt) ; What kind of call rooles? Or i need call var obj = document.getElementById(MyForm.MyLabel.id); var txt =obj.text; Thanks of all.
  9. Excuse me for a questions. I. In dragdrop i am return file url to brouser. function dragStart(evt) { var fName = MyForm.MyLabel.Text; files = "image/jpeg:"+fName+":"+document.location+"/temp/"+fName; event.dataTransfer.setData("DownloadURL",files); return true; } Then dragdrop started file not exists because he is in database field and download file in dragdrop start not rooles. Pleas answer stuped-me how in unigui capture file request (localhost:8077/temp/myfile.jpg) for file creating and returning file dynamicallyю 2 Secondary question - in dragdrop start i need know filename Now i create TLabel put in caption filename field value from database then cursor moved and get file name as MyForm.MyLabel.text Invisible components like TQuery or TDataset can be visible in javascript client events. I need database field values in javascript. Or need create custom control! create publushed property for example CurValue and get file name as MyForm.MyGrid.CurValue, i am reall sorry for my bad english. Possible create standart TUniDatasource object with method FieldValue("FieldName") visible in client side like javascript object? (Ajax request is delayed and javascript work in one thread because impossible call ani funnction in javascript and give result from server (getTimeout is complex way by me ). But standart prepared values will be useful i think) Can i obtain IdHTTPServer in unigui such as procedure TForm1.IdHTTPServer1CommandGet(AThread: TIdPeerThread; ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo); begin ... File prepare; IdHTTPServer1.ServeFile(AThread,AResponseInfo,'path to file'); ... end; Thank you for any help. Gurov Nick
  10. In Delphi now included AnyDac - powefull component pack. Another rooles DB components - unidac. All db components have restriction on TConnection Component depends on sqlserver model. For example UNIDAC fpor SQLServer (etc sdac) must have personsl TUniCOnnection per thread. And because need put TUniConnection to MainDataModule with is unic per thread not in ServerModule wich is separated between threads. Database layer MSSQL Client can hand one connection for several queries simalteneozly thred-safe but AnyDac Sdac Zeos all falld if put Connection component in ServerModule Be ready. Impossible put ZConnection1 in ServerModule. Nik Gurov (russian) Are the SDAC connection components thread-safe?Yes, SDAC is thread-safe, but there is a restriction. The same TMSConnection object cannot be used in several threads at the same time. So if you have a multithreaded application, you should have a TMSConnection object for each thread that uses SDAC. - See more at: http://www.devart.com/sdac/faq.html#sthash.0ThnNgQe.dpuf
  11. Thanks very much for butiful example how do dragdrop from desktop to browser I done this from desktop to browser and from one tunidbgrid to another tunidbgrid Google Chrome allow dragdrop from browser to desktop. If you want to drag from tunudbgrid need put tunihtmlframe invisible and in his body do grid draggable and assign dragstart event <script type="text/javascript"> var yg = document.getElementById(YouForm.YouGrid.id); function GetGrid(obj) { var grid = obj; var par = 0; while((par==0)&&(grid!=null)){ if(grid == yg){ par = 1; }else{ grid = grid.parentNode; } } return grid; } function dragStart(evt) { /* Hear we can get grid id and call ajax to create file /img/page.png var curgrid = GetGrid(evt.target); if (curgrid==null) return true; ajaxRequest(ajaxtarget, "createtmpfile", ["curgrid="+curgrid.id]); */ files = "image/jpeg:Page5.jpg:"+document.location+"/img/page.png"; event.dataTransfer.setData("DownloadURL",files); return true; } function initEventHandlers() { // set EventHandlers for dropbox for drag and drop: // // yg.draggable = true; yg.addEventListener("dragstart", dragStart, false); } initEventHandlers(); </script>
  12. How using unigui controls do forum like this forum. Need control like ctrlgrid Left sideof record data and author right side message body and height of record must be of messagebody text height Typical tasks such as forum i think must be created simply with component pack. Great thasks for UNIGUI. Today already its cool
  13. I have two frame with grid and dragdrop files from desctop ajax In event onload of dragdrop html5 exaple you have file data and can use library for image detection. You can more image handling fore eaple image shadowing Javascript librarys for image type detection exists in sourceforge.ned and another places http://www.pixastic.com/lib/ Exist FaceRecognition Delphi libraries for example http://delphideep.blogspot.ru/2013/03/face-recognition-with-delphi.html Hear how to grap from webcab foto and upload to the base http://forums.unigui.com/index.php?/topic/3642-capturing-camera/ after need recognize by delphi recognition library. I do and its work.
  14. hear exist examle how do dragdrop html5. I am done so And where in javascrip code handled event draon dragstart and drop On drop you can check fileextension and exist javascrip library understatndig kind of file - peg img gif and so on client browser side before sending to server. C-dll have interfece using image file/string and coordinates To use need export dll inteface by delphi dll export tools Will be created pascal wrapper such as MSoffise wrappers. Dll reaklli recognize faces but in additional need html5 webcam integration study,
  15. In design interface need create master-detail forms. Create detail form need use nmaster form as Owner. Then closed Master form automatic close detail and destroy form. Nou possible create form on UniApplication. Form := TFormClass.Create(UniApplication); Need DetailForm := TDetailFormClass.Create(MasterForm)
  16. I am autoanswering: in tunihtmlframe need assign draggable var grid = document.getElementById(Form.MainGrid.id); grid.draggable = true; Really amazing possibility html5 dragdrop in unigui.
  17. Dear programmers. How do dragdrop from one unidbgrid to another. First of all need set property draggable=true. But where write this property. Secondery need assign dragdrop events. I am use html 5 example and put on grid form tunihtmlframe with this code <script type="text/javascript"> var grid = document.getElementById(LeftDocs.MainGrid.id); function dragStart(evt) { alert('startdrag'); } grid.addEventListener("dragstart", dragStart, false); But event not fiered Please help me. PS Full script version: <script type="text/javascript"> // set vars (RUN = DoInit, ajaxtarget = Target for ajaxRequests, dropbox = dropbox Element for events): var ajaxtarget = DocTbl.dropHtml; var ldropbox = document.getElementById(LeftDocs.MainGrid.id); var rdropbox = document.getElementById(RightDocs.MainGrid.id); var curtarget; function GetGrid(obj) { var grid = obj; var par = 0; while((par==0)&&(grid!=null)){ if(grid == ldropbox){ par = 1; }else if (grid == rdropbox){ par = 2; }else{ grid = grid.parentNode; } } return grid; } function dragStart(evt) { alert('startdrag'); var curgrid = GetGrid(evt.target); //new Object(); var par = GetGrid(ev.target, curgrid); if (curgrid!=null) { ev.dataTransfer.effectAllowed='copy'; ev.dataTransfer.setData("gridid", curgrid.getAttribute('id')); ev.dataTransfer.setDragImage(evt.target,100,100); return true; } } function dragEnter(evt) { evt.stopPropagation(); evt.preventDefault(); } function dragExit(evt) { evt.stopPropagation(); evt.preventDefault(); } function dragOver(evt) { evt.stopPropagation(); evt.preventDefault(); } function drop(evt) { evt.stopPropagation(); evt.preventDefault(); curtarget = GetGrid(evt.target); if (curtarget == ldropbox){ par = 1; } else if (curtarget == rdropbox){ par = 2; } else { par = 0; } //alert(ev.target.id); // get Files and Count: var files = evt.dataTransfer.files; var count = files.length; // Only call the handler if 1 or more files was dropped: if (count > 0) { curtarget = par; handleFiles(files); } else { var gridid = ev.dataTransfer.getData("gridid"); if (gridid!=0) { var srcgrid = document.getElementById(gridid); // var grid = GetGrid(obj); if((srcgrid!=null)&&(srcgrid!=curtarget)) { ajaxRequest(ajaxtarget, "drop data", ["par="+par]); } } } } function initEventHandlers() { // set EventHandlers for dropbox for drag and drop: ldropbox.addEventListener("dragenter", dragEnter, false); ldropbox.addEventListener("dragexit", dragExit, false); ldropbox.addEventListener("dragover", dragOver, false); ldropbox.addEventListener("drop", drop, false); ldropbox.addEventListener("dragstart", dragStart, false); rdropbox.addEventListener("dragenter", dragEnter, false); rdropbox.addEventListener("dragexit", dragExit, false); rdropbox.addEventListener("dragover", dragOver, false); rdropbox.addEventListener("drop", drop, false); rdropbox.addEventListener("dragstart", dragStart, false); } function handleFiles(files) { // for each file to upload: for (var i = 0, f; f = files; i++) { // init FileReader for this file: var reader = new FileReader(); // notify the upload start: ajaxRequest(ajaxtarget, "uploadingfile", ["filename="+f.name, "filesize="+f.size, "filetype="+f.type]); // set event handler "reader.onprogress": reader.onprogress = (function(f) { return function(e) { // notify file upload progress (e is a Progressevent): var percentLoaded = Math.round((e.loaded / e.total) * 100); ajaxRequest(ajaxtarget, "uploadingprogress", ["filename="+f.name, "filesize="+f.size, "filetype="+f.type, "loaded="+e.loaded, "total="+e.total, "percent="+percentLoaded]); } })(f); // set event handler "reader.onload": reader.onload = (function(f) { return function(e) { // send to server e.target.result , filename, filesize and filetype: ajaxRequest(ajaxtarget, "uploadedfile", ["filename="+f.name, "filesize="+f.size, "filetype="+f.type, "content="+e.target.result, "id="+curtarget]); }; })(f); //start read operation for this file: reader.readAsDataURL(f); } } alert('initEventHandlers'); initEventHandlers(); </script>
  18. I have two tunidbgrid and i want to dagdrop from one to another and from one to desktop. From computer to grid - hear exist sample based on html5 and it very useful - i did dragdrop from computer to tunidbgrid. How do from grid to computer and from grid to grid? If use html5 then Where i can write draggable=true for tunidbgrid? Possible dragdrop example add to unigui examples? For example drop file from unigui to computer and dragdrop from unigui to unigui child pucture puzzle .
  19. Dear Farshad Mohajeri During spring we dispute about interface and you told web interface is not gui interface. Today is autumn but i think web interfase more and mor in future be same as gui. Popup Menu is very very rules thank a lot of to you. I am write short procedure in keydown event with loop from all actions: procedure TAnyHtmlFrame.MainGridKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); var i: Integer; act: TContainedAction; ss: TShortCut; begin ss := ShortCut(Key, Shift); for i:=0 to (MainActionList.ActionCount-1) do begin act := MainActionList.Actions; if TAction(act).ShortCut=ss then begin act.OnExecute(act); Key := 0; Shift := []; Exit; end; end; end; And now actions shortcut works. Need only butifull write shortcut in menu. Now I write html code in caption property .Caption := 'Insert <b>Ins</b> I think it will be in UNIGUI code - automatic insert ShortCut from Action to Caption of menu item and key down event But before it afcase need do POPUPMENU property in UNIGUI controls But you deside to do smth. in unigui. Thanks thanks thanks for you anmazing control set unigui
  20. PopupMenu items not show shortcuts from attachad actions
  21. Please ask me how do anything after main form show. I want to play music such in example "HTML5 Audio" and write on UniFormShow UniSession.SendResponse('audio2.load(); audio2.play();'); it raize error I am attempt write in Client Evet afterrender audio2.load(); audio2.play(); not work on Ajax procedure TMainForm.UniFormAjaxEvent(Sender: TComponent; EventName: string; Params: TStrings); begin if EventName='afterrender' then begin UniSession.SendResponse('audio2.load(); audio2.play();'); end; end; not work Use TUniTimer procedure TMainForm.UniFormAjaxEvent(Sender: TComponent; EventName: string; Params: TStrings); begin if EventName='afterrender' then begin UniTimer1.Enabled := True; end; end; and procedure TMainForm.UniTimer1EventHandler(Sender: TComponent; EventName: string; Params: TStrings); begin UniSession.SendResponse('var ael=document.getElementById("audio2");ael.load();ael.play()'); end; Timer event not fiered Is exist event fiered after form already show rendered ad?
  22. TUniDBRadioGroup not found in palette
  23. Thanks for response dear Farshad.
  24. I am use popup menu for grid on frame on panel on form How calculate position for popup method call? What class have properties Parent, Left,Top? Why with Unypopup menu opens system browser popup menu? For example: grid1 on frame1 on panel1 on panel2 on form1 procedure TFrame1.Grid1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); var F: TUniForm; X0,Y0: Integer; begin MainMenu.Popup(X+Left+Parent.left+Parent.Parent.Left+Parent.Parent.Parent.Left, etc ); end; end; Recursive procedure? function TAnyHtmlFrame.FindParentForm(var X:Integer; var Y: Integer): TUniForm; var Ct: TObject; begin //x := 0; y := 0; Result := nil; Ct := Self; while (C<>nil) do begin if Ct is TUniCOntrol then begin Inc(x, TUniCOntrol(Ct).Left); Inc(y, TUniCOntrol(Ct).Top); C := TUniControl(Ct).Parent; end else if Ct is TUniFrame then begin Inc(x, TUniFrame(Ct).Left); Inc(y, TUniFrame(Ct).Top); C := TUniFrame(Ct).Parent; end else if Ct is TUniForm then begin Inc(x, TUniForm(Ct).Left); Inc(y, TUniForm(Ct).Top); Ct := TUniForm(Ct).Parent; end end; end; Is it possible do normal property PopupMenu for Unigui Controls and do whis internally? Why i must for all controls write OnMouse Down and call .Popup and calculate position? Why with TUniPopup menu opens system browser popup by right mouse down? TUniXPopupMenu work properly before TUniPopupMenu This popup menu is very very useful for interface. But in current situation too difficult to use it Thanks for reply Nik Gurov (altagur)
×
×
  • Create New...