8 gru 2012

Tworzenie wyrażenia dla RegExp z wykorzystaniem złączenia stringów

var name_srch_comma = name_srch.replace(RegExp(", *","g"), '|');
//name_srch_comma = name_srch_comma.replace(',',', ');
var re=new RegExp("("+name_srch+")","gi");
var re_c=new RegExp("("+name_srch_comma+")","gi");
var tmp_data=data.split("");
console.log("("+name_srch_comma+")"); // (Warszawa|Polna)
desc=tmp_item[0]+', '+tmp_item[3];
desc=desc.replace(re_c,"<strong>$1</strong>");

Tworzenie ze złączenia stringów wyrażenia dla RegExp

8 gru 2012

Wyrażenie reguralne wykorzystanie w funkcji replace

function open_popup(url, w, h, t, l) {
  let param = popup_param(w, h, t, l);
  let Win = window.open("",'popup_window',param);
  Win.focus();
  return Win;
};
  
function program_print() {
  let el = document.getElementById('program-list');
  if(el!=undefined) {
    let Win=open_popup();
    let html=el.innerHTML;
    html=html.replace('program_print','window.print','g');
    html=html.replace(/<input\b[^>]*?/ig, "");
    Win.document.write(html);
  }
};

Wyrażenie regularne wykorzystanie w funkcji replace. Kod html pobierany jest z doma strona i przekley do nowego okna.

8 gru 2012

Kolorowanie komórek w Excelu

' With Worksheets(1).Range("n1:q40")
' With ActiveSheet.Range("o1:r45")
' With ActiveSheet.UsedRange
With Selection
Set c = .Find(1, LookIn:=xlValues)
Dim firstAddress
If Not c Is Nothing Then
firstAddress = c.Address
Do
' c.Value = 8
' c.Interior.Color = 65432
c.Interior.ColorIndex = 27
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With

Kolorowanie komórek w Excelu. W pętli następuje sprawdzenie wartości komórki, jeżeli jest 1 kolor komórki ustawiany jest na żółty. Kolorwanie wykonywane jest na zaznaczonym myszką obszarze Excela.

8 gru 2012

Generowanie listy kwadransów w smartach

<select name="time">
!{section name=ih start=0 loop=24 step=1}!
!{section name=im start=0 loop=60 step=15}!
<option>!{$smarty.section.ih.index|string_format:"%02d"}!:!{$smarty.section.im.index|string_format:"%02d"}!</option>
!{/section}!
!{/section}!
</select>

Generowanie listy kwadransów w smartach