用户:Darkstar88/LocalStorage.js

来自口袋百科
跳转至: 导航搜索

注意:在保存之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。

  • Firefox/Safari:按住“Shift”的同时单击“刷新”,或按“Ctrl-F5”或“Ctrl-R”(Mac为“⌘-R”)
  • Google Chrome:按“Ctrl-Shift-R”(Mac为“⌘-Shift-R”)
  • Internet Explorer:按住“Ctrl”的同时单击“刷新”,或按“Ctrl-F5”
  • Opera:在“工具→首选项”中清除缓存
$(function($){
    $.ajaxSetup({
        cache: true
    });
    if(window.localStorage){
        if ((1330534613700 < JSON.parse(localStorage.getItem("PokemonStorageTimestamp")))
            &&(window.Pokemon_BaseStats = JSON.parse(localStorage.getItem("Pokemon_BaseStats")))
            &&(window.Pokemon_Name = JSON.parse(localStorage.getItem("Pokemon_Name")))
            &&(window.Pokemon_Color = JSON.parse(localStorage.getItem("Pokemon_Color")))){
        }else{
            $.getScript("/w/index.php?title=MediaWiki:Pokemon.js&action=raw&ctype=text/javascript",function(){
                localStorage.setItem("Pokemon_BaseStats",JSON.stringify(Pokemon_BaseStats));
                localStorage.setItem("Pokemon_Name",JSON.stringify(Pokemon_Name));
                localStorage.setItem("Pokemon_Color",JSON.stringify(Pokemon_Color));
                localStorage.setItem("PokemonStorageTimestamp",JSON.stringify((new Date()).getTime()));
            });
        }
    }else{
        $.getScript("/w/index.php?title=MediaWiki:Pokemon.js&action=raw&ctype=text/javascript");
    }
});