Archive for the “javascript” Category

sablona pro jquery – puvodne odsud http://snipplr.com/view.php?codeview&id=52488

( function( $ ) {

// Global variables
var i, j;

// Default settings

var settings = {
"property" : 'value'
};

// Methods

var methods = {

init: function(options) {

// Capture $(this) global as a local variable
var $this = $(this);

// Extend settings with provided options
if( options ) {
$.extend(settings, options);
}

// Example method call
$this.pluginName('methodTwo');

$this.pluginName('methodThree');

},

methodTwo: function() {

},

methodThree: function() {

}

};

// Plugin namespace initialization

$.fn.pluginName = function(methd) {

if( methods[method] ) {
return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 ));
} else if (typeof method === 'object' || !method ) {
return methods.init.apply( this, arguments );
} else {
$.error( 'Method ' + method + ' does not exist on jQuery.pluginName' );
}

}

// Standalone functions

function doThis(property) {

return 1;

}

} (jQuery) );

Sdílejte:
  • Facebook
  • Add to favorites
  • Twitter
  • del.icio.us
  • Digg
  • LinkedIn
  • Google Bookmarks
  • email
  • Print

Comments No Comments »

pokud zkusite ie9 explorer na strankach s cufonem, asi rychle zjistite ze nefunguje.

pokud se prepne do compatibility modu, tak ano ale jinak ne.. nebo nenasel jsem zpusob jak to zapnout.

jedna z moznosti jak cufon zprovoznit je aktualizovat coufon.
https://github.com/sorccu/cufon/raw/master/js/cufon.js
(preferuji tuto moznost, zkousel jsem a funguje vse ok)

dalsi moznost je

<!--[if gte IE 9]>
<script type="text/javascript"> Cufon.set('engine', 'canvas'); </script>
<![endif]-->

nebo pridat

<meta content="IE=8" http-equiv="X-UA-Compatible" />

Sdílejte:
  • Facebook
  • Add to favorites
  • Twitter
  • del.icio.us
  • Digg
  • LinkedIn
  • Google Bookmarks
  • email
  • Print

Comments No Comments »

Jiz drive jsem zkousel javascriptovy validator http://www.pudil.net/alf/2008/06/19/really-easy-field-validation-opravdu-lehka-validace/.

Nyni jsem nasel takovy hezci . vypada dost dobre. http://zendold.lojcomm.com.br/fvalidator/

Sdílejte:
  • Facebook
  • Add to favorites
  • Twitter
  • del.icio.us
  • Digg
  • LinkedIn
  • Google Bookmarks
  • email
  • Print

Comments No Comments »

IEtester je vyborna aplikace která dokáže mít na jedněch windowsech několik internet explorerů.

V současné době ietester (v0.2.3) zvláda internet explorer 5.5, 6, 7, 8 beta 2.

(oficiálně píšou IETester is a free WebBrowser that allows you to have the rendering and javascript engines of IE8 beta 2, IE7 IE 6 and IE5.5 on Vista and XP, as well as the installed IE in the same process.)

Stáhnout se dá na http://www.my-debugbar.com/wiki/IETester/HomePage

pár věcí neumi ješte:

  • java aplety
  • flash v IE6 nefunguje
  • a par drobností jako je resize okna není v pořádku mezi verzemi apod… ale více na oficialních stránkách IE testeru
Sdílejte:
  • Facebook
  • Add to favorites
  • Twitter
  • del.icio.us
  • Digg
  • LinkedIn
  • Google Bookmarks
  • email
  • Print

Comments No Comments »

Pár dní dozadu jsme řešili problém kde nám javascript v internet exploreru byl neskutecne pomaly. V tabulce o xy zaznamech jsme aktualizovali nekolik polozek pomoci ajaxu. Ve firefoxu v pohode ale v Ie to delalo dost problemy v radek nekolik stovek milisekund..

Na adrese http://bytes.com/forum/thread624774.html je post Search DOM elements with XPath (getElementById too slow) v blogu kde je řešení problému s pomalým javascriptem. Hold Internet explorer není schopen zpracovat pořádně javascript a je velice pomalý.

Nejdůležitější je v komentářích, doporučuji pečlivě přečíst.
Skoro na konci blogu je tento kód který je nadevše, kde je vidět že použitím childNodes je rychlejší nez getElementById

var rows = 200;
var cols = 200;

// init table
var s = [];
for (var r=0; r < rows; ++r) {
s.push(‘
‘);
for (var c= 0; c < cols; ++c) {
s.push(‘ ‘ + ‘c_’ + r + ‘_’ + c);
}
}
document.write( s.join(”) + ‘<\/table>’)

var table = document.getElementById(‘table’);
var clicked = 0;
table.onclick = function() {
var start_r = 10; var end_r = 40;
var start_c = 10; var end_c = 40;
var t1 = new Date();
var method = ”;
++clicked;
if ((clicked%2) == 1) {
for (var r = start_r; r < end_r; ++r){
for (var c = start_c; c < end_c; ++c){
document.getElementById(‘c_’ + r + ‘_’ + c).innerHTML = “Slow!”;
}
}
method = “Using getDocumentById”;
}
else{
var elems = table.getElementsByTagName(‘TBODY’);
var tbody = elems[0];
for (var r = start_r; r < end_r; ++r) {
var row = tbody.childNodes[r];
for (var c = start_c; c < end_c; ++c) {
row.childNodes[start_c].innerHTML = “Fast!”;
}
}
method = “Using childNodes”;
}
var t2 = new Date();
alert((t2.getTime() – t1.getTime())/1000 + “s”);
}

v komentáři je napsáno:

A demo is attached. using getElementById on IE takes 23 seconds,
compared to 0.3 seconds using childNodes. in FF the difference is
closer : 3s vs 0.3 seconds.

Sdílejte:
  • Facebook
  • Add to favorites
  • Twitter
  • del.icio.us
  • Digg
  • LinkedIn
  • Google Bookmarks
  • email
  • Print
Tags:

Comments No Comments »

pokud je potreba ucinne validovat formular je Really easy field validation to prave pro pouziti

staci kliknout na odkaz tetlaw.id.au/view/javascript/really-easy-field-validation a dostane te se na stranku i s demem jak vse krasne funguje, je to opravdu jednoduche demo zde.

velice a jednoduse popsane a vyborne aplikovatelne. je to zalozene na prototype.js

Sdílejte:
  • Facebook
  • Add to favorites
  • Twitter
  • del.icio.us
  • Digg
  • LinkedIn
  • Google Bookmarks
  • email
  • Print
Tags: ,

Comments No Comments »

how to show listquerydialog (CAknListQueryDialog) and set item to listbox

jak zobrazit listquerydialog a dat do nej nejake prvky


CDesCArray *itemTextArray = new (ELeave) CDesCArrayFlat(10);

for( TInt i = 0; i < 12; i++ )
{
TBuf<256> item;

item.Format(_L("%d"), i );
itemTextArray->AppendL(item);
}

XYZContainerView::RunListQuery1L(NULL, itemTextArray, NULL);
Sdílejte:
  • Facebook
  • Add to favorites
  • Twitter
  • del.icio.us
  • Digg
  • LinkedIn
  • Google Bookmarks
  • email
  • Print
Tags:

Comments No Comments »

from: http://pixy.cz/blogg/clanky/js-rozmery-okna.html

function winH() {
if (window.innerHeight)
/* NN4 a kompatibilní prohlížeče */
return window.innerHeight;
else if
(document.documentElement &&
document.documentElement.clientHeight)
/* MSIE6 v std. režimu - Opera a Mozilla
již uspěly s window.innerHeight */
return document.documentElement.clientHeight;
else if
(document.body && document.body.clientHeight)
/* starší MSIE + MSIE6 v quirk režimu */
return document.body.clientHeight;
else
return null;
}

Sdílejte:
  • Facebook
  • Add to favorites
  • Twitter
  • del.icio.us
  • Digg
  • LinkedIn
  • Google Bookmarks
  • email
  • Print
Tags:

Comments No Comments »

vkladani textu na urcitou pozici v textareii ..

<script>
<!--
function simple_tag(tag_name) {
     try {
         textarea = document.getElementById('textarea');
         var pretext = textarea.value.substring(0, textarea.selectionStart);
         var posttext = textarea.value.substring(textarea.selectionEnd,
textarea.value.length);
         var selection =
textarea.value.substring(textarea.selectionStart, textarea.selectionEnd);
         textarea.value = pretext + '<' + tag_name + '>' + selection + '</' + tag_name + '>' + posttext;
         textarea.focus();
     }
     catch(exception) {
         alert(exception.message);
     }
}
-->
</script>
<button onclick="simple_tag('b');return false;">aaa</button> <textarea id="textarea" name="textarea"></textarea>
Sdílejte:
  • Facebook
  • Add to favorites
  • Twitter
  • del.icio.us
  • Digg
  • LinkedIn
  • Google Bookmarks
  • email
  • Print
Tags:

Comments No Comments »

regularni vyraz pro kontrolu v javascriptu pro email
navazuju na on submit

function kontrola_udaju() {
  var re = /^(([^<>()[\],;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|
	(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.
	[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;

  if (!kontrola_povinne_polozky('email', 'Prosím vyplňte email')) {
    return false;
  }

  if (!re.test(document.getElementById('email').value)){
    //alert (document.getElementById('email').value)
    alert('Špatně vyplněný email')
    return false;
  }
  return true;
}
</script>
Sdílejte:
  • Facebook
  • Add to favorites
  • Twitter
  • del.icio.us
  • Digg
  • LinkedIn
  • Google Bookmarks
  • email
  • Print
Tags:

Comments No Comments »

dynamicke zobrazeni napriklad pocitani procent v zavilosti na progresu prace :smile:

proste to zobrazuje procenta

<span id="procs" name="procs">

</span>

<?
echo  "<script type=\"text/javascript\">".
      "function show_proc(val0, val1, val2) { ".
      "document.getElementById('procs').innerHTML = val0;".
       //"document.getElementById('op').innerHTML = val1;".
       //"document.getElementById('celkem').innerHTML = val2;".
     "}".
   "</script>\n";

for ($i=0; $i<100; $i++){
   sleep(1); //for debug purposes
   echo "<script type=\"text/javascript\">".
     "show_proc('".$i."', '".count($op)."', '".$i."')".
        "</script>\n";
   flush();
}

?>
Sdílejte:
  • Facebook
  • Add to favorites
  • Twitter
  • del.icio.us
  • Digg
  • LinkedIn
  • Google Bookmarks
  • email
  • Print
Tags:

Comments No Comments »

jak udelat kulate rohy u obrazku v javascriptu

http://www.netzgesta.de/corner/

Sdílejte:
  • Facebook
  • Add to favorites
  • Twitter
  • del.icio.us
  • Digg
  • LinkedIn
  • Google Bookmarks
  • email
  • Print
Tags:

Comments No Comments »

docela uzitecny pro sklerotiky

http://developer.mozilla.org/en/docs/DOM:element

Sdílejte:
  • Facebook
  • Add to favorites
  • Twitter
  • del.icio.us
  • Digg
  • LinkedIn
  • Google Bookmarks
  • email
  • Print
Tags:

Comments No Comments »