Tips and Tricks in a world of Mix

Archive for the ‘Client’ Category

localStorage The system cannot find the path specified.

In Ie10 localStorage suddenly has disappeared.

I’ve reinstalled the browser. Reset the Settings of the browser.

Internet Options –> Advanced Tab –> Enabled DOM Storage

image

Also

Internet Options –> set to accept all cookies

image 

Still no localStorage ..

How do I retrieve the lost part of IE ? How to restore localStorage ?

 

Found the solution in Introduction to Web Storage 

“Clearing the Storage Areas

Session state is released as soon as the last window to reference that data is closed. However, users can clear storage areas at any time by selecting Delete Browsing History from the Tools menu in Internet Explorer, selecting the Cookies check box, and clicking OK. This clears session and local storage areas for all domains that are not in the Favorites folder and resets the storage quotas in the registry. Clear the Preserve Favorite Site Data check box to delete all storage areas, regardless of source.

To delete key/value pairs from a storage list, iterate over the collection with removeItem or use clear to remove all items at once. Keep in mind that changes to a local storage area are saved to disk asynchronously.”

 

Apparently what  did the trick at the end was the clearing of the Preserve Favorite Site Data  check box .

image

Advertisements

Minify JS on rebuilding the web

 

Download JSMIN from http://www.crockford.com/javascript/jsmin.html

Instead of opening the WebSite  project , open a WebApp .

(you can see diff here and here – actually it’s an issue by itself )

So , on the Property Pages of your WebApp –> goto  build events –>

build one time script for rebuilding the minified files on each build/rebuild of the project like so :

"$(ProjectDir)..\jsmin\jsmin" < "$(ProjectDir)\scripts\models\employee.js” > "$(ProjectDir)\scripts\models\employee.min.js"

(you must adjust the script line accordingly to the position of the JSMIN in your project)

this will create a few lines of code ..

then you add instead of the regular employee.js  the newly created employee.min.js to your index.html (start page with references to JavaScript files )

Also , be careful to add newly created files to the project – Include in project . Check that it also entered into the Source Safe you are using.

Check in to all and let your team use the minified files on rebuilding the project.

Datejs – Manipulate Javascript Dates – a full library in one file

150 countries globalization

A variety of functions – including first day of week , comparison et cetera .

Download updated library (from 2008) at this address.

APIvery useful and simple.

Website
(Maybe a bit old date on the update of the library , but very effective.. )

 

 

cellDateTime comes from wcf in format of

"/Date(1326602100000+0200)/"

 

after a small extension usage of :

 

String.prototype.DateWCF = function (dateformat) {
    return new Date(parseInt(this.match(/\/Date\(([0-9]+)(?:.*)\)\//)[1])).format(dateformat);
};

—-

cellDateTime.DateWCF(‘dd/mm/yyyy HH:MM’)

—–

Usage of date-he-IL.js :

<script src="scripts/infrastructure/date/date-he-IL.js" type="text/javascript"></script>

///parse from string

  if (m == 0) {
  firstDateOfWeek = Date.parse(currentCell.CellDateTime());
   ///if it’s not sunday , go to the last sunday 
   
if (Date.parse(currentCell.CellDateTime()).getDayName() != "Sunday")
                  firstDateOfWeek.moveToDayOfWeek(0, -1);

}
  //current date of the cell – first date + j index of the number of days loop
 
var checkedDate = firstDateOfWeek.clone().add(j).days();

   //compare 
  
if (Date.compare(checkedDate, Date.parse(currentCell.CellDateTime())) == 0) {
                      //if the date exists get out and check next date
                     
IsCellExistsForCheckedDate = true;
   }

Working with tables through JS–animations , drag and drop

 

Nice library to check out

http://www.redips.net/javascript/drag-and-drop-table-content-animation/

 

http://www.redips.net/javascript/drag-and-drop-table-content/#smile_img

 

http://www.redips.net/my/preview/REDIPS_drag/

Workaround crush browsers – Work Offline – Client-side Storage

 

I’ve found a few technologies that can give you the option of handling the browser crush or actually working for some time offline , without some fancy monstress framework implemented synchronizing every thing you do. You’ll probably need to implement sync by yourself..

List of the Technologies :

1)jStorage – store data locally with JavaScript

image

2)Alternative Client-Side Storage using Sessvars.js

IE7 gave up at 32 Mb with a “out of memory” error. Firefox gave up at 32-64 Mb -sometimes crashed there about – otherwise threw an “out of memory” error.Safari gave up at 64 Mb and crashed. Opera has a limit built in (wise) and gave up after 2 Mb, throwing the error “Object to large (implementation limit.)”

 

3) My Sample – implementing the example published by parts in Apples site.

tutorial of Apple for Safari explaining how to work with Isolated Storage.

 

 

4)https://github.com/marcuswestin/store.js 

 

Now , when you have my research , go crush your browsers freely !

Welch Allyn IT3800 code interceptor

 

Look at the scanner jack.

If it looks like this:

, then it’s a keyboard wedge scanner. It acts like a keyboard: just types your barcode into an edit field.

If it looks like this:

, it’s a serial port scanner.

You need to create an instance of System.IO.Ports.SerialPort and use it to communicate with the scanner.

If it looks like this:

, it’s a USB scanner. From programmer’s point of view, it can be either a keyboard wedge or a serial port scanner.

 

Ours was wedge scanner. If we want to intercept the barcode input , for instance for validation or some logic decision where to show the input , then you should catch the Ctrl+b event , initialize a flag saying you’re now reading the barcode . On each KeyPress you’ll hit , if it’s not “Enter” (the end of Barcode input) and the flag of  (Ctrl+b)  (Start Barcode Read) is true , add each time add the value to some parameter. When the “Enter” comes you have all the bar code data in the parameter. :

 

  1: var barcodeWorking = false;
  2: var barcode = "";
  3: 
  4: //This function fired when ctrl+b insert : begin reading with barcode
  5: function FireEventB_KeyAndONE_Key()//Override the function of KeboardUse.js
  6:       {
  7:           barcodeWorking = true;
  8:           window.focus();//כדי שהברקוד לא יכתב לרכיב טקסט בדף
  9:       }
 10: 
 11: function KeyPress(theKey)
 12:       {
 13:            var key=theKey.keyCode || theKey.which;
 14:            if(barcodeWorking)
 15:            {
 16:                if(key == ENTER_KEY)//'Enter' pressed : end of the barcode
 17:                {
 18:                     alert(barcode); )//לעשות מה שצריך עם הברקוד
 19:                     barcode = "";
 20:                     barcodeWorking = false;
 21:                }
 22:            else
 23:            {
 24:                 barcode += String.fromCharCode(key);
 25:            } 
 26:         }
 27:       }

 

Don’t forget to connect the KeyPress to Body tag.

   1:  <body language="javascript" onload="windows_onload();" oncontextmenu='return false' onkeypress="KeyPress(event)">

 

The idea has been generated by me.

The source code (implementation) has been written by Sharon Said.

Tag Cloud

%d bloggers like this: