Samstag, März 17, 2012

voll dynamischer jquery dialog

Demo HTML Seite:
<html>
    <head>
        <title>dynamic buttons for jquery.dialog</title>
        <script type="text/javascript" src="js/jquery.js"></script>
        <script type="text/javascript" src="js/jquery-ui.js"></script>
        <script type="text/javascript" src="js/dialog-func.js"></script>
    </head>
    <body>
        <p><a href="#" id="update-license" value="1" class="dialog">Open Dialog</a></p>
        <div id="result"></div>
    </body>
</html>
This is the corresponding javascript file dialog-func.js
$(function(){
    var $dialog = $('<div id="dia"></div>')
    .dialog({
        autoOpen: false,
    width: 100,
});
$('.dialog').click(function(){
    $func = $(this).attr('id');
    $id = $(this).attr('value');
    $.get('ajax.function.php', {func:$func,id:$id}, 
        function(data){
            var buttonDefs = {}; 
            buttonDefs[data.okbutton] = function(){eval(data.okfunc);};
            buttonDefs["Cancel"] = function() { $(this).dialog("close"); };
            $('#dia').dialog({title: data.title});
            $('#dia').html(data.html);
            $('#dia').dialog( "option", "buttons", buttonDefs);
        },  
        "json"
        );  
    $dialog.dialog('open');
    return false;
});
});
While Cancel is hard coded, "OK" is fully dynamical. Here comes the dynamic content via ajax.function.php
<?php
$titleString = 'Information';
$bodyString="Func: " . $_REQUEST['func'] . '
Id: ' . $_REQUEST['id']; $okButtonName = 'Ok-Button-Text'; $okButtonFunc = '$("#result").html("Show this string.");$(this).dialog("close");'; echo json_encode(array( 'title'=>$titleString, 'html'=>$bodyString, 'okbutton'=>$okButtonName, 'okfunc'=>$okButtonFunc ));

Freitag, März 16, 2012

Testcase Aufbau für Vergessliche

public void testCase()
{
    Given;

    When;

    Then;
}

Dienstag, Februar 28, 2012

vim und die Statuszeile

Zunaechst muss sie eingeblendet werden:
set laststatus=2
Danach kann man zB mit dieser hier starten:
set statusline=%t[%{strlen(&fenc)?&fenc:'none'},%{&ff}]%h%m%r%y%=%c,%l/%L\ %P
weiter geht's dann hier.

Dienstag, Februar 14, 2012

mc und entfernte Dateisysteme

Das man mittels
cd ftp://username:password@host.net/path
in mc eine FTP Verbindung aufbauen kann, ist ja schon ein alter Hut. Neu für mich war, das das auch mit scp geht:
cd sh://host/path
Das ganze vermischt mit .ssh/config ergibt einen sehr komfortablen SCP Browser.

Donnerstag, Februar 09, 2012

Linke Alt Taste als Metakey in XTerm definieren

Die Einstellungen für XTerm:
cat >> ~/XTerm<<"EOF"
XTerm*eightBitInput:   false
XTerm*metaSendsEscape: true
EOF
Und für xmodmap:
cat >> ~/.xmodmap<<"EOF"
keysym Alt_L = Meta_L Alt_L
EOF

Html Popups mit CSS

Der Originalbeitrag kommt von psacake.com.

Es wird ein Link ausgenutzt, um die Funktionalitaet bereit zu stellen:
This is the LinkThis is the Popup
Und nun noch der CSS Code:
a.info{
    position:relative; /*this is the key*/
    z-index:24; background-color:#ccc;
    color:#000;
    text-decoration:none}

a.info:hover{z-index:25; background-color:#ff0}

a.info span{display: none}

a.info:hover span{ /*the span will display just on :hover state*/
    display:block;
    position:absolute;
    top:2em; left:2em; width:15em;
    border:1px solid #0cf;
    background-color:#cff; color:#000;
    text-align: center}
ohne-css.gehts-gar.net hat das noch etwas weiter getrieben und eine Grafik integriert:
a.info:hover span
{
display:block;
position:absolute;
top:-60px;
left:300px;
width:234px;
height: 60px;
background: url(grafik.jpg);
}

Montag, Februar 06, 2012

ersetzen eines Strings in allen Dateien

find . -name '*.html' | xargs perl -pi -e 's/oldtext/newtext/g'
oder aber mit
sed -i 's/oldtext/newtext/g' *.html