Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
BrowserUtils |
|
| 1.0;1 |
1 | /** | |
2 | * Copyright 2010 The Kuali Foundation Licensed under the | |
3 | * Educational Community License, Version 2.0 (the "License"); you may | |
4 | * not use this file except in compliance with the License. You may | |
5 | * obtain a copy of the License at | |
6 | * | |
7 | * http://www.osedu.org/licenses/ECL-2.0 | |
8 | * | |
9 | * Unless required by applicable law or agreed to in writing, | |
10 | * software distributed under the License is distributed on an "AS IS" | |
11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | |
12 | * or implied. See the License for the specific language governing | |
13 | * permissions and limitations under the License. | |
14 | */ | |
15 | ||
16 | package org.kuali.student.common.ui.client.util; | |
17 | ||
18 | /** | |
19 | * This provides a library of JSNI methods. | |
20 | * | |
21 | */ | |
22 | 0 | public class BrowserUtils { |
23 | public static native String getOperatingSystem() /*-{ | |
24 | if (navigator.appVersion.indexOf("Win")!=-1) return "Windows"; | |
25 | if (navigator.appVersion.indexOf("Mac")!=-1) return OSName="MacOS"; | |
26 | if (navigator.appVersion.indexOf("X11")!=-1) return OSName="UNIX"; | |
27 | if (navigator.appVersion.indexOf("Linux")!=-1) return OSName="Linux"; | |
28 | return "Unknown: " + navigator.appVersion; | |
29 | }-*/; | |
30 | ||
31 | public static native String getString(String name) /*-{ | |
32 | return eval("$wnd."+name); | |
33 | }-*/; | |
34 | ||
35 | public static native String getUserAgent() /*-{ | |
36 | return navigator.userAgent.toLowerCase(); | |
37 | }-*/; | |
38 | ||
39 | /** | |
40 | * Redirect browser window to a different url | |
41 | * @param url | |
42 | */ | |
43 | public static native void redirect(String url)/*-{ | |
44 | $wnd.location = url; | |
45 | }-*/; | |
46 | ||
47 | /** | |
48 | * Reload the current browser page. | |
49 | */ | |
50 | public static native void reload()/*-{ | |
51 | $wnd.location.reload(); | |
52 | }-*/; | |
53 | ||
54 | public static native String getClassAttr()/*-{ | |
55 | if(navigator.appName == "Microsoft Internet Explorer"){ | |
56 | return "className"; | |
57 | } else { | |
58 | return "class"; | |
59 | } | |
60 | }-*/; | |
61 | ||
62 | } |