Hice una prueba del uso de Transmilenio, aunque la muestra es pequeña (32 viajes), el resultado es concluyente.
En la ruta Virrey a Granja Carrera 77 (La mayoría de la muestra) en estos 32 viajes gaste 1080 minutos de mi tiempo (en promedio 34 minutos), de este tiempo 798 minutos fueron ya en el bus (en promedio 25 minutos), y en espera fueron 4 horas con 42 minutos (en promedio 8 minutos).
En este tiempo pasé 252 buses con el letrero En tránsito (en promedio 8 diarios), y la cantidad de buses que pasaron que no pude subirme fueron 84 (en promedio 4 buses).
Basado en la lógica de Enrique Peñalosa, que un Transmilenio hace lo mismo que un Metro, hice una prueba en Bicicleta, en cada viaje me gastaba 45 minutos en promedio, por lo que basado en esa lógica mi bicicleta hace lo mismo que un Transmilenio y es más barata.
lunes, enero 27, 2020
miércoles, septiembre 05, 2012
sábado, junio 05, 2010
Extendiendo un control TreePanel
/** * Allow: Dynamic enabling/disabling of drag and/or drop. * Author: murrah * Post: 21893 #4 */ Ext.ux.TreeDocs = function(config) { Ext.ux.TreeDocs.superclass.constructor.call(this, config); }; /** * Allow: Extend more the Tree. / Add Mask to TreePanel * Author: HACKPRO TM / OutpostMM * Post: - / 43645 #6 */ Ext.extend(Ext.ux.TreeDocs, Ext.tree.TreePanel, { maxNumber: 0, allowDrag: function(allow) { if (allow) { if ( (this.enableDD) || (this.enableDrag) ) { this.dragZone = new Ext.tree.TreeDragZone(this, this.dragConfig || { ddGroup: this.ddGroup || "TreeDD", scroll: this.ddScroll }); } } else if (this.dragZone != undefined) { this.dragZone.unreg(); // Unregister the dragZone so Dragging is disabled. } }, allowDrop: function(allow) { if (allow) { if ( (this.enableDD) || (this.enableDrop) ) { this.dropZone = new Ext.tree.TreeDropZone(this, this.dropConfig || { ddGroup: this.ddGroup || "TreeDD", appendOnly: this.ddAppendOnly === true }); } } else if (this.dropZone != undefined) { this.dropZone.unreg(); // Unregister the dropZone so Dropping is disabled. } }, /** * Allow: Recursive Count Nodes write by HACKPRO TM based in the zesh code. * Author: zesh * Post: 1930 #3 */ recursiveCount: function(node) { if (node.hasChildNodes()) { var totalNodes = 0; // Recurse on all child nodes of the current node. for (var i = 0; i < node.childNodes.length; i++) { totalNodes += node.childNodes.length; this.recursiveCount(node.childNodes[i]); } } return totalNodes; }, recursiveMaxID: function(node) { if (node.hasChildNodes()) { // Recurse on all child nodes of the current node. for (var i = 0; i < node.childNodes.length; i++) { var nID = node.childNodes[i].id; if (nID) { nID = parseInt(nID.replace(/\D/g, ''), 10); } else { nID = -1; } if (nID > this.maxNumber) { this.maxNumber = nID; } this.recursiveMaxID(node.childNodes[i]); } } return this.maxNumber; }, getMaxID: function() { var rootTree = this.getRootNode(); this.recursiveMaxID(rootTree); return this.recursiveMaxID(rootTree); }, getCountNodes: function() { var rootTree = this.getRootNode(); var len = rootTree.childNodes.length + this.recursiveCount(rootTree) + 1; return len; }, removeChildren: function(node) { while (node.firstChild) { var c = node.firstChild; node.removeChild(c); c.destroy(); } }, putRootNode: function(node, jsonData) { this.removeChildren(node); this.getRootNode().appendChild(jsonData); }, /** * @cfg {Boolean} mask Indicates if the tree panel should have a loadmask applied when loading nodes */ mask: false, maskObject: null, /** * @cfg {Object} maskConfig A configuration object that can be applied to the loadmask. */ maskConfig: { msg: "Cargando..." }, // init initComponent:function() { // call parent Ext.ux.TreeDocs.superclass.initComponent.apply(this, arguments); if (this.mask) { this.on('render', this.createMask, this); } }, // end initComponent /** * @private */ createMask: function() { if (this.maskObject == null) { var mask = new Ext.LoadMask(this.getEl(), this.maskConfig); } else { var mask = new Ext.LoadMask(this.maskObject, this.maskConfig); } this.getLoader().on('beforeload', mask.show, mask); this.getLoader().on('load', mask.hide, mask); } }); Ext.reg("treedocs", Ext.ux.TreeDocs);
viernes, junio 04, 2010
JavaScript image combobox v2.1 by Marghoob Suleman
Encontré hace algunos días, este gran Jquery Plugin, hice un pequeño skin para el mismo y adicione un pequeño código para arreglar un problema al cargar con elementos no visibles inicialmente.
El código original lo pueden descargar de http://www.marghoobsuleman.com/jquery-image-dropdown
Como se vería el skin que hice
Pueden descargar el skin desde aquí
No olviden visitar la web del autor.
El código original lo pueden descargar de http://www.marghoobsuleman.com/jquery-image-dropdown
Como se vería el skin que hice
Pueden descargar el skin desde aquí
No olviden visitar la web del autor.
Etiquetas:
ComboBox,
ImageComboBox,
Jquery
domingo, mayo 23, 2010
Generic Code to use any SQLite DB with C#
How use SQLite Database with C# and System.Data.SQLite using SharpDevelop
Original by Zhanshan Dong
Original by Zhanshan Dong
/* * Original by Zhanshan Dong * A little modified by HACKPRO TM. * Created: 22/05/2010 * Hour: 10:20 p.m. * */ using System; using System.Windows.Forms; using System.Data; using System.Data.SQLite; using System.IO; public class ConnSQLite { private SQLiteConnection Conn; private SQLiteCommand Cmd; private bool isConnect = false; public ConnSQLite(string dbName, string connection) { bool hasDBFile = File.Exists(dbName); if (hasDBFile == true) { ConnectDB(connection); Cmd = CreateCMD(); } else { isConnect = false; } } ~ConnSQLite() { if (isConnect == true) { Cmd.Dispose(); Conn.Close(); } } private void ConnectDB(string connection) { Conn = new SQLiteConnection(connection); Conn.Open(); if (Conn.State.ToString() == "Open") { isConnect = true; } else { isConnect = false; } } private SQLiteCommand CreateCMD() { SQLiteCommand cmd = new SQLiteCommand(); return Conn.CreateCommand(); } private void disposeCMD(SQLiteCommand cmd) { cmd.Dispose(); } public bool IsConnect() { return isConnect; } public void ExecuteNonQuerySQL(string SQL) { Cmd.CommandText = SQL; Cmd.ExecuteNonQuery(); } public SQLiteDataReader ExecuteQuerySQL(string SQL, SQLiteCommand cmd) { cmd.CommandText = SQL; return cmd.ExecuteReader(); } public DataTable RecordSet(string SQL) { SQLiteDataAdapter da = new SQLiteDataAdapter(SQL, Conn); DataSet ds = new DataSet(); DataTable dt = new DataTable(); ds.Reset(); da.Fill(ds); dt = ds.Tables[0]; return dt; } public double MAXId(string SQL) { SQLiteCommand cmd = CreateCMD(); SQLiteDataReader dbReader = ExecuteQuerySQL(SQL, cmd); double rowVal = 0; if (dbReader.HasRows == true) { while (dbReader.Read()) { rowVal = dbReader.GetDouble(0); } } else { rowVal = 0; } dbReader.Close(); cmd.Dispose(); return rowVal; } public int getRowCount(string SQL) { SQLiteCommand cmd = CreateCMD(); SQLiteDataReader dbReader = ExecuteQuerySQL(SQL, cmd); int rowCount = 0; if (dbReader.HasRows) { dbReader.Read(); rowCount = dbReader.GetInt32(0); } dbReader.Close(); cmd.Dispose(); return rowCount; } }
Etiquetas:
C#,
Database,
SQLite,
System.Data.SQLite
Prevent Loop No-Leaf Nodes in ExtJS TreeView
Using this overrider function you can stop the loading waiting loop in the TreeView.
/** * Allow: Stop loading No-Leaf Node. * Author: HACKPRO TM * Post: - */ Ext.override(Ext.tree.TreeLoader, { load: function(A, B) { if (this.clearOnLoad) { while (A.firstChild) { A.removeChild(A.firstChild); } } if (this.doPreload(A)) { if (typeof B == "function") { B(); } } else if (this.dataUrl || this.url) { this.requestData(A, B); } else if (typeof B == "function") { B(); } } }); Ext.override(Ext.tree.TreeNodeUI, { updateExpandIcon : function() { if (this.rendered) { var n = this.node, c1, c2; var cls = n.isLast() ? "x-tree-elbow-end" : "x-tree-elbow"; var hasChild = n.hasChildNodes(); var cls1 = ''; if (hasChild || n.attributes.expandable || n.attributes.isFolder) { if (n.expanded) { cls1 = "-minus"; c1 = "x-tree-node-collapsed"; c2 = "x-tree-node-expanded"; } else { cls1 = "-plus"; c1 = "x-tree-node-expanded"; c2 = "x-tree-node-collapsed"; } if (this.wasLeaf) { this.removeClass("x-tree-node-leaf"); this.wasLeaf = false; } if (n.attributes.isFolder && n.attributes.leaf) { cls1 = ''; } cls += cls1; if (this.c1 != c1 || this.c2 != c2) { Ext.fly(this.elNode).replaceClass(c1, c2); this.c1 = c1; this.c2 = c2; } } else { if (!this.wasLeaf) { Ext.fly(this.elNode).replaceClass("x-tree-node-expanded", "x-tree-node-leaf"); delete this.c1; delete this.c2; this.wasLeaf = true; } } var ecc = "x-tree-ec-icon " + cls; if (this.ecc != ecc) { this.ecNode.className = ecc; this.ecc = ecc; } } } });
Etiquetas:
ExtJS,
No-Leaf Nodes,
TreePanel,
TreeView
sábado, mayo 09, 2009
Encrypt/Decrypt String with Javascript
Encrypt/Decrypt string using Javascript, based in the PHP class and VB Code.
Copyrigth HACKPRO TM (C) 2008-2009
How to use:
$Security.Encrypt_Text(string, [utf8]);
$Security.Decrypt_Text(string, [utf8]);
/** ********************************************************* * Reservados todos los derechos HACKPRO TM © 2005 * *-------------------------------------------------------* * Siéntase libre para usar esta clase en sus páginas, * * con tal de que TODOS los créditos permanecen intactos.* * Sólo ladrones deshonrosos transmite el código que los * * programadores REALES escriben con difícultad y libre- * * mente lo comparten quitando los comentarios y diciendo* * que ellos escribieron el código. * *-------------------------------------------------------* * Encrypts and Decrypts a chain. * *-------------------------------------------------------* *-------------------------------------------------------* * Original in VB for: Kelvin C. Perez. * * E-Mail: kelvin_perez@msn.com * * WebSite: http://home.coqui.net/punisher * *+++++++++++++++++++++++++++++++++++++++++++++++++++++++* * Programmed in PHP for: Heriberto Mantilla Santamaría. * * E-Mail: heri_05-hms@mixmail.com * * WebSite: www.geocities.com/hackprotm/ * *-------------------------------------------------------* * IMPORTANT NOTE * *-------------------------------------------------------* * Feel free to use this class in your pages, provided * * ALL credits remain intact. Only dishonorable thieves * * download code that REAL programmers work hard to write* * and freely share with their programming peers, then * * remove the comments and claim that they wrote the * * code. * *-------------------------------------------------------* * @author Heriberto Mantilla Santamaría * * @version 1.1 * ********************************************************* * All Rights Reserved HACKPRO TM © 2005 * ********************************************************* */ /** * Portion of this code is the php.js * ----------------------------------------------------------------------------------- * More info at: http://phpjs.org * * This is version: 2.47 * php.js is copyright 2009 Kevin van Zonneveld. * * Portions copyright Brett Zamir (http://brettz9.blogspot.com), Kevin van * Zonneveld (http://kevin.vanzonneveld.net), Onno Marsman, Michael White * (http://getsprink.com), Waldo Malqui Silva, Paulo Ricardo F. Santos, Jack, * Philip Peterson, Jonas Raoni Soares Silva (http://www.jsfromhell.com), Ates * Goral (http://magnetiq.com), Legaev Andrey, Martijn Wieringa, Nate, * Philippe Baumann, Enrique Gonzalez, Webtoolkit.info * (http://www.webtoolkit.info/), Ash Searle (http://hexmen.com/blog/), travc, * Jani Hartikainen, Carlos R. L. Rodrigues (http://www.jsfromhell.com), d3x, * Johnny Mast (http://www.phpvrouwen.nl), marrtins, Alex, Erkekjetter, Andrea * Giammarchi (http://webreflection.blogspot.com), GeekFG * (http://geekfg.blogspot.com), Mirek Slugen, Breaking Par Consulting Inc * (http://www.breakingpar.com/bkp/home.nsf/0/87256B280015193F87256CFB006C45F7), * Ole Vrijenhoek, Josh Fraser * (http://onlineaspect.com/2007/06/08/auto-detect-a-time-zone-with-javascript/), * Steven Levithan (http://blog.stevenlevithan.com), Public Domain * (http://www.json.org/json2.js), Marc Palau, mdsjack * (http://www.mdsjack.bo.it), David, Arpad Ray (mailto:arpad@php.net), * Pellentesque Malesuada, Thunder.m, Aman Gupta, Tyler Akins * (http://rumkin.com), Alfonso Jimenez (http://www.alfonsojimenez.com), Karol * Kowalski, AJ, Caio Ariede (http://caioariede.com), Sakimori, gorthaur, * Steve Hilder, john (http://www.jd-tech.net), David James, class_exists, * noname, Steve Clay, T. Wild, Hyam Singer * (http://www.impact-computing.com/), kenneth, Subhasis Deb, Pyerre, Felix * Geisendoerfer (http://www.debuggable.com/felix), djmix, Jon Hohle, Douglas * Crockford (http://javascript.crockford.com), mktime, sankai, Sanjoy Roy, * 0m3r, Marco, Thiago Mata (http://thiagomata.blog.com), madipta, Gilbert, * ger, Bryan Elliott, David Randall, Ozh, T0bsn, Tim Wiel, Peter-Paul Koch * (http://www.quirksmode.org/js/beat.html), Bayron Guevara, MeEtc * (http://yass.meetcweb.com), Brad Touesnard, XoraX (http://www.xorax.info), * echo is bad, J A R, duncan, Paul, Linuxworld, Marc Jansen, Der Simon * (http://innerdom.sourceforge.net/), Lincoln Ramsay, LH, Francesco, Slawomir * Kaniecki, marc andreu, Eric Nagel, Bobby Drake, rezna, Mick@el, Pierre-Luc * Paour, Martin Pool, Kirk Strobeck, Pul, Luke Godfrey, Christian Doebler, * YUI Library: * http://developer.yahoo.com/yui/docs/YAHOO.util.DateLocale.html, Blues at * http://hacks.bluesmoon.info/strftime/strftime.js, penutbutterjelly, Gabriel * Paderni, Blues (http://tech.bluesmoon.info/), Anton Ongson, Simon Willison * (http://simonwillison.net), Kristof Coomans (SCK-CEN Belgian Nucleair * Research Centre), Saulo Vallory, hitwork, Norman "zEh" Fuchs, sowberry, * Yves Sucaet, Nick Callen, ejsanders, johnrembo, dptr1988, Pedro Tainha * (http://www.pedrotainha.com), T.Wild, uestla, Valentina De Rosa, * strcasecmp, strcmp, metjay, DxGx, Alexander Ermolaev * (http://snippets.dzone.com/user/AlexanderErmolaev), ChaosNo1, Andreas, * Garagoth, Manish, Cord, Matt Bradley, Robin, FremyCompany, Tim de Koning, * taith, Victor, stensi, Arno, Nathan, nobbler, Mateusz "loonquawl" Zalega, * ReverseSyntax, Jalal Berrami, Francois, Scott Cariss, Tod Gentille, baris * ozdil, booeyOH, Cagri Ekin, Luke Smith (http://lucassmith.name), Ben Bryan, * Leslie Hoare, Andrej Pavlovic, Dino, mk.keck, Rival, Diogo Resende, Yannoo, * gabriel paderni, FGFEmperor, jakes, Atli Þór, Howard Yeend, Allan Jensen * (http://www.winternet.no), Benjamin Lupton * * Dual licensed under the MIT (MIT-LICENSE.txt) * and GPL (GPL-LICENSE.txt) licenses. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL KEVIN VAN ZONNEVELD BE LIABLE FOR ANY CLAIM, DAMAGES * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. */ (function() { if (typeof(Security) == "undefined") { var Security = function() { if (window == this || !this.init) { return new Security(); } else { return this.init(); } }; } var nEncKey, cText, nCharSize, cSourceText; Security.prototype = { init : function() { }, Encrypt_Text : function(cText, utf8) { if (utf8) { var eText = this.utf8_encode(cText); } else { var eText = cText; } var nCounter = 0; // Get a random Number between 1 and 100. This will be the multiplier // for the Ascii value of the characters. this.nEncKey = this.intval((100 * this.Rnd()) + 1); // Loop until we get a random value betwee 5 and 7. This will be // the lenght (with leading zeros) of the value of the Characters. this.nCharSize = 0; var nUpperBound = 10; var nLowerBound = 5; this.nCharSize = this.intval((nUpperBound - nLowerBound + 1) * this.Rnd() + nLowerBound); // Encrypt the Size of the characters and convert it to String. // This size has to be standard so we always get the right character. var cCharSize = this.fEncryptedKeySize(this.nCharSize); // Convert the KeyNumber to String with leading zeros. var cEncKey = this.NumToString(this.nEncKey, this.nCharSize); // Get the text to encrypt and it's size. var cEncryptedText = ''; var nTextLenght = this.strlen(eText); // Loop thru the text one character at the time. for (nCounter = 1; nCounter <= nTextLenght; nCounter++) { // Get the Next Character. var cChar = this.Mid(eText, nCounter, 1); // Get Ascii Value of the character multplied by the Key Number. var nChar = this.ord(cChar) * this.nEncKey; // Get the String version of the Ascii Code with leading zeros. // using the Random generated Key Lenght. var cChar2 = this.NumToString(nChar, this.nCharSize); // Add the Newly generated character to the encrypted text variable. cEncryptedText += cChar2; } // Separate the text in two to insert the enc // key in the middle of the string. var nLeft = this.intval(this.strlen(cEncryptedText) / 2); var cLeft = this.strleft(cEncryptedText, nLeft); var nRight = this.strlen(cEncryptedText) - nLeft; var cRight = this.strright(cEncryptedText, nRight); // Add a Dummy string at the end to fool people. var cDummy = this.CreateDummy(); // Add all the strings together to get the final result. this.cSourceText = cEncryptedText; this.InsertInTheMiddle(this.cSourceText, cEncKey); this.InsertInTheMiddle(this.cSourceText, cCharSize); cEncryptedText = this.cSourceText; cEncryptedText = this.CreateDummy() + cEncryptedText + this.CreateDummy(); return cEncryptedText; }, Decrypt_Text : function(cText, utf8) { var cTempText = cText; var cDecryptedText = ''; var len = this.strlen(cTempText); var nChar2 = 0; var nChar = 0; this.cText = ''; // Replace alpha characters for zeros. for (var nCounter = 1; nCounter <= len; nCounter++) { cChar = this.Mid(cTempText, nCounter, 1); if (this.is_numeric(cChar) == true) { this.cText += cChar; } else { this.cText += '0'; } } // Get the size of the key. this.cText = this.strleft(this.cText, this.strlen(this.cText) - 4); this.cText = this.strright(this.cText, this.strlen(this.cText) - 4); this.nCharSize = 0; this.Extract_Char_Size(this.cText, this.nCharSize); this.Extract_Enc_Key(this.cText, this.nCharSize, this.nEncKey); // Decrypt the Size of the encrypted characters. nTextLenght = this.strlen(this.cText); // Loop thru text in increments of the Key Size. var nCounter = 1; do { // Get a Character the size of the key. cChar = this.Mid(this.cText, nCounter, this.nCharSize); // Get the value of the character. nChar = this.Val(cChar); // Divide the value by the Key to get the real value of the // character. if (this.nEncKey > 0) { nChar2 = parseInt(nChar / this.nEncKey); } // Convert the value to the character. cChar2 = this.chr(nChar2); cDecryptedText += cChar2; nCounter += parseInt(this.nCharSize); } while (nCounter <= nTextLenght); // Clear any unwanted spaces and show the decrypted text. cDecryptedText = this.trim(cDecryptedText); if (utf8) { return this.utf8_decode(cDecryptedText); } else { return cDecryptedText; } }, Extract_Char_Size : function(cText, nCharSize) { // Get the half left side of the text. var nLeft = this.intval(this.strlen(cText) / 2); var cLeft = this.strleft(cText, nLeft); // Get the half right side of the text. var nRight = this.strlen(cText) - nLeft; var cRight = this.strright(cText, nRight); // Get the key from the text. var nKeyEnc = this.Val(this.strright(cLeft, 2)); var nKeySize = this.Val(this.strleft(cRight, 2)); if (nKeyEnc >= 5) { this.nCharSize = parseInt(nKeySize) + parseInt(nKeyEnc); } else { this.nCharSize = parseInt(nKeySize) - parseInt(nKeyEnc); } this.cText = this.strleft(cLeft, this.strlen(cLeft) - 2) + this.strright(cRight, this.strlen(cRight) - 2); }, Extract_Enc_Key : function(cText, nCharSize, nEncKey) { var cEncKey = ''; // Get the real size of the text (without the previously // stored character size). var nLenght = this.strlen(cText) - nCharSize; // Get the half left and half right sides of the text. var nLeft = this.intval(nLenght / 2); var cLeft = this.strleft(cText, nLeft); var nRight = nLenght - nLeft; var cRight = this.strright(cText, nRight); // Get the key from the text. cEncKey = this.Mid(cText, nLeft + 1, nCharSize); // Get the numeric value of the key. this.nEncKey = this.Val(this.trim(cEncKey)); // Get the real text to decrypt (left side + right side). this.cText = cLeft + '' + cRight; }, fEncryptedKeySize : function(nKeySize) { var nLowerBound = 0; var nKeyEnc = this.intval((nKeySize - nLowerBound + 1) * this.Rnd() + nLowerBound); if (nKeyEnc >= 5) { nKeySize = parseInt(nKeySize) - parseInt(nKeyEnc); } else { nKeySize = parseInt(nKeySize) + parseInt(nKeyEnc); } return this.NumToString(nKeyEnc, 2) + this.NumToString(nKeySize, 2); }, NumToString : function(nNumber, nZeros) { // Check that the zeros to fill are not smaller than the actual size. var cNumber = this.trim(nNumber); var nLenght = this.strlen(cNumber); if (nZeros < nLenght) { nZeros = 0; } var nUpperBound = 122; var nLowerBound = 65; var nCounter = 0; for (nCounter = 1; nCounter <= (nZeros - nLenght); nCounter++) { // Add a zero in front of the string until we reach the desired size. var lCreated = false; do { nNumber = this.intval((nUpperBound - nLowerBound + 1) * this.Rnd() + nLowerBound); if ((nNumber > 90) && (nNumber < 97)) { lCreated = false; } else { lCreated = true; } } while (lCreated == false); cChar = this.chr(nNumber); cNumber = cChar + cNumber; } // Return the resulting string. return cNumber; }, InsertInTheMiddle : function(cSourceText, cTextToInsert) { // Get the half left and half right sides of the text. var nLeft = this.intval(this.strlen(cSourceText) / 2); var cLeft = this.strleft(cSourceText, nLeft); var nRight = this.strlen(cSourceText) - nLeft; var cRight = this.strright(cSourceText, nRight); // Insert cTextToString in the middle of cSourceText. this.cSourceText = cLeft + cTextToInsert + cRight; }, CreateDummy : function() { var nUpperBound = 122; var nLowerBound = 48; var nCounter = 0; var cDummy = ''; for (nCounter = 1; nCounter <= 4; nCounter++) { var lCreated = false; do { nDummy = this.intval((nUpperBound - nLowerBound + 1) * this.Rnd() + nLowerBound) if (((nDummy > 57) && (nDummy < 65)) || ((nDummy > 90) && (nDummy < 97))) { lCreated = false; } else { lCreated = true; } } while (lCreated == false); cDummy += this.chr(nDummy); } return cDummy; }, is_numeric : function(mixed_var) { // More info at: http://phpjs.org // This is version: 2.47 php.js is copyright 2009 Kevin van Zonneveld. if (mixed_var === '') { return false; } return !isNaN(mixed_var * 1); }, strlen : function(string) { var str = string + ''; return str.length; }, strright : function(tmp, nRight) { var len = this.strlen(tmp); if (nRight == 0){ str = ''; } else if (nRight < len) { str = this.Mid(tmp, len - nRight + 1, len); } return str; }, strleft : function(tmp, nLeft) { var len = this.strlen(tmp); if (nLeft == 0){ str = ''; } else if (nLeft < len) { str = this.Mid(tmp, 1, nLeft); } return str; }, Mid : function(tmp, start, length) { str = this.substr(tmp, start - 1, length); return str; }, substr : function(f_string, f_start, f_length) { var str = f_string + ''; return str.substr(f_start, f_length); }, trim : function(f_string) { var str = f_string + ''; while (str.charAt(0) == (" ")) { str = str.substring(1); } while (str.charAt(str.length-1) == " ") { str = str.substring(0,str.length-1); } return str; }, Rnd : function() { do { var tmp = Math.abs( Math.tan( Math.random() ) ); } while ((tmp > 1) || (tmp < 0)); tmp = this.Mid(tmp, 1, 8); return tmp; }, Val : function(tmp) { var length = this.strlen(tmp); var tmp2 = 0; for (i = 1; i <= length; i++) { var tmp1 = this.substr(tmp, i - 1, 1); if (this.is_numeric(tmp1) == true) { tmp2 += tmp1; } } return this.intval(tmp2); }, intval : function(mixed_var, base) { // More info at: http://phpjs.org // This is version: 2.47 php.js is copyright 2009 Kevin van Zonneveld. var tmp; var type = typeof(mixed_var); if (type == 'boolean') { if (mixed_var == true) { return 1; } else { return 0; } } else if (type == 'string') { tmp = parseInt(mixed_var * 1); if (isNaN(tmp) || !isFinite(tmp)) { return 0; } else { return tmp.toString(base || 10); } } else if (type == 'number' && isFinite(mixed_var)) { return Math.floor(mixed_var); } else { return 0; } }, chr : function(ascii) { return String.fromCharCode(ascii); }, ord : function(string) { string += ''; return string.charCodeAt(0); }, utf8_encode : function(string) { // More info at: http://phpjs.org // This is version: 2.47 php.js is copyright 2009 Kevin van Zonneveld. string = (string + '').replace(/\r\n/g, "\n").replace(/\r/g, "\n"); var utftext = ""; var start, end; var stringl = 0; start = end = 0; stringl = string.length; for (var n = 0; n < stringl; n++) { var c1 = string.charCodeAt(n); var enc = null; if (c1 < 128) { end++; } else if ((c1 > 127) && (c1 < 2048)) { enc = String.fromCharCode((c1 >> 6) | 192) + String.fromCharCode((c1 & 63) | 128); } else { enc = String.fromCharCode((c1 >> 12) | 224) + String.fromCharCode(((c1 >> 6) & 63) | 128) + String.fromCharCode((c1 & 63) | 128); } if (enc != null) { if (end > start) { utftext += string.substring(start, end); } utftext += enc; start = end = n + 1; } } if (end > start) { utftext += string.substring(start, string.length); } return utftext; }, utf8_decode : function(str_data) { // More info at: http://phpjs.org // This is version: 2.47 php.js is copyright 2009 Kevin van Zonneveld. var tmp_arr = [], i = 0, ac = 0, c1 = 0, c2 = 0, c3 = 0; str_data += ''; while (i < str_data.length) { c1 = str_data.charCodeAt(i); if (c1 < 128) { tmp_arr[ac++] = String.fromCharCode(c1); i++; } else if ((c1 > 191) && (c1 < 224)) { c2 = str_data.charCodeAt(i + 1); tmp_arr[ac++] = String.fromCharCode(((c1 & 31) << 6) | (c2 & 63)); i += 2; } else { c2 = str_data.charCodeAt(i + 1); c3 = str_data.charCodeAt(i + 2); tmp_arr[ac++] = String.fromCharCode(((c1 & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); i += 3; } } return tmp_arr.join(''); } }; window.$Security = Security(); })();
Etiquetas:
Decrypt,
Encrypt,
Javascript
jueves, mayo 07, 2009
TreeCombo (ExtJS)
Pequeña extensión para extender un Tree con un Combo.
/** * @author Possible author is roytmana * @version 1.0 * @class Ext.ux.TreeCombo * @extends Ext.form.ComboBox *+++++++++++++++++++++++++++++++++++++++ * Edit by HACKPRO TM *+++++++++++++++++++++++++++++++++++++++ */ Ext.ux.TreeCombo = Ext.extend(Ext.form.ComboBox, { lastKeys : '', admitLeaf: true, treeTypeAhead: false, initList : function() { if (this.list != undefined) { return; } if (this.editable !== false) { this.el.on("keyup", this.onKeyUpTree, this) } if (this.treeTypeAhead) { this.taTask = new Ext.util.DelayedTask(this.onTreeTypeAhead, this); } var tConf = { floating : true, listeners : { click : this.onNodeClick, scope : this }, alignTo : function(el, pos) { this.setPagePosition(this.el.getAlignToXY(el, pos)); }, keys : [{ key : 9, fn : function() { this.onNodeClick(this.list.getSelectionModel() .getSelectedNode()); }, scope : this }, { key : 27, fn : function() { this.collapse(); this.focus(true, true); }, scope : this }] }; if (this.treeConfig) { Ext.applyIf(tConf, this.treeConfig); if (this.treeConfig.listeners) { Ext.applyIf(tConf.listeners, this.treeConfig.listeners); } if (tConf.loader) { tConf.loader.on("load", this.onTreeLoad, this); } } this.list = new Ext.tree.TreePanel(tConf); if (!this.list.rendered) { var lw = this.listWidth || Math.max(this.wrap.getWidth(), this.minListWidth); this.list.render(document.body); this.list.setWidth(lw); this.list.alignTo(this.wrap, this.listAlign); this.innerList = this.list.body; this.innerList.setWidth(lw); this.innerList.setWidth(lw - this.list.getFrameWidth('lr')); this.list.hide(); } }, doQuery : function(q, forceAll) { this.expand(); }, collapseIf : function(e) { if (!e.within(this.wrap) && !e.within(this.list.el)) { this.collapse(); } }, selectNext : function() { var sm = this.list.getSelectionModel(); if (!sm.getSelectedNode()) { sm.select(this.list.getRootNode()); } sm.selectNext(); }, selectPrev : function() { var sm = this.list.getSelectionModel(); if (!sm.getSelectedNode()) { sm.select(this.list.getRootNode()); } sm.selectPrevious(); }, onViewClick : function(doFocus) { this.collapse(); if (doFocus !== false) { this.el.focus(); } }, findNode : function(value, node, rootPath, like) { var field = this; if (node == null || node == undefined) { node = field.list.getRootNode(); } var value = value; if (node.isLoaded() == true) { if (node.childNodes.length > 0) { field.nodeFound = node.findChild('text', value); if (field.nodeFound == null || field.nodeFound == undefined) { node.cascade(function() { if (this.text == value) { if ( (this.getPath('text') == rootPath) || (rootPath == null) ) { field.nodeFound = this; } } else if (like == true) { var str = this.text; var found = str.indexOf(value); if (found >= 0) { field.nodeFound = this; } } if (field.nodeFound != null && field.nodeFound != undefined) { return false; } }); } } } else { field.list.getLoader().load(node, function(loader, node, rootPath, like) { node.loaded = true; field.nodeFound = field.findNode(value, node, rootPath, like); }); } return field.nodeFound; }, setValue : function(value, rootPath) { if (this.list == undefined) { this.initList(); } if (value == '') { this.setRawValue(''); return; } this.el.removeClass(this.emptyClass); var nodeFound = this.findNode(value, null, rootPath, null); if (nodeFound != null && nodeFound != undefined) { text = nodeFound.attributes['text']; if (text.length == 0) { text = (!empty(this.value) ? this.value : ''); } if ( (nodeFound.isLeaf() == false) && (this.admitLeaf == false) ) { return; } var nodePath = nodeFound.getPath(); var treeRoot = this.list.getRootNode(); treeRoot.reload(); this.list.expandPath(nodePath); this.list.selectPath(nodePath); this.setRawValue(text); if (this.hiddenField) { this.hiddenField.value = value; } } else { this.setRawValue(); var treeroot = this.list.getRootNode(); treeroot.reload(); this.list.collapseAll(); } }, setValueFromNode : function(node) { this.setRawValue(node.attributes.text); if (this.hiddenField) { this.hiddenField.value = node.id; } }, openCombo : function(){ this.onTriggerClick(); }, onTreeTypeAhead : function(){ var newValue = this.getRawValue(); var selStart = this.getRawValue().length; if (selStart <= 0) { this.setRawValue(''); var treeroot = this.list.getRootNode(); treeroot.reload(); this.list.collapseAll(); return; } var nodeFound = this.findNode(newValue, null, null, true); if (nodeFound != null && nodeFound != undefined) { text = nodeFound.attributes['text']; var len = text.length; if (selStart != len) { if ( (nodeFound.isLeaf() == false) && (this.admitLeaf == false) ) { return; } var nodePath = nodeFound.getPath(); var treeRoot = this.list.getRootNode(); treeRoot.reload(); this.list.expandPath(nodePath); this.list.selectPath(nodePath); this.setRawValue(text); this.selectText(selStart, text.length); if (this.hiddenField) { this.hiddenField.value = newValue; } this.focus.defer(10, this); } } }, onKeyUpTree : function(A) { if (this.editable !== false && !A.isSpecialKey()) { this.lastKeys = A.getKey(); if (this.treeTypeAhead && (this.lastKeys == Ext.EventObject.BACKSPACE || this.lastKeys == Ext.EventObject.DELETE) ) { this.taTask.delay(250); return; } if (this.treeTypeAhead) { this.onTreeTypeAhead(); } } }, onNodeClick : function(node, e) { if ( (node.isLeaf() == false) && (this.admitLeaf == false) ) { return; } var oldValue = this.getValue(); this.setValueFromNode(node); this.collapse(); if (this.treeTypeAhead) { this.focus(true, false); } else { this.focus(false, false); } this.fireEvent('select', this, oldValue, this.getValue()); this.fireEvent('change', this, node); this.fireEvent('rootchanged', node); }, onTreeLoad : function(loader, node, response) { if (this.list.getRootNode() == node) { if (this.hiddenField && this.hiddenField.value && this.hiddenField.value != '') { var n = this.list.getNodeById(this.hiddenField.value); if (n) { n.select(); this.setRawValue(n.attributes.text); } else { this.list.getSelectionModel().clearSelections(); this.setRawValue(''); this.hiddenField.value = ''; } } } } }); Ext.reg('treecombo', Ext.ux.TreeCombo);
Suscribirse a:
Entradas (Atom)