1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395
|
Set fso=CreateObject("Scripting.FileSystemObject")
Set WshShell=WScript.CreateObject("WScript.Shell")
wFolder=WshShell.SpecialFolders("AppData")& "\Psjournal"
function wDir(a)
wDir=wFolder&uf(a="","","\"&a)
end function
if not fso.FolderExists(wFolder)then
fso.CreateFolder wFolder
end if
dim buff,pz
function RStr()
RStr=Mid(buff,pz,7)
if len(RStr)=7 then
RStr=Mid(buff,pz+7,clng(RStr)-1000000)
pz=pz+7+len(RStr)
end if
end function
sub WStr(v)
buff=buff&cstr(1000000+len(v))&v
pz=len(buff)
end sub
dim cinf,cky,splid,dexit,bbc
class POST:dim title,loc,cdt,edt,ctxt,cselected:end class
sub nmsg(a,b,c,d,e)
dim n
set n=new POST
n.title=a
n.loc=b
n.cdt=c
n.edt=d
n.ctxt=e
n.cselected=false
cinf.add cstr(n.cdt),n
end sub
function tstr(dt)
tstr=year(dt)&"-"&month(dt)&"-"&day(dt)
end function
sub ldpost()
dim pth,v
cinf.RemoveAll
pth=wDir(tstr(cky))
if fso.fileExists(pth) then
Set v=fso.OpenTextFile(pth,1,,-1)
buff=v.readall
pz=1
v.close
while(RStr="POST"):
nmsg RStr,RStr,RStr,RStr,RStr
wend
end if
buff=""
end sub
sub svpost()
dim i,n,v
for each n in cinf.items
WStr "POST"
WStr n.title
WStr n.loc
WStr n.cdt
WStr n.edt
WStr n.ctxt
next
pz=1
Set v=fso.OpenTextFile(wDir(tstr(cky)),2,true,-1)
v.write(buff)
v.close
buff=""
end sub
Set cinf=CreateObject("Scripting.Dictionary")
cky=now
dim ie,Dc,Wn,cv,nv,inedi
function uf(t,v,f)
if t then:uf=v:else uf=f
end function
function link(t,o,c)
link="<a href='#' onclick=""return SQ('"&o&"|"&c&"')"">"&t&"</a>"
end function
function pst(tl,txt,dt,ud)
pst="<dl><dt><input type=checkbox onclick=""SQ('Sel|"&dt&"|'+checked);"_
&"DD"&ud&".style.backgroundColor=checked?'#ffff00':'';""/><b>"&tl&"</b></dt>"_
&"<dd id=DD"&ud&"><div id=btm></div>"&txt&"</dd>"&uf(dt<>-1,"<dd id=hd>"&link("Editer","Edit",dt)&" | <i>"&dt&"</i></dd>","")&"</dl>"
end function
function dlg(tl,txt,cid)
dlg="<div id=prv></div><div style='border:outset;width:100%;padding:10px;"_
&"background-color:#aaaaaa'>"_
&"<p><input class='edit' type=text id='@T"&cid&"' value="""&tl&"""/></p>"_
&adm("B","b",1)&adm("I","i",1)&adm("U","u",1)&" | "&adm("L","left",1)&adm("Center","center",1)&adm("R","right",1)_
&" | "&adm("Url","url",1)&adm("Color","color",1)&adm("Size","size",1)_
&" | "&adm("List","list",1)&adm("*","*",0)&adm("Ind","indent",1)_
&adm("Noparse","noparse",1)&adm("Region","region",1)&adm("Box","box",1) &adm("HL","hlight",1)_
&"<textarea class='edit' id='@B"&cid&"'rows=20 cols=40>"&txt&"</textarea>"_
&"<div id=hd align=center>["&link("Valider","Validate",cid)&" | "_
&link("Annuler","Cancel","")&" | "&link("Preview","Prev",cid)&" | "&link("Word","Spl",cid)&"]</div></div>"
inedi=true
end function
function GetId(tx)
set GetId=Dc.getElementById(tx)
end function
sub LDay
dim s,t,n,i
ldpost
i=0
for each n in cinf.items
t=pst(n.title,bbcode(n.ctxt),n.cdt,i)&t
i=i+1
next
if cinf.count=0 then:t="<center>Aucun élément</center>"
GetId("pR").innerHtml=t
GetId("YD").innerText=cky
end sub
sub wdoc
set Dc=ie.Document
set Wn=Dc.parentWindow
with Dc.createStyleSheet("stl")
.cssText=replace(replace("#pL,#pR{height:450px;overflow:auto;padding:5px}"_
&".ps{$1-$2:#B1CBE4}"_
&"#box{$1-$2:#eeeeee;margin:2px}"_
&"#hlght{$2:white;$1-$2:green;padding:1px;line-height:160%}"_
&"#tdno{cursor:pointer}"_
&"#Yr{font-size:14px;font-weight:bold;text-align:center}"_
&"#btm{margin-bottom:4px;$2:green}"_
&"table,dl,.edit{cursor:auto;font-size:11px;font-family:Verdana;width=100%;border:0px}"_
&"dt,#wlayer{$1-$2:#dac4bc}"_
&"dt,dd,#pL,.edit,#box{border:1px #B38675 solid;padding:2px}"_
&"dd{$1-$2:#ffe9e1;border-top:none;margin-left:20px}"_
&"blockquote,ul{margin:2px;margin-left:20px;}"_
&".edit{$2:#4343B9;$1-$2:#eeeeff;}"_
&"body{cursor:default;$1-$2:#95A5B5;overflow:hidden;margin:0px;}"_
&"a,#hd a{$2:white;text-decoration:none};"_
&"a:hover,#hd a:hover{text-decoration:underline}"_
&"dl a{$2:#FF00FF;};"_
&"#hd{padding:3px;$1-$2:#004080;$2:white}"_
&"#tdsel{$1-$2:#7700aa;$2:white}","$1","background"),"$2","color")
end with
Wn.execScript"function SQ(o){rtv.value=o;rtv.click();"_
&"rtv.value='';return false;};"_
&"function opcl(d,m)"_
&"{if(m.innerText=='+')m.innerText='-',d.style.display='inline';"_
&"else m.innerText='+',d.style.display='none';}","JScript"
set Dc.oncontextmenu=GetRef("pmenu")
set nv=Dc.createElement("div")
bdw
end sub
sub bdw
Dc.Body.InnerHTML="<input type='hidden' id='rtv'><div id=wlayer style='position:absolute;visibility:hidden;"_
&"left:0px;top:0px;width:100%;height:700px;z-index:1'></div>"_
&"<table cellspacing=0 cellpadding=3>"_
&"<tr id=hd><td id=Yr>"&link("«","YDW","-1")&"<tt id=YD>"&cky&"</tt>"&link("»","YUP","1")&"</td><td>"&wTopMenu&"</td></tr>"_
&"<tr><td width=100 valign=top><div id=pL>"&cal(year(cky))&"</div></td><td valign=top><div id=pR> </div></td><tr></table>"
set cv=GetId("rtv")
set cv.onclick=GetRef("cvclick")
LDay
end sub
function TxtToHtml(tx)
nv.innertext=tx
TxtToHtml=nv.innerhtml
nv.innerhtml=""
end function
function HtmlToTxt(tx)
nv.innerhtml=tx
HtmlToTxt=nv.innertext
nv.innerhtml=""
end function
function HasHist(d)
HasHist=isdate(d)and(fso.fileExists(wDir(tstr(d))))
end function
function wTopMenu
wTopMenu=link("Nouveau","Add","")&" | "&link("Supprimer","Delete","")
end function
function cala(dy,dm)
dim i,j,dt,dc,s,d,c,at
dt=DateSerial(dy,dm,1)
d=Weekday(dt,0)
dc=28
while(dm=month(DateSerial(dy,dm,dc+1))):dc=dc+1:wend
s="<div align=center style='background-color:#888888;color:#ffffff;'>"
s=s&MonthName(dm)
s=s&"<table cellSpacing=1><tr bgcolor='#eeeeee'>"
for i=1 to 7
s=s&"<td>"&WeekDayName(i,true,0)&"</td>"
next
s=s&"</tr>"
for i=0 to 5
s=s&"<tr>"
for j=1 to 7
c=(i*7+j-d)+1
dt=DateSerial(dy,dm,c)
jsc=" onclick=""if(this.id=='tdsel')return;try{tdsel.id='tdno';}catch(e){};"_
&"this.id='tdsel';SQ('Date|"&dt&"');"" "
if(c<1)or(c>dc)then
s=s&"<td></td>"
else
at=uf(DateDiff("d",Now,dt)=0,"bgcolor=red style='color:white'",_
uf(HasHist(dt),"class='ps'","bgcolor='#eeeeee'"))
at=at&uf(DateDiff("d",cky,dt)=0,"id=tdsel","id=tdno")
s=s&"<td "&at&jsc&"align='right'>"&c&"</td>"
end if
next
s=s&"</tr>"
next
cala=s&"</table></div>"
end function
function cal(dy)
dim i
for i=1 to 12
cal=cal&cala(dy,i)&"<br>"
next
end function
function adm(c,tg,cl)
adm="<a href=# onclick=""var rg=document.selection.createRange();if(rg.text.length==0)return false;"_
&"rg.text='["+tg+"]'+rg.text+'"+uf(cl<>0,"[/"+tg+"]","")+"';return false;"">"+c+"</a> "
end function
function pmenu()
on error resume next
pmenu=left(Wn.event.srcElement.id,1)="@"
If(not pmenu) and(Not(Dc.Selection Is Nothing))Then
pmenu=Dc.Selection.Type="Text"
End If
end function
Set jscnsl=CreateObject("MSScriptControl.ScriptControl")
jscnsl.Language="jscript"
jscnsl.Addcode "function ggg3(uu,ot,ct,fn){"_
&"var t='',s=uu+'',p1=pc=p2=0;"_
&"while(1){"_
&"p1=s.indexOf(ot,p2);if(p1==-1)break;"_
&"p2=s.indexOf(ct,p1);if(p2==-1)break;"_
&"t+=s.substring(pc,p1)+fn(s.substring(p1+ot.length,p2));"_
&"pc=p2+ct.length;"_
&"}"_
&"t+=s.substring(pc,uu.length);"_
&"return t;"_
&"}"_
&"var ChL=Array('','','','','','','','','','',"_
&"'','','','','[box]','[/box]','[hlight]','[/hlight]');"_
&"var RepL=Array('<b>','</b>','<i>','</i>','<u>','</u>','<div align=left>','</div>','<div align=right>',"_
&"'</div>','<div align=center>','</div>','<blockquote>','</blockquote>','<div id=box>','</div>','<span id=hlght>','</span>');"_
&"var esq={'<':'<','>':'>','""':'"','&':'&'};"_
&"function hsv(inp,op,cl,fn){return ggg3(inp+'',op,cl,function(c){"_
&"var ix,p1,p2;ix=c.indexOf(']');if(ix==-1)return c;p1=(c.charAt(0)=='=')? c.slice(1,ix):'';"_
&"p2=c.slice(++ix);return fn(p1+'',p2+'');});"_
&"}"_
&"function bbcode(st)"_
&"{var sq,eq=Array(),ui=0;sq=(st+'').replace(/(\<)|(\>)|(\&)|(\"")/g,function($1){return esq[$1];});"_
&"sq=ggg3(sq,'','',function(c){var ky='<<&>>'+(ui++);eq[ky]=c;return ky+' ';"_
&"});"_
&"sq=ggg3(sq,'','',function(c){"_
&"return '<ul><li>'+(c.split(/(\s*\[\*\])/g).join('</li>\r<li>'))+'</li></ul>';"_
&"});"_
&"for(var I=0;I<ChL.length;I+=2)"_
&"sq=ggg3(sq,ChL[I],ChL[I+1],function(c){return RepL[I]+c+RepL[I+1];});"_
&"sq=hsv(sq,'[size','[/size]',function(a,b){return b.fontsize(a);});"_
&"sq=hsv(sq,'[color','[/color]',function(a,b){return b.fontcolor(a);});"_
&"sq=hsv(sq,'[url','[/url]',function(a,b){return'<a href=""'+((a!='')?a:b)+'"" target=view>'+b+'</a>';});"_
&"sq=hsv(sq,'[region','[/region]',function(a,b){var yd=(Math.random()+'').slice(3);"_
&"return'<a id=btm href=# onclick=""opcl(L'+yd+',M'+yd+');return false;""> <font face=""Courier New""id=M'+yd+'>+"_
&"</font> '+a+'</a> <span style=""display:none""id=L'+yd+'>'+b+'</span>';});"_
&"sq=sq.replace(/(<<&>>\d+)/g,function($1){return eq[$1];});"_
&"return sq.split(/\n/).join('<br>').split(/\r\n/).join('<br>');"_
&"}"
class BBCodeC:dim data:end class
set bbc=new BBCodeC
jscnsl.AddObject "bbvalue",bbc
function bbcode(cd)
bbc.data=cd
bbcode=jscnsl.eval("bbcode(bbvalue.data)")
bbc.data=""
end function
function wspell(tx)
Dim W,D
Set D=WScript.CreateObject("Word.Document")
Set W=D.Application
W.visible=true
on error resume next
W.Assistant.on=false
W.Activate
D.Content.Text=replace(replace(tx,vbcrlf&vbcrlf,vbcr),vbcrlf,vbverticaltab)
Wn.Alert "Cliquer sur OK lorsque vous terminer l'édition du texte dans Word"
wspell=replace(replace(D.Content.Text,vbcr,vbcrlf&vbcrlf),vbverticaltab,vbcrlf)
GetId("prv").innerText=""
D.Close 0
set w=nothing
end function
sub cvclick
dim u,nx,nb,nn,tl,tx
u=split(cv.value,"|")
if instr("Validate Prev Spl",u(0))=0then
if inedi then:if not Wn.Confirm("Vous risquez de perdre le poste en cours d'édition")then:exit sub
inedi=false
end if
select case u(0)
case"YUP","YDW":cky=DateSerial(year(cky)+clng(u(1)),1,1):bdw
case"Date":cky=CDate(u(1)):LDay
case"Cancel":inedi=false:LDay
case"Add":GetId("pR").innerHtml=dlg("","","New")
case"Prev":GetId("Prv").innerHtml=pst("",bbcode(GetId("@B"&u(1)).value),-1,-1)
case"Sel":cinf(cstr(u(1))).cselected=cbool(u(2))
case"Spl":splid="@B"&u(1)
case"Edit"
set nb=cinf(cstr(u(1)))
GetId("pR").innerHtml=dlg(nb.title,nb.ctxt,u(1))
case"Validate"
set tl=GetId("@T"&u(1))
set tx=GetId("@B"&u(1))
if(tl.value="")or(tx.value="")then:Wn.Alert"Tous les champs sont obligatoires":exit sub
inedi=false
if u(1)="New" then
nmsg TxtToHtml(tl.value),"UNLOCK",Now," ",tx.value
svpost
if cinf.count=1 then:bdw:else:LDay
else
set nb=cinf(cstr(u(1)))
nb.title=TxtToHtml(tl.value)
nb.ctxt=tx.value
svpost
LDay
end if
case"Delete"
nn=0
for each nb in cinf.items
if nb.cselected then:nn=nn+1
next
if nn=0 then:exit sub
if Wn.Confirm("Supprimer les éléments sélectionnés")then
if nn=cinf.count then
fso.DeleteFile wDir(tstr(cky))
bdw
else
for each nb in cinf.items
if nb.cselected then:cinf.remove(nb.cdt)
next
svpost
LDay
end if
end if
end select
end sub
Set ie=WScript.CreateObject("InternetExplorer.Application","ie_")
With ie
.Width=700
.Height=550
.Visible=1
.Resizable=0
.ToolBar=0
.StatusBar=0
.MenuBar=0
.Navigate"about:blank"
Wscript.Sleep 250
End With
sub ie_onquit
dexit=true
end sub
sub ie_TitleChange(Tx)
if Tx="about:blank"then:wdoc
end sub
Do While not dexit
if splid<>""then
dim sv
set sv=GetId("wlayer").style
sv.visibility="visible"
GetId(splid).value=wspell(GetId(splid).value)
splid=""
sv.visibility="hidden"
end if
Wscript.Sleep 250
Loop |
Partager