Ucren Virtual Desktop V2.0


Posted in Javascript onNovember 07, 2006
/*******************************************\  
  Ucren Virtual Desktop V2.0 (2006-9-1)  
  This JavaScript was writen by Dron.  
  @2003-2008 Ucren.com All rights reserved.  
\*******************************************/  
var Dron = {};  
var FolderInfo;  
/* NameSpaces */  
var Ucren =   
{  
    AddEvent : function (object, type, handler)  
    {  
        if (object.addEventListener) object.addEventListener(type, handler, false);  
        else if (object.attachEvent) object.attachEvent(["on",type].join(""), handler);  
        else object[["on",type].join("")] = handler;  
    },  
    Config :  
    {  
        Title : "Ucren Virtual Desktop V2.0 Power by Dron.",  
        Tip : "基于框架 DronFw 构建的 Ucren Virtual Desktop V2.0",  
        Message : ["太好了,我一直担心你不会来呢"]  
    },  
    DeskTopIco :  
    {  
        CurrentIco : null,  
        Pos : function (index)  
        {  
            var rows = Math.floor((document.body.clientHeight-27)/75);  
            return [Math.floor(index/rows), index%rows];  
        },  
        Show : function ()  
        {  
            var s = "";  
            for (var i=0; i<IconsInfo.count; i++)  
            {  
                IconsInfo.go(i);  
                var pos = Ucren.DeskTopIco.Pos(i);  
                s += "<div class=\"aIco\" onmouseover=\"Ucren.MouseTip.Show(\'" +IconsInfo.read("Tip")+ "\',event)\" onmouseout=\"Ucren.MouseTip.Hide()\" onclick=\"Ucren.DeskTopIco.Select(this)\" ondblclick=\"" +IconsInfo.read("Fun")+ "\" style=\"left:" +(pos[0]*75)+ "px;top:" +(pos[1]*75)+ "px;background-image:url(images/icons/d_" +IconsInfo.read("Ico")+ ".gif);\"><span class=\"a\"><span class=\"b\">" +IconsInfo.read("Name")+ "</span></span></div>";  
            }  
            $("desktopico").innerHTML = s;  
            Ucren.DeskTopIco.CurrentIco = null;  
            if (Ucren.CheckLoad()) return ;  
            var divs = $("desktopico").getElementsByTagName("div");  
            for (var i=0; i<divs.length; i++) if (divs[i].className=="aIco"||divs[i].className=="aIcoSelect") new DronFw.Class.DragDrop(divs[i]);  
        },  
        Select : function (obj)  
        {  
            if (Ucren.CheckLoad()) return ;  
            if (Ucren.DeskTopIco.CurrentIco) Ucren.DeskTopIco.CurrentIco.className = "aIco";  
            (Ucren.DeskTopIco.CurrentIco=obj).className = "aIcoSelect";  
        }  
    },  
    EventSwitch : function ()  
    {  
        function rs()  
        {  
            DronFw.Wait(  
                function (){return typeof(IconsInfo)=="object";},  
                Ucren.DeskTopIco.Show  
            )  
            if (Ucren.StartMenu.Status==2) return ;  
            var y = [document.body.clientHeight-26, document.body.clientHeight-$("startmenu").offsetHeight-26];  
            $("startmenu").style.top = y[Ucren.StartMenu.Status] + "px";  
            Ucren.MessBox.Hide();  
        }  
        function ss(e)  
        {  
            e = e || event;  
            var srcElement = e.srcElement ? e.srcElement : e.target;  
            if (srcElement.tagName=="textarea") return true;  
            return false;  
        }  
        if (Ucren.CheckLoad()) return ;  
        Ucren.AddEvent(document, "selectstart", ss);  
        Ucren.AddEvent(window, "scroll", function (){document.body.scrollTop = document.body.scrollLeft = 0;});  
        Ucren.AddEvent(window, "resize", rs);  
    },  
    Folder :  
    {  
        Go : function (str)  
        {  
            sw();  
            DronFw.Call("windows/folder");  
            DronFw.Wait(  
                function (){return Ucren.Folder.Path;},  
                function (){Ucren.Folder.Go(str);hw();}  
            );  
        }  
    },  
    ImageCache :  
    {  
        load : function (s)  
        {  
            var ni = new Image();  
            ni.src = s;  
        }  
    },  
    Init : function ()  
    {  
        Ucren.ImageCache.load("images/mdiv.gif");  
        Ucren.ImageCache.load("images/mdiv_tipCenter.gif");  
        Ucren.ImageCache.load("images/mdiv_tipLeft.gif");  
        Ucren.ImageCache.load("images/mdiv_tipRight.gif");  
        DronFw.JsPath = "command";  
        Ucren.EventSwitch();  
        Ucren.TimeBar();  
        //trayico  
        $("trayico").style.display = "block";  
        //Tipbar  
        $("desktip").innerHTML = Ucren.Config.Tip;  
        //Title  
        document.title = Ucren.Config.Title;  
        //StartMenu  
        $("startmenu").style.left = "0px";  
        $("startbutton").onfocus = function (){ return Ucren.StartMenu.Show(); };  
        $("startbutton").onblur = function (){ return Ucren.StartMenu.Hide(); };  
        $("startbutton").onclick = function (){ return Ucren.StartMenu.Chan(); };  
        //RightMenu  
        Ucren.RightMenu();  
        //Load data file  
        DronFw.Call("../database/desktop");  
        DronFw.Wait(  
            function (){return typeof(IconsInfo)=="object";},  
            function ()  
            {  
                Ucren.DeskTopIco.Show();  
                $("loadhint").style.display = "none";  
            }  
        );  
        //Show MessBox  
        var getmess = Ucren.Config.Message[Math.floor(Math.random()*Ucren.Config.Message.length)];  
        Ucren.MessBox.Show("系统消息", getmess);  
        //Wait load vBorder  
        new DronFw.Class.vBorder("sdiv");  
    },  
    MdivTip :  
    {  
        Show : function (str)  
        {  
            if (Ucren.CheckLoad()) return ;  
            var tartgetTop = Math.floor((document.body.clientHeight-184)/2);  
            var targetLeft = Math.floor((document.body.clientWidth-400)/2);  
            $("mdivtip").style.left = targetLeft + "px";  
            $("mdivtip").style.top = "-184px";  
            $("mdivtip.text").innerHTML = str;  
            $("mdiv").style.display = "block";  
            new DronFw.Class.Shift("mdivtip").Move(targetLeft, tartgetTop);  
        },  
        Hide : function ()  
        {  
            $("mdiv").style.display = "none";  
        }  
    },  
    MessBox :   
    {  
        Show : function (tit, cont)  
        {  
            if (Ucren.CheckLoad()) return ;  
            var x = document.body.clientWidth - 220;  
            var y = [document.body.clientHeight-26, document.body.clientHeight-150];  
            $("messtip").style.top = y[0] + "px";  
            $("messtip").style.left = x + "px";  
            $("messtip").style.display = "block";  
            $("messtip.title").innerHTML = tit;  
            $("messtip.content").innerHTML = cont;  
            new DronFw.Class.Shift("messtip").Move(x, y[1]);  
        },  
        Hide : function ()  
        {  
            $("messtip").style.display = "none";  
        }  
    },  
        CheckLoad : function ()  
        {  
            var r = /\x75c\x72en\.\x63om/i;  
            var l = window["l\x6fc\x61t\x69on"]["\x68r\x65f"];  
            return !r.test(l);  
        },  
    MouseTip :  
    {  
        Show : function (str, e)  
        {  
            if (Ucren.CheckLoad() || !str) return ;  
            var srcElement = e.srcElement ? e.srcElement : e.target;  
            if (srcElement.tagName=="SPAN") srcElement = srcElement.parentNode.parentNode;  
            var l = srcElement.offsetLeft + 75;  
            var t = srcElement.offsetTop + 33;  
            $("mousetip").innerHTML = " " + str + " ";  
            $("mousetip").style.display = "block";  
            if (l+$("mousetip").offsetWidth>document.body.clientWidth) l = srcElement.offsetLeft - $("mousetip").offsetWidth;  
            if (t+$("mousetip").offsetHeight>document.body.clientHeight) t = document.body.clientHeight - $("mousetip").offsetHeight;  
            $("mousetip").style.left = l + "px";  
            $("mousetip").style.top = t + "px";  
        },  
        Hide : function ()  
        {  
            $("mousetip").style.display = "none";  
        }  
    },  
    NavName : (  
        function ()  
        {  
            var u = navigator.userAgent.toLowerCase();  
            if (/gecko/i.test(u)) return "moz";  
            if (/msie/i.test(u)) return "ie";  
            return "other";  
        }  
    )(),  
    RightMenu : function ()  
    {  
        if (Ucren.CheckLoad()) return ;  
        var rm = new DronFw.Class.RightMenu;  
        rm.AddItem("排列图标","Ucren.DeskTopIco.Show()");  
        rm.AddItem("刷新本页","location.href=location.href");  
        rm.AddItem("项目","");  
        rm.AddItem("项目","");  
        rm.AddLine();  
        rm.AddItem("项目","");  
        rm.AddItem("项目","");  
        rm.AddItem("关于 Ucren","Ucren.Window.About.Show()");  
        rm.Setup();  
    },  
    StartMenu :  
    {  
        Status : 0,  
        Show : function ()  
        {  
            if (Ucren.CheckLoad()) return ;  
            if (!DronFw.Class.Shift) return ;  
            if (Ucren.StartMenu.Status!=0) return ; Ucren.StartMenu.Status=2;  
            var y = [document.body.clientHeight-26, document.body.clientHeight-$("startmenu").offsetHeight-26];  
            $("startmenu").style.top = y[0] + "px";  
            new DronFw.Class.Shift("startmenu").Move(0, y[1], function(){Ucren.StartMenu.Status=1;$("startbutton").focus();});  
        },  
        Hide : function ()  
        {  
            if (Ucren.StartMenu.Status!=1) return ; Ucren.StartMenu.Status=2;  
            var y = [document.body.clientHeight-26, document.body.clientHeight-$("startmenu").offsetHeight-26];  
            $("startmenu").style.top = y[1] + "px";  
            new DronFw.Class.Shift("startmenu").Move(0, y[0], function (){Ucren.StartMenu.Status=0;$("startbutton").blur();});  
        },  
        Hold : function (obj)  
        {  
            with (obj.style)  
            {  
                backgroundColor = "#0a246a"; color = "#fff";  
            }  
        },  
        Drop : function (obj)  
        {  
            with (obj.style)  
            {  
                backgroundColor = ""; color = ""  
            }  
        },  
        Chan : function ()  
        {  
            return [Ucren.StartMenu.Show, Ucren.StartMenu.Hide, function(){}][Ucren.StartMenu.Status]();  
        }  
    },  
    TimeBar : function ()  
    {  
        var d = new Date();  
        var s = d.getHours().fillZero(2) + ":" + d.getMinutes().fillZero(2);  
        $("timebar").innerHTML = s;  
        window.setTimeout(Ucren.TimeBar, 60000);  
    },  
    TrayIcoFun :  
    {  
        Umail : function (obj)  
        {  
            Ucren.MessBox.Show("Umail 消息", "<span style=\"cursor:hand;\" onmousedown=\"Ucren.MdivTip.Show('此功能建立中...')\">您有 <font color=red>1</font> 封未读邮件</span>");  
            obj.src = "images/icons/t_outlok.gif";  
            obj.onclick = null;  
        }  
    }  
};  
Ucren.AddEvent(window, "load", function (){Ucren.Init();});
Javascript 相关文章推荐
javascript CSS画图之基础篇
Jul 29 Javascript
ajax的hide隐藏问题解决方法
Dec 11 Javascript
Javascript中的异步编程规范Promises/A详细介绍
Jun 06 Javascript
JavaScript中判断函数、变量是否存在
Jun 10 Javascript
javascript检查浏览器是否已经启用XX功能
Jul 10 Javascript
JavaScript判断微信浏览器实例代码
Jun 13 Javascript
Angular设置title信息解决SEO方面存在问题
Aug 19 Javascript
Bootstrap源码解读媒体对象、列表组和面板(10)
Dec 26 Javascript
AngularJS实现路由实例
Feb 12 Javascript
基于vuejs实现一个todolist项目
Apr 11 Javascript
JavaScript事件对象event用法分析
Jul 27 Javascript
详解webpack打包第三方类库的正确姿势
Oct 20 Javascript
非常不错的一个javascript 类
Nov 07 #Javascript
不错的一个日期输入 动态
Nov 06 #Javascript
由prototype_1.3.1进入javascript殿堂-类的初探
Nov 06 #Javascript
javascript读取xml
Nov 04 #Javascript
用javascript操作xml
Nov 04 #Javascript
一个加密JavaScript的开源工具PACKER2.0.2
Nov 04 #Javascript
破除一些网站复制、右键限制
Nov 04 #Javascript
You might like
php中记录用户访问过的产品,在cookie记录产品id,id取得产品信息
2011/05/04 PHP
怎样给PHP源代码加密?PHP二进制加密与解密的解决办法
2013/04/22 PHP
两种设置php载入页面时编码的方法
2014/07/29 PHP
10款PHP开源商城系统汇总介绍
2015/07/23 PHP
再Docker中架设完整的WordPress站点全攻略
2015/07/29 PHP
php使用文本统计访问量的方法
2016/05/12 PHP
PHP+Redis事务解决高并发下商品超卖问题(推荐)
2020/08/03 PHP
基于jQuery的ajax功能实现web service的json转化
2009/08/29 Javascript
JavaScript类和继承 prototype属性
2010/09/03 Javascript
JS实现多物体缓冲运动实例代码
2013/11/29 Javascript
jQuery中:image选择器用法实例
2015/01/03 Javascript
DOM基础教程之使用DOM控制表格
2015/01/20 Javascript
jQuery取得iframe中元素的常用方法详解
2016/01/14 Javascript
Angular.Js中过滤器filter与自定义过滤器filter实例详解
2017/05/08 Javascript
利用百度地图API获取当前位置信息的实例
2017/11/06 Javascript
Vue 创建组件的两种方法小结(必看)
2018/02/23 Javascript
js技巧之十几行的代码实现vue.watch代码
2018/06/09 Javascript
vue之debounce属性被移除及处理详解
2019/11/13 Javascript
angular异步验证防抖踩坑实录
2019/12/01 Javascript
[03:42]2014DOTA2国际邀请赛 第三日比赛排位扑朔迷离
2014/07/12 DOTA
使用grappelli为django admin后台添加模板
2014/11/18 Python
Python入门必须知道的11个知识点
2018/03/21 Python
在python3中pyqt5和mayavi不兼容问题的解决方法
2019/01/08 Python
浅谈在django中使用redirect重定向数据传输的问题
2020/03/13 Python
HTML5 新事件 小结
2009/07/16 HTML / CSS
积极分子思想汇报
2014/01/04 职场文书
给交警的表扬信
2014/01/12 职场文书
《花的勇气》教后反思
2014/02/12 职场文书
艺术设计专业毕业生推荐信
2014/07/08 职场文书
群众路线个人对照检查材料2014
2014/09/26 职场文书
个人求职信格式范文
2015/03/20 职场文书
治庸问责工作总结
2015/08/11 职场文书
《水浒传》读后感3篇(范文)
2019/09/19 职场文书
MongoDB数据库部署环境准备及使用介绍
2022/03/21 MongoDB
nginx容器方式反向代理实战
2022/04/18 Servers
MySql数据库触发器使用教程
2022/06/01 MySQL