N
Nonlim
Имеется простенький поиск на lotusscript, который берет из бд строки с именами пользователей и ищет конкретного (простым вводом символов в строку поиска и нажатием кнопки).
Как можно реализовать этот поиск с использованием Javascript (необходимо для WEB-интерфейса)?
<div class="sp-wrap"><div class="sp-head-wrap"><div class="sp-head folded clickable">Код</div></div><div class="sp-body"><div class="sp-content">
P.S.-знаю, я - неумный. Но всё же?
Как можно реализовать этот поиск с использованием Javascript (необходимо для WEB-интерфейса)?
<div class="sp-wrap"><div class="sp-head-wrap"><div class="sp-head folded clickable">Код</div></div><div class="sp-body"><div class="sp-content">
Код:
Sub Click(Source As Button)
On Error Goto errh
Dim sw As Switchboard
Dim w As New notesuiworkspace
Dim col As notesdocumentcollection
Dim uidoc As notesuidocument
Dim doc As notesdocument
Dim note As notesdocument
Dim keys() As String
Dim result() As String
Dim resultID() As Integer
Dim sel As Variant
Dim i As Integer
Dim isPost As Boolean
Dim Person_Name As Variant
Dim Person_Notes As Variant
Dim Dialog_Post As Variant
Dim Dialog_Dep As Variant
Dim site As String
Set uidoc = w.CurrentDocument
Set doc = uidoc.Document
If doc.GetItemValue("Dialog_Search")(0) = "" Then Exit Sub
If doc.GetItemValue("Dialog_Search")(0) = searchKey And wasFound = True Then
w.RefreshParentNote
uidoc.Close
Exit Sub
End If
searchKey = doc.GetItemValue("Dialog_Search")(0)
site = doc.GetItemValue("Dialog_Site")(0)
If searchView Is Nothing Then
Set sw = New SwitchBoard
Set itstaff = sw.getdatabase("ITStaffManager")
If doc.GetItemValue("Dialog_Role")(0) <> "" Then
If doc.Dialog_NoUser(0) = "1" Then
Set searchView = itstaff.GetView("PLPeopleByRolesAll")
Else
Set searchView = itstaff.GetView("PLPeopleByRoles")
End If
Else
If site = "" Then
Set searchView = itstaff.GetView("AllUser")
Else
Set searchView = itstaff.GetView("PLPeopleBySite")
End If
End If
End If
If doc.GetItemValue("Dialog_Role")(0) <> "" Then
Redim keys(1)
keys(0) = doc.GetItemValue("Dialog_Role")(0)
keys(1) = Fulltrim(searchKey)
Else
Redim keys(0)
keys(0) = Fulltrim(searchKey)
End If
If site <> "" Then
keys(0) = site & "~#" & keys(0)
End If
Set col = searchView.GetAllDocumentsByKey(keys)
If col.Count = 0 Then
Print "Соответствий не найдено"
Exit Sub
End If
Redim result(col.Count - 1)
Redim resultID(col.Count - 1)
Set note = col.GetFirstDocument
Do Until note Is Nothing
resultID(i) = i
If note.GetItemValue("Form")(0) = "Post" Then isPost = True Else isPost = False
If isPost = False Then
result(i) = note.GetItemValue("Person_Name")(0)
If note.GetItemValue("Person_Post")(0) <> "" Then
result(i) = result(i) & " - " & note.GetItemValue("Person_Post")(0)
End If
Else
result(i) = note.GetItemValue("Post_Owner")(0)
If note.GetItemValue("Post_Name")(0) <> "" Then
result(i) = result(i) & " - " & note.GetItemValue("Post_Name")(0)
End If
result(i) = result(i) & " (совместитель)"
End If
i = i + 1
Set note = col.GetNextDocument(note)
Loop
If i = 1 Then
Set note = col.GetFirstDocument
Else
sort result, resultID
sel = w.Prompt(4,"Поиск","Выберите:",result(0),result)
If Isempty(sel) Then Exit Sub
i = Arraygetindex(result, sel)
Set note = col.GetNthDocument(resultID(i) + 1)
End If
If note Is Nothing Then Exit Sub
If Isnull(Arraygetindex(doc.Dialog_ID, note.UniversalID)) Then
Person_Name=Evaluate({@Trim(@Right(PROPERTIES;"[NAME]"))}, note)
Person_Notes=Evaluate({tmp:=@Trim(@Right(PROPERTIES;"[NTSN]"));@If(tmp="";"-";tmp)}, note)
Dialog_Post=Evaluate({tmp:=@Trim(@Right(PROPERTIES;"[POST]"));@If(tmp="";"-";tmp)+@If(Form="Post";" (совместитель)";"")}, note)
Dialog_Dep=Evaluate({ref:=@Trim(@Right(PROPERTIES;"[$REF]"));
@While(ref!="";dev:=@Implode(@Trim(@GetDocField(ref;"Abbreviation"):dev);"/");
ref:=@Trim(@Right(@GetDocField(ref;"PROPERTIES");"[$REF]")));dev}, note)
If doc.Dialog_Multi(0)="" Then
doc.Dialog_Names = Person_Name
doc.Dialog_Notes = Person_Notes
doc.Dialog_ID = note.UniversalID
doc.Dialog_Post = Dialog_Post
doc.Dialog_Dep = Dialog_Dep
doc.Dialog_Types = "0"
Else
doc.Dialog_Names = Fulltrim(Arrayappend(doc.Dialog_Names, Person_Name))
doc.Dialog_Notes = Fulltrim(Arrayappend(doc.Dialog_Notes, Person_Notes))
doc.Dialog_ID = Fulltrim(Arrayappend(doc.Dialog_ID, note.UniversalID))
doc.Dialog_Post = Fulltrim(Arrayappend(doc.Dialog_Post, Dialog_Post))
doc.Dialog_Dep = Fulltrim(Arrayappend(doc.Dialog_Dep, Dialog_Dep))
doc.Dialog_Types = Fulltrim(Arrayappend(doc.Dialog_Types, "0"))
End If
Call uidoc.Refresh
wasFound = True
End If
Exit Sub
errh:
Msgbox Error & " в строке " & Erl, 16, "Ошибка"
Exit Sub
End Sub
P.S.-знаю, я - неумный. Но всё же?